Webhooks play an important part in your integration of Cashramp. They are how we'll notify you of any changes that happen to the transactions you initiate, such as a user cancelling, no agents being available, or a successful payment.
Cashramp webhook payload structure
All Cashramp webhook payloads follow the same structure:
an event_type field describing the type of event
a data object whose contents vary with the type of event.
Here are sample payloads for the different kinds of webhook notifications you might receive:
{"event_type":"chargeback.initiated","data": {"id":"TWVyY2hhbnRDaGFyZ2ViYWNrLWQ2MGVjMjI3LThhNTYtNDMxNS1hNWQ4LTk3N2JhNmFhNmE3Mw==","status":"pending","reason":"A MoMo reversal was initiated by your customer","payment_request": { "id": "VHlwZXM6OkNhc2hyYW1wOjpBUEk6Ok1lcmNoYW50UGF5bWVudFJlcXVlc3QtYmMxYTMzMzktNTM5YS00Y2ZkLWE3ZmEtMTM1MzllZGVhNWQw",
"reference":"c9b1082d49185da9","amount":100,"currency":"usd" } }}
You should respond to our webhook events immediately with 200 OK HTTP status code. Any other response code will be treated as a failed delivery of the event.
Remember to return 200 OK before starting any long-running tasks. Long-running tasks will lead to a request timeout.
Best practices
Webhook Token Verification
Your webhook URL is publicly accessible, and bad actors can send fake data to it in an attempt to trick your application into releasing value to them.
Webhook events sent from Cashramp carry a X-CASHRAMP-TOKEN header. You should check that the header's value matches your webhook token before processing the event.