Closed verybigelephants closed 7 months ago
Oh boy, i have just discovered you can do exactly this with Deeplinks of billingPortal session, when flow
is set to subscription_update_confirm
. The days i have spent programming a seamless product swap on my backend for various paymnt methods 😭
What's worst is that i have spent hours on a Stripe API-help customer support and they have claimed me that this thing is not possible with Stripe API
Anyways, here's the sample code in case this thread comes up in some search results for someone:
$stripe = new \Stripe\StripeClient('...');
$stripe->billingPortal->sessions->create([
'customer' => 'cus_customerid',
'return_url' => 'url to direct a user when they click on "back" button',
'flow_data' => [
'type' => 'subscription_update_confirm',
'subscription_update_confirm' => [
'subscription' => $current_user_subscription->id,
'items' => [
[
'id' => $current_user_subscription->items->first()->id, //subscription item like 'si_...'
'price' => $new_prouct_price, //new price to confirm
'quantity' => 1
]
],
],
'after_completion' => [
'type' => 'redirect',
'redirect' => ['return_url' => 'url to direct user after they complete the confirmation' ],
],
]
]);
My takeout from this is: never trust a Stripe customer support
Hey @verybigelephants I was in a middle of typing a response explaining this option and then just saw the update. I'm glad you figured this one out though I'm sorry you didn't get the advice you wanted from our support team. If you ever need help about our products and APIs, you can contact us on our Discord server https://stripe.com/go/developer-chat It's staffed by my team and we help developers with coding-related questions throughout the day! Thanks for taking the time to carefully write down how to solve this for other developers, this is really appreciated!
@remi-stripe thank you for the kind words, will definitely do in case i need help in the future!
Is your feature request related to a problem? Please describe.
This is a feature request related to Stripe API itself, rather than just Stripe PHP client, so my apologies if this is a wrong place to post, but i found no other channel for API feature requests.
Right now, we can make use of comfortable Stripe Checkout when creating a new Subscription like this
However, when we want to swap the subscription for a new one there's no such option for Checkout.
Describe the solution you'd like
It would be incredibly useful to have the stripe Checkout be able to have some kind of
'mode'=>'subscription-update'
where we just pass the parameter noting which subscription is being updated/purchased/prorated.Or something like
Describe alternatives you've considered
The problem is that now we have to do subscription swapping without extra user consent/payment handing on Stripe checkout page and handle mandates and what not for all possible paymnt methods OR use generig Billing customer portal, where user will be presented with all possible options for their subscription, which leads to lower conversion rates (also in this case we are forced to make the subscriptions upgradable/downgradable in the billing portal and maintain the swappable prices in Stripe dashboard which is prone to error). So none of them really ideal.
Additional context
No response