Skip to main content

When to use MarxPay

MarxPay is a one-time, redirect-only checkout for a project that has MarxPay tender variants enabled in its Gateway Vault. Use the shared createOrder() function to prepare checkout; use the functions below only on your backend to bind and inspect a MarxPay return safely.
The shared UPG lifecycle—availability, createOrder(), and completePayment()—is documented in Quick Setup. This page covers only MarxPay-specific functions.

SDK Functions

Verify a browser return

The browser return contains merchantRID and trId. Those values are identifiers, not payment proof. Compare them against the pair your backend saved when it created the checkout session before doing anything else.
SDK response — MarxPayReturnVerification:
The SDK exposes these as $verification->verified, $verification->merchantRid, $verification->trId, and $verification->requestId. A mismatch raises an exception; do not change order state.

Initiate a verified MarxPay payment

Use this function only after verifyReturn() succeeds for the same saved merchantRID and trId. It asks MarxPay to initiate the bound transaction. It does not replace the final common UPG completion step.
SDK response — MarxPayPaymentResult:
The PHP object properties are $result->merchantRid, $result->trId, $result->paymentStatus, $result->providerStatus, $result->amount, $result->currency, $result->paymentMethod, $result->expiresAt, and $result->requestId. payment_status can be succeeded, pending, failed, or unknown; a started payment is not automatically a completed payment.

Retrieve an order summary

Use this read-only function to retrieve the current safe summary for the same transaction. It validates that the returned provider data belongs to the supplied merchantRid and trId before mapping the result.
SDK response — MarxPayPaymentResult:
This is a safe SDK projection. Raw MarxPay gateway and card data are intentionally not returned.

Payment Elements

When server-side availability returns more than one enabled MarxPay tender, Payment Elements renders each one as a separate method card. Each card keeps gateway: 'marxpay' and mode: 'redirect', then sends the selected tender as providerOptions.payment_method to your backend.
For rendering, events, visual customization, and checkout lifecycle details, see More Payment Elements features.

Gateway-specific options

providerOptions.payment_method accepts only OTHER, AMEX, OTHER_USD, AMEX_USD, and PAY_BY_BANK_ACCOUNT.
  • OTHER and AMEX are LKR-only.
  • OTHER_USD and AMEX_USD are USD-only.
  • PAY_BY_BANK_ACCOUNT is available only if the connected MarxPay merchant account enables it.
  • Omitting the option defaults to OTHER for LKR and OTHER_USD for USD.
AvraAPI validates the tender against the order currency and enabled Gateway Vault payment methods. A browser selection never overrides that check.

Completion, webhooks, and safety

Even after a successful return binding or order-summary call, a browser return is not payment proof. Preserve the original server-only completion context and call common completePayment() for the final reconciliation and canonical payment result. Do not send merchantRID, trId, or summary data into client-controlled state.
Last modified on October 1, 2026