bug fix with handling of payments/subscriptions

legacy
Steve L. Nyemba 4 years ago
parent c1bf7abe42
commit aa3eacd8ac

@ -72,7 +72,7 @@ def get_plans_json(id):
"""
This function returns the plans for a given product
"""
HEADER="Content-type:application/json"
HEADER={"Content-type":"application/json"}
try:
mystore = store.factory.instance(name=id)
return json.dumps(mystore.get.plans()),HEADER
@ -163,19 +163,22 @@ def me ():
# mystore = store.factory.instance(name = session['product']['name'])
# mystore.init(email=session['auth']['user']['uid'])
try:
email = session['auth']['user']['uid']
name = session['product']['name']
mystore = store.factory.instance(name=name,email=email)
payments = mystore.user.invoices()
cards = mystore.user.card.html() if mystore.user.card.exists() else None
_args = {'context':CONTEXT,"user":session['auth']['user'],"product":session['product'],"plan":session['plan'],"payments":payments,"cards":cards}
return render_template('me.html',**_args)
if 'auth' in session and 'product' in session :
email = session['auth']['user']['uid']
name = session['product']['name']
mystore = store.factory.instance(name=name,email=email)
payments = mystore.user.invoices()
cards = mystore.user.card.html() if mystore.user.card.exists() else None
_args = {'context':CONTEXT,"user":session['auth']['user'],"product":session['product'],"plan":session['plan'],"payments":payments,"cards":cards}
return render_template('me.html',**_args)
except Exception as e:
print (e)
pass
return redirect("https://the-phi.com")
return render_template("none.html",context=CONTEXT)
# return redirect("http://healthcareio.the-phi.com")
@app.route("/me/card",methods=['POST'])
def me_card ():
if 'auth' in session :
@ -244,7 +247,7 @@ def redirect(id ) :
This function will redirect to a given product page given a payload. The payload is intended to set the a session
:info
"""
mystore = store.factory.instance(name=id)
args = {"context":CONTEXT,"product":mystore.product}
HEADER = {"Location":mystore.product['metadata']['uri']}
@ -338,7 +341,7 @@ def _payme(id) :
_args['metadata'] = {"payment":"charge","product":id}
_args['statement_descriptor'] = " ".join([str(info['amount']),id])
r = user.charge(**_args)
r = user.charge(**_args)
if not r :
msg,status = "Payment error enountered",403
@ -378,9 +381,12 @@ def init(product):
#
#@TODO: Log that uid, has initiated use of product
#
return json.dumps(features),200
HEADERS ={"content-type":"application/json"}
return features,HEADERS
@app.route("/<id>/init",methods=['POST','PUT'])
def _init(id):
return init(id)
# @app.route('/subscribe/<product>',methods=['POST'])
# def subscribe(product):
# """

Loading…
Cancel
Save