微信支付需要监听WeixinJSBridgeReady
时间:2014-09-04 17:14:10
收藏:0
阅读:1287
<script language="javascript">
var str = <?php echo $str;?>;
function callpay()
{
document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
WeixinJSBridge.invoke(‘getBrandWCPayRequest‘,str,function(res){
WeixinJSBridge.log(res.err_msg);
//alert(res.err_code+res.err_desc+res.err_msg);
switch (res.err_msg){
case ‘get_brand_wcpay_request:cancel‘:
location.href="/?_a=fail&order_sn=<?php echo $order_sn;?>";
break;
case ‘get_brand_wcpay_request:fail‘:
location.href="/?_a=fail&order_sn=<?php echo $order_sn;?>";
break;
case ‘get_brand_wcpay_request:ok‘:
location.href="/?_a=done&order_sn=<?php echo $order_sn;?>&ac=<?php echo $authcode?>";
break;
}
});
}, false);
}
callpay();
</script>
var str = <?php echo $str;?>;
function callpay()
{
document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
WeixinJSBridge.invoke(‘getBrandWCPayRequest‘,str,function(res){
WeixinJSBridge.log(res.err_msg);
//alert(res.err_code+res.err_desc+res.err_msg);
switch (res.err_msg){
case ‘get_brand_wcpay_request:cancel‘:
location.href="/?_a=fail&order_sn=<?php echo $order_sn;?>";
break;
case ‘get_brand_wcpay_request:fail‘:
location.href="/?_a=fail&order_sn=<?php echo $order_sn;?>";
break;
case ‘get_brand_wcpay_request:ok‘:
location.href="/?_a=done&order_sn=<?php echo $order_sn;?>&ac=<?php echo $authcode?>";
break;
}
});
}, false);
}
callpay();
</script>
评论(0)