Webhooks
Webhooks lets you to integrate with CriptanPay by allowing you to subscribe to a set of charge events. You can subscribe to the events by going to your settings page and adding a new webhook subscription.
Events
Below is the list of all available webhook events:
Event | Description |
---|---|
charge:paid | Charge has been paid, but hasn't been confirmed yet |
charge:confirmed | Charge has been confirmed and the associated payment is completed |
charge:expired | Charge has expired without a payment being made |
charge:delayed | The payment was made after the specified time |
charge:underpaid | The payment was made for an inferior quantity of what was requested |
charge:refund_pending | A refund has been requested, but it hasn't been resolved yet |
charge:refunded | They payment has been sucessfully refunded |
Fields
The payload of the webhook has the following structure:
An example of a payload would be this:
caution
We send amount as strings for both fiat and cryptocurrency amount for consistency. Bear in mind that cryptocurrency payments can (and will) be numbers larger than what many programming languages can support safely. As an example, an ETH payment can have up to 18 decimals, so you will need to treat those numbers with cautions to avoid rounding errors.
Security
Every CriptanPay webhook request includes an x-signature
header. This header contains the SHA256 HMAC signature of the raw request payload, computed using your webhook shared secret as the key. You can obtain your shared webhook secret from your settings page.
warning
Make sure that you verify the webhook signature before acting on it inside your system!!
Using Typescript, you can verify a webhook like this: