Overview
Webhooks allow you to receive real-time notifications when payment events occur. This is essential for updating your application’s state when payments are completed, expired, or fail.Supported Events
Payment Completed
Triggered when a payment is successfully completed and confirmed on the blockchain.
Payment Expired
Triggered when a payment expires without being completed.
Setting Up Webhooks
Step 1: Configure Webhook URL
Set your webhook URL in the merchant dashboard or when creating payments:Step 2: Create Webhook Endpoint
Create an endpoint in your application to receive webhook notifications:Step 3: Handle Events
Process different webhook events in your application:Webhook Payloads
Payment Completed
Payment Expired
Webhook Verification
All webhooks are signed using HMAC-SHA256 to ensure they come from Transaction API.Verification Process
1
Get Webhook Secret
Find your webhook secret in the merchant dashboard.
2
Create HMAC Hash
Create HMAC-SHA256 hash of the request body using your secret.
3
Compare Signatures
Compare the computed hash with the
X-Webhook-Signature header.Example Implementation
Webhook Retries
Transaction API will retry failed webhook deliveries:- Retry Schedule: 1, 5, 15, 30, 60 minutes
- Max Retries: 5 attempts
- Timeout: 30 seconds per attempt
- Success Response: HTTP 200 status code
Testing Webhooks
Using ngrok for Local Development
Webhook Logs
Monitor webhook delivery in your dashboard:- Go to Webhook Logs in your merchant dashboard
- View delivery status and response codes
- Debug failed deliveries with request/response details
Best Practices
1
Verify Signatures
Always verify webhook signatures to ensure authenticity.
2
Handle Duplicates
Implement idempotency to handle duplicate webhook deliveries.
3
Respond Quickly
Process webhooks asynchronously to avoid timeouts.
4
Log Everything
Log all webhook events for debugging and auditing.
Common Issues
Webhook Not Receiving
Webhook Not Receiving
- Check if your endpoint is accessible from the internet
- Verify the webhook URL is correct
- Ensure your server is running and responding
Signature Verification Failing
Signature Verification Failing
- Ensure you’re using the correct webhook secret
- Check that you’re hashing the raw request body
- Verify the signature header format
Duplicate Events
Duplicate Events
- Implement idempotency using payment IDs
- Store processed event IDs to prevent reprocessing