Reputation: 31
I am building an application that uses Stripe to handle payment. We are using stripe connect to take application fees from our users who use our platform to handle their bookings. On stripe documentation, I learned that I can use a payment flow stripe call: Save payment details during payment. This part of the implementation is working. As expected, stripe saved the payment details during the user's payment and we would like to use that payment details in the future. To do this, stripe recommended a workflow like this: When you’re ready to charge your customer off-session, use the Customer and PaymentMethod IDs to create a PaymentIntent. Then, to generate a list of payment IDs that a customer has, I used the stripe method:
const paymentMethods = await stripe.paymentMethods.list({ customer: '{{CUSTOMER_ID}}', type: 'card', });
This returned an object with a data field which is an array of cards associated with that customer along with the payment id. I am in test mode so, the customer has more than one card. In fact, the cards are more than 5 in number. The question is how do I determine which card to use in a situation where there is more than one card for the customer? Or Am I at liberty to use any of the cards? Is there something like a default card associated with the user? I tried sending the array of ids but stripe paymentIntent API rejected it, the typescript error stated that payment_method requires a string and not a string[]
Upvotes: 1
Views: 1386
Reputation: 1181
I assume you're using this guide to save the PaymentMethod to use in the future. If so, when you pass setup_future_usage
, it indicates that you're going to use the PaymentMethod for future payments. If the customer has more than one PaymentMethod attached to it, you can use whichever card. However, please note that if the customer does not recognize the charge, the end customer may dispute it. So it's important that they are aware that their card will be charged.
As far as default PaymentMethods, it is't relevant if you're using invoices. You can set a default PaymentMethod on the customer to use by passing invoice_settings.default_payment_method
on the Customer Update request for instance. However, I do not think that is what you're after from the above question.
Upvotes: 0