#nullable enable
namespace Baya.Application.Contracts.Payments;

/// <summary>
/// Verifies an inbound PSP/BNPL callback's authenticity and extracts its idempotency key + payload. A callback
/// is authenticated by <b>signature</b>, not a user session; an invalid signature must mutate <b>nothing</b>
/// (stored with <c>signature_valid = 0</c>, <c>processing_status = ignored</c>). Where a provider offers no
/// signature, the real adapter falls back to the mandatory server-side <c>verify</c> re-check.
/// </summary>
public interface IWebhookVerifier
{
    WebhookVerification Verify(string provider, IReadOnlyDictionary<string, string> headers, string rawBody);
}

/// <param name="SignatureValid">False ⇒ the callback is stored ignored and no money moves.</param>
/// <param name="ExternalEventId">The provider's event id — half of the <c>(provider, external_event_id)</c> key.</param>
/// <param name="EventType">The provider's event type; a success type triggers the confirm path.</param>
/// <param name="GatewayReferenceCode">The reference tying the callback to a pending transaction.</param>
/// <param name="IsSuccessEvent">Whether this event asserts a successful capture (gates the confirm path).</param>
public sealed record WebhookVerification(
    bool SignatureValid,
    string ExternalEventId,
    string EventType,
    string? GatewayReferenceCode,
    bool IsSuccessEvent);
