Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["OrderID"] != null)
            {
                string orderid = Request.QueryString["OrderID"].ToString();
                tbOrders order = new tbOrders();

                OrderBLL orderbll = new OrderBLL();
                order=  orderbll.getOrdersViewModel(int.Parse(orderid));

                bankpay.Orderid=   order.OrderNo;//订单编号
                bankpay.Amount = order.totalMoney.ToString();//订单金额
                bankpay.OrderDate = order.createdate.ToString();//订单日期
                bankpay.Path1 = Server.MapPath(@"bank\user.crt");//拆分pfx后缀的证书后的公钥路径
                bankpay.Path2 = Server.MapPath(@"bank\user.crt");
                bankpay.Path3 = Server.MapPath(@"bank\user.key");//拆分pfx后缀的证书后的私钥路径

                //加密
                bankpay.Msg = bankpay.InterfaceName + bankpay.InterfaceVersion + bankpay.MerID + bankpay.MerAcct + bankpay.MerURL + bankpay.NotifyType + bankpay.Orderid + bankpay + bankpay.Amount + bankpay.CurType + bankpay.ResultType + bankpay.OrderDate + bankpay.VerifyJoinFlag;

                ICBCEBANKUTILLib.B2CUtil obj = new ICBCEBANKUTILLib.B2CUtil();
                //加载公钥,私玥,密码,如果返回的0则成功
                if (obj.init(bankpay.Path1, bankpay.Path2, bankpay.Path3, bankpay.Key) == 0)
                {
                    bankpay.MerSignMsg = obj.signC(bankpay.Msg, bankpay.Msg.Length);
                    bankpay.MerCert = obj.getCert(1);
                }
                else
                {
                    Response.Write(obj.getRC());

                }

            }
        }
Beispiel #2
0
    public BankPay  GetPayInfo()
    {
        //从订单信息表中获取订单编号、订单金额
        string    strSql  = "select Round(TotalPrice,2) as TotalPrice from tb_OrderInfo where OrderID=" + Convert.ToInt32(Page.Request["OrderID"].Trim());
        DataTable dsTable = dbObj.GetDataSetStr(strSql, "tbOI");

        bankpay.Orderid   = Request["OrderID"].Trim();                                                     //订单编号
        bankpay.Amount    = Convert.ToString(float.Parse(dsTable.Rows[0]["TotalPrice"].ToString()) * 100); //订单金额
        bankpay.OrderDate = DateTime.Now.ToString("yyyyMMddhhmmss");                                       //交易日期时间
        bankpay.Path1     = Server.MapPath(@"bank\user.crt");                                              //公钥路径
        bankpay.Path2     = Server.MapPath(@"bank\user.crt");                                              //拆分pfx后缀的证商品后的公钥路径
        bankpay.Path3     = Server.MapPath(@"bank\user.key");                                              //拆分pfx后缀的证商品后的私钥路径
        //下面是需要加密的明文字符串
        bankpay.Msg = bankpay.InterfaceName + bankpay.InterfaceVersion + bankpay.MerID + bankpay.MerAcct + bankpay.MerURL + bankpay.NotifyType + bankpay.Orderid + bankpay.Amount + bankpay.CurType + bankpay.ResultType + bankpay.OrderDate + bankpay.VerifyJoinFlag;
        ICBCEBANKUTILLib.B2CUtil obj = new ICBCEBANKUTILLib.B2CUtil();               //项目中引用组件,以声明的方式创建com组件
        if (obj.init(bankpay.Path1, bankpay.Path2, bankpay.Path3, bankpay.Key) == 0) //加载公钥、私钥、密码,如果返回0则初始化成功
        {
            bankpay.MerSignMsg = obj.signC(bankpay.Msg, bankpay.Msg.Length);         //加密明文
            bankpay.MerCert    = obj.getCert(1);                                     //提取证商品
        }
        else
        {
            Response.Write(obj.getRC());//返回签名失败信息
        }
        return(bankpay);
    }
Beispiel #3
0
        public void PostProcessPayment(PaymentInfo order)
        {
            DateTime      datatime   = DateTime.Now;
            string        v_hms      = datatime.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string        v_ymd      = datatime.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string        icbcAmount = decimal.Ceiling(order.OrderAmount.ToDecimal() * 100).ToString(); //订单金额,以分为单位
            StringBuilder TranData   = new StringBuilder();

            TranData.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>");
            TranData.Append("<B2CReq>");
            TranData.Append("<interfaceName>ICBC_PERBANK_B2C</interfaceName>");         //接口名
            TranData.Append("<interfaceVersion>1.0.0.3</interfaceVersion>");            //版本号
            TranData.Append("<orderInfo>");
            TranData.Append("<orderDate>" + v_ymd + v_hms + "</orderDate>");            //交易日期时间格式为:YYYYMMDDHHmmss
            TranData.Append("<orderid>" + order.SysOrderNo + "</orderid>");             //订单号
            TranData.Append("<amount>" + icbcAmount + "</amount>");                     //订单金额
            TranData.Append("<curType>001</curType>");                                  //支付币种
            TranData.Append("<merID>4000EC20001125</merID>");                           //商户代码
            TranData.Append("<merAcct>4000023819200132437</merAcct>");                  //商户账号
            TranData.Append("</orderInfo>");
            TranData.Append("<custom>");
            TranData.Append("<verifyJoinFlag>0</verifyJoinFlag>");                      //检验联名标志
            TranData.Append("<Language>ZH_CN</Language>");                              //语言版本
            TranData.Append("</custom>");
            TranData.Append("<message>");
            TranData.Append("<goodsID></goodsID>");                                     //商品编号
            TranData.Append("<goodsName></goodsName>");                                 //商品名称
            TranData.Append("<goodsNum></goodsNum>");                                   //商品数量
            TranData.Append("<carriageAmt></carriageAmt>");                             //已含运费金额
            TranData.Append("<merHint></merHint>");                                     //商城提示
            TranData.Append("<remark1></remark1>");                                     //备注字段1
            TranData.Append("<remark2></remark2>");                                     //备注字段2
            TranData.Append("<merURL>" + order.ResultNotifyURL + "</merURL>");          //返回商户URL
            TranData.Append("<merVAR></merVAR>");                                       //返回商户变量
            TranData.Append("</message>");
            TranData.Append("</B2CReq>");
            string tranData = TranData.ToString();

            ICBCEBANKUTILLib.B2CUtil icbc = new ICBCEBANKUTILLib.B2CUtil();
            int    IcbcNew  = icbc.init(HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.key"), "12345679");
            string Icbcsign = icbc.signC(tranData, tranData.Length);
            string merCert  = icbc.getCert(1);

            tranData = PayHelper.Base64Code(tranData);

            HttpHelper http = new HttpHelper();

            http.Url = order.PayOnlineProviderUrl;
            http.Add("interfaceName", "ICBC_PERBANK_B2C"); //接口名
            http.Add("interfaceVersion", "1.0.0.3");       //版本号
            http.Add("tranData", tranData);                //交易数据
            http.Add("merSignMsg", Icbcsign);              //订单签名数据
            http.Add("merCert", merCert);                  //商城公匙
            http.Post();
        }
        public void PostProcessPayment(PaymentInfo order)
        {
            DateTime datatime = DateTime.Now;
            string v_hms = datatime.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string v_ymd = datatime.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string icbcAmount = decimal.Ceiling(order.OrderAmount.ToDecimal() * 100).ToString(); //订单金额,以分为单位
            StringBuilder TranData = new StringBuilder();
            TranData.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>");
            TranData.Append("<B2CReq>");
            TranData.Append("<interfaceName>ICBC_PERBANK_B2C</interfaceName>");         //接口名
            TranData.Append("<interfaceVersion>1.0.0.3</interfaceVersion>");            //版本号
            TranData.Append("<orderInfo>");
            TranData.Append("<orderDate>" + v_ymd + v_hms + "</orderDate>");            //交易日期时间格式为:YYYYMMDDHHmmss
            TranData.Append("<orderid>" + order.SysOrderNo + "</orderid>");             //订单号
            TranData.Append("<amount>" + icbcAmount + "</amount>");                     //订单金额
            TranData.Append("<curType>001</curType>");                                  //支付币种
            TranData.Append("<merID>4000EC20001125</merID>");                           //商户代码
            TranData.Append("<merAcct>4000023819200132437</merAcct>");                  //商户账号
            TranData.Append("</orderInfo>");
            TranData.Append("<custom>");
            TranData.Append("<verifyJoinFlag>0</verifyJoinFlag>");                      //检验联名标志
            TranData.Append("<Language>ZH_CN</Language>");                              //语言版本
            TranData.Append("</custom>");
            TranData.Append("<message>");
            TranData.Append("<goodsID></goodsID>");                                     //商品编号
            TranData.Append("<goodsName></goodsName>");                                 //商品名称
            TranData.Append("<goodsNum></goodsNum>");                                   //商品数量
            TranData.Append("<carriageAmt></carriageAmt>");                             //已含运费金额
            TranData.Append("<merHint></merHint>");                                     //商城提示
            TranData.Append("<remark1></remark1>");                                     //备注字段1
            TranData.Append("<remark2></remark2>");                                     //备注字段2
            TranData.Append("<merURL>" + order.ResultNotifyURL + "</merURL>");          //返回商户URL
            TranData.Append("<merVAR></merVAR>");                                       //返回商户变量
            TranData.Append("</message>");
            TranData.Append("</B2CReq>");
            string tranData = TranData.ToString();
            ICBCEBANKUTILLib.B2CUtil icbc = new ICBCEBANKUTILLib.B2CUtil();
            int IcbcNew = icbc.init(HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.key"), "12345679");
            string Icbcsign = icbc.signC(tranData, tranData.Length);
            string merCert = icbc.getCert(1);
            tranData = PayHelper.Base64Code(tranData);

            HttpHelper http = new HttpHelper();
            http.Url = order.PayOnlineProviderUrl;
            http.Add("interfaceName", "ICBC_PERBANK_B2C");    //接口名
            http.Add("interfaceVersion", "1.0.0.3");          //版本号
            http.Add("tranData", tranData);         //交易数据
            http.Add("merSignMsg", Icbcsign);       //订单签名数据
            http.Add("merCert", merCert);           //商城公匙 
            http.Post();
        }