Skip to Content
Docs

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.

Headless checkout only. Universal checkout displays payment methods automatically. You need this method only when you build your own checkout UI with Headless checkout.

const paymentMethods = await checkout.getPaymentMethods()

Returns

The method returns an ordered array of payment method objects. The order reflects your merchant configuration.

FieldTypeDescription
paymentMethodTypestringUnique identifier for the payment method. Pass this value to checkout.headless().
namestringOptional. User-friendly display label (for example, "Card" or "ApplePay").
supportedCardBrandsstring[]Present when paymentMethodType is "card". Lists accepted card brands (for example, ["visa", "mastercard", "amex", "discover"]).
redirectbooleanPresent and true when the method redirects the customer to the provider to complete the payment on every device.
fieldsarrayOptional. 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().

FieldTypeDescription
idstringField name. Use this as the key when passing values to checkout.headless().
labelstringUser-friendly label for the field.
typestringOne of "input", "date", "checkbox", "radio", or "select". Defaults to "input" when omitted.
validationobjectOptional. Constraints on the field value. See Validation.
placeholderstringOptional. Placeholder text for the field.
inputTypestringOptional. HTML input type attribute (for example, "email" or "tel").
optionsarrayOptional. Choices for select and radio fields. Each item has { label: string, value: string }.
descriptionstringOptional. 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)

The checkout session must be initialized before you call this method. getPaymentMethods() returns a promise, so await it or use .then().

Next steps

Was this page helpful?