做微信支付的时候遇到了这个纠结的问题,新版本的微信支付已经不需要paysignkey了,结果开发的时候发现还是要填写商户密钥key,说是在微信审核成功后发回的邮件中,可是找来找去也没有在邮件中找到这个参数,网上查了好多文章,都说在邮件中,可我邮件中确实没有啊,问了客服,答非所问,干脆自己在找找,终于在网上找到了这篇文章,感谢大神,终于解决了我的问题,同时也要分享出来,3.3.6的微信支付文档说的确实很少....
一、有言在先
1、俺家公众号开通微信支付时间是9月22号,所以适用文档版本号是v3.3.6,当时一不小心从微信客服那里拿到一个v2.7的文档,扑腾了1天时间,从一个个水坑里爬出来又跌入尿坑,把人坑惨了,后面找到相关人士才拿到真相,不过现在公众平台也可以下载到了~希望大家伙绕开这个坑!
2、最重要一点:此文有软广告嫌疑,慎入!先帮朋友们把评论写在这里~~~
二、需要到这些地方去扒参数
1、登录微信公众号管理后台mp.weixin.qq.com,在左侧菜单栏找到开发者中心,点开如下图就能看到AppID和AppSecret:
2、在微信支付通过之后,财付通会发3封邮件到申请人邮箱中,俺家之前开通过财付通的账户用于主站支付接口, 不过这次又新发了一个财付通账号,不过让人惊喜的是这次微信支付免了保证金,不知为啥?
点开weixinpay那封邮件就可以看到这些账号信息,把附件中pem格式的文件下载保存到web服务器上,请记下文件绝对路径,在下面代码中需要用到:
3、登录微信商户平台(mch.weixin.qq.com),去设置商户支付密钥Key:
4、登录微信公众号管理后台mp.weixin.qq.com,设置支付配置,支付测试,支付白名单
三、找到参数来配置该个类class WxPayConf
class WxPayConf
{
//=======【基本信息设置】=====================================
//微信公众号身份的唯一标识。审核通过后,在微信发送的邮件中查看
const APPID = "填上二、1中看到的AppID";
//受理商ID,身份标识
const MCHID = "填上二、2中看到的MCHID";
//商户支付密钥Key。审核通过后,在微信发送的邮件中查看(如果没有,可以登录微信商户平台去设置)
const KEY = "填上二、3中设置的密钥";
//JSAPI接口中获取openid,审核后在公众平台开启开发模式后可查看
const APPSECRET = "填上二、1中看到的AppSecret";
//=======【JSAPI路径设置】===================================
//获取access_token过程中的跳转uri,通过跳转将code传入jsapi支付页面
const JS_API_CALL_URL = "http://www.xxx.com/wxpay/js_api_call.PHP";
//=======【证书路径设置】=====================================
//证书路径,注意应该填写绝对路径
const SSLCERT_PATH = "填上二、2中下载的pem文件放在服务器上的路径";
const SSLKEY_PATH = "填上二、2中下载的pem文件放在服务器上的路径";
//=======【异步通知url设置】===================================
//异步通知url,商户根据实际开发过程设定
const NOTIFY_URL = http://www.xxxx.com/wxpay/notify_url.php;
}
四、JSAPI支付
微信JS API只能在微信内置浏览器中使用,其他浏览器调用无效。
下面代码是微信官方提供的JS API支付demo
include_once("WxPayHelper/WxPayHelper.php");
- //使用js<span id="69_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="69_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=api&k0=api&k1=%CE%A2%D0%C5&k2=xml&k3=head&k4=php&k5=%D6%A7%B8%B6&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=7&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">api</span></a></span>接口$jsApi = new JsApi();//=========步骤1:网页授权获取用户openid============//通过code获得openidif(!isWeixin()){ echo "请在<span id="70_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="70_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%CE%A2%D0%C5&k0=%CE%A2%D0%C5&k1=xml&k2=head&k3=php&k4=%D6%A7%B8%B6&k5=%D0%A1%B5%EA&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=8&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">微信</span></a></span>内扫描<span id="71_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="71_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%B6%FE%CE%AC%C2%EB&k0=%B6%FE%CE%AC%C2%EB&k1=%BA%AF%CA%FD&k2=%C9%CC%C6%B7&k3=api&k4=%CE%A2%D0%C5&k5=xml&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=4&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">二维码</span></a></span>"; exit;}if (!isset($_GET['code'])){ //触发微信返回code码 $url = $jsApi->createOauthUrlForCode(WxPayConf::JS_API_CALL_URL."); Header("Location: $url");}else{ //获取code码,以获取openid $code = $_GET['code']; $jsApi->setCode($code); $openid = $jsApi->getOpenId(); } if(empty($order)){ echo "数据错误!"; exit; }}//=========步骤2:使用统一<span id="72_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="72_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%D6%A7%B8%B6&k0=%D6%A7%B8%B6&k1=%D0%A1%B5%EA&k2=%B6%FE%CE%AC%C2%EB&k3=%BA%AF%CA%FD&k4=%C9%CC%C6%B7&k5=api&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=2&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">支付</span></a></span>接口,获取prepay_id============//使用统一支付接口$unifiedOrder = new UnifiedOrder();//设置统一支付接口参数//设置必填参数//appid已填,商户无需重复填写//mch_id已填,商户无需重复填写//noncestr已填,商户无需重复填写//spbill_create_ip已填,商户无需重复填写//sign已填,商户无需重复填写$unifiedOrder->setParameter("openid","$openid");//<span id="73_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="73_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%C9%CC%C6%B7&k0=%C9%CC%C6%B7&k1=api&k2=%CE%A2%D0%C5&k3=xml&k4=head&k5=php&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=6&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">商品</span></a></span>描述$unifiedOrder->setParameter("body","test");//商品描述//自定义订单号,此处仅作举例$timeStamp = time();$out_trade_no = timeStamp;$total_fee = 1;$unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商户订单号$unifiedOrder->setParameter("total_fee",$total_fee);//总金额$unifiedOrder->setParameter("notify_url",WxPayConf::NOTIFY_URL);//通知地址$unifiedOrder->setParameter("trade_type","JSAPI");//交易类型//非必填参数,商户可根据实际情况选填//$unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号//$unifiedOrder->setParameter("device_info","XXXX");//设备号//$unifiedOrder->setParameter("attach","XXXX");//附加数据//$unifiedOrder->setParameter("time_start","XXXX");//交易起始时间//$unifiedOrder->setParameter("time_expire","XXXX");//交易结束时间//$unifiedOrder->setParameter("goods_tag","XXXX");//<span id="74_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="74_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%C9%CC%C6%B7&k0=%C9%CC%C6%B7&k1=api&k2=%CE%A2%D0%C5&k3=xml&k4=head&k5=php&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=6&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">商品</span></a></span>标记//$unifiedOrder->setParameter("openid","XXXX");//用户标识//$unifiedOrder->setParameter("product_id","XXXX");//商品ID$prepay_id = $unifiedOrder->getPrepayId();//=========步骤3:使用js<span id="75_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="75_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=api&k0=api&k1=%CE%A2%D0%C5&k2=xml&k3=head&k4=php&k5=%D6%A7%B8%B6&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=7&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">api</span></a></span>调起<span id="76_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="76_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%D6%A7%B8%B6&k0=%D6%A7%B8%B6&k1=%D0%A1%B5%EA&k2=%B6%FE%CE%AC%C2%EB&k3=%BA%AF%CA%FD&k4=%C9%CC%C6%B7&k5=api&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=2&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">支付</span></a></span>============$jsApi->setPrepayId($prepay_id);$jsApiParameters = $jsApi->getParameters();function isWeixin(){ $agent = strtolower($_SERVER['HTTP_USER_AGENT']); $is_weixin = strpos($agent, 'micromessenger') ? true : false ; if($is_weixin){ return true; }else{ return false; }}?><html><<span id="77_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="77_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=head&k0=head&k1=php&k2=%D6%A7%B8%B6&k3=%D0%A1%B5%EA&k4=%B6%FE%CE%AC%C2%EB&k5=%BA%AF%CA%FD&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=10&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">head</span></a></span>><meta http-equiv="content-type" content="text/html;charset=utf-8" /><title><span id="78_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="78_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%CE%A2%D0%C5&k0=%CE%A2%D0%C5&k1=xml&k2=head&k3=php&k4=%D6%A7%B8%B6&k5=%D0%A1%B5%EA&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=8&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">微信</span></a></span>安全支付</title><script type="text/javascript"> //调用微信JS <span id="79_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="79_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=api&k0=api&k1=%CE%A2%D0%C5&k2=xml&k3=head&k4=php&k5=%D6%A7%B8%B6&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=7&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">api</span></a></span> <span id="80_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="80_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%D6%A7%B8%B6&k0=%D6%A7%B8%B6&k1=%D0%A1%B5%EA&k2=%B6%FE%CE%AC%C2%EB&k3=%BA%AF%CA%FD&k4=%C9%CC%C6%B7&k5=api&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=2&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">支付</span></a></span> function jsApiCall() { WeixinJSBridge.invoke( 'getBrandWCPayRequest', <?<span id="81_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="81_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=php&k0=php&k1=%D6%A7%B8%B6&k2=%D0%A1%B5%EA&k3=%B6%FE%CE%AC%C2%EB&k4=%BA%AF%CA%FD&k5=%C9%CC%C6%B7&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=1&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">php</span></a></span> echo $jsApiParameters; ?>, function(res){ WeixinJSBridge.log(res.err_msg); //alert(res.err_code+res.err_desc+res.err_msg); } ); } function callpay() { if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', jsApiCall, false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', jsApiCall); document.attachEvent('onWeixinJSBridgeReady', jsApiCall); } }else{ jsApiCall(); } } </script></<span id="82_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="82_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=head&k0=head&k1=php&k2=%D6%A7%B8%B6&k3=%D0%A1%B5%EA&k4=%B6%FE%CE%AC%C2%EB&k5=%BA%AF%CA%FD&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=10&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">head</span></a></span>><body onload=""></br></br></br></br><div align="center"><button style="width: 210px; height: 30px; background-color: #FE6714; border: 0px #FE6714 solid; cursor: pointer; color: white; font-size: 16px;" type="button" onclick="callpay()">贡献一下</button></div></body></html>
![](//pubimage.360doc.com/wz/default.gif)
![](//pubimage.360doc.com/wz/default.gif)
将其中的微信支付参数修改成自己申请得到的,然后将网页上传到微信支付目录下,使用公众号给测试账号回复该网页地址。用户就可以实现一次JS API支付。
五、NATIVE支付
采用了官方提供的demo,native支付模式2完成
下面代码是微信官方提供的natice支付demo
include_once("WxPayHelper/WxPayHelper.php");
- //使用统一<span id="60_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="60_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%D6%A7%B8%B6&k0=%D6%A7%B8%B6&k1=%D0%A1%B5%EA&k2=%B6%FE%CE%AC%C2%EB&k3=%BA%AF%CA%FD&k4=%C9%CC%C6%B7&k5=api&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=2&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">支付</span></a></span>接口 $unifiedOrder = new UnifiedOrder(); //设置统一支付接口参数 //设置必填参数 //appid已填,商户无需重复填写 //mch_id已填,商户无需重复填写 //noncestr已填,商户无需重复填写 //spbill_create_ip已填,商户无需重复填写 //sign已填,商户无需重复填写 $unifiedOrder->setParameter("body","贡献一分钱");//<span id="61_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="61_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%C9%CC%C6%B7&k0=%C9%CC%C6%B7&k1=api&k2=%CE%A2%D0%C5&k3=xml&k4=head&k5=php&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=6&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">商品</span></a></span>描述 //自定义订单号,此处仅作举例 $timeStamp = time(); $out_trade_no = WxPayConf::APPID."$timeStamp"; $unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商户订单号 $unifiedOrder->setParameter("total_fee","1");//总金额 $unifiedOrder->setParameter("notify_url",WxPayConf::NOTIFY_URL);//通知地址 $unifiedOrder->setParameter("trade_type","NATIVE");//交易类型 //非必填参数,商户可根据实际情况选填 //$unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号 //$unifiedOrder->setParameter("device_info","XXXX");//设备号 //$unifiedOrder->setParameter("attach","XXXX");//附加数据 //$unifiedOrder->setParameter("time_start","XXXX");//交易起始时间 //$unifiedOrder->setParameter("time_expire","XXXX");//交易结束时间 //$unifiedOrder->setParameter("goods_tag","XXXX");//<span id="62_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="62_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%C9%CC%C6%B7&k0=%C9%CC%C6%B7&k1=api&k2=%CE%A2%D0%C5&k3=xml&k4=head&k5=php&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=6&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">商品</span></a></span>标记 //$unifiedOrder->setParameter("openid","XXXX");//用户标识 //$unifiedOrder->setParameter("product_id","XXXX");//商品ID //获取统一<span id="63_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="63_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%D6%A7%B8%B6&k0=%D6%A7%B8%B6&k1=%D0%A1%B5%EA&k2=%B6%FE%CE%AC%C2%EB&k3=%BA%AF%CA%FD&k4=%C9%CC%C6%B7&k5=api&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=2&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">支付</span></a></span>接口结果 $unifiedOrderResult = $unifiedOrder->getResult(); //商户根据实际情况设置相应的处理流程 if ($unifiedOrderResult["return_code"] == "FAIL") { //商户自行增加处理流程 echo "通信出错:".$unifiedOrderResult['return_msg']."<br>"; } elseif($unifiedOrderResult["result_code"] == "FAIL") { //商户自行增加处理流程 echo "错误代码:".$unifiedOrderResult['err_code']."<br>"; echo "错误代码描述:".$unifiedOrderResult['err_code_des']."<br>"; } elseif($unifiedOrderResult["code_url"] != NULL) { //从统一<span id="64_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="64_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%D6%A7%B8%B6&k0=%D6%A7%B8%B6&k1=%D0%A1%B5%EA&k2=%B6%FE%CE%AC%C2%EB&k3=%BA%AF%CA%FD&k4=%C9%CC%C6%B7&k5=api&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=2&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">支付</span></a></span>接口获取到code_url $code_url = $unifiedOrderResult["code_url"]; //商户自行增加处理流程 //...... }?><!DOCTYPE HTML><html><<span id="65_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="65_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=head&k0=head&k1=php&k2=%D6%A7%B8%B6&k3=%D0%A1%B5%EA&k4=%B6%FE%CE%AC%C2%EB&k5=%BA%AF%CA%FD&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=10&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">head</span></a></span>> <meta charset="UTF-8"> <title><span id="66_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="66_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=%CE%A2%D0%C5&k0=%CE%A2%D0%C5&k1=xml&k2=head&k3=php&k4=%D6%A7%B8%B6&k5=%D0%A1%B5%EA&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=8&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">微信</span></a></span>安全支付</title></head><body> <div align="center" id="qrcode"> </div> <div align="center"> <p>订单号:<?<span id="67_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="67_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=php&k0=php&k1=%D6%A7%B8%B6&k2=%D0%A1%B5%EA&k3=%B6%FE%CE%AC%C2%EB&k4=%BA%AF%CA%FD&k5=%C9%CC%C6%B7&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=1&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">php</span></a></span> echo $out_trade_no; ?></p> </div> <div align="center"> <form action="./order_query.php" method="post"> <input name="out_trade_no" type='hidden' value="<?php echo $out_trade_no; ?>"> <button type="submit" >查询订单状态</button> </form> </div> <br> <div align="center"> <form action="./refund.php" method="post"> <input name="out_trade_no" type='hidden' value="<?php echo $out_trade_no; ?>"> <input name="refund_fee" type='hidden' value="1"> <button type="submit" >申请退款</button> </form> </div> <br> <div align="center"> <a href="../index.<span id="68_nwp" style="width:auto; height:auto; float:none"><a target="_blank" id="68_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Eth7%2Ecn%2FProgram%2Fphp%2F201410%2F296997%2Eshtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=smileking_cpr&k=php&k0=php&k1=%D6%A7%B8%B6&k2=%D0%A1%B5%EA&k3=%B6%FE%CE%AC%C2%EB&k4=%BA%AF%CA%FD&k5=%C9%CC%C6%B7&sid=3688a2967a2c536b&ch=0&tu=u1682280&jk=07dffeb6060aa1bd&cf=29&fv=15&stid=9&urlid=0&luki=1&seller_id=1&di=128" style="text-decoration:none"><span style="width:auto; height:auto; color:rgb(0,0,255); font-size:14px; float:none">php</span></a></span>">返回首页</a> </div></body> <script src="./qrcode.js"></script> <script> if(<?php echo $unifiedOrderResult["code_url"] != NULL; ?>) { var url = "<?php echo $code_url;?>"; //参数1表示图像大小,取值范围1-10;参数2表示质量,取值范围'L','M','Q','H' var qr = qrcode(10, 'M'); qr.addData(url); qr.make(); var wording=document.createElement('p'); wording.innerHTML = "扫我,扫我"; var code=document.createElement('DIV'); code.innerHTML = qr.createImgTag(); var element=document.getElementById("qrcode"); element.appendChild(wording); element.appendChild(code); } </script></html>
![](//pubimage.360doc.com/wz/default.gif)
六、调用WxPayHelper.php存在的问题
在做开发时,官方demo 提供的wxPayHeler.php 存在部分问题,导致结果sign 错误。
使用jpapi 支付时候需要修改3
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。