富贵资源网 Design By www.hznty.com
一、发货通知
为了更好地跟踪订单的情况,需要第三方在收到最终支付通知之后,调用发货通知API告知微信后台该订单的发货状态。
发货时间限制:虚拟、服务类24小时内,实物类72小时内。
请在收到支付通知后,按时发货,并使用发货通知接口将相关信息同步到微信后台。若平台在规定时间内没有收到,将视作发货超时处理。
发货通知API的URL为:
https://api.weixin.qq.com/pay/delivernotify"htmlcode">
{ "appid" : "wwwwb4f85f3a797777", "openid" : "oX99MDgNcgwnz3zFN3DNmo8uwa-w", "transid" : "111112222233333", "out_trade_no" : "555666uuu", "deliver_timestamp" : "1369745073", "deliver_status" : "1", "deliver_msg" : "ok", "app_signature" : "53cca9d47b883bd4a5c85a9300df3da0cb48565c", "sign_method" : "sha1" }
上述内容参数说明如下表所示:
微信公众平台在校验ok之后,会返回数据表明是否通知成功,例如:{"errcode":0,"errmsg":"ok"}如果有异常,会在errcode和errmsg描述出来,如果成功errcode就为0。
二、程序实现
程序中的一些参数来自本博客前面的微信支付开发数据。读者请参照运行
<"WxPayHelper.php"); //1. 获取access token $appid = "wx0000000000000000"; $appsecret = "e76050733ce76050733ce76050733cdd"; $url = "https://api.weixin.qq.com/cgi-bin/token"; $result = https_request($url); $jsoninfo = json_decode($result, true); $access_token = $jsoninfo["access_token"]; //2.准备参数 $deliver_timestamp = time(); //2.1构造最麻烦的app_signature $obj['appid'] = $appid; $obj['appkey'] = "8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6k"; $obj['openid'] = "o0pk9uIVnlY-fJkzFKEbQ6LJ4cFc"; $obj['transid'] = "1218614901201405273313473135"; $obj['out_trade_no'] = "JfuKdiBig4zZnE4n"; $obj['deliver_timestamp'] = $deliver_timestamp; $obj['deliver_status'] = "1"; $obj['deliver_msg'] = "ok"; $WxPayHelper = new WxPayHelper(); //get_biz_sign函数受保护,需要先取消一下,否则会报错 $app_signature = $WxPayHelper->get_biz_sign($obj); //3. 将构造的json提交给微信服务器,查询 $jsonmenu = ' { "appid" : "'.$obj['appid'].'", "openid" : "'.$obj['openid'].'", "transid" : "'.$obj['transid'].'", "out_trade_no" : "'.$obj['out_trade_no'].'", "deliver_timestamp" : "'.$deliver_timestamp.'", "deliver_status" : "'.$obj['deliver_status'].'", "deliver_msg" : "'.$obj['deliver_msg'].'", "app_signature" : "'.$app_signature.'", "sign_method" : "sha1" }'; $url = "https://api.weixin.qq.com/pay/delivernotify".$access_token; $result = https_request($url, $jsonmenu); var_dump($result); function https_request($url, $data = null){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; }
运行后返回结果
string(27) "{"errcode":0,"errmsg":"ok"}"
以上就是对开发微信支付发货通知的资料整理,希望能帮到开发微支付的朋友。
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...