Minor cosmetic changes @TODO: Invoice for billing

legacy
Steve L. Nyemba 8 years ago
parent a85242087f
commit c3ae16aef8

@ -110,9 +110,16 @@ def is_customer (app_name):
info = couchdb.read()
lsub = info['subscriptions']
plans = [dict(item['plan'],**{"status":item['status']}) for item in lsub]
plans = [dict(dict(item['plan'],**{"status":item['status']}),**{"subscription":item['id']}) for item in lsub]
if pid is not None:
plans = [item for item in plans if item['id'] == pid]
#
# Caching the subscription identifiers so we can create an invoice later on (if need be)
# @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 :
@ -122,8 +129,28 @@ def is_customer (app_name):
# 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)
html = """
<form action="/pay" 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)
amount = amount / 100
return render_template('bill.html',apikey=apikey,app_name=app_name.replace('-',' '),plans=plans,total_amount=amount,html=html)
"""
This function is intended to performa an actual payment
"""
@ -133,9 +160,13 @@ def pay():
token = request.form['stripeToken']
uid = request.form['stripeEmail']
tokenType = request.form['stripeTokenType']
DB = COUCHDB.get_db(CONFIG['couchdb']['db']) ;
couchdb = CouchdbReader(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
DB = couchdb.dbase #COUCHDB.get_db(CONFIG['couchdb']['db']) ;
handler = Domain.User(DB,stripe) ;
plans = session['plans']
# Assuming all is fine, we must do the following at this point
# - create an invoice with the designated subscriptions
# - create a charge on the invoice
#
# Let's insure the preconditions are met i.e
# card,invoice

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

@ -43,7 +43,7 @@
}
@media only screen and (min-device-width: 768px){
body {font-size:12px}
table {width:70%; margin-left:15%}
table {width:60%; margin-left:20%}
}
</style>
<body>
@ -55,7 +55,7 @@
<tr>
<td style="width:50%">
<div align="left" class="default">
<img src="/static/img/logo.png" style="width:48px" class="left" style="margin:4px">
<img src="/static/img/logo-0.png" style="width:48px; margin:4px" class="left" style="margin:4px">
<div style="padding:8px">The Phi Technology
<div class="small" style="text-transform:capitalize">{{ app_name }}</div>
</div>
@ -87,9 +87,11 @@
{% endfor %}
<tr style="font-size:11px; ">
<td align="right"></td>
<td align="right" style="background-color:#f3f3f3;"> Amount Due <span style="font-weight:bold">$ {{ total_amount }}</span></td>
<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%">
<span class="action">Purchase</span>
{{html|safe}}
</td>
</table>
<br>

Loading…
Cancel
Save