Stripe customer portal not accepting session variable

25 Views Asked by At
@auth.route('/create-customer-portal-session', methods=['GET', 'POST'])

def customer_portal():

   getting = db.child('users').child(session['account_name']).get()
   getting = json.loads(json.dumps(getting.val()))

   session = stripe.billing_portal.Session.create(
   customer=getting['customer_id'],
   return_url=YOUR_DOMAIN,
   )
   print(session.url)
   return redirect(session.url, code=303)

My session variable is assigned during the login or sign up phase and can't be used. This is the error "UnboundLocalError: local variable 'session' referenced before assignment" I have no problems using this session variable across the website.

It's important to be able to access the variable as it's what i use to get the stripe customer id value

0

There are 0 best solutions below