【发布时间】:2022-06-10 21:10:07
【问题描述】:
Payment Method of a customer 结帐后,付款方式将保存在客户仪表板中。如何使用 API 调用将该付款方式设置为默认值,或者在一次付款成功结帐时,有什么方法可以在第一时间将其设置为默认值。 Want to make it like this with API calls
【问题讨论】:
标签: stripe-payments checkout payment-method
Payment Method of a customer 结帐后,付款方式将保存在客户仪表板中。如何使用 API 调用将该付款方式设置为默认值,或者在一次付款成功结帐时,有什么方法可以在第一时间将其设置为默认值。 Want to make it like this with API calls
【问题讨论】:
标签: stripe-payments checkout payment-method
您可以在 webhook[2] 中收听 checkout.session.completed[1] 事件。获得该对象后,您可以检索付款意图 [3] 并使用 charges.data[0].payment_method [4] 更新 [5] 客户的默认付款方式 [6]。
[1]https://stripe.com/docs/api/events/types#event_types-checkout.session.completed
[2] https://stripe.com/docs/webhooks
[3] https://stripe.com/docs/api/payment_intents/retrieve
[4] https://stripe.com/docs/api/charges/object#charge_object-payment_method
[5] https://stripe.com/docs/api/customers/update
[6]https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
【讨论】: