Overview
Setting up webhooks allows your application to receive real-time notifications about payment events. This guide will walk you through the complete setup process.Prerequisites
Before setting up webhooks, ensure you have:1
HTTPS Endpoint
A publicly accessible HTTPS endpoint (webhooks cannot be sent to HTTP
endpoints)
2
Server Capability
Ability to receive and process POST requests
3
API Key
Your InventPay API key from the dashboard
Configuration Methods
You can configure webhooks in two ways:Dashboard
Visual interface for easy setup Best for: Non-technical users, testing
API
Programmatic configuration Best for: Automated deployments, CI/CD
Setup via Dashboard
Step 1: Access Webhook Settings
- Log in to InventPay Dashboard
- Navigate to Settings → Webhooks
- Click Configure Webhook
Step 2: Enter Webhook URL
Enter your webhook endpoint URL:Step 3: Save Configuration
- Click Save Webhook URL
- Copy your Webhook Secret (shown once)
- Store the secret securely in your environment variables
Step 4: Test Your Webhook
Click Send Test Webhook to verify your endpoint is working correctly.Setup via API
Configure Webhook Endpoint
Get Current Configuration
Test Webhook Delivery
Implementing Your Webhook Endpoint
Basic Webhook Handler
Here’s a complete webhook endpoint implementation:Key Implementation Points
1. Verify Signature First
1. Verify Signature First
Always verify the webhook signature before processing to ensure the request is from InventPay.
2. Return 200 Immediately
2. Return 200 Immediately
Respond with 200 status within 5 seconds to acknowledge receipt.
javascript // Return 200 immediately res.status(200).send('OK'); // Process asynchronously processWebhook(event).catch(console.error); 3. Handle Idempotency
3. Handle Idempotency
Use webhook ID or payment ID to prevent duplicate processing.
4. Log Everything
4. Log Everything
Log all webhook deliveries for debugging and auditing.
Testing Your Webhook
Local Testing with ngrok
For local development, use ngrok to expose your local server:1
Install ngrok
Download from ngrok.com
2
Start Your Server
Run your webhook server locally (node server.js or python app.py)
3
Expose with ngrok
Run: ngrok http 3000
4
Use ngrok URL
Copy the HTTPS URL (e.g., https://abc123.ngrok.io) and set it as your
webhook URL
5
Test
Send a test webhook from dashboard or API
Testing Checklist
Before going live, verify:✓ Signature Verification Works
✓ Signature Verification Works
Test with both valid and invalid signatures
✓ All Event Types Handled
✓ All Event Types Handled
Ensure you handle all relevant event types
✓ Idempotency Implemented
✓ Idempotency Implemented
Send duplicate webhooks to verify idempotency
✓ Error Handling Works
✓ Error Handling Works
Test error scenarios and recovery
✓ Response Time < 5 seconds
✓ Response Time < 5 seconds
Ensure endpoint responds quickly
✓ HTTPS Certificate Valid
✓ HTTPS Certificate Valid
Verify SSL certificate is valid and trusted
Webhook Security Best Practices
Use HTTPS Only
Never accept webhooks over HTTP
Verify Signatures
Always verify HMAC signature
Validate IP Addresses
Optional: Whitelist InventPay IPs
Rate Limiting
Implement rate limiting on webhook endpoint
Monitor Failures
Set up alerts for failed webhooks
Rotate Secrets
Periodically rotate webhook secrets
Security Guide
Learn more about webhook security
Monitoring Webhooks
Dashboard Monitoring
View webhook activity in your dashboard:- Go to Webhooks → Deliveries
- See recent deliveries and their status
- View response codes and retry attempts
- Inspect failed deliveries
API Monitoring
Troubleshooting
Webhooks Not Being Received
Webhooks Not Being Received
Possible Causes:
- Webhook URL not configured
- Firewall blocking requests
- Server not responding
- Verify webhook URL in dashboard
- Check firewall and security group rules
- Test endpoint with test webhook
- Check server logs for errors
Signature Verification Failing
Signature Verification Failing
Possible Causes: - Using wrong webhook secret - Body modified by
middleware - Incorrect signature calculation Solutions: 1. Verify webhook
secret from dashboard 2. Use raw request body for verification 3. Check HMAC
algorithm (SHA-256) 4. Log both signatures for comparison
Webhooks Timing Out
Webhooks Timing Out
Possible Causes: - Synchronous processing taking too long - Database
queries blocking response Solutions: 1. Return 200 immediately 2. Process
webhooks asynchronously 3. Use background jobs for heavy processing 4.
Optimize database queries
Receiving Duplicate Webhooks
Receiving Duplicate Webhooks
This is Normal: Retries may cause duplicatesSolution:
Implement idempotency using webhook ID or payment ID
Advanced Configuration
Custom Headers
Add custom headers to webhook requests (Enterprise feature):Event Filtering
Subscribe to specific events only (Enterprise feature):Multiple Webhook URLs
Configure different URLs for different event types (Enterprise feature):Enterprise Features
Contact sales for advanced webhook features
Webhook IP Addresses
For additional security, you can whitelist InventPay webhook IPs:IP addresses are subject to change. We recommend signature verification over
IP whitelisting.
