List payment methods
Retrieve available payment methods for the current Headless checkout session.
The checkout.getPaymentMethods() method returns an ordered list of
payment methods available for the current checkout session. Use it in
a Headless checkout integration to build your own payment method
selector.
const paymentMethods = await checkout.getPaymentMethods()Returns
The method returns an ordered array of payment method objects. The order reflects your merchant configuration.
| Field | Type | Description |
|---|---|---|
paymentMethodType | string | Unique identifier for the payment method. Pass this value to checkout.headless(). |
name | string | Optional. User-friendly display label (for example, "Card" or "ApplePay"). |
supportedCardBrands | string[] | Present when paymentMethodType is "card". Lists accepted card brands (for example, ["visa", "mastercard", "amex", "discover"]). |
redirect | boolean | Present and true when the method redirects the customer to the provider to complete the payment on every device. |
fields | array | Optional. Additional fields the customer must fill before submitting. See Field object. |
Field object
When a payment method needs additional input (for example, a bank
identifier for iDEAL), the fields array describes each form field.
Supply the collected values as the second argument to
checkout.headless().
| Field | Type | Description |
|---|---|---|
id | string | Field name. Use this as the key when passing values to checkout.headless(). |
label | string | User-friendly label for the field. |
type | string | One of "input", "date", "checkbox", "radio", or "select". Defaults to "input" when omitted. |
validation | object | Optional. Constraints on the field value. See Validation. |
placeholder | string | Optional. Placeholder text for the field. |
inputType | string | Optional. HTML input type attribute (for example, "email" or "tel"). |
options | array | Optional. Choices for select and radio fields. Each item has { label: string, value: string }. |
description | string | Optional. Hint text to guide the customer, typically rendered below the field or in a tooltip. |
Validation
When present, the validation object can include any combination of
these constraints:
{
required?: boolean
max?: number
min?: number
maxLength?: number
minLength?: number
pattern?: string
}Example
const paymentMethods = await checkout.getPaymentMethods()
// Example response
// [
// {
// paymentMethodType: 'card',
// name: 'Card',
// supportedCardBrands: ['amex', 'discover', 'mastercard', 'visa']
// },
// { paymentMethodType: 'applepay', name: 'ApplePay' },
// { paymentMethodType: 'googlepay', name: 'GooglePay' }
// ]
// Render each method in your UI
paymentMethods.forEach(method => {
console.log(method.paymentMethodType, method.name)
})
// When the customer selects a method, submit with checkout.headless()
await checkout.headless(selectedMethod.paymentMethodType, fieldValues)Next steps
- Display available payment methods: Step-by-step guide for building a payment method selector.
- checkout.headless(): Submit a payment using the selected payment method.
- checkout.canMakePayments(): Detect Apple Pay and Google Pay availability before rendering wallet buttons.
Was this page helpful?