Overview
Webhooks allow you to receive real-time notifications when transaction events occur. Instead of polling for transaction status updates, DCash will send HTTP POST requests to your configured webhook URL when transactions complete.Configuring Webhooks
You can configure webhook URLs in two ways:- Per-request: Include the
webhook_urlparameter in your API request - Default URL: Set a default webhook URL in your merchant portal
Per-request webhook URLs take precedence over the default URL configured in your merchant portal.
Webhook Security
To ensure webhook requests originated from DCash:- Verify the source IP address: All webhooks are sent from
41.209.57.197 - Use HTTPS endpoints: Ensure encrypted transmission of transaction data
- Validate transaction data: Cross-check the transaction details against your records
Webhook Payload Structure
Deposit (C2B) Webhooks
When a C2B deposit transaction completes, your webhook receives:Unique identifier for the transaction
Merchant-provided reference ID from the original request
Status of the transaction (e.g., “completed”, “failed”)
Email of the user who made the deposit
Amount deposited
Currency code (e.g., “USD”)
Description of the transaction
Timestamp of completion (format: YYYYMMDDHHMMSS)
Withdrawal (B2C) Webhooks
When a B2C withdrawal transaction completes, your webhook receives:Responding to Webhooks
Your webhook endpoint should:- Respond quickly: Return a
200 OKresponse within 5 seconds - Process asynchronously: Handle the webhook data in a background job if needed
- Be idempotent: Handle duplicate webhook deliveries gracefully using
transaction_id
Example Webhook Handler
Webhook Retry Logic
If your endpoint doesn’t respond with a200 OK status:
- DCash will retry the webhook up to 3 times
- Retries occur at increasing intervals (5 min, 30 min, 2 hours)
- After 3 failed attempts, you’ll need to use the Check Transaction Status endpoint
Testing Webhooks
During development, you can test webhooks using:- Webhook testing tools: Use services like webhook.site or ngrok to create temporary public URLs
- Sandbox environment: All sandbox transactions trigger webhooks to help you test your integration
Transaction Statuses
Webhook notifications may include these transaction statuses:| Status | Description |
|---|---|
completed | Transaction completed successfully |
failed | Transaction failed |
pending | Transaction is still processing |
When you receive a “completed” status, the funds have been successfully transferred.
Troubleshooting
Webhook not received
If you don’t receive a webhook notification:- Check that your webhook URL is correctly configured
- Verify your endpoint is publicly accessible
- Use the Check Transaction Status endpoint to get the transaction result
- Check your server logs for incoming requests
Multiple webhook deliveries
Webhooks may be delivered more than once. Implement idempotency using thetransaction_id to prevent duplicate processing.
Best Practices
Use HTTPS endpoints
Use HTTPS endpoints
Always use HTTPS webhook URLs to ensure secure transmission of transaction data.
Verify source IP address
Verify source IP address
Always verify that webhook requests come from DCash’s server IP: 41.209.57.197
Validate webhook data
Validate webhook data
Verify that the transaction details match your records before processing.
Log all webhooks
Log all webhooks
Keep logs of all webhook deliveries for debugging and audit purposes.
Handle errors gracefully
Handle errors gracefully
If processing fails, return 200 OK to prevent retries, then handle the error separately.
Monitor webhook health
Monitor webhook health
Set up alerts for failed webhook deliveries to catch issues quickly.