#tonymx-update-paymentmethod
1 messages · Page 1 of 1 (latest)
Hi there! A Checkout Session would only be to collect a paymentmethod from your customer. Are you trying to update the PaymentMethod for use on their Subscription after their Subscription has already been started? Can you tell me a bit more about exactly what you are trying to do?
I'm trying to update the paiement method on a subscription that is already started.
Got it. And you are sending your Customer through a new Checkout Session to collect a new PaymentMethod?
Yes I'm sending the customer_id and subscription_id.
=>
payment_intent_data: {
metadata: {
customer_id: findedRpaUserService.stripe_customer_id,
subscription_id: findedRpaUserService.stripe_subscription
}
}
Okay, and do you want to use the new PaymentMethod for all Subscriptions on the customer (do any of your Customers have multiple Subscriptions) or just for the individual Subscription?
Just for the individual.
Okay got it so you want to grab the new PaymentMethod ID that was created via the Checkout Session and you want to update the PaymentMethod Default on the Subscription directly: https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
Yes but I need to create a session bedore.
If I try with your code, the user is not redirected to the page to update the details.
The function "stripe.subscriptions.update" don't have a success_url and cancel_url.
You would do the above after they have completed the Checkout Session
The Checkout Session is to collect the new PaymentMethod
Ok but when I try to execute "checkout.sessions.create" with mode "setup" I got the error.
And this is my main issue.
I'm not able to create a session with mode to "setup".
Okay, so you can't set payment_intent_data on a setup Checkout Session. You can set that metadata on the Checkout Session itself (https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-metadata) if you want to.
Otherwise, if you want to pass the Customer ID in to the Checkout Session you would do that here: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
You would not pass this as metadata
Ok thank you it works !!!