应用场景1.

该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。需要调用查询接口的情况:◆当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;◆调用支付接口后,返回系统错误或未知交易状态情况;◆调用被扫支付API,返回USERPAYING的状态;◆调用关单或撤销接口API之前,需确认支付状态;

接口说明2.

这里如果已经做好了统一下单,《微信小程序开发(五)小程序支付-统一下单》。再做查询订单就是一件很简单的事情了。但是这里需要注意的是商户订单号-out_trade_no这个,因为我们在统一下单的时候有这个,查村订单也是根据这个区查询,后面的关闭订单,退款都可以根据这个去操作。

代码实现/**根据商户订单号out_trade_no查询订单*/router.all('/api/wxpay/orderQuery',function(req,res,next){varparamreq.query||req.params;varout_trade_noparam.out_trade_no;varnonce_strgetNonceStr();varbodyData'xml';bodyData+'appid'+wxConfig.AppID+'/appid';bodyData+'mch_id'+wxConfig.Mch_id+'/mch_id';bodyData+'nonce_str'+nonce_str+'/nonce_str';bodyData+'out_trade_no'+out_trade_no+'/out_trade_no';varsignorderQuerySign(wxConfig.AppID,wxConfig.Mch_id,nonce_str,out_trade_no);bodyData+'sign'+sign+'/sign';bodyData+'/xml';varurlStr'https://api.mch.weixin.qq.com/pay/orderquery';request({url:urlStr,method:'POST',body:bodyData},function(error,response,body){if(!errorresponse.statusCode200){varreturnValue{};parseString(body,function(err,result){if(result.xml.return_code[0]'SUCCESS'result.xml.result_code[0]'SUCCESS'){returnValue.msg'操作成功';returnValue.status'100';returnValue.resultresult;res.end(JSON.stringify(returnValue));}else{returnValue.msgresult.xml.return_msg[0];returnValue.status'102';returnValue.resultresult;res.end(JSON.stringify(returnValue));}});}})});//查询/关闭订单签名算法functionorderQuerySign(appid,mch_id,nonce_str,out_trade_no){varret{appid:appid,mch_id:mch_id,nonce_str:nonce_str,out_trade_no:out_trade_no};varstrraw(ret);strstr+'key'+key;varmd5StrcryptoMO.createHash('md5').update(str).digest('hex');md5Strmd5Str.toUpperCase();returnmd5Str;};总结3.

其实代码实现很简单就是看微信的文档就可以。

TAG标签: 微信小程序开发七小程序支付查询订单微信小程序怎么查订单微信小程序订单列表

http://www.xiaochengxub.com/read-96156.html