[英]Stripe -- after confirmCardPayment, how to attach the new card to the customer?
I am using a setupIntent
to save a card to a customer for future use.我正在使用
setupIntent
将卡保存给客户以供将来使用。 I pass the client_secret from the setupIntent
to the confirmCardSetup
in js.我将 client_secret 从
setupIntent
给 js 中的confirmCardSetup
。
Later, I create a paymentIntent
with that card.后来,我用那张卡创建了一个
paymentIntent
。 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.如果它被拒绝并且状态为
requires_payment_method
然后我 email 客户并给他们一个表格以输入新卡,并使用 js 中的confirmCardPayment
提交。 This works well and the charge succeeds (or becomes requires_capture
).这很好用并且收费成功(或变为
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.我知道我可以拆下旧卡然后连接新卡,但是它不会使用
setupIntent
完成,如果我将来要从 session 对卡充电,这显然更合适。
You can also save a card for future use during a payment using setup_future_usage=off_session
by following this guide .您还可以按照本指南使用
setup_future_usage=off_session
保存卡片以供将来在付款期间使用。 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.setup_future_usage
选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.