Webhooks
How your server learns that a payment succeeded, failed, expired or was refunded.
Add an endpoint in the dashboard under Webhooks, or with the API. CSHPay sends an HTTP POST with a JSON body to it for each event. Test and live mode have separate endpoints and separate signing secrets.
Events
| Type | Sent when |
|---|---|
payment.succeeded | Kina Bank approved the payment and CSHPay verified the result |
payment.failed | The card was declined, or the gateway reported a final failure |
payment.expired | An hour after an unpaid payment passed its expiry |
refund.succeeded | Kina Bank reversed the payment |
refund.failed | Kina Bank declined to reverse it |
Body
{
"id": "0f6c6f0e-…",
"type": "payment.succeeded",
"mode": "test",
"createdAt": "2026-11-18T00:14:09.512Z",
"data": {
"payment": {
"id": "7b0e3c0a-…",
"reference": "ORDER-14",
"amount": "968.62",
"currency": "PGK",
"status": "succeeded",
"gateway": { "approvalCode": "123456", "authorizedAmount": "968.62", "rrn": "…", "order": "…" },
"paidAt": "2026-11-18T00:14:09.101Z",
"metadata": {}
}
}
}payment.expired can, rarely, be followed by payment.succeeded for the same payment: a customer who was already on Kina Bank's page at the moment of expiry can still finish paying. The later event is the truth.Verify the signature
Every delivery carries a header:
Header
Cshpay-Signature: t=1700000000,v1=3b843bacfb18cc5554542fdcc84d815b399c52758e508a6fcecf0a2af4efea2b
v1 is the HMAC-SHA256, in hex, of the string <t>.<raw body> using your endpoint's signing secret. To verify:
- Read the raw request body, before any JSON parsing.
- Compute the HMAC of
t + "." + bodywith your secret. - Compare it with
v1using a constant-time comparison. - Reject the delivery if
tis more than five minutes from now. This stops a captured delivery being replayed later.
You can check your implementation against this known value:
Test vector
secret: whsec_abc
t: 1700000000
body: {"a":1}
signature: 3b843bacfb18cc5554542fdcc84d815b399c52758e508a6fcecf0a2af4efea2bVerify against the raw body. If your framework parses the JSON and you re-serialise it, spacing and key order can change and the signature will not match.
Respond quickly, and expect repeats
- Answer with any
2xxstatus within 10 seconds. Do slow work afterwards. - Anything else, including a redirect, counts as a failure and is retried.
- The same event can arrive more than once. Make your handler safe to repeat, for example by storing each event
idyou have processed.
| Attempt | When |
|---|---|
| 1 | Immediately |
| 2 | 1 minute later |
| 3 | 5 minutes later |
| 4 | 30 minutes later |
| 5 | 2 hours later |
| 6 | 6 hours later |
| 7 | 12 hours later |
| 8 | 24 hours later |
After the eighth attempt the delivery is marked failed. You can see every attempt and resend a delivery from the dashboard under Webhooks.
Each delivery also carries Cshpay-Event-Id, Cshpay-Event-Type and Cshpay-Delivery-Attempt headers.
Endpoint rules
- Live endpoints must use
https. Test endpoints may usehttp. - The address must be reachable from the internet; private and local addresses are refused.
- Up to five active endpoints per mode.
