- 微信支付调接口查询订单支付状态的时候老是报错?说:商户号和订单信息不匹配
1、相关接口: var url ="https://api.mch.weixin.qq.com/pay/orderquery"; 2、接口参数: let formData = "<xml>"; formData += "<appid>" + 'wxd3c1c2cc4b2946b4' + "</appid>"; formData += "<mch_id>" + '1585826731' + "</mch_id>"; formData += "<nonce_str>" + 've73xtcjOGgYPr9J123' + "</nonce_str>"; formData += "<transaction_id>" + '4200000938202104126155956086' + "</transaction_id>"; formData += "<sign>" + 'E5F0BAAFA**************5380DB2F10' + "</sign>"; //sign是在https://pay.weixin.qq.com/wiki/tools/signverify/手动产生的; formData += "</xml>"; 编译结果: [图片]
2021-04-12 - 模板消息运行不报错但手机就是没有消息发过来,为什么?
在学模板消息时,获得了openid、formid等,运行不报错,但手机真机上就是没有消息发过来,为什么?跪求大神指教,调试好多天了。 代码如下: //app.js App({ openid: null, onLaunch: function () { var that = this; wx.login({ success: function (res) { wx.request({ url: 'https://pinke.applinzi.com/login.php', //仅为示例,并非真实的接口地址 data: { code: res.code }, header: { 'content-type': 'application/json' // 默认值 }, success: function (res) { var data = res.data; var openid = data.openid; that.openid = openid; } }) }, }); } }) ======================= //index.js //获取应用实例 const app = getApp() Page({ data: {}, onLoad: function () { //console.log("hahah :"+app.openid); }, formSubmit: function (e) { var openid = app.openid; var formid = e.detail.formId; var goose = e.detail.value.goose; var address = e.detail.value.address; var time = e.detail.value.time; console.log(e); console.log("wosh是formid:" + formid); console.log("wosh是GOOSE:" + goose); wx.request({ url: 'https://pinke.applinzi.com/moban.php', data: { openid: openid, time: time, address: address, goose:goose, formid:formid }, header: { 'content-type': 'application/json' // 默认值 }, success: function (res) { console.log(res.data) console.log("已经成功回调request") } }) } }) ======================== 后台php: <?php function httpPost($data,$url) { $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; MSIE 5.01; windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);//要求结果为字符串且输出到屏幕上 // curl_setopt($ch, CURLOPT_HEADER, 0);//设置header // curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 // $data = curl_exec($ch);//运行curl $tmpinfo=curl_exec($ch); if(curl_errno($ch)){ return curl_error($ch); } curl_close($ch); return $tmpinfo; } function getAccessToken() { // access_token 应该全局存储与更新,以下代码以写入到文件中做示例 // 如果是企业号用以下URL获取access_token // $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret"; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret"; $res = json_decode($this->httpGet($url)); $access_token = $res->access_token; return $access_token; } function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true); curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); return $res; } $formid=$_GET["formid"]; $openid=$_GET["openid"]; $address=$_GET["address"]; $goose=$_GET["goose"]; $time=$_GET["time"]; $seats="123456789"; $templateid="tSUGEFLRf69vk1A6Ap1MC1Clhdasu6MekZhMXQe670I"; $data=<<<END { "touser": "{$openid}", "template_id": "{$templateid}", "page": "logs", "form_id": "{$formid}", "data": { "keyword1": { "value": "{$goose}", "color": "#173177" }, "keyword2": { "value": "$address", "color": "#173177" }, "keyword3": { "value": "$time", "color": "#173177" } }, "emphasis_keyword": "keyword1.DATA" } END; $appid="wxe9252c5efb58fcce"; $secret="96c39e56274719aa8bf6fbd7c32f96fa"; $getTokenApi="api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}"; $resultStr=httpGet($getTokenApi); $arr=json_decode($resultStr,true); $token=$arr["access_token"]; $templateApi="https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={$token}"; $res=httpPost($data,$templateApi); ?> 好几天了,实在不会,求指教。。。谢谢了。
2017-10-17