//调用微信JS api 支付 function jsApiCall() { WeixinJSBridge.invoke( 'getBrandWCPayRequest', <?PHP echo $param ?>, function(res){ WeixinJSBridge.log(res.err_msg); alert(res.err_code+res.err_desc+res.err_msg); } ); }
$totalFee = $order['money']/100; $out_trade_no = date('Ymd',time()).uniqid(); $notifyUrl = url('index/notify','','html',true); $timestamp = strval(time());
ajax请求支付参数在不同的手机上可能会出现问题
<script> $(function () { wx.config({ debug: true,//调试模式 appId: '<?php echo $signPackage['appId'] ?>', timestamp: <?php echo $signPackage['timestamp'] ?>, nonceStr: '<?php echo $signPackage['nonceStr'] ?>', signature: '<?php echo $signPackage['signature'] ?>', jsApiList: [ 'chooseWXPay' ] }); $(".js-btn-wxpay").click(function () { if (typeof WeixinJSBridge == "undefined") { alert("请在微信中打开"); return; } var success = false; wx.chooseWXPay({ timestamp: <?php echo $bizPackage['timeStamp'] ?>, nonceStr: '<?php echo $bizPackage['nonceStr'] ?>', package: '<?php echo $bizPackage['package'] ?>', signType: '<?php echo $bizPackage['signType'] ?>', paySign: '<?php echo $bizPackage['paySign'] ?>', success: function (res) { success = true; }, complete: function () { if (success) { alert('支付成功'); } else { alert('支付失败'); } } }); }); }); </script>