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 This function returns the plans for a given product
""" """
HEADER="Content-type:application/json" HEADER={"Content-type":"application/json"}
try: try:
mystore = store.factory.instance(name=id) mystore = store.factory.instance(name=id)
return json.dumps(mystore.get.plans()),HEADER return json.dumps(mystore.get.plans()),HEADER
@ -163,19 +163,22 @@ def me ():
# mystore = store.factory.instance(name = session['product']['name']) # mystore = store.factory.instance(name = session['product']['name'])
# mystore.init(email=session['auth']['user']['uid']) # mystore.init(email=session['auth']['user']['uid'])
try: try:
email = session['auth']['user']['uid'] if 'auth' in session and 'product' in session :
name = session['product']['name'] email = session['auth']['user']['uid']
name = session['product']['name']
mystore = store.factory.instance(name=name,email=email) mystore = store.factory.instance(name=name,email=email)
payments = mystore.user.invoices() payments = mystore.user.invoices()
cards = mystore.user.card.html() if mystore.user.card.exists() else None 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} _args = {'context':CONTEXT,"user":session['auth']['user'],"product":session['product'],"plan":session['plan'],"payments":payments,"cards":cards}
return render_template('me.html',**_args) return render_template('me.html',**_args)
except Exception as e: except Exception as e:
print (e)
pass 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']) @app.route("/me/card",methods=['POST'])
def me_card (): def me_card ():
if 'auth' in session : if 'auth' in session :
@ -338,7 +341,7 @@ def _payme(id) :
_args['metadata'] = {"payment":"charge","product":id} _args['metadata'] = {"payment":"charge","product":id}
_args['statement_descriptor'] = " ".join([str(info['amount']),id]) _args['statement_descriptor'] = " ".join([str(info['amount']),id])
r = user.charge(**_args) r = user.charge(**_args)
if not r : if not r :
msg,status = "Payment error enountered",403 msg,status = "Payment error enountered",403
@ -378,9 +381,12 @@ def init(product):
# #
#@TODO: Log that uid, has initiated use of 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']) # @app.route('/subscribe/<product>',methods=['POST'])
# def subscribe(product): # def subscribe(product):
# """ # """

Loading…
Cancel
Save