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 sharedcreateOrder() 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
- PHP SDK
- Laravel SDK
- Node.js SDK
Verify a browser return
The browser return containsmerchantRID 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.
- PHP SDK
- Laravel SDK
- Node.js SDK
MarxPayReturnVerification:$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 afterverifyReturn() 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.
- PHP SDK
- Laravel SDK
- Node.js SDK
MarxPayPaymentResult:$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 suppliedmerchantRid and trId before mapping the result.
- PHP SDK
- Laravel SDK
- Node.js SDK
MarxPayPaymentResult: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 keepsgateway: 'marxpay' and mode: 'redirect', then sends the selected tender as providerOptions.payment_method to your backend.
Gateway-specific options
providerOptions.payment_method accepts only OTHER, AMEX, OTHER_USD, AMEX_USD, and PAY_BY_BANK_ACCOUNT.
OTHERandAMEXare LKR-only.OTHER_USDandAMEX_USDare USD-only.PAY_BY_BANK_ACCOUNTis available only if the connected MarxPay merchant account enables it.- Omitting the option defaults to
OTHERfor LKR andOTHER_USDfor USD.
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 commoncompletePayment() for the final reconciliation and canonical payment result. Do not send merchantRID, trId, or summary data into client-controlled state.