Skip to main content
Version: 1.0.0

Webhooks

Webhooks are merchant-wide, event-based notifications configured once at the merchant account level by Zenith. The merchant provides an HTTPS endpoint URL, and Zenith registers it against the merchant account.

Once registered, Zenith will POST JSON payloads whenever:

  • A transaction status changes (e.g. Pending → Successful) across any payment method or channel.
  • PayTo mandate status changes
  • isSettledToMerchant status changes

Webhooks are dispatched on a scheduler/timer that evaluates states and posts updates. All payment methods and channels trigger the same webhook mechanism.

Per-transaction callbacks

If you are using the Hosted Payment Page and need immediate, per-transaction notifications, see Callbacks and Returns. Callbacks are HPP-only and apply to a single transaction.

Callbacks vs Webhooks​

Requirements​

  • HTTPS POST endpoint – Must be reachable from Zenith's servers.
  • Stable URL – The endpoint is configured once by Zenith; changes require contacting Zenith.

Webhook Headers​

Every webhook has three headers.

  • x-signature: a 64-character code, different for every webhook. It proves the webhook came from ZenPay and was not changed. See Verifying the Signature.
  • x-version: 1. The webhook format version, the same as Version in the body.
  • x-platform: zenpay. Who sent it.

Verifying the Signature​

Each webhook is signed, so you can check that it came from ZenPay and was not changed. The signature is in the x-signature header. It is the HMAC-SHA256 of the request body, written as lowercase hex, and the key is your ZenPay API key for the environment that sent the webhook (sandbox or live).

To check a webhook:

  1. Read the request body as text, exactly as it arrived.
  2. Work out the HMAC-SHA256 of that text, with your API key as the key.
  3. Compare it with the x-signature header.
  4. If they match, parse the JSON and process the webhook. If they do not match, answer 401 and ignore it.
Check the body before you parse it

Use the text you received, not JSON you parsed and turned back into text. ZenPay writes whole amounts with a decimal point ("CustomerFee":0.0). Parsing and writing the JSON again drops it (0), so the text changes and the signature no longer matches.

In Node.js:

import { createHmac, timingSafeEqual } from 'node:crypto';

function isFromZenPay(rawBody, apiKey, signature) {
const expected = Buffer.from(createHmac('sha256', apiKey).update(rawBody).digest('hex'));
const received = Buffer.from(signature);
return received.length === expected.length && timingSafeEqual(received, expected);
}
The same webhook can arrive twice

Only the body is signed and there is no timestamp, so a replayed copy still passes. Make handling the same webhook twice harmless, for example by skipping a PaymentReference and PaymentStatus pair you have already handled.

Webhook Payload Fields​

The body has four top-level fields. The payment details are inside Payload.

{
"Version": 1,
"Event": "New",
"PayloadType": "Payment",
"Payload": { "PaymentReference": "250899", "PaymentStatus": 3, "...": "..." }
}
FieldTypeNotes
VersionnumberWebhook format version. Same value as the x-version header.
EventstringWhat happened, for example New.
PayloadTypestringWhat Payload holds, for example Payment.
PayloadobjectThe payment details, listed below.

Payment fields​

These fields are inside Payload.

FieldTypeNotes
PaymentReferencestringUnique payment reference assigned by Zenith.
CustomerNamestring | nullName of the customer; null when there is none.
CustomerReferencestringReference provided by the merchant.
PaymentStatusnumberNumeric status code.
PaymentStatusDisplaystringHuman-readable payment status.
BaseAmountnumberBase amount before fees.
FundsToMerchantnumberNet amount payable to the merchant.
CustomerFeenumberFee charged to the customer.
MerchantFeenumberFee charged to the merchant.
PaymentAmountnumberTotal amount of the transaction.
AccountOrCardNostringMasked account or card number.
PaymentMethodnumberNumeric code for the payment method.
PaymentMethodDisplaystringHuman-readable payment method.
PaymentCardTypenumberNumeric code for the card type.
PaymentCardTypeDisplaystringHuman-readable card type.
SubCardTypenumber | nullNumeric code for the sub card type; null when there is none.
SubtCardTypeDisplaystring | nullHuman-readable sub card type; null when there is none. Field name is misspelled, this is not an error in documentation. Also sent as SubCardTypeDisplay.
SubCardTypeDisplaystring | nullHuman-readable sub card type. Same value as SubtCardTypeDisplay.
ProcessingDateTimestringUTC ISO-8601 datetime (yyyy-MM-ddTHH:mm:ss).
SettlementDatestring | nullUTC ISO-8601 date (yyyy-MM-dd), or null.
ProcessorReferencestringReference from the processor/gateway.
IsPaymentSettledToMerchantbooleanIndicates if the payment has been settled.
FailureCodestringFailure code; an empty string when there is none. Not on every webhook.
FailureReasonstringFailure reason; an empty string when there is none. Not on every webhook.
MerchantUniquePaymentIdstring | nullUnique payment ID from the merchant; null when there is none.
MerchantCodestringMerchant identifier.
AdditionalReferencestring | nullAdditional reference; null when there is none.
PaymentSourcenumberNumeric source identifier.
PaymentSourceDispalystringHuman-readable payment source. Field name is misspelled, this is not an error in documentation. Also sent as PaymentSourceDisplay.
PaymentSourceDisplaystringHuman-readable payment source. Same value as PaymentSourceDispaly.
IsPaymentRecalledbooleanIndicates if the payment has been recalled.
IsPaymentRetryScheduledbooleanIndicates if a retry of the payment is scheduled. Not on every webhook.
IsPaymentRefundedbooleanIndicates if the payment has been refunded.
Sku1string | nullnull when empty.
Sku2string | nullnull when empty.
AdditionalDataobjectProcessor details: AuthCode, RRN and STAN. Not on every webhook.
CardTypeValuenumberNumeric code for the card type.
CardTypeStringstringName of the card type, for example MasterCard.
SubCardTypeValuenumber | nullNumeric code for the sub card type; null when there is none.
SubCardTypeStringstring | nullName of the sub card type; null when there is none.
SettlementTypestringSettlement type, for example Net or Gross.
SettlementFrequencyValuenumberNumeric code for the settlement frequency (1 Daily, 2 Monthly).
SettlementFrequencyStringstringSettlement frequency, for example Daily or Monthly.

Webhook Examples​

These are example webhooks from sandbox payments, grouped by checkout mode. Each entry is one payment, and its buttons select the messages in the order they arrived. Select a mode and payment to see the webhook as one JSON object: headers holds the three headers ZenPay sets (x-signature, x-version, x-platform), and body holds the JSON that ZenPay sends. On the wire the headers travel beside the body, not inside it, and only the body is signed. Signature verification uses the original received body, including its whitespace.

Webhook reference

{
"headers": {
"x-platform": "zenpay",
"x-signature": "53e842e7fe4392ca6813f35bc12ed2da00179aa8c64d1a5cfa946d1fd146d3b8",
"x-version": "1"
},
"body": {
"Version": 1,
"Event": "New",
"PayloadType": "Payment",
"Payload": {
"PaymentReference": "250905",
"CustomerName": "Jaina Proudmoore",
"CustomerReference": "CUST-523YU4BE",
"PaymentStatus": 3,
"PaymentStatusDisplay": "Successful",
"BaseAmount": 214.18,
"FundsToMerchant": 214.18,
"CustomerFee": 0,
"MerchantFee": 0,
"PaymentAmount": 214.18,
"AccountOrCardNo": "625094XXXXXX0016",
"PaymentMethod": 0,
"PaymentMethodDisplay": "Credit / Debit Card",
"PaymentCardType": 21,
"PaymentCardTypeDisplay": "UnionPay - International Cards",
"SubCardType": null,
"SubtCardTypeDisplay": null,
"SubCardTypeDisplay": null,
"ProcessingDateTime": "2026-11-03T20:33:18",
"SettlementDate": "2026-11-05",
"ProcessorReference": "1456-P-BVFV6A4PZBSBIMWE",
"IsPaymentSettledToMerchant": false,
"MerchantUniquePaymentId": "OOLrdYj3SNVXY9uQBfM4Vw",
"MerchantCode": "1337",
"AdditionalReference": "ADD-QQ8KDNW3",
"PaymentSource": 36,
"PaymentSourceDispaly": "Pub.Online Payment - Customer",
"PaymentSourceDisplay": "Pub.Online Payment - Customer",
"IsPaymentRecalled": false,
"IsPaymentRefunded": false,
"Sku1": null,
"Sku2": null,
"CardTypeValue": 21,
"CardTypeString": "UnionPay",
"SubCardTypeValue": null,
"SubCardTypeString": null,
"SettlementType": "Gross",
"SettlementFrequencyValue": 2,
"SettlementFrequencyString": "Monthly"
}
}
}