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.

FieldTypeDescription
transactionIdstringThe payment waiting on the customer
method'mobile_wallet' | …The method used
walletstring | undefinedThe mobile wallet’s code

onSuccess

FieldTypeDescription
idstringWatenga transaction ID (re-read it on your server: GET /v1/transactions/{id})
amountnumberPaid amount
currencystringISO 4217 code
referencestringYour reference
statusstringcompleted, processing (credited, settling) or escrow_held (TrustPay)
paidAtstringISO 8601 timestamp
gatewaystringThe method or wallet that paid
walletTypestring | undefinedThe mobile wallet’s code, for mobile money
cardLast4string | undefinedLast four digits, for cards
cardBrandstring | undefinedVISA, 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.

FieldTypeDescription
transactionIdstring | undefinedThe payment that was not made
method'card' | 'mobile_wallet' | …The method the customer tried
walletstring | undefinedThe mobile wallet’s code
reason'cancelled' | 'declined'Cancelled by the customer, or declined (a refused or lapsed prompt)

onError

FieldTypeDescription
codestringMachine-readable code (see the error-code reference)
messagestringMessage 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:

ParameterMeaning
watenga_paymentThe Watenga transaction ID: re-read it on your server before you fulfil the order
watenga_statuspaid, pending or failed: a hint for the page, never proof of payment