Danish Sharma
Danish Sharma

Reputation: 147

How to make Payment Method set as default in stripe after one time checkout payment

Payment Method of a customer After checkout the payment method gets saved in the customer dashboard. How to make that Payment method set as default using API calls or is there any way to make it default at the first place when there is a successful checkout of one time payment. Want to make it like this with API calls

Upvotes: 2

Views: 1782

Answers (1)

Tarzan
Tarzan

Reputation: 1077

You could listen to the checkout.session.completed[1] event in your webhooks[2]. Once you get that object you could retrieve the Payment Intent [3] and use the charges.data[0].payment_method [4] to update[5] the customer’s default payment method[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

Upvotes: 2

Related Questions