直接放在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 />
'getBrandWCPayRequest',<br />
{$jsApiParameters},<br />
function(res){<br />
WeixinJSBridge.log(res.err_msg);<br />
if(res.err_msg == 'get_brand_wcpay_request:cancel') {<br />
alert("您已取消了此次支付");<br />
return;<br />
} else if(res.err_msg == 'get_brand_wcpay_request:fail') {<br />
alert("支付失败");<br />
return;<br />
} else if(res.err_msg == 'get_brand_wcpay_request:ok') {<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('WeixinJSBridgeReady', jsApiCall, false);<br />
}else if (document.attachEvent){<br />
document.attachEvent('WeixinJSBridgeReady', jsApiCall); <br />
document.attachEvent('onWeixinJSBridgeReady', jsApiCall);<br />
}<br />
}else{<br />
jsApiCall();<br />
}<br />
}<br />
</script><br>
<br>
<br>
<br>
<br>
<button><br>
确认支付<br>
</button><br>
<br>
<br>