bug fix around endpoint

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

@ -64,23 +64,14 @@ class User:
has_plan = False
# lsub = lsub.data
#
# At this point We should either subscribe the user or not
#
if has_plan == False :
r = self.subscribe(id,plans)
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.db.save_doc(self.user)
def subscriptions(self):

@ -102,18 +102,28 @@ def cancel_subscribe(name) :
This function defines if a given user is a customer or not
We should be able to tell by how we create customers
"""
@app.route('/checkout',methods=['GET'])
def is_customer ():
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)
return render_template('checkout.html',bill=bill,key=key)
@app.route('/checkout/<app_name>',methods=['GET'])
def is_customer (app_name):
uid = request.args.get('uid')
pid = request.args.get('pid')
couchdb = CouchdbReader(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
info = couchdb.read()
lsub = info['subscriptions']
plans = [dict(item['plan'],**{"status":item['status']}) for item in lsub]
if pid is not None:
plans = [item for item in plans if item['id'] == pid]
# 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
"""

Loading…
Cancel
Save