Webhooks
Asynchronous notifications will be sent to the Merchant when a Payment, Refund or other transaction changes status. The Merchant must provide a Notification URL for receiving such notifications. This URL must be HTTPS, accessible via Internet and with a valid SSL certificate issued from a trusted Certificate Authority.
For the callback to succeed, the system expects a 2xx HTTP status code
within 20 seconds of the notification call (connect timeout 10 seconds, read timeout 20 seconds). Otherwise, the notification
will be treated as unsent and The Kingdom Bank will try to send it again later. Please note that multiple notifications may be
sent for the same payment (matching the same foreignTransactionId).
The HTTP method used for sending the notification will be POST, with JSON content, sent with
Content-Type: application/json; charset=UTF-8.
It is highly recommended to validate the incoming webhook by calculating a signature of its body (using the algorithm for request signing) and
comparing it with the X-Signature header. The notification is signed with one of your active Signature Keys, not necessarily the one used for the original request;
the X-Signature-Key-Id header always holds the Key ID of the key used.
As an additional security measure, you can whitelist the IPs that The Kingdom Bank will be using to send webhooks. The list is available from your integration manager upon request.
Payment status
Every notification will send a status denoting what has happened with the payment. Below is a table describing the different statuses.
| Status | Description |
|---|---|
| FAILED | The payment has failed due to an error reported by the downstream processor, the customer or our backoffice cancelled the payment, or the payment timed out on The Kingdom Bank's side |
| PENDING | The payment is pending confirmation from the customer. At this point, the payment may or may not be processed |
| SCHEDULED | The customer has instructed the payment but the money has not yet reached our settlement account. Since there is a risk that the payment may be cancelled, the money is not yet added to your merchant account balance. Typically, when receiving this status, you would reserve the item in your inventory, but wait until the PROCESSED notification for the actual shipment. |
| PROCESSED | The customer completed the payment and the money has been added to your merchant account balance |
| OVERPAID, UNDERPAID | Deprecated. Sent when the customer paid more or less than requested; rely on the overpaid and underpaid flags of the notification instead |
The full notification body is described under Callbacks on each operation that takes a notificationUrl, for example Create Payment Request.
Notifications Retry algorithm
Notifications are retried up to 12 times in the span of 4 days after which they need to be manually resent
| Attempt | Delay after previous attempt |
|---|---|
| 1 | Immediately after status change |
| 2 | 3 seconds |
| 3 | 5 seconds |
| 4 | 15 seconds |
| 5 | 30 seconds |
| 6 | 1 minute |
| 7 | 5 minutes |
| 8 | 15 minutes |
| 9 | 30 minutes |
| 10 | 3 hours |
| 11 | 6 hours |
| 12 | 1 day |
| 13 | 3 days |