Ejemplo n.º 1
0
 //商户证书 HttpContext.Current.Server.MapPath("~/..");
 /// <summary>
 /// 获取工商银行验证信息
 /// </summary>
 /// <param name="argIcbc"></param>
 /// <returns></returns>
 public static ICBC GetCheckInfo(ICBC argIcbc)
 {
     string strMerSignMsg = string.Empty;
     B2CUtil icbcObj = new B2CUtil();
     int jg = icbcObj.init(strCertFN, strCertFNM, strKeyFN, strKey);
     if (jg == 0)
     {
         argIcbc.MerSignMsg = icbcObj.signC(argIcbc.TranData, argIcbc.TranData.Length);
         if (argIcbc.MerSignMsg == "")
         {
             int returnCode = icbcObj.getRC();
             //("错误编码:" + returnCode + ",签名错误");
         }
         argIcbc.MerCert = icbcObj.getCert(1);
         byte[] bytes = Encoding.Default.GetBytes(argIcbc.TranData);
         argIcbc.TranData = Convert.ToBase64String(bytes);
     }
     else
     {
         //(jg.ToString() + ",证书错误或私钥错误编码");
     }
     return argIcbc;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取工商银行验证信息
        /// </summary>
        /// <param name="argIcbc"></param>
        /// <returns></returns>
        public static ICBC GetCheckReturnInfo(ICBC argIcbc)
        {
            string strMerSignMsg = string.Empty;
            B2CUtil icbcObj = new B2CUtil();

            if (icbcObj.init(strCertFN, strCertFNM, strKeyFN, strKey) == 0)
            {
                argIcbc.TranData = Common.Decode(argIcbc.TranData);
                //判断验证银行签名是否成功
                if (icbcObj.verifySignC(argIcbc.TranData, argIcbc.TranData.Length, argIcbc.MerSignMsg, argIcbc.MerSignMsg.Length) == 0)
                {
                    argIcbc.IsCheck = true;
                }
                else
                    argIcbc.IsCheck = true;
            }
            else
            {
                argIcbc.IsCheck = false;
            }
            return argIcbc;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Form["notifyData"] != null)
     {
         try
         {
             ICBC icbcInfo = new ICBC();
             icbcInfo.TranData = Request.Form["notifyData"];
             icbcInfo.MerSignMsg = Request.Form["signMsg"].ToString();
             icbcInfo = CBCPayOnline.GetCheckReturnInfo(icbcInfo);
             //自定义返回的变量
             //string myOrderid = Encrypt.Decode(Request.Form["merVAR"].ToString());
             if (icbcInfo.IsCheck)
             {
                 DataSet myds = new DataSet();
                 StringReader strReader = new StringReader(icbcInfo.TranData);
                 myds.ReadXml(strReader);
                 FileStream fs = new FileStream("D:\\cc.txt", FileMode.Append);
                 StreamWriter sw = new StreamWriter(fs, Encoding.Default);
                 sw.Write(ToJson(myds));
                 sw.Close();
                 fs.Close();
                 DataTable mytable = new DataTable();
                 mytable = myds.Tables["bank"];
                 string payDate = myds.Tables["orderInfo"].Rows[0]["orderDate"].ToString().Trim();
                 string userNum = myds.Tables["custom"].Rows[0]["UserNum"].ToString().Trim();//联名客户在商户的会员号
                 userNum += "," + myds.Tables["bank"].Rows[0]["TranBatchNo"].ToString().Trim();
                 string amount = myds.Tables["orderInfo"].Rows[0]["amount"].ToString().Trim();
                 string orderid = myds.Tables["orderInfo"].Rows[0]["orderid"].ToString().Trim();
                 if (null != mytable && mytable.Rows.Count > 0)
                 {
                     if (mytable.Rows[0]["tranStat"].ToString().Trim() == "1")
                     {
                         WebBLL.UpdatePayOrder(true, true, orderid, payDate, userNum, amount);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
         }
     }
 }