Skip to content

基于Flask的jsAPI应用

passioncsu edited this page May 18, 2016 · 1 revision

Welcome to the wzhifuSDK wiki! SDK用起来很棒,但是wiki还是有点单薄。本人基于flask开发下述代码希望能够帮到有需要的人,毕竟就因为这个我摸索了一晚上。。。 from wzhifuSDK import * @app.route('/pay/', methods=['GET', 'POST']) def wechat_testpay(): # if request.method == 'GET': data = request.args code = data.get('code', u'') pub = JsApi_pub() pub.setCode(code) openid = pub.getOpenid() order_pub = UnifiedOrder_pub() order_pub.setParameter("openid",openid) order_pub.setParameter("body","贡献一分钱") order_pub.setParameter("out_trade_no",str(int(time.time()))) order_pub.setParameter("total_fee",'10') order_pub.setParameter("notify_url",WxPayConf_pub.NOTIFY_URL) order_pub.setParameter("trade_type","JSAPI") prepayId = order_pub.getPrepayId() pub.setPrepayId(prepayId) Parameters = pub.getParameters() return render_template('pay.htm',Parameters = Parameters)

Clone this wiki locally