Introduction
Learn how to integrate and handle Mavapay webhooks
Webhook Integration Guide
Webhooks allow your application to receive real-time notifications about events that occur in your Mavapay account. This guide explains how to integrate, secure, and handle webhook notifications.
Overview
Mavapay uses webhooks to notify your application when events happen in your account. Instead of polling our API, webhooks enable your application to be notified in real-time when events occur.
Setting Up Webhooks
1. Register Your Webhook Endpoint
First, register your webhook endpoint using our API:
2. Update Webhook Configuration
You can update your webhook configuration at any time:
Event Types
Mavapay currently supports two types of webhook events:
payment.received
- Triggered when a payment is receivedpayment.sent
- Triggered when a payment is sent
Event Payloads
payment.received
payment.sent
Security
Verifying Webhook Signatures
To ensure the webhook requests are coming from Mavapay, we sign each request with your webhook secret. The signature is included in the X-Mavapay-Signature
header.
Here’s how to verify the signature (Node.js example):
Best Practices
-
Verify Signatures: Always verify webhook signatures to ensure requests are from Mavapay.
-
Idempotency: Process webhooks idempotently using the event ID to avoid duplicate processing.
-
Quick Response: Respond to webhooks quickly (within 5 seconds) to acknowledge receipt.
-
Retry Logic: Implement retry logic in case your endpoint is temporarily unavailable.
-
Logging: Log webhook requests for debugging and auditing purposes.
-
Error Handling: Implement proper error handling for failed webhook processing.
Testing Webhooks
You can use our staging environment to test webhooks:
We recommend using tools like webhook.site or ngrok for local development.
Test Event
You can trigger a test event to verify your webhook setup:
Troubleshooting
Common issues and solutions:
-
Invalid Signature: Double-check your webhook secret and signature verification code.
-
Timeout: Ensure your endpoint responds within 5 seconds.
-
SSL Error: Make sure your endpoint has a valid SSL certificate.
-
Wrong Content-Type: Your endpoint should accept
application/json
.
Support
If you need help with webhooks:
- Email: info@mavapay.co
- Documentation: https://docs.mavapay.co
- API Reference: https://docs.mavapay.co/api-reference