#marve-subscription-defaultpm
1 messages · Page 1 of 1 (latest)
marve-subscription-defaultpm
The right way is
- Create a Subscription
- Confirm the PaymentIntent client-side with PaymentElement
The best doc to follow is https://stripe.com/docs/billing/subscriptions/build-subscriptions
specifically 'payment_settings' => ['save_default_payment_method' => 'on_subscription'], is what you are after
it will automatically make that PaymentMethod the default after a successful confirmation
O so I just add this to the subscription: payment_behavior: 'default_incomplete', payment_settings: { save_default_payment_method: 'on_subscription' }, expand: ['latest_invoice.payment_intent'],
yep
And I don't need to do anything else on the frontend?
Before I had to do: confirmCardPayment { set_up_future_usage: off_session }
If not, none of the cards were being saved
you seem to mix up a ton of stuff
you cna't pay without collecting card details client-side
so yes you absolutely need to confirm the associated PaymentIntent client-side since you have no card details until then
I do recommend taking 10 minutes and carefully reading that doc I linked
No, I mean the cards weren't being attached as payment methods to the customer
If i don't use set_up_future_usage: off_session client-side
I was just told by stripe support that If I dont do this, subscriptions won't work because the default_payment_method has to have been previously attached to the customer
I'm sorry you're rushing way too fast down the wrong path
I don't have context on what you discussed with Stripe support and I don't really understand what's going on. There are like 10 different ways to integrate with Subscriptions, Elements, etc. I need to know exactly what the problem is, because right now I gave you an end to end guide that covers this in details with PaymentElement
O sorry
The flow is
- Create the Subscription with the right
payment_settings - Client-side collect card details in PaymentElement and confirm the PaymentIntent all in one request
I assume your code does nothing like this at all. Like maybe you collect card details first before even creating the Subscription?
Nono, i create the subscription, I was missing the payment_settings and then I collect details client side and confirmCardPayment of course
Sorry I wasn't explaining correctly
What I was doing was calling stripe.subscription.update after all this to set the payment method : which is what I was told by Stripe support. They also told me to make sure that when confirming the card payment client side, that I passed set_up_future_usage: off_session because if not, the payment method would not be attached to the customer which they said meant I wouldn't be able to set the default method for the subs
all good, I just want to make sure I'm not missing anything obvious. A lot of people asking your questions are basically integrating in a completely different way where they collect card details first so none of this works
And yeah okay based on what you said, our support team was mostly confused/wrong
So no need for this anymore right: confirm card payment client side and set_up_future_usage: off_session client side ?
as long as you create the Subscription with the right payment_settings, when you successfully confirm the PI client-side it will just work
no worries at all. This is not easy to explain in a few words as a flow
can you test this and let me know if you're unblocked or if you still see some issues?
Yes of course, let me tweak a couple of things and Ill get back to you
Works, amazing! Thanks again really, you clarified in 2 seconds. For some reason I was told that I first had to attach the pm to the customer for it to work which just made me spiral
yeah the payment_settings feature is new-ish, it shipped like 2 months ago
so it's not super well known but it makes this flow so much easier
It's definitely a life saver - so much simpler