|
|
@ -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
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|