Documentation
¶
Overview ¶
Package verify implements webhook signature verification.
A Verifier inspects the incoming request headers and raw body and returns nil when the signature is valid. Verifiers are pure: no I/O, no clock access except through the injectable now() used by timestamped schemes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HMAC ¶
HMAC verifies an HMAC-SHA256 signature of the raw request body carried in a single header, optionally prefixed (e.g. GitHub's "sha256=").
type Iyzico ¶
Iyzico verifies iyzico's X-IYZ-SIGNATURE-V3 webhook signatures.
Unlike GitHub/Stripe, iyzico does not sign the raw body: the signature is HMAC-SHA256 (lowercase hex, secretKey as key) over a concatenation of payload fields, and the field list depends on the event family:
direct secretKey + iyziEventType + paymentId + paymentConversationId + status
hpp secretKey + iyziEventType + iyziPaymentId + token + paymentConversationId + status
subscription merchantId + secretKey + iyziEventType + subscriptionReferenceCode +
orderReferenceCode + customerReferenceCode
The family is detected from the payload shape: a token field means HPP (checkout form / pay-with-iyzico), a subscriptionReferenceCode means subscription, anything else is direct. Subscription events need the merchant id, which is not in the payload — configure verify.merchant_id_env.
Numeric fields (iyziPaymentId is a JSON number) are rendered exactly as they appear in the JSON document via json.Number; re-encoding them through float64 would corrupt large ids and break the signature.
type Stripe ¶
Stripe verifies Stripe webhook signatures.
Stripe sends a Stripe-Signature header of the form "t=<unix>,v1=<hex>,v1=<hex>,v0=..." where each v1 value is HMAC-SHA256(secret, "<t>.<raw body>"). Multiple v1 entries appear during secret rotation; any single match is accepted. Signatures older (or newer) than Tolerance are rejected to limit replay.