Skip to main content

When to use OnePay

Use OnePay when your project has an active OnePay Gateway Vault configuration and you need a provider-hosted checkout in LKR or USD. Start checkout with the shared createOrder() function, then use the OnePay-specific status function only from your backend when you need to observe a pending transaction.
The shared UPG lifecycle—availability, createOrder(), and completePayment()—is documented in Quick Setup. This page covers only OnePay-specific functions and presentation.

SDK Functions

Retrieve a OnePay transaction status

Use status() for a transaction ID that your backend stored from the prepared checkout session. It retrieves the OnePay provider observation and returns a small, safe summary. It is useful for bounded polling while an order remains pending; it is not a substitute for the normal shared completion flow.
SDK response — associative array:
paid_on is null when OnePay has not supplied a payment time. provider_status is SUCCESS or PENDING in this status summary. The SDK does not return OnePay credentials, raw request signatures, or provider-native response data.

Prepare a callback payload

OnePay callbacks can wake up your completion handler, but they are not payment proof. Preserve the callback exactly in a OnePayCallbackPayload, then pass its array to shared completePayment() together with the original server-only completion context.
SDK response — the exact callback array under callback:
The original callback fields are preserved unchanged. Do not trust them as a successful payment result: the shared completion request independently retrieves OnePay transaction status.

Prepare a browser-return payload

A customer returning to your application is only a signal to check the payment. Wrap the query parameters and complete the original payment on your backend; never mark an order as paid from the browser redirect alone.
SDK response — the exact query array under return:
OnePay’s returned transaction ID, when present, is bound to the prepared transaction before provider status is used for the final result.

Payment Elements

Use an explicit OnePay method when you want to control its title and placement. Keep the mode returned by server-side availability: overlay uses the official OnePay SDK presentation, while redirect sends the customer to the prepared hosted URL.
If the official overlay cannot start and the prepared session permits it, Elements can hand off to the OnePay redirect URL. That browser presentation is not a payment result. For rendering, visual customization, events, and the checkout lifecycle, see More Payment Elements features.

Gateway-specific options

There are no released OnePay tender-selection providerOptions. Your backend may choose redirect or overlay only after availability confirms that OnePay and the selected mode are usable for the active project environment.
  • The OnePay transaction reference comes from the prepared session; do not invent or replace it in browser code.
  • The configured Gateway Vault environment is selected on the backend. A buyer must never select sandbox or production.
  • overlay does not remove the need for a return URL and a configured OnePay notification path.

Completion, webhooks, and safety

On a callback or browser return, pass the stored completion context and one of the payloads above to common completePayment() with its default reconcileProvider: true. OnePay status is the authority for a terminal result. The normalized response can be succeeded, pending, failed, cancelled, or unknown; fulfil only when it is verified and paymentStatus is succeeded. If status retrieval is temporarily unavailable, retain the order as pending and retry from your backend with bounded, idempotent work. Never use an overlay event, callback arrival, or browser redirect as proof of payment.
Last modified on October 1, 2026