本文实例为大家分享了Thinkphp微信公众号支付接口,供大家参考,具体内容如下
第一步
先把文件夹的那两个图片 配置成一样的路径 除了域名要改 其他保持一致。第二步
把 Weixinpay 这个文件夹放在 \ThinkPHP\Library\Vendor 将Weixinpay文件夹放置到这个Vendor文件夹中第三步
把 WxJsAPIController.class.php 这个php文件 \Home\Controller 这里面第四步
把 WxJsAPI这个文件夹 放置在 \Home\View 这个里面第五步
成功调用微信公众号支付功能jsApiCall.html
<div class="jb51code">
<pre class="brush:xhtml;">
<!DOCTYPE html>
<script type="text/javascript">
//调用微信JS api 支付
function jsApiCall()
{
WeixinJSBridge.invoke(
'getBrandWCPayRequest',<?php echo $jsApiParameters; ?>,function(res){
WeixinJSBridge.log(res.err_msg);
if(res.err_msg == "get_brand_wcpay_request:ok"){
//alert(res.err_code+res.err_desc+res.err_msg);
/这里写如果支付成功的话执行什么操作/
}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();
}
}