Overview
Webhooks allow you to receive real-time notifications for payment events such as completion, failure, and refunds. ZAFA PAY sends HTTP POST requests to your registered URL when payment status changes.The Webhook Secret can be found in the “Merchant Settings” section of the merchant dashboard (https://admin.zafapay.com).
Event Types
| Event | Description |
|---|---|
payment.succeeded | Payment completed successfully |
payment.failed | Payment failed |
payment.canceled | Payment canceled |
payment.refunded | Refund completed |
payment.chargeback | Chargeback occurred |
Payload
Event type (e.g.,
payment.succeeded)Transaction ID
Payment status (
succeeded, failed, canceled, refunded, chargeback)Payment amount
Currency code
Payment method (
card, depot, etc.)Merchant’s order ID (the value specified as
external_id when creating the payment)Product name (the value specified when creating the payment)
Customer ID (the value specified when creating the payment)
Customer’s email address (the value specified when creating the payment)
Customer’s phone number (the value specified when creating the payment)
Refunded amount
Transaction creation timestamp (ISO 8601 format)
Webhook sent timestamp (ISO 8601 format)
Payload Example
Signature Verification
Webhook requests include a signature header. Verify this signature to confirm the request was sent by ZAFA PAY.Signature Header
| Environment | Header Name |
|---|---|
| Sandbox | X-Zafapay-Signature-Sandbox |
| Production | X-Zafapay-Signature |
Verification Method
The signature is an HMAC-SHA256 hash of the request body (JSON string).Node.js
Response
Return HTTP status code2xx when the webhook is successfully received.
Retry
ZAFA PAY automatically retries webhooks in the following cases:- HTTP status code other than
2xxis returned - Connection timeout occurs
Best Practices
1
Always Verify Signature
Signature verification is essential to prevent unauthorized requests
2
Ensure Idempotency
The same event may be sent multiple times. Use
transaction_id as a key to prevent duplicate processing3
Return Response Quickly
Process webhooks asynchronously and return
200 immediately. Long processing times will cause timeout retries4
Log Errors
Log received payloads and processing results for debugging