#jm - Subscription Payment Method
1 messages ยท Page 1 of 1 (latest)
Hi ๐
The invoice has an associated payment intent with a client secret you can use.
In this section of our docs you can see how it is passed to the front-end to collect payment information:
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription
Is that the same method to update the subscribed client's default payment method?
In which case? Back-end, front-end? I'm referring to this approach:
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#complete-payment
If that is not what you are looking for then perhaps you could explain your scenario in more detail?
Oh I see... so in order to update the payment method, I need to:
- Create a new intent with the client id and payment method (backend)
- Add the new card to the intent (frontend)
- Update the subscription with the subscription id and the payment intent method (backend)
- Bill the next cycle using that subscription that has linked the client and payment method, thus creating the new invoice for that billing
Am I right?
It depends on what you want to accomplish. Where in the billing cycle is the customer updating the payment method?
It could be at any moment, I plan to add an "update payment method" on their use's portal, so they can update the payment at any moment (without changing the plan)
Yikes, sorry for the delay
Okay so you are using the Customer Portal for this update?
It's ok.
Nope, I am not using the customer portal, I plan to create a custom one
If you're using customer portal, I would think that the above provided workflow would work.
You can also set the invoice default payment method on the customer object: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
But I am not using the customer portal. Can I change the invoice default payment whenever I see fit?
Hi ๐ jumping in as my teammate needed to step away. Yes you can. Naturally it makes sense to do so when your customers are expecting you to, but you're in control of the Customer object and can update it as you see fit.
Nice, then, what would be the recommended way, updating the customer invoice's default payment method or updating the subscription's default payment method?
stripe.customers.update vs stripe.subscriptions.update
I suppose both require an intent with the payment_method and client attached
Yes, both require you to provide the ID of a payment method that has already been created (based on the flow you're describing sounds like this will be done via a Setup Intent).
Which to use will depend on your flow. If a subscription has a default_payment_method set, then that takes precedence over the settings on the customer record. So if default_payment_method was previously set on a subscription, then that subscription will explicitly need to be updated.
If a subscription doesn't have a default_payment_method or default_source set, then it will fall back onto information from the customer record. So if your subscriptions don't have a default_payment_method specified then they'd pull from the customer's invoice_settings.default_payment_method.
Which you should use is going to fluctuate depending on your exact scenario and what you're trying to accomplish. For example, setting this at the customer level requires less updates when the payment method is changed if the customer has a large number of subscriptions, but setting it at the subscription level allows for more granular control over how each subscription is paid for.
Wow... great info, thank you.
For case, each customer will have only 1 subscription
@granite dawn did you have more questions?
Not right now, I am reading the links you guys shared. Thank you ๐
Oh yes, one more question!
Do I need to retrieve the latest created intent in order to send it to the frontend and setup Elements, so I can update the payment method, or is it ok to just create a new Intent on the fly with the customer's id (backend) and send it to the frontend?
you can create it on the fly though it's best to use the one that hasn't been confirmed yet
How can I retrieve the last that hasn't been confirmed?