Thinkphp整合微信支付功能(2)

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" /> <meta content="telephone=no"/> <title>下</title> <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> <meta content=""> <meta content=""> <script type="text/javascript"> var order_sn = "{$res['order_sn']}"; //调用微信JS api 支付 function jsApiCall(){ WeixinJSBridge.invoke( 'getBrandWCPayRequest', <?php echo $jsApiParameters; ?>, function(res){ //如果支付成功 if (res.err_msg == 'get_brand_wcpay_request:ok') { //支付成功后跳转的地址 location.href = "{:U('Home/User/my_order')}"; }else if (res.err_msg == 'get_brand_wcpay_request:cancel') { alert('请尽快完成支付哦!'); }else if (res.err_msg == 'get_brand_wcpay_request:fail') { alert('支付失败'); }else { alert('意外错误'); } //WeixinJSBridge.log(res.err_msg); //alert(res.err_code+res.err_desc+res.err_msg); /*if (res.err_msg == 'get_brand_wcpay_request:ok') { alert('支付成功'); }else { alert('取消支付'); }*/ } ); } 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> <style> *{font-family:'微软雅黑','Microsoft YaHei';} body #head{position:relative;z-index:99999999999999;padding:0 10px;} body .zh-head{padding:0 0 0 0;height:auto;} .zh-head-conter{position:relative;height:40px;} .zh-logo{position:absolute;left:50%;top:0;margin:0 0 0 -60px;float:none;width:auto;} .zh-logo a{display:block;} .zh-logo img{width:120px;height:40px;display:block;} .heads_fix .zh-logo{} #head{position:fixed!important;left:0;top:0;right:0;z-index:99999;background:#fff;border-bottom:1px solid #ddd;} .zh-logo{height:40px;} .flowpay{margin-top:25%;} .flowpay dt{text-align:center;} .flowpay strong.price{font-size:40px;} .wxLogo{text-align:center;} .wxLogo img{} .flowpay dd{margin:0;padding:20px 0 10px 0;} .flowpay dd input{margin:0 auto;padding:0;width:90%;height:45px;line-height:45px;border:0;border-radius:4px;background:#0CBC0A;color:#fff;font-size:17px;display:block;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;} </style> </head> <body> <!--头部开始--> <div> <dl> <dt> <p><img src="https://www.jb51.net/__PUBLIC__/home/images/1479953699138120.png" alt=""></p> 本次订单需支付:¥<strong>{$res['order_amount']}</strong>&nbsp;元 </dt> <dd> <input type="button" value="立即支付" /> </dd> </dl> </div> <!--尾结束--> </body> </html>

然后就是类文件啦:

Thinkphp整合微信支付功能

那个cacert是证书存放目录;证书不一定需要的;

vendor文件夹在我的文件里面找找就可以。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/249f890fa3fbe95493485ed26c16a3ed.html