Events
Callbacks fired by the Watenga.js checkout, in the order a payment meets them. A callback is a hint for your page: before you fulfil an order, confirm the payment on your server (re-read the transaction, or wait for the payment.capture.completed webhook).
onReady
The checkout is on the page and its payment methods are shown. Called once per mount. No payload.
onPending
A payment is waiting on the customer: a mobile-money prompt on their phone. The checkout keeps asking and says so; another payment is refused until this one is paid or declined, so the customer is never charged twice.
| Field | Type | Description |
|---|---|---|
transactionId | string | The payment waiting on the customer |
method | 'mobile_wallet' | … | The method used |
wallet | string | undefined | The mobile wallet’s code |
onSuccess
| Field | Type | Description |
|---|---|---|
id | string | Watenga transaction ID (re-read it on your server: GET /v1/transactions/{id}) |
amount | number | Paid amount |
currency | string | ISO 4217 code |
reference | string | Your reference |
status | string | completed, processing (credited, settling) or escrow_held (TrustPay) |
paidAt | string | ISO 8601 timestamp |
gateway | string | The method or wallet that paid |
walletType | string | undefined | The mobile wallet’s code, for mobile money |
cardLast4 | string | undefined | Last four digits, for cards |
cardBrand | string | undefined | VISA, MASTER, AMEX or ZIMSWITCH, for cards |
onCancel
The customer cancelled a card payment, or refused (or let lapse) a mobile-money prompt. Nothing was charged and the checkout stays open so they can try again. Without onCancel, a cancelled card payment is reported to onError with the code PAYMENT_CANCELLED.
| Field | Type | Description |
|---|---|---|
transactionId | string | undefined | The payment that was not made |
method | 'card' | 'mobile_wallet' | … | The method the customer tried |
wallet | string | undefined | The mobile wallet’s code |
reason | 'cancelled' | 'declined' | Cancelled by the customer, or declined (a refused or lapsed prompt) |
onError
| Field | Type | Description |
|---|---|---|
code | string | Machine-readable code (see the error-code reference) |
message | string | Message you can show the customer |
onClose
The customer closed the checkout (modal). No payload.
Return parameters
A card payment may leave your page for the card issuer’s check and come back. Watenga.js then replaces the provider’s parameters in the address with its own, so your page and server read one format:
| Parameter | Meaning |
|---|---|
watenga_payment | The Watenga transaction ID: re-read it on your server before you fulfil the order |
watenga_status | paid, pending or failed: a hint for the page, never proof of payment |