#_timothee

1 messages · Page 1 of 1 (latest)

manic gorgeBOT
atomic imp
#

I'm trying to get the subscription_update_confirm flow type to work but I'm not sure how it is supposed to work.

serene steeple
#

Hi! Let me help you with this.

#

Do you want to let the customer confirm a specific update, or choose the update?

atomic imp
#

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.

serene steeple
#

Makes sense. So what's not working here for you?

atomic imp
#

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.

serene steeple
#

Where do you take this value from? plan_business_monthly?

atomic imp
#

It's the ID of the new plan. When the user clicks on "upgrade" I pass over the plan Id.

serene steeple
#

Are you using Plans or Prices to specify items of the Subscription?

atomic imp
#

Plans.

serene steeple
#

I am not sure this flow supports Plans unfortunately. Let me check.

atomic imp
#

Ok.

atomic imp
#

Ok. So, it looks like there is no way to upgrade to another plan from the portal with deep links. Correct ?

serene steeple
#

If you use Plans, then no, unfortunately.

atomic imp
#

Ok. Thank you for your help !

#

Is it possible to use Stripe Checkout to make a user upgrade to another plan?

serene steeple