bug fix around endpoint

legacy
Steve L. Nyemba 8 years ago
parent 2416259498
commit cd14d6a4cf

@ -64,23 +64,14 @@ class User:
has_plan = False has_plan = False
# lsub = lsub.data
#
# At this point We should either subscribe the user or not
#
if has_plan == False : if has_plan == False :
r = self.subscribe(id,plans) r = self.subscribe(id,plans)
lsub.data.append(r[0]) lsub.data.append(r[0])
lsub = self.cast(lsub.data)
#
# We need to save the document & the information
# #
# Backing up the information to be processed later
# - We assume any interaction with the payment classes will start by updating information associated operation
lsub = self.cast(lsub.data)
self.user['subscriptions'] = lsub self.user['subscriptions'] = lsub
self.db.save_doc(self.user) self.db.save_doc(self.user)
def subscriptions(self): def subscriptions(self):

@ -102,18 +102,28 @@ def cancel_subscribe(name) :
This function defines if a given user is a customer or not This function defines if a given user is a customer or not
We should be able to tell by how we create customers We should be able to tell by how we create customers
""" """
@app.route('/checkout',methods=['GET']) @app.route('/checkout/<app_name>',methods=['GET'])
def is_customer (): def is_customer (app_name):
bill = {"amount":0,"count":0} uid = request.args.get('uid')
key = "" pid = request.args.get('pid')
if 'user-plans' in session : couchdb = CouchdbReader(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
plans = session['user-plans'] ; info = couchdb.read()
amount = [plan['amount'] for plan in plans if plan['amount'] > 0] lsub = info['subscriptions']
if len(amount) > 0:
key = CONFIG['stripe']['pub'].strip() plans = [dict(item['plan'],**{"status":item['status']}) for item in lsub]
bill['count'] = len(amount) if pid is not None:
bill['amount']= sum(amount) plans = [item for item in plans if item['id'] == pid]
return render_template('checkout.html',bill=bill,key=key) # bill = {"amount":0,"count":0}
# key = ""
# if 'user-plans' in session :
# plans = session['user-plans'] ;
# amount = [plan['amount'] for plan in plans if plan['amount'] > 0]
# if len(amount) > 0:
# key = CONFIG['stripe']['pub'].strip()
# bill['count'] = len(amount)
# bill['amount']= sum(amount)
amount = sum([item['amount'] for item in plans])/100
return render_template('bill.html',app_name=app_name.replace('-',' '),plans=plans,key=None,total_amount=amount)
""" """
This function is intended to performa an actual payment This function is intended to performa an actual payment
""" """

Loading…
Cancel
Save