使用flask-重定向url冲突;登录

时间:2017-05-09 20:53:43

标签: python flask flask-wtforms flask-login

我目前有一个烧瓶服务器和一个角度js前端,用户可以从第三方供应商那里购买东西。

这些第三方供应商有自己的支付网关,我将我的前端连接到......所以在付款时,我们将用户重定向到支付网关...一旦付款,我们我们的烧瓶服务器上有一个重定向网址,用于捕获成功消息(以及付款详细信息)。

这里的问题是,由于我们在前端进行(因为这是第三方的网站),烧瓶登录似乎不起作用。我们使用会话来存储购买的一些数据,因此,我们似乎无法将客户购买的产品与他购买的交易联系起来!

我在下面给了我的apis:

@api.route('/quoteRequest/',methods = ['POST'])
# @flask_login.login_required
def carquote():
    data = request.get_json()
    c = quoteController.FUTGENGI(data = data, lob = "Motor", stage="quote")
    d = c.finOutput
    finalQuotes = []
    finalQuotes.append(d)
    return Response(json.dumps(finalQuotes),mimetype = "application/json")
@api.route("/proposalRequest/",methods = ['POST'])
def proposalRequest():
    data = request.get_json()
    current_app.logger.debug(data)
    c = quoteController.FUTGENGI(data = data, lob = "Motor", stage="proposal")
    output = json.loads(c.quoteDict)
    session['proposal'][data['Quote']['insurerID']] = data
    return Response(json.dumps(output),mimetype = "application/json")


#Redirect URL:
@api.route('/FUTGENGI/policyCreate/', methods = ['GET','POST'])
def policyCreate(insurerID):
    if request.method == "GET":
        par = OrderedDict(
        WS_P_ID = request.args.get('TranID')
        TID = request.args.get('UID')
        PGID = request.args.get('PaymentID')
        Premium = request.args.get('Amt')
        Response = request.args.get('Response')
        )
        if(par['Response'] == "Success"):
            for k,v in par.items():
                session['proposal']['FUTGENGI'][k] = v
            c = quoteController.FUTGENGI(data = session['proposal']['FUTGENGI'], lob = "Motor", stage="payment")
            return Response(json.dumps(c.paymentOutput), mimetype = "application/json")
        else:
            return Response(json.dumps({"output":"Oops.  Something went wrong.  Please try again"}), mimetype = "application/json")

0 个答案:

没有答案