When to use KOKO
Use KOKO for an LKR-only, buy-now-pay-later redirect checkout. The sharedcreateOrder() 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
- PHP SDK
- Laravel SDK
- Node.js SDK
Retrieve a signed KOKO order view
UseorderView() 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.
- PHP SDK
- Laravel SDK
- Node.js SDK
KokoOrderView:$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. UsefromForm() to require the exact callback binding fields before shared completion. This helper validates that the required fields are present; signature verification occurs during completePayment().
- PHP SDK
- Laravel SDK
- Node.js SDK
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.
- PHP SDK
- Laravel SDK
- Node.js SDK
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.Gateway-specific options
There are no released KOKO-specific checkoutproviderOptions.
- 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 sharedcompletePayment() 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.