后台对接微信支付中所需要做的一些流程
- wx.requestPayment({
- timeStamp : '', // 时间戳, 必填 (后台传回)
- nonceStr : '', // 随机字符串, 必填 (后台传回)
- package : '', // 统一下单接口返回的 prepay_id 参数值, 必填 (后台传回)
- signType : 'MD5', // 签名算法, 非必填,(预先约定或者后台传回)
- paySign : '', // 签名 , 必填 (后台传回)
- success:function(res){ // 成功后的回调函数
- // do something
- }
- })
小程序请求后台提供的下单接口
传递商品 id, 商品描述 body, 总金额 total_fee 等
后台接收到请求参数
小程序得到支付的参数, 发起支付
微信支付及其后台处理, 请求我们后台预留的回调接口
后台回调接口在接收到回调请求时, 对订单进行后续处理
- $arr = [
- 'appid' => $appid,
- 'body' => $body,
- 'mch_id' => $mch_id,
- 'nonce_str' => $nonce_str,
- 'notify_url' => $notify_url,
- 'openid' => $openid,
- 'out_trade_no' => $out_trade_no,
- 'spbill_create_ip' => $spbill_create_ip,
- 'total_fee' => $total_fee,
- 'trade_type' => 'JSAPI'
- ]
- $str = 'appid=$appid&body=$body&mch_id=$mch_id&nonce_str=$nonce_str¬ify_url=$notify_url&openid=$openid&out_trade_no=$out_trade_no&spbill_create=$spbill_create&total_fee=$total_fee&trade_type=JSAPI&key=$key'
- $sign = md5(str);
- $newarr = [
- 'appId' => $this->appid, // 小程序 ID
- 'timeStamp' => '', // 新生成一个时间戳
- 'nonceStr' => $this->createNoncestr(), // 随机字符串
- 'package' => 'prepay_id=' . $unifiedorder['prepay_id'], // 微信后台返回的数据包
- 'signType' => 'MD5'
- ]
image.PNG
https://api.weixin.qq.com/sns/jscode2session?appid=********&secret=********&js_code=********&grant_type=authorization_code
请点赞! 因为你的鼓励是我写作的最大动力!
官方微信公众号
吹逼交流群: 711613774
吹逼交流群
来源: http://www.jianshu.com/p/b18cd2f3281c