Webhooks
Webhooks allow you to receive real-time notifications about transaction status changes.
Configuring Webhooks
- In your merchant dashboard, go to API Integration
- Click Webhooks for your token
- Add your webhook URL
- Select events to listen for:
payment.successpayment.failedpayout.successpayout.failed
Webhook Payload
{
"event": "payment.success",
"data": {
"transactionId": 123,
"reference": "API_DEP_123_1234567890",
"amount": 1000,
"type": "deposit",
"status": "completed"
},
"timestamp": "2024-01-15T10:30:00.000Z"
}
Webhook Security
Webhooks are signed with HMAC SHA256. Verify the signature using the X-MbiyoPay-Signature header:
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(JSON.stringify(payload))
.digest('hex');
return signature === `sha256=${expectedSignature}`;
}