#jm-update-subscription-pm
1 messages · Page 1 of 1 (latest)
Hello 👋
Give me a moment to take a look
I believe there are two ways you can handle this for future invoices
- Update customer's
invoice_settings.default_payment_method - Set it as the Subscription’s
default_payment_method
If you want to do this with Stripe Checkout, we have a guide here
https://stripe.com/docs/payments/checkout/subscriptions/update-payment-details
I am not using Stripe Checkout but Stripe Elements
ah okay!
The idea is the same as you can set it as default PM as suggested above
Do I need to create a new checkout session only to update the payment method, I better no redirect my user, I was thinking using the PaymentMethods API instead, is that possible?
Oh! sorry for the confusion. You can certainly use the API. I was pointing towards the two options in order to update PM for future invoices.
It is ok. So returning to the original question, if I plan to use the PaymentMethods API, I need an Intent to use with Elements, do I create a new setup intent or I better use the existing one from latest_invoice.payment_intent from the subscription?
You'd probably want to use a new setup intent as you're setting the payment method up for off_session usage
Got it, then what configuration does the new setup intent needs to have?
Not sure what you mean by configuration here
Can you clarify? 😄
Let's say that off_session is one configuration parameter for the setup intent, do I need to set more parameters?
Not really but you could add more information into the metadata so that its easier to identify and link the SetupIntent back to subscription and/or customer. You don't have to though.
customer_id: 'cus_FOsk5sbh3ZQpAU',
subscription_id: 'sub_8epEF0PuRhmltU',
},
And then, return the intent to the front end to create the Elements inputs, create a new PaymentMethod with the Elements, and send it to the backend to update the customer's or the subscription's default_payment_method, am I right?
yup, correct
Awesome!
What about updating a payment method, like the zip address or card expiry?
as in for the same payment method i.e. card ?
Right now, yes, but I plan to add new payment methods like Apple Pay or Google Pay
And I would like to let the user update those methods as well
Gotcha. You could compare the fingerprint of the card object to check if it already exists and then update the associated payment method
https://stripe.com/docs/api/cards/object#card_object-fingerprint
https://stripe.com/docs/api/payment_methods/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This needs to be updated using Elements or with a normal input forms?
I believe you can use a normal form for this
Got it, what about Apple Pay and Google Pay, those could be updated?
You should be able to
Let me check if we have any public resources on this
Great