Webhooks are POST requests sent from Fenan Pay to your server, containing important transaction status updates.
Event Types
Fenan Pay sends different types of webhook events based on the transaction status:Payment Events
PAYMENT_SUCCESSPAYMENT_FAILEDPAYMENT_EXPIRED
Withdrawal Events
WITHDRAWAL_SUCCESSWITHDRAWAL_FAILED
Webhook Payload Structure
The webhook payload contains a transaction event object with the following key components:Example Webhook Events
Success Transaction
Withdrawal Success Example
Acknowledging Webhooks
To properly acknowledge receipt of a webhook, your server must respond with:200
text/plain
SUCCESS
Fenan Pay will retry the webhook up to 3 times at 2-minute intervals if not properly acknowledged.
Best Practices
- Verify signatures: Always verify the webhook signature before processing the payload.
- Parse the body: Remember that the
bodyfield is a JSON string that needs to be parsed. - Process asynchronously: Handle webhook processing in the background to respond quickly.
- Idempotency: Design your webhook handler to be idempotent to safely handle potential duplicate events.
- Logging: Maintain detailed logs of received webhooks for troubleshooting and auditing.
Example Webhook Handler
Here’s a basic example of a webhook handler in Node.js:Webhook Log
You can track how your server is handling webhooks in the Fenan Pay dashboard. This is very important for debugging and ensuring that your webhook processing is functioning correctly.