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 remove a stored payment method — for example, when a customer asks to forget a card, or after a one-off purchase where you don’t want to retain card details. For request and response details, see the Delete payment method API. To obtain a paymentMethodId, list the customer’s stored payment methods with client.getPaymentMethods().
Delete a payment method
import { useMoonPay } from "@moonpay/platform-sdk-react-native";

export function ForgetCardButton({
  paymentMethodId,
}: {
  paymentMethodId: string;
}) {
  const { client } = useMoonPay();

  const handleDelete = async () => {
    // Call this after the client has an active connection.
    const result = await client.deletePaymentMethod(paymentMethodId);

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

    // On success, `result.value` is `undefined`.
  };

  // ...
}

Parameters

ParameterTypeRequiredDescription
paymentMethodIdstringThe id of the stored card to delete. Obtain this from client.getPaymentMethods().

Result

client.deletePaymentMethod() returns a Result<void, DevPlatformApiError>. The API responds with 204 No Content on success, so result.value is undefined — there is no response body to read. Check result.ok to confirm the delete succeeded.

Result envelope

Result<void, DevPlatformApiError>
FieldTypeRequiredDescription
okbooleanWhether the operation succeeded.
valueundefinedPresent when ok is true. Always undefined (no response body).
errorDevPlatformApiErrorPresent when ok is false.

DevPlatformApiError

The standard MoonPay Platform API error shape.
FieldTypeRequiredDescription
codeDevPlatformApiErrorCodeA machine-readable error code (for example, "not_found", "unauthorized"). See the error reference for the full list.
messagestringA developer-friendly message.
errorsDevPlatformApiErrorDetail[]Optional list of field-level errors.
types.ts
type DevPlatformApiError = {
  code: DevPlatformApiErrorCode;
  message: string;
  errors?: DevPlatformApiErrorDetail[];
};

type DevPlatformApiErrorDetail = {
  field?: string;
  message: string;
};