Skip to main content

Documentation Index

Fetch the complete documentation index at: https://dev.moonpay.com/llms.txt

Use this file to discover all available pages before exploring further.

Use this method to list the customer’s available payment methods, plus any cards they have on file. For request and response details, see the List payment methods API.
Get payment methods
import { createClient } from "@moonpay/platform-sdk-web";

const client = createClient({ sessionToken: "c3N0XzAwMQ==" });

// Call this after the client has an active connection (for example, after
// `client.getConnection()` returns `status: "active"` or after `client.connect()`
// completes).
const result = await client.getPaymentMethods();

if (!result.ok) {
  // Handle error
  console.error(result.error.code, result.error.message);
  return;
}

console.log(result.value.data); // Available payment-method configs
console.log(result.value.storedCards); // Saved cards on file (if any)

Result

client.getPaymentMethods() returns a Result<ListPaymentMethodsResponse, GetPaymentMethodsError>.

Result envelope

Result<ListPaymentMethodsResponse, GetPaymentMethodsError>
FieldTypeRequiredDescription
okbooleanWhether the operation succeeded.
valueListPaymentMethodsResponsePresent when ok is true.
errorGetPaymentMethodsErrorPresent when ok is false.

ListPaymentMethodsResponse

FieldTypeRequiredDescription
dataPaymentMethodConfig[]Payment methods (Apple Pay, Google Pay, card, etc.) available to the customer with their capabilities and availability.
storedCardsStoredCardPaymentMethod[]Cards the customer has saved on file. Present when the connected customer has at least one saved card.

PaymentMethodConfig

FieldTypeRequiredDescription
typePaymentMethodTypeThe payment method type (for example, "apple_pay", "google_pay", "card").
capabilitiesPaymentMethodCapabilitiesDetails about how this payment method can be used.
availabilityPaymentMethodAvailabilityWhether this payment method is available for the current session.

PaymentMethodCapabilities

FieldTypeRequiredDescription
supportedCurrenciesstring[]A list of ISO 4217 fiat currency codes that this payment method can be used with.
supportedTransactionTypesstring[]The kinds of transactions this payment method can be used for.

PaymentMethodAvailability

FieldTypeRequiredDescription
activebooleanWhether this payment method is available for the current session.
unavailableReasonstringIf the payment method is unavailable, a developer-friendly message.

StoredCardPaymentMethod

A card the customer has saved on file. Use the id directly in client.getQuote() to quote against a specific stored card. See the API reference for the full shape, including network brand, expiry, and last4.
FieldTypeRequiredDescription
idstringThe stored card identifier. Pass this to getQuote({ paymentMethod: { type: "card", id } }).
typestringThe payment method type, typically "card".

GetPaymentMethodsError

GetPaymentMethodsError is the standard MoonPay Platform API error shape, DevPlatformApiError.
FieldTypeRequiredDescription
codeDevPlatformApiErrorCodeA machine-readable error code (for example, "unauthorized", "connection_required"). See the error reference for the full list.
messagestringA developer-friendly message.
errorsDevPlatformApiErrorDetail[]Optional list of field-level errors.
types.ts
type ListPaymentMethodsResponse = {
  data: PaymentMethodConfig[];
  storedCards?: StoredCardPaymentMethod[];
};

type PaymentMethodConfig = {
  type: PaymentMethodType;
  capabilities: PaymentMethodCapabilities;
  availability: PaymentMethodAvailability;
};

type PaymentMethodCapabilities = {
  supportedCurrencies: string[];
  supportedTransactionTypes: string[];
};

type PaymentMethodAvailability = {
  active: boolean;
  unavailableReason?: string;
};

type GetPaymentMethodsError = {
  code: DevPlatformApiErrorCode;
  message: string;
  errors?: DevPlatformApiErrorDetail[];
};