@bates-solutions/stripe API Reference - v2.2.1
    Preparing search index...

    Class PaymentMethodsService

    Payment Methods service wrapping Stripe PaymentMethods: read, attach to and detach from customers, and set a customer's default.

    To save a card for later (off-session) charges, collect it with a SetupIntent (see setupIntents); Stripe attaches it to the customer when the SetupIntent succeeds.

    const { data: cards } = await stripe.paymentMethods.list({ customerId: 'cus_123', type: 'card' });
    await stripe.paymentMethods.setDefault('cus_123', cards[0].id);
    Index
    • Attach a payment method to a customer.

      Prefer a SetupIntent for cards you will charge off-session: attaching directly skips the authentication and mandate a SetupIntent collects.

      Parameters

      • paymentMethodId: string
      • options: { customerId: string; idempotencyKey?: string }

      Returns Promise<PaymentMethod>

      When paymentMethodId or customerId is missing

    • Detach a payment method from its customer. It can't be used again afterwards.

      Parameters

      • paymentMethodId: string
      • Optionaloptions: { idempotencyKey?: string }

      Returns Promise<PaymentMethod>

      When paymentMethodId is missing

    • Make a payment method the customer's default for invoices and subscriptions (invoice_settings.default_payment_method). The payment method must already be attached to the customer.

      Parameters

      • customerId: string
      • paymentMethodId: string
      • Optionaloptions: { idempotencyKey?: string }

      Returns Promise<Customer>

      The updated customer

      When customerId or paymentMethodId is missing