Webhook
Webhooks allow your application to receive real-time notifications about events that occur within the payment gateway. This document provides a comprehensive guide to setting up and handling webhooks.
Overview
Webhooks are HTTP callbacks that send event data to a specified URL in your application. When an event is triggered, our servers will send a POST request to your webhook endpoint containing details about the event.
Supported Events
The following events are supported:
payment.completed
: Triggered when a payment is successfully completed.payment.failed
: Triggered when a payment attempt fails.refund.initiated
: Triggered when a refund is initiated.refund.completed
: Triggered when a refund is successfully processed.customer.created
: Triggered when a new customer is created.customer.updated
: Triggered when a customer's information is updated.
Setting Up Webhooks
Step 1: Configure Your Webhook Endpoint
First, set up an endpoint in your application to receive webhook events. The endpoint should be able to handle POST requests and process the incoming data.
Example in Node.js (Express)
Example in Python (Flask)
Step 2: Register Your Webhook URL
Register your webhook URL in the payment gateway dashboard or via the API.
Example API Request
Example Response
Verifying Webhooks
To ensure the integrity of the data sent to your webhook endpoint, we sign each webhook event. You should verify this signature to confirm that the request is from our servers.
Verifying the Signature
Each webhook request includes a X-Signature header which you can use to verify the authenticity of the event.
Example in Node.js (Express)
Example in Python (Flask)
Handling Retries
If your webhook endpoint is unavailable or returns a non-2xx status code, we will retry the delivery for up to 24 hours with exponential backoff. Ensure your endpoint is idempotent to handle potential duplicate events.
Example Webhook Payload
Here’s an example of the payload sent for a payment.completed event:
Webhooks provide a powerful way to receive real-time updates about events in the payment gateway. Follow the steps outlined in this guide to set up and handle webhooks securely. If you have any questions or need further assistance, please contact our support team.
Was this page helpful?
Helpful (0)
Not helpful (0)
© Copyright 2024. All rights reserved.