renderMethods() turns safe server-generated availability data into selectable payment-method cards. It never calls AvraAPI from the browser and it never receives Project credentials or Gateway Vault secrets.
The safest default is to omit methods. Payment Elements then reads the availability bootstrap your backend placed in the page and shows only methods that are currently configured and available.
Default: server-discovered methods
On your backend, callavailability() with the same trusted merchant domain that you use when creating the order. Place the resulting browser-safe availability payload next to the mount target. Select the backend implementation that renders your checkout page.
- PHP
- Laravel
- Node.js
methods array:
The PHP SDK also has
renderMethods(), which can render a standalone secret-free mount for a simple server-rendered page. For a full checkout that calls elements.checkout(), use one browser-created Elements instance and the availability bootstrap pattern above so that the form, selection, and checkout share the same instance.Production priority and environment safety
When a gateway has both active Production and Sandbox Vault profiles, AvraAPI resolves Production by default. A trusted SDK environment override or a trusted explicit server-side selection can override that resolution. Elements does not choose the profile. Anenvironment value on a method only controls the visible Testing mode badge, and it is deliberately omitted from selected() and from the createOrder callback. Your backend must resolve and bind the actual gateway environment during createOrder().
All renderMethods() options
The
auto theme option uses the package’s default visual tokens. It does not dynamically switch between light and dark according to the buyer’s operating-system preference.
Explicit methods
Use explicit methods only when your server has already determined that the cards are safe to show. The supported gateway codes arepayhere, marxpay, directpay, payplus, webxpay, koko, onepay, and stripe.
Explicit method fields
hosted_session is accepted only for legacy compatibility and is normalized to redirect. New integrations should use redirect.
MarxPay payment-method variants
MarxPay is the current gateway whose public availability can contain more than one payment-method card for the same gateway. Each card usesgateway: 'marxpay' and mode: 'redirect'; its providerOptions.payment_method value tells your backend which MarxPay option the buyer selected.
There are five supported MarxPay values:
Let AvraAPI choose the safe set
The usual choice is still the server-discovered pattern shown above. When the MarxPay Vault profile enables several variants,availability() returns them as separate safe cards with the correct provider_options.payment_method value. It also omits a variant that the project has not enabled.
If you create a MarxPay order without a payment_method, AvraAPI uses OTHER for an LKR order and OTHER_USD for a USD order. Those defaults do not make a disabled Vault option available.
Show only the variants you want
You can deliberately render one MarxPay card, or several separate cards. For example, this selector offers LKR cards, USD cards, and bank-account payment as distinct buyer choices:OTHER_USD object. To offer a smaller list, remove the variants that do not fit the order currency or your checkout design. With multiple MarxPay cards, the first available card is selected by default; defaultGateway cannot distinguish variants because they all use the same marxpay gateway code.
Other gateway-specific behavior
No other currently released gateway exposes selectable payment-method variants throughrenderMethods() in the same way. DirectPay can be rendered as separate overlay or embedded cards, but that is a checkout-mode choice rather than a provider payment-method option. PayHere accepts selected optional checkout fields, and DirectPay supports an opt-in customer prefill; neither creates multiple gateway-specific payment-method cards. Other gateways currently return one provider-managed method list or one checkout card.
Read and manage the selector
renderMethods() returns a controller. Use it for UI state; do not use it as payment confirmation.
selected(), availability(), markUnavailable({ reason, message }), mount(), and destroy().
Unavailable and stale-page behaviour
Payment Elements disables any explicit method withavailable: false. If no selectable method remains, it renders an accessible unavailable panel and emits payment_methods_unavailable.
It also converts these fresh server availability failures from your createOrder callback into a safe disabled state:
This covers a page that was rendered before a UPG slot was released, an entitlement changed, a configuration was removed, or a project was paused. Refresh server-generated availability before allowing another checkout attempt.
Credential failures are intentionally collapsed into the generic browser error
elements_checkout_failed. Diagnose the actual credential problem only on your backend.
Continue with Checkout lifecycle, events & errors.
Visual & Samples
Open the Visual Playground — Payment Methods to explore the real method-card UI without API keys. It lets you switch the documentation theme, preview Sandbox versus Live badges, inspect the safe server-discovered example, define gateway cards, choose supported checkout modes, and copy the generatedrenderMethods() code. The playground uses static browser-safe example data only; it does not inspect a real project’s UPG slot, Vault profile, or gateway health.