Bug fixes for showing user's bill

legacy
Steve L. Nyemba 8 years ago
parent b72f76fdc6
commit 8b7467219d

@ -179,6 +179,9 @@ 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)
r = couchdb.view('federation/uid_map',key=uid)
id = r[0]['value']
couchdb = CouchdbReader(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=id,create=False)
info = couchdb.read()
lsub = info['subscriptions']
@ -190,39 +193,13 @@ def is_customer (app_name):
# @TODO Improve this process later on by allowing user's to pay for what they can (not everything)
#
session['plans'] = plans
# 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)
html = """
<form action="/pay/:app_name" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key=":key"
data-email=":email"
data-amount=":amount"
data-name="The Phi Technology LLC"
data-description=""
data-image="https://s3.amazonaws.com/stripe-uploads/acct_15kiA1EUWsmgY81Amerchant-icon-1443577505909-the-phi-logo.png"
data-locale="auto">
</script>
</form>
"""
session['plans']
amount = sum([item['amount'] for item in plans])
apikey = CONFIG['stripe']['pub'].strip()
html = html.replace(":email",uid).replace(":amount",str(amount)).replace(":key",apikey).replace(":app_name",app_name)
amount = amount / 100
return render_template('bill.html',apikey=apikey,app_name=app_name.replace('-',' '),plans=plans,total_amount=amount,html=html)
return render_template('bill.html',apikey=apikey,app_name=app_name.replace('-',' '),plans=plans,total_amount=amount)
if __name__ == '__main__' :
app.debug = True ;

@ -1,6 +1,8 @@
<meta charset="UTF-8">
<meta http-equiv="cache-control" content="no-cache">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1">
<link rel="shortcut icon" href="{{context}}/static/img/logo-0.png">
<style>
body{
font-family:sans-serif;
@ -78,8 +80,11 @@
</tr>
{% for item in plans %}
<tr class="" style="font-size:11px">
<td> {{item.statement_descriptor}} </td>
<tr class="default" >
<td style="text-transform:capitalize">
<div class="default">{{item.metadata.info|safe}} </div>
</td>
<td align="right"> {{item.amount/100}} </td>
<td style="text-transform:capitalize"> {{item.status}} </td>
@ -90,7 +95,7 @@
<td align="right" style="border-top:1px solid #CAD5E0"> Amount Due <span style="font-weight:bold">$ {{ total_amount }}</span></td>
<td align="center" style="width:20%">
{{html|safe}}
</td>
</table>

@ -470,6 +470,8 @@ class Couchdb:
create = args['create'] if 'create' in args else False
if self.dbase.doc_exist(self.uid) == False and create == True:
self.dbase.save_doc({"_id":self.uid})
def view(self,id,**args):
return self.dbase.view(id,**args).all()
"""
Insuring the preconditions are met for processing
"""

Loading…
Cancel
Save