#Yashish
1 messages · Page 1 of 1 (latest)
The Customer Portal cannot be used to make payments but you can have the update create a new Invoice and send your user to the Invoice's Stripe-hosted page
in python would this be a correct way?
session = stripe.checkout.Session.create( customer=customer_id, payment_method_types=['card'], subscription_data={ 'items': [{ 'plan': new_plan_id, }], }, success_url='https://example.com/success', cancel_url='https://example.com/cancel', )
You can't update plans with Checkout unfortunately. That would create a new subscription
so if we want to update the plan and allow the user to make the payment by open the stripe session then how can we do that
Set proration behavior to always_invoice https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior
And then send your user to the new invoice's hosted_invoice_url https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url
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.
can you please provide with some code example
This code shows how to change prices https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
I don't think we have sample code that explicitly shows linking to the new invoice but it is pretty Straightforward
You would check the latest_invoice property on your subscription after you have updated it. That property will have an invoice ID (in_1234) that you can use to retrieve the invoice and send the user to that URL
how we can do this
And then send your user to the new invoice's hosted_invoice_url
You can either give them a link to it on your page or you can cause a redirect to that URL
Usually redirects are either done with Javascript or by having your server return a 303 redirect
So if you want the redirect to be manual from the user, you can give them a link or button to click on for it
If you want the redirect to be automatic after the user clicks to upgrade your subscription, you can have your server make the update, find the URL, and return a 303 redirect to it
not abe to fully understand it.
Which part do you understand? I can try to re-explain the rest