Home > php教程 > php手册 > 直接vender的微信官方支付V3包

直接vender的微信官方支付V3包

WBOY
Release: 2016-06-07 11:35:28
Original
1478 people have browsed it

直接放在vender的微信官方支付V3包,只是做了简单的路径修正,保持了官方直接下载的源文件
调用示例// +----------------------------------------------------------------------<br> // | Author: 左边 (加群:366504956(刚建,欢迎)  交流thinkphp下微信开发)<br> // +----------------------------------------------------------------------<br> <br> <br> public function Index(){<br>         //商户基本信息,可以写死在WxPay.Config.php里面,其他详细参考WxPayConfig.php        <br>         define('APPID','wx9dc408cb04cd6d2d');<br>         define('MCHID', '1709319401');<br>         define('KEY', 'e10adc3949ba59abbe56e757f20f883e');<br>         define('APPSECRET', '8c97c84a34f4be1d46bd35b7e51df86a');    <br> <br>         vendor('Pay.JSAPI');<br>         $tools = new \JsApiPay();<br>         $openId = 'oql2ZwUwTvQsD73jTZuzRc2KFYEA';<br>         $Out_trade_no=date('YHis').rand(100,1000);<br>         $Total_fee='测试';<br>         $Body='啥也不说';<br>         $Total_fee=1;<br>         $input = new \WxPayUnifiedOrder();<br>         $input->SetBody($Body);<br>         $input->SetOut_trade_no($Out_trade_no);<br>         $input->SetTotal_fee($Total_fee);<br>         $input->SetNotify_url("http://xx.xxx.com/pay/notify.php");<br>         $input->SetTrade_type("JSAPI");<br>         $input->SetOpenid($openId);<br>         $order = \WxPayApi::unifiedOrder($input);<br>         $this->jsApiParameters = $tools->GetJsApiParameters($order);<br>         $this->display();<br>     }htmlnbsp;html><br> <br>     <meta> <br>     <title>微信安全支付</title> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <meta> <br> <br>     <script><br /> //调用微信JS api 支付<br /> function jsApiCall()<br /> {<br /> WeixinJSBridge.invoke(<br /> &#039;getBrandWCPayRequest&#039;,<br /> {$jsApiParameters},<br /> function(res){<br /> WeixinJSBridge.log(res.err_msg);<br /> if(res.err_msg == &#039;get_brand_wcpay_request:cancel&#039;) {<br /> alert("您已取消了此次支付");<br /> return;<br /> } else if(res.err_msg == &#039;get_brand_wcpay_request:fail&#039;) {<br /> alert("支付失败");<br /> return;<br /> } else if(res.err_msg == &#039;get_brand_wcpay_request:ok&#039;) {<br /> alert("支付成功!");//跳转到订单页面<br /> <br /> } else {<br /> alert("未知错误"+res.error_msg);<br /> return;<br /> }<br /> }<br /> );<br /> }<br /> <br /> function callpay()<br /> {<br /> if (typeof WeixinJSBridge == "undefined"){<br /> if( document.addEventListener ){<br /> document.addEventListener(&#039;WeixinJSBridgeReady&#039;, jsApiCall, false);<br /> }else if (document.attachEvent){<br /> document.attachEvent(&#039;WeixinJSBridgeReady&#039;, jsApiCall); <br /> document.attachEvent(&#039;onWeixinJSBridgeReady&#039;, jsApiCall);<br /> }<br /> }else{<br /> jsApiCall();<br /> }<br /> }<br /> </script><br> <br> <br> <br> <br>     <button><br>         确认支付<br>     </button><br> <br> <br>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template