When to use DirectPay
DirectPay is the released in-page gateway for LKR and USD one-time payments. The sharedcreateOrder() 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
- PHP SDK
- Laravel SDK
- Node.js SDK
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.- PHP SDK
- Laravel SDK
- Node.js SDK
DirectPayCallbackPayload::toArray():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.- PHP SDK
- Laravel SDK
- Node.js SDK
PaymentCompletionResult:$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. Usemode: '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.
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 releasedproviderOptions.prefill_customer option is an explicit opt-in:
- Omit it or set it to
falseby default. DirectPay’s browser package can log its input, so customer contact fields are not prefilled automatically. - Set
prefill_customer: trueonly 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.
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 sharedcompletePayment() 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.