首页 新闻 会员 周边

微信支付-支付验证签名失败 V3

0
[已解决问题] 解决于 2015-09-25 16:41

按照微信支付接口的流程,对一些参数具体话后,还是失败,心拔凉拔凉的,请高手指点下,谢谢!

        //公众账号ID
        string appid = Info.AppId;
        //商品描述
        string body = order.Code;
        //商户号
        string mch_id = "***";
        //随机字符串
        string nonce_str = GetCode(32);
        //通知地址-接收微信支付成功通知
        string notify_url = "http://****/cart/weixinnotify_url.aspx";
        //用户标识 -用户在商户appid下的唯一标识
        string openid = OpenId;
        //商户订单号
        string out_trade_no = order.Code;
        //下单IP
        string spbill_create_ip = GetIP(this.Context);
        //总金额 分为单位
        int total_fee = 1;
        //交易类型 -JSAPI、NATIVE、APP
        string trade_type = "JSAPI";
        //微信签名
        string tmpStr = "appid=" + appid + "&body=" + body + "&mch_id=" + mch_id + "&nonce_str=" + nonce_str + "&notify_url=" + notify_url + "&openid=" + openid + "&out_trade_no=" + out_trade_no + "&spbill_create_ip=" + spbill_create_ip + "&total_fee=" + total_fee + "&trade_type=" + trade_type + "&key=****";
        paySign = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "MD5").ToUpper();


        string url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
        string xml = "<xml>";
        xml += "<appid>" + appid + "</appid>";
        xml += "<body>" + body + "</body>";
        xml += "<mch_id>" + mch_id + "</mch_id>";
        xml += "<nonce_str>" + nonce_str + "</nonce_str>";
        xml += "<notify_url>" + notify_url + "</notify_url>";
        xml += "<openid>" + openid + "</openid>";
        xml += "<out_trade_no>" + out_trade_no + "</out_trade_no>";
        xml += "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>";
        xml += "<total_fee>" + total_fee + "</total_fee>";
        xml += "<trade_type>" + trade_type + "</trade_type>";
        xml += "<sign>" + paySign + "</sign>";
        xml += "</xml>";
        string v = PostWebRequests(url, xml);
        prepay_id = v;
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
            appId: '***', // 必填,公众号的唯一标识
            timestamp: "<%=Timer %>", // 必填,生成签名的时间戳
            nonceStr: '<%=Timer %>', // 必填,生成签名的随机串
            signature: "<%=GetSignature() %>", // 必填,签名,见附录1
            jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
        });

        wx.ready(function () {
            wx.chooseWXPay({
                appId: "***",
                timestamp: "<%=Timer %>",
                nonceStr: "<%=RdCode %>",
                package: "prepay_id=<%=prepay_id %>",
                signType: "MD5",
                paySign: "<%=paySign %>",
                success: function (res) {
                    alert("成功");
                },
                cancel: function () {
                    alert("用户已取消");
                },
                error: function (e) {
                    alert("失败");
                }
            });
        });

    </script>

 

以上代码中的,prepay_id和paySign 的结果和微信提供的签名测试结果对比了,都是正确的,就是不知道错误在哪

imluzhi的主页 imluzhi | 初学一级 | 园豆:37
提问于:2015-09-23 21:40
< >
分享
最佳答案
0
imluzhi | 初学一级 |园豆:37 | 2015-09-25 16:41
其他回答(3)
0

没用过

JackWang-CUMT | 园豆:2866 (老鸟四级) | 2015-09-24 05:07
0

你咋解决的 我也遇见这问题了  统一下下单成功 然后提交订单 先提示支付成功 然后又提示 支付验证签名失败

nod22 | 园豆:206 (菜鸟二级) | 2015-11-29 09:11
0

亲, 你怎么解决, chooseWXPay中的paySign到底是怎么个签名, 求指教

Leone- | 园豆:202 (菜鸟二级) | 2016-01-24 22:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册