#Naveed | Web3Auth - PaymentMethod
1 messages · Page 1 of 1 (latest)
👋 Thanks for reaching out
If you mean to do it in the same request api call, you can't.
First you need to create your SetupIntent:
https://stripe.com/docs/payments/save-and-reuse?platform=web#web-create-intent
Then, you collect the Payment Details
https://stripe.com/docs/payments/save-and-reuse?platform=web#web-collect-payment-details
Then, you update your customer with the PaymentMethod as default one:
https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Is there any way I can do the confirmSetup and assign it as default on server side.
E.g. atm im using Stripe elements so my client-side code is doing the following
await this.stripe.confirmSetup({
elements: this.elements,
redirect: "if_required",
confirmParams: {
payment_method_data: {
billing_details: {
email: "gg@gg.com",
},
},
},
});
the response does return the payment method id which as you mentioned i can utilise to update my customers default payment method
But im thinking perhaps id like to do this on server side so something like myServer.confirmSetup and in that on server side i would do both the confirmation and the assigning default
but idk how this would work out since stripe.confirmSetup makes use of elements as a param
The confirmSetup, doesn't return the PaymentMethod Id, you need to fetch the customer PaymentMethod and the attached as a default PaymentMethod in his invoice_settings
https://stripe.com/docs/payments/save-and-reuse?platform=web#charge-saved-payment-method
I miss understand you question so, then you can use it directly after confirming the SetupIntent
Hi! I'm taking over this thread.
But im thinking perhaps id like to do this on server side so something like myServer.confirmSetup and in that on server side i would do both the confirmation and the assigning default
Technically it's possible to confirm a setupintent server side with https://stripe.com/docs/api/setup_intents/confirm
But it the payment method require actions (like for 3DS), then it will have to be done on the frontend. That's why we recommend doing the confirmation directly on the frontend.
So I recommend doing what os4m37 suggested:
- Create the SetupIntent (backend)
- Collect the payment details & confirm the SetupIntent (frontend)
- Then update the default payment method of the customer (backend) with https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Ahhh I see... it's crystal clear now thank you guys!