Skip to main content
The SDK ships helpers for verifying webhook signatures and parsing event payloads. For the full list of webhook events and payload shapes, see the Webhooks reference.

Setup

Pass your webhook public key when initializing the SDK:
Copy the public key from Developer → Webhook in the dashboard. Sandbox and production have different keys, so use the one that matches environment.

Verify and Parse

The signature covers the exact bytes Afriex sent, so verify the raw request body. If a JSON body parser such as express.json() runs first, you get a parsed object instead of the bytes Afriex signed, and every signature check fails. In Express, read the webhook route with express.raw() and pass the body to the SDK as it is. verify and verifyAndParse take a Buffer or a string: Store each event before you acknowledge it, and act on it afterwards, outside the request. Afriex waits up to 15 seconds for a 2xx, retries anything slower, and sends every event at least once, so key what you store on the event’s id. See Duplicates, ordering, and replays.
id and createdAt are part of every webhook body. The SDK’s WebhookPayload type includes them from the first release after @afriex/sdk 5.0.0. On 5.0.0, upgrade, or read them from the parsed JSON.

Verify Only

Validate the signature without parsing. payload is the raw body, as above:

Trigger Test Webhook (Sandbox)

Send a test webhook to your endpoint in sandbox:
For CHECKOUT_SESSION.CREATED, use the checkoutId returned when you created the checkout as resourceId.
Test webhook triggers only work in the sandbox environment.