Receive payment callbacks
Your HTTPScallback_url receives POST events for payment state changes:
The body contains
event_id, type, reference, tx_reference, occurred_at, transaction, and quote. The transaction and quote follow the payment details response. reference is your merchant reference; tx_reference identifies the payment attempt. Pending pricing may be an estimate; final pricing reflects the accepted result.
Verify the signature
Callbacks include these headers:X-Sarafa-Key. Verify the signature against the raw request body bytes, before parsing JSON. Do not parse and serialize the body again for verification.
The signing key is the binary SHA-256 digest of the original secret: only the portion after . in your API key. It is not the full API key or the hexadecimal hash string.
Acknowledge and reconcile
- Verify the signature and store the event durably before acknowledging with HTTP
2xx. - Deduplicate by
event_id; repeated delivery must not repeat fulfillment or accounting. - Handle events arriving out of order. Never revert a final payment to
pending. - When the outcome is uncertain, read the transaction using
tx_reference, or read the checkout using your merchant reference.
Errors and retries
Example error response:
issues array with path and message. The response header X-Request-Id identifies the request even when the body does not include request_id. Include it when contacting support.
After a timeout or uncertain response, retry with the same merchant reference and unchanged payload, including any originally supplied quote_token. Use transaction reads or verified callbacks to establish the outcome before starting a replacement payment.