Skip to main content
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 { useMoonPay } from "@moonpay/platform-sdk-react-native";

export function PaymentMethodsList() {
  const { client } = useMoonPay();

  const load = async () => {
    // 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.paymentMethodConfigs); // Available payment-method configs
    console.log(result.value.data.paymentMethods); // Stored payment methods, such as saved cards (if any)
  };

  // ...
}

Result

client.getPaymentMethods() returns a Result<{ data: ListPaymentMethodsResponse }, GetPaymentMethodsError>.

Result envelope

Result<{ data: ListPaymentMethodsResponse }, GetPaymentMethodsError>
FieldTypeRequiredDescription
okbooleanWhether the operation succeeded.
value{ data: ListPaymentMethodsResponse }Present when ok is true.
errorGetPaymentMethodsErrorPresent when ok is false.

ListPaymentMethodsResponse

FieldTypeRequiredDescription
paymentMethodConfigsPaymentMethodConfig[]Payment methods (Apple Pay, Google Pay, card, etc.) available to the customer with their capabilities and availability.
paymentMethodsStoredPaymentMethod[]Payment methods the customer has stored on file, such as saved cards.

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.
allowsDeletionbooleanWhether this payment method can be deleted via client.deletePaymentMethod().
requiresWidgetbooleanWhether this payment method requires the MoonPay widget to complete the payment flow.

PaymentMethodAvailability

FieldTypeRequiredDescription
activebooleanWhether this payment method is available for the current session.
reasonsstring[]If the payment method is unavailable, a list of machine-readable reasons.

StoredPaymentMethod

A payment method the customer has stored on file. Use the id directly in client.getQuote() to quote against a specific stored payment method. Stored cards extend the base shape with card details — see the API reference for the full shape, including network brand, expiry, and last4.
FieldTypeRequiredDescription
idstringThe stored payment method 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", "not_found"). See the error reference for the full list.
messagestringA developer-friendly message.
errorsDevPlatformApiErrorDetail[]Optional list of field-level errors.
types.ts
type ListPaymentMethodsResponse = {
  paymentMethodConfigs?: PaymentMethodConfig[];
  paymentMethods?: StoredPaymentMethod[];
};

type StoredPaymentMethod = {
  id: string;
  type: PaymentMethodType;
};

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

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

type PaymentMethodAvailability = {
  active: boolean;
  reasons?: string[];
};

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