Skip to main content

When to use DirectPay

DirectPay is the released in-page gateway for LKR and USD one-time payments. The shared createOrder() call prepares the signed DirectPay browser session. Choose overlay to open the provider checkout window or embedded to present it in a dedicated page container. In both cases, the signed DirectPay callback—not a browser event—decides the final payment result.
The shared UPG lifecycle—availability, createOrder(), and completePayment()—is documented in Quick Setup. This page covers the released DirectPay V3 one-time checkout only.

SDK Functions

Preserve a signed DirectPay callback

DirectPay signs the exact callback body with the configured HMAC secret. Read the original body and the exact Authorization header from your backend callback request before parsing or transforming either value. The SDK wrapper only preserves them for shared completion.
SDK response — DirectPayCallbackPayload::toArray():
The wrapper rejects missing or blank values. The raw body and Authorization signature are server-only evidence: do not construct them from a browser event, and do not send them to browser state, logs, queues, or analytics.

Complete a signed DirectPay callback

Use the stored completion context and the exact callback payload. AvraAPI verifies the callback HMAC, parses the verified body, validates amount and currency against the prepared order, and checks a returned order ID whenever DirectPay supplies one.
SDK response — PaymentCompletionResult:
The SDK exposes $result->paymentStatus, $result->providerStatus, $result->gatewayReference, $result->amount, and $result->currency. SUCCESS and APPROVED map to succeeded; PENDING and PROCESSING map to pending; unrecognised statuses map to unknown. The current released adapter maps DirectPay cancellation and decline statuses to failed.

Payment Elements

Render DirectPay as one explicit method. Use mode: 'embedded' when your page has the dedicated DirectPay container; change only the mode to overlay when you want the provider window instead. The checkout session must still be created by your backend through the shared SDK flow.
An Elements checkout_completed, close, or error event is UI state only. For rendering, the required embedded container, visual customization, events, and the checkout lifecycle, see More Payment Elements features.

Gateway-specific options

The released providerOptions.prefill_customer option is an explicit opt-in:
  • Omit it or set it to false by default. DirectPay’s browser package can log its input, so customer contact fields are not prefilled automatically.
  • Set prefill_customer: true only when you accept that the approved customer fields will be included in the provider checkout session.
  • Merchant credentials, HMAC secret, callback signature, and checkout signing values are never browser options.
The DirectPay V3 browser session has no released redirect URL mode. Do not attempt to use DirectPay’s separate unpublished/advanced provider operations as UPG SDK functions.

Completion, webhooks, and safety

DirectPay does not have a released, authenticated status lookup in the current UPG scope. Do not invent polling or treat an overlay/embedded browser event as confirmation. The only authoritative path is the signed callback to your configured response URL, followed by shared completePayment() with the original server-only completion context. Fulfil only a verified succeeded result. Preserve pending and unknown orders for merchant-side handling rather than changing their payment status from client-side UI events.
Last modified on October 1, 2026