环迅支付银行直连Server to Server以下代码结果是Response.Write("商户签名不正确,请联系客服!"),做个这个的指点下哪里原因

过_客 发布于 2013/08/05 15:31
阅读 2K+
收藏 1
/// <summary>
        /// 银行直连Server to Server
        /// </summary>
        [HttpGet]
        public void BnakListPay()
        {
            //IPS发起的主动对账程序,多次发送机制,可解决掉单问题。使用该功能前,请先阅读IPS主动对账接口文档并提供商户号和主动对账程序地址给到IPS进行配置
            //接收数据
            string billno = Request["billno"];
            string amount = Request["amount"];
            decimal blances = Convert.ToDecimal(amount);
            string currency_type = Request["Currency_type"];
            string mydate = Request["date"];
            string succ = Request["succ"];
            string msg = Request["msg"];
            string attach = Request["attach"];
            string ipsbillno = Request["ipsbillno"];
            string retEncodeType = Request["retencodetype"];
            string signature = Request["signature"];
            string bankbillno = Request["bankbillno"];
            //获取商户证书
            PayManage pm = new PayManage();
            using (XPotContext context = ContextFactory.GetContext())
            {
                PayManageModel pay = new PayManageModel()
                {
                    Context = context
                };
                pm = pay.FindCurrentMember();
            }
            string buskey = pm.Key;
            //登陆http://merchant.ips.com.cn/商户后台下载的商户证书内容
            byte[] decbuff = Convert.FromBase64String(buskey);
            string key = System.Text.Encoding.UTF8.GetString(decbuff);
            string merchant_key = key;

            //签名原文
            //billno+【订单编号】+currencytype+【币种】+amount+【订单金额】+date+【订单日期】 +succ+【成功标志】+ipsbillno+【IPS订单编号】+retencodetype +【交易返回签名方式】 +【商户内部证书】
            string content = "billno" + billno + "currencytype" + currency_type + "amount" + amount + "date" + mydate + "succ" + succ + "ipsbillno" + ipsbillno + "retencodetype" + retEncodeType + merchant_key;

            //签名是否正确
            Boolean verify = false;

            //验证方式:16-md5withRSA  17-md5
            if (retEncodeType == "16")
            {
                string pubfilename = "C:\\PubKey\\publickey.txt";
                RSAMD5Class m_RSAMD5Class = new RSAMD5Class();
                int result = m_RSAMD5Class.VerifyMessage(pubfilename, content, signature);

                //result=0   表示签名验证成功
                //result=-1  表示系统错误
                //result=-2  表示文件绑定错误
                //result=-3  表示读取公钥失败
                //result=-4  表示签名长度错
                //result=-5  表示签名验证失败
                //result=-99 表示系统锁定失败
                if (result == 0)
                {
                    verify = true;
                }
            }
            else if (retEncodeType == "17")
            {
                
                //Md5摘要
                string signature1 = FormsAuthentication.HashPasswordForStoringInConfigFile(content + merchant_key, "MD5").ToLower();
                if (signature1 == signature)
                {
                    verify = true;
                }
            }
            //判断签名验证是否通过
            if (verify == true)
            {
                if (succ != "Y")
                {
                    //交易失败
                    Response.Write("交易失败");
                }
                else
                {
                    //支付验证成功后处理本地数据
                    string unames = WebSecurity.CurrentUserName;
                        using (XPotContext xop = new XPotContext())
                        {
                            PayModel pmo = new PayModel()
                            {
                                Context = xop
                            };
                            if (pmo.HuanxunOKGoidPay(billno, blances, unames))
                            {
                                Response.Write("ipscheckok");
                                Response.End();
                            }
                            else
                            {
                                Response.Write("订单处理异常!");
                            }
                        }
                }
            }
            else
            {
                Response.Write("商户签名不正确,请联系客服!");
            }
        }

加载中
0
过_客
过_客
就没谁做个环迅支付直连银行的么?
过_客
过_客
//Md5摘要 067 string signature1 = FormsAuthentication.HashPasswordForStoringInConfigFile(content + merchant_key, "MD5").ToLower(); 答案:content参数里面已经包含商户证书了,再加一次就不对了。
0
过_客
过_客
retEncodeType是等于17用的md5加密
返回顶部
顶部