消息关闭
    暂无新消息!
问个问题 微信支付 总提示get_brand_wcpay_request:fail 也不跳转支付页面 哪位大神指点一下 谢谢
function doWxpay() {
            if (typeof('WeixinJSBridge') == "undefined") {
                alert('WeixinJSBridge:undefined');
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                    document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                }
            } else {
                onBridgeReady();
            }
        }

        function onBridgeReady() {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId": "<%=appId %>",     //公众号名称,由商户传入
                    "timeStamp": " <%=timeStamp %>",//时间戳,自1970年以来的秒数
                    "nonceStr": "<%=nonceStr %>", //随机串
                    "package": "<%=package %>",
                    "signType": "MD5",         //微信签名方式:
                    "paySign": "<%=paySign %>" //微信签名 
                },
                    function (res) {
                        if (res.err_msg == "get_brand_wcpay_request:ok") {
                            alert("ok");
                            window.location.href = "V_WXPayOK.aspx?orderId=<%=partnerid %>";
                        }     // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok,
                        else {
                            alert(res.err_msg);
                            window.location.href = "V_WXPayFail.aspx?orderId=<%=partnerid %>&action=Cancel";
                        }
                    }
                );
            }

这种方式不可以了吗?

下面代码判断是否成功有误 修改后代码如下:
success: function (res) {
                    if(res.errMsg == "chooseWXPay:ok" ) {
                        //支付成功
                    }else{
                        alert(res.errMsg);
                    }
                },
                cancel:function(res){
                    //支付取消
                }

可参考:http://blog.csdn.net/hefeng_aspnet/article/details/50679495

6个回答

︿ 3
已解决
<script type="text/javascript">
        //通过config接口注入权限验证配置
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
            appId: "<%=appId %>", // 必填,公众号的唯一标识
            timestamp: "<%=timeStamp %>", // 必填,生成签名的时间戳
            nonceStr: "<%=nonceStr %>", // 必填,生成签名的随机串
            signature: "<%=sSignature %>",// 必填,签名
            jsApiList: ['checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'hideMenuItems',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'showAllNonBaseMenuItem',
            'translateVoice',
            'startRecord',
            'stopRecord',
            'onRecordEnd',
            'playVoice',
            'pauseVoice',
            'stopVoice',
            'uploadVoice',
            'downloadVoice',
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'getNetworkType',
            'openLocation',
            'getLocation',
            'hideOptionMenu',
            'showOptionMenu',
            'closeWindow',
            'scanQRCode',
            'chooseWXPay',
            'openProductSpecificView',
            'addCard',
            'chooseCard',
            'openCard'] // 必填,需要使用的JS接口列表
        });

        //通过ready接口处理成功验证
        wx.ready(function () {
            // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后

            document.querySelector('#getBrandWCPayRequest').onclick = function () {
                wx.chooseWXPay({
                    timestamp: "<%=timeStamp%>", // 支付签名时间戳 注意这里的s 文档新版大写 但是我的小写才好使
                    nonceStr: "<%=nonceStr%>", // 支付签名随机串
                    package: "<%=package%>", // 统一支付接口返回的package包
                    signType: "MD5", // 签名方式,'MD5'
                    paySign: "<%=paySign %>", // 支付签名
                 success: function (res) {
                     if (res.err_msg == "get_brand_wcpay_request:ok") {
                         alert("支付成功");
                         // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 
                     }
                     else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                         alert("cancel");
                         // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 
                     }
                     else if (res.err_msg == "get_brand_wcpay_request:fail") {
                         alert("fail");
                         // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 
                     }
                 }
                });
            };
        });
    </script>
︿ 1
我遇到了这个问题,但是现在微信支付不需要白名单了,要怎么解决,无法跳转页面