#_timothee
1 messages · Page 1 of 1 (latest)
I'm trying to get the subscription_update_confirm flow type to work but I'm not sure how it is supposed to work.
Hi! Let me help you with this.
Do you want to let the customer confirm a specific update, or choose the update?
I have a list of plans in the dashboard. When the user clicks on "upgrade" I would like him to go to a stripe customer portal page where he can see the proration etc. and confirm payment if needed.
I don't want the user to choose the plan again.
Makes sense. So what's not working here for you?
Are you following this? https://stripe.com/docs/customer-management/portal-deep-links
Yes I'm following this.
I built this :
@dashboard.route('/purchase_plan/<plan_id>')
@login_required
def purchase_plan(plan_id):
if plan_id not in [plan['id'] for plan in stripe_displayed_plans]:
flash('This plan does not exist.', 'danger')
return redirect(url_for('dashboard.plans'))
if current_user.stripe_customer_id and current_user.is_subscribed():
if plan_id == current_user.plan()['id']:
flash('You are already subscribed to this plan.', 'warning')
return redirect(url_for('dashboard.plans'))
return redirect(stripe.billing_portal.Session.create(
customer=current_user.stripe_customer_id,
flow_data={'type': 'subscription_update_confirm',
'subscription_update_confirm': {
'subscription': current_user.subscription()['id'],
'items': [{'id': plan_id, 'quantity': 1}],
}},
return_url=url_for('dashboard.plans', _external=True)).url, code=303)
return redirect(stripe.checkout.Session.create(
line_items=[dict(price=plan_id, quantity=1)],
client_reference_id=current_user.id,
mode='subscription',
success_url=url_for('dashboard.billing', _external=True)).url, code=303)
But I get this error : stripe.error.InvalidRequestError: Request req_jlPNFRRJBJitDt: No subscription item with this ID (plan_business_monthly) on the subscription.
It looks like the "items" in the subscription_update_confirm dict should include the existing items. But it does not make any sense to me since somehow, the portal needs to know which new plan the user wants to subscribe to. Not the existing plan he is already subscribed too.
I don't get how it is supposed to work.
Where do you take this value from? plan_business_monthly?
It's the ID of the new plan. When the user clicks on "upgrade" I pass over the plan Id.
Are you using Plans or Prices to specify items of the Subscription?
Plans.
I am not sure this flow supports Plans unfortunately. Let me check.
Ok.
Yes, currently it works with items and Prices: https://stripe.com/docs/api/customer_portal/sessions/create#create_billing_portal_session-flow_data-subscription_update_confirm-items-id
Ok. So, it looks like there is no way to upgrade to another plan from the portal with deep links. Correct ?
If you use Plans, then no, unfortunately.
Ok. Thank you for your help !
Is it possible to use Stripe Checkout to make a user upgrade to another plan?
In this case, only to create a new Subscription, which is also an option in your case. I would recommend looking into implementing Subscriptions without Plans: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements