#nancy-paymentmethod-attach
1 messages · Page 1 of 1 (latest)
Hello @tight dawn. In theory you should never use createPaymentMethod.There are some exceptions but it's really rare and it's not our default integration path
If you are creating a subscription you should
1/ Create a Customer
2/ Create a Subscription
3/ Get the Subscription's Invoice's PaymentIntent's client_secret
4/ Use that to collect payment method details client-side and confirm the payment
@royal hawk - this is for an existing customer, with an existing subscription when they want to update their default payment method (customer.invoice_settings.default_payment_method) (collected using cardElement). What would be that path in doing so? Don't we have to convert the cardElement to PaymentMethod and attached it to the customer? Or is there another suggested path
Gotcha so in that case use a SetupIntent https://stripe.com/docs/payments/save-and-reuse
once you have that, you can change their invoice_settings[default_payment_method]
Do you need a setup intent for every payment method update?
SetupIntent is the API used to collect payment method details. So yes, you create one every time a customer wants to change their payment method details
@tight dawn did you have any other question?
Amazing, have a great day 🙂
Hi Jack!
thanks for unarchiving this
Early in the thread @royal hawk suggested to use setupIntent https://stripe.com/docs/payments/save-and-reuse to get payment Method. I created an setupIntent, but I am unsure how to connect this with cardElement and subsequently get a paymentMethod back that i can attached on to customter's invoice_settings[default_payment_method]. The document shared is for paymentElement. So, if you can shine some light on this, that would be great.
Sure no problem. You can also use SetupIntent with CardElement.
Do you have documentation on this?
Once you create a SetupIntent, you can return the SetupIntent's clientSecret to the front end, where you can call stripe.confirmCardSetup https://stripe.com/docs/js/setup_intents/confirm_card_setup
There's no dedicated SetupIntent for CardElement doc but you can refer to this doc https://stripe.com/docs/payments/card-element and replace the PaymentIntent with SetupIntent, confirmCardPayment with confirmCardSetup.
but stripe.confirmCardSetup still return setupIntent? I guess my confusion is, I need a paymentMethod.id to update to the customer's invoice_setting, how do i get that?
Once the SetupIntent is succeeded, you can get the payment_method (https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method) from the SetupIntent object, and set it as the customer's default_payment_method (https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method)
cool! let me give that a try.
sorry, one more question. stripe.confirmCardSetup , is this to be done on client side or server side.
stripe.confirmCardSetup is a frontend API.