Why Use Webhooks?
Instead of repeatedly checking for updates (polling), webhooks provide instant notifications when events occur in your Monieswitch account. This approach is:- More efficient than polling
- Not subject to rate limits
- Highly scalable
- Real-time and reliable
Webhook Approach
- One-time webhook URL registration
- Automatic notifications when events occur
- Immediate updates
- More efficient communication
Traditional Polling
- Your server repeatedly requests updates
- Each request requires a response
- High number of API calls
- Potential delays in getting updates
Signature Validation
Events sent from Monieswitch carry thex-monieswitch-signature
header. The value of this header is a HMAC SHA512 signature of the event payload signed using your secret key. Verifying the header signature should be done before processing the event.
Example
Implementation Guide
1. Creating Your Webhook Endpoint
Set up a POST endpoint on your server to receive webhook notifications. Your endpoint should:- Accept JSON payloads
- Return a 200 OK response
- Process events asynchronously
2. Update Webhook URL in Dashboard
In your Monieswitch account settings, add your webhook URL to receive notifications. This URL should be publicly accessible and secure.Event Types Reference
Payout Events
Static Account Funding Events
Virtual Account Collection Events
Wallet Debit
Card Events
Sandbox Funding
Status Code Reference
Event Type | Status Code | Meaning |
---|---|---|
virtual.account.payment.success | success | Payment confirmed and processed |
virtual.account.payment.pending | pending | Payment initiated but not completed |
virtual.account.payment.failed | failed | Payment attempt failed |
payout.success | SUCCESS | Transfer completed successfully |
payout.pending | PENDING | Transfer initiated but not completed |
payout.failed | FAILED | Transfer failed to complete |
static.account.payment.success | SUCCESS | Static account funding successful |
static.account.payment.pending | PENDING | Static account funding pending |
static.account.payment.failed | FAILED | Static account funding failed |
debit.wallet | SUCCESS | Wallet debit transaction completed |
sandbox.fund.success | SUCCESS | Sandbox funding successful |
card.settlement | SUCCESSFUL | Card settlement completed |
Best Practices
1. Event Handling
- Always verify event type before processing
- Implement idempotency checks using reference/transaction IDs
- Handle each event type independently
- Log all received events for audit purposes
2. Status Verification
- Confirm both event type and status match
- Check failure reasons for failed events
- Implement appropriate error handling
- Validate webhook signature before processing
3. Processing Order
- Process
pending
events beforesuccess
orfailed
- Store
pending
state for reconciliation - Update records for both success and failure events
- Maintain event sequence for audit trails
4. Failure Handling
- Implement retry logic where appropriate
- Store failure reasons for analysis
- Send appropriate notifications
- Consider automated recovery flows
5. Security
- Always validate webhook signatures
- Use HTTPS for webhook endpoints
- Implement proper authentication
- Log security events for monitoring