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

TypeSent when
payment.succeededKina Bank approved the payment and CSHPay verified the result
payment.failedThe card was declined, or the gateway reported a final failure
payment.expiredAn hour after an unpaid payment passed its expiry
refund.succeededKina Bank reversed the payment
refund.failedKina 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:

  1. Read the raw request body, before any JSON parsing.
  2. Compute the HMAC of t + "." + body with your secret.
  3. Compare it with v1 using a constant-time comparison.
  4. Reject the delivery if t is 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: 3b843bacfb18cc5554542fdcc84d815b399c52758e508a6fcecf0a2af4efea2b
Verify 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 2xx status 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 id you have processed.
AttemptWhen
1Immediately
21 minute later
35 minutes later
430 minutes later
52 hours later
66 hours later
712 hours later
824 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 use http.
  • The address must be reachable from the internet; private and local addresses are refused.
  • Up to five active endpoints per mode.