How webhooks work
Afriex delivers event notifications for customer, payment method, transaction, and checkout session updates to the webhook URL you configure in your dashboard.Set up your webhook endpoint
- Open the Dashboard.
- Go to Developer.
- Select the Webhook tab.
- Save your webhook URL.
https://your-domain.com/webhook
Afriex IP addresses
Security and signature validation
Every webhook request includes anx-webhook-signature header. You must validate this signature before processing the payload.
- Header:
x-webhook-signature - Algorithm: ECDSA with SHA-256
- Key: elliptic-curve,
secp384r1(P-384). It is not an RSA key. - Signature format: DER-encoded, then base64-encoded
- Signed data: the exact raw request body (
string/Buffer) - Public key source: Developer → Webhook in the Dashboard
- Environment note: Sandbox and production use different public keys
Libraries that expect a raw
r||s (IEEE P1363) signature, such as WebCrypto and JOSE libraries, need the DER signature converted first. Node’s crypto module reads DER by default, so the sample below needs no conversion.Response and retries
Return a success response quickly after verification and processing.- On success: return
200(or another2xxstatus). Afriex waits up to 15 seconds for your response before treating the attempt as failed, so aim well inside that budget and do slow work after acknowledging. - On verification failure: return
400or401 - Retry behavior: Afriex makes up to 12 delivery attempts, the first one and then up to 11 retries, with exponential backoff starting at 30 seconds.
- 30s → 1m → 2m → 4m → 8m → 16m → 32m → about 1h → about 2h → about 4h → about 8h
Duplicates, ordering, and replays
Every webhook body carries two fields besidesevent and data:
The signature covers the whole body, so both fields are signed. You verify the signature exactly as before.
Build your handler for three cases:
- The same event more than once. Afriex retries any delivery that doesn’t get a
2xxwithin 15 seconds, even if you processed it. Store theidof each event you process. When a delivery’sidis one you have, return200and skip it. - Events out of order. A retried event can arrive after a newer one, and
TRANSACTION.UPDATEDcan arrive beforeTRANSACTION.CREATED. Compare the payload’sdata.updatedAtwith the version you have stored, and ignore anything older. - Replayed deliveries. A captured delivery still has a valid signature if someone sends it again. Your stored
ids stop a replay, because it carries anidyou’ve already processed. Retries can arrive up to about 16 hours aftercreatedAt, so keep eachidfor at least a day.
