#datapata - Subscriptions + Elements
1 messages · Page 1 of 1 (latest)
Hi there! Give me just a few minutes to get up to speed
So, I wouldn't recommend trying to attach the Payment Method during step 6, simply because your customer could abandon the payment flow, which would require a lot of meticulous error-handling.
Rather, I would suggest having an endpoint just listen for the payment_intent.succeeded Event and program your handler to make additional API calls to attach the Payment Method from there.
There isn't a way to get the Payment Method ID until after you confirm the Payment Method on step 6, because that is the first time the card details are actually being submitted to Stripe in that payment flow scenario.
@wet silo I see, thanks. I was hoping for an option in Elements or when creating the subscription that would make elements attach it if the payment succeeded. Cause that is what happens here https://stripe.com/docs/payments/save-during-payment#web-submit-payment, right?
So confirmPayment() doesn't set the default payment method for the customer, it simply attaches it. Either way, you'll have to update the default payment method as an additional step via customer.invoice_settings.default_payment_method: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
I was hoping for an option in Elements or when creating the subscription that would make elements attach it if the payment succeeded.
Re. the above: attaching the payment method to the Payment Intent on success still happens, there's just not a way to set it as default on the customer without making another server-side API call.
I see, thanks!