Skip to main content
Webhooks are a crucial component of the Fenan Pay system, allowing real-time notifications of transaction events to be sent directly to your server. This guide will walk you through the process of handling these webhook notifications securely and efficiently.
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_SUCCESS
  • PAYMENT_FAILED
  • PAYMENT_EXPIRED

Withdrawal Events

  • WITHDRAWAL_SUCCESS
  • WITHDRAWAL_FAILED

Webhook Payload Structure

The webhook payload contains a transaction event object with the following key components:
Always verify the webhook signature to ensure the body’s integrity and authenticity. Read more about verifying webhook signatures.

Example Webhook Events

Success Transaction

Withdrawal Success Example

Acknowledging Webhooks

To properly acknowledge receipt of a webhook, your server must respond with:
Status Code
number
200
Content-Type
string
text/plain
Response Body
string
SUCCESS
Fenan Pay will retry the webhook up to 3 times at 2-minute intervals if not properly acknowledged.

Best Practices

  1. Verify signatures: Always verify the webhook signature before processing the payload.
  2. Parse the body: Remember that the body field is a JSON string that needs to be parsed.
  3. Process asynchronously: Handle webhook processing in the background to respond quickly.
  4. Idempotency: Design your webhook handler to be idempotent to safely handle potential duplicate events.
  5. 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.
Webhook Log in Dashboard
By following these guidelines, you’ll ensure robust and secure handling of Fenan Pay webhooks, keeping your system in sync with the latest transaction statuses.