I am using a setupIntent
to save a card to a customer for future use. I pass the client_secret from the setupIntent
to the confirmCardSetup
in js.
Later, I create a paymentIntent
with that card. If it is declined and the status is requires_payment_method
then I email the customer and give them a form to enter a new card, and subit that using confirmCardPayment
in js. This works well and the charge succeeds (or becomes requires_capture
).
How do I then attach that new payment method to the customer? If I do nothing, then their old saved card is still their primary payment method.
I only want to keep one card on file for each customer. I know I can detach the old card and then attach the new one, but then it will not have been done using a setupIntent
, which is apparently more appropriate if I'm going to be charging the card in the future off session.
You can also save a card for future use during a payment using setup_future_usage=off_session
by following this guide . The payment method will be automatically attached to the customer provided on the Payment Intent.
Your existing flow can be used, you'd just extend it by:
setup_future_usage
option.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.