pacan
pacan

Reputation: 3

Pay using the customer's saved payment method in Stripe Elements

I've created a PaymentIntent that has the customer's payment_method specified. When I create a payment form using Stripe Elements, I get the following result: stripe form

But I want the card input form to be displayed as in the checkout session. Somehow like this: expected stripe form

Upvotes: 0

Views: 1320

Answers (1)

soma
soma

Reputation: 2219

It's not possible to pre-fill the payment method of the Payment Element. But if you already have a PaymentMethod saved for the customer, then you don't need the Payment Element at all:

  1. Create the PaymentIntent on the backend with payment_method: pm_xxx and confirm: true.
  2. Then check the PaymentIntent status:
    • If it's succeeded, then there's nothing else to do.
    • If it's requires_action, then you need to confirm it on the frontend using stripe.confirmCardPayment().

Upvotes: 2

Related Questions