How to make subscription using saved cards in stripe with node/React

Viewed 29

I made a subscription using a card, i want to do another subscription with the existing saved card. While subscribing the second time I want to use my previously saved card while the first subscription. I have that card detail from the strip payment method list API

I am creating subscription

      const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{
        price: priceId,
      }],
      payment_behavior: 'default_incomplete',
      expand: ['latest_invoice.payment_intent'],
    });

    res.send({
      subscriptionId: subscription.id,
      clientSecret: subscription.latest_invoice.payment_intent.client_secret,
    });

and on the UI i am doing confirmCardPayment with stripe for the first subscription

  stripe.confirmCardPayment(clientSecret, {
    payment_method: {
      card: cardElement,
      billing_details: {
        name: nameInput.value,
      },
    }
  })

I have the list of saved cards in the UI now i want to use the saved card and do the subscription

1 Answers

There are a couple of ways to set this up. One way is to set the customer’s invoice_settings.default_payment_method here. Alternatively, you’d be able to use the customer’s attached PaymentMethod when creating the second subscription. You’d pass that PaymentMethod id on default_payment_method here.

Related