微信內公眾號支付無需點選直接發起支付js
阿新 • • 發佈:2019-02-16
<script type="text/javascript"> 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('支付取消.'); history.back(-1); } window.location.href="<?php echo $return_url;?>"; } ); } 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(); } } callpay(); </script>