Skip to main content

When to use KOKO

Use KOKO for an LKR-only, buy-now-pay-later redirect checkout. The shared createOrder() function prepares the signed provider form. Your backend then preserves either KOKO’s signed callback or browser return and completes the original session. AvraAPI verifies the signed callback and, by default, reconciles it with KOKO’s signed order view before an order can be fulfilled.
The shared UPG lifecycle—availability, createOrder(), and completePayment()—is documented in Quick Setup. This page covers only KOKO-specific functions and presentation.

SDK Functions

Retrieve a signed KOKO order view

Use orderView() from your backend to inspect a KOKO order that your application created. The SDK requests the provider’s signed order view, verifies the returned order ID and RSA signature, and maps the verified fields into KokoOrderView.
SDK response — KokoOrderView:
The SDK object exposes $view->orderId, $view->gatewayReference, $view->providerStatus, and $view->requestId. It also has $view->native, the raw signed provider object. native is server-only diagnostic data and must not be returned to a browser, logs, queues, or analytics.

Prepare a signed callback payload

KOKO posts a signed form to the configured notification URL. Use fromForm() to require the exact callback binding fields before shared completion. This helper validates that the required fields are present; signature verification occurs during completePayment().
SDK response — callback payload:
The five field names intentionally match KOKO’s callback contract. Do not rename, reformat, or reconstruct them before completion. AvraAPI verifies the callback signature using the Vault-held KOKO public key.

Prepare a browser-return payload

KOKO’s browser return is unsigned. It is still useful to trigger completion, but it cannot prove payment. fromQuery() requires the order ID and keeps the optional transaction ID and status only when they are present.
SDK response — return payload:
Only orderId is required by the wrapper. During shared completion, AvraAPI retrieves the signed order view and rejects a returned trnId that does not match it.

Payment Elements

Use an explicit KOKO method when you want to promote eligible instalment checkout alongside other payment methods. The prepared KOKO session is a signed redirect form; Elements handles the standard browser hand-off but does not embed KOKO or present a plan selector.
Render KOKO only when server-side availability reports an active, usable LKR configuration. For rendering, visual customization, events, and the checkout lifecycle, see More Payment Elements features.

Gateway-specific options

There are no released KOKO-specific checkout providerOptions.
  • KOKO accepts LKR only; a non-LKR checkout is rejected by the backend.
  • The provider form fields, plugin registration values, and signature are created from Vault configuration on the backend. Do not create or alter them in the browser.
  • Store the order ID and server-only completion context with your pending order. Never expose the signature or Vault configuration.

Completion, webhooks, and safety

On KOKO callback, call shared completePayment() with the stored completion context and the exact callback payload. The default reconcileProvider: true verifies the callback signature and compares it with KOKO’s signed order view. A browser-return flow also obtains the signed order view before it can result in a final payment state. The normalized completion result may be succeeded, pending, failed, cancelled, or unknown. Fulfil only a verified succeeded result. Retain non-final orders for a bounded, idempotent backend retry; never use a browser return alone as proof of payment.
Last modified on October 1, 2026