Webhooks
Webhooks (or callbacks) let you automatically receive asynchronous events from Paycashless when important events happen — like when a payment status changes or a virtual account gets credited.
Register your webhook URLs
Webhooks are currently registered when you call APIs via the callbackUrl
field.
Webhook Structure
All webhooks have the same payload structure.
event
: the name of the eventdata
: event data specific to the event being sent
Webhook Retries
Always acknowledge a webhook instantly by responding with 2xx
, else it will be considered as failed. Failed webhooks are retried with constant backoff for a maximum of 3 times with a delay of 1 minute.
Webhook Security
To ensure you are receiving webhooks from Paycashless we provide Request-Signature
and Request-Timestamp
in the webhook request header.
This is similar to the API signing request, but in reverse. You MUST validate the signature to ensure it’s originating from Paycashless.
Webhook signature is signed using HMAC SHA-512 with your API secret as the signing key. Request-Signature
and Request-Timestamp
will be provided in the webhook request header for you to reconstruct the message for verification.
To verify the signature follow the process below:
Step | Action | Description |
---|---|---|
1 | Hash | Take the event data object, stringify the object and hash it with HMAC SHA-512 algorithm using your API secret as the signing key (output should be hex-encoded). |
2 | Concatenate | Concatenate your full callback url exactly as you provided it, hashed event data , and Request-Timestamp from the header. There are no spaces or other characters between these values. The order of the fields must follow the order stipulated here. |
3 | Sign | Take the string from the Concatenate step and generate a HMAC SHA-512 signature using your API secret as the signing key. |
4 | Encode | Take the output of the Sign step and hex-encode it. |
5 | Verify | Compare the recreated signature with the content of Request-Signature header. |
The fields used to generate the signature are as follows. If the conditions below are not met, you won’t be able to recreate the Request-Signature
header.
Field | Description |
---|---|
Callback URL | Lowercased full URL as provided with the base url and search parameters (e.g. https://yourwebsite.com/callback/paycashless?notify=all ). |
Hashed Body | The event data object, stringified and hashed using HMAC SHA-512 algorithm. |
Timestamp | The value gotten from Request-Timestamp header. |
Study the node.js webhook verification example code below: