Ejemplo n.º 1
0
        protected new void Page_Load(object sender, EventArgs e)
        {
            HKModel hkModel = HKModel;

            BLL.HKModel.Insert(hkModel);

            //测试地址
            string form_url        = GuoFuBao.url;
            string merchantID      = GuoFuBao.merchantID;
            string virCardNoIn     = GuoFuBao.virCardNoIn;
            string VerficationCode = GuoFuBao.VerficationCode;

            //商户订单编号
            string Billno = hkModel.HKCode;

            //支付结果成功返回的商户URL
            string url         = "http://" + HttpContext.Current.Request.Url.Authority.ToString();
            string Merchanturl = url + "/Payment/GuoFuBao/OrderReturn.aspx";

            string asyurl = url + "/Payment/GuoFuBao/OrderReturnAsy.aspx";

            //订单金额(保留2位小数)
            string Amount = hkModel.RealMoney.ToString("F2");

            //订单日期
            string BillDate = hkModel.HKCreateDate.ToString("yyyyMMddHHmmss");

            string gopayServerTime = GuoFuBao.Get_Http("https://gateway.gopay.com.cn/time.do", 10000);

            // 组织加密明文
            string plain = "version=[2.2]tranCode=[8888]merchantID=[" + merchantID + "]merOrderNum=[" + Billno + "]tranAmt=[" + Amount + "]feeAmt=[]tranDateTime=[" + BillDate + "]frontMerUrl=[" + Merchanturl + "]backgroundMerUrl=[" + asyurl + "]orderId=[]gopayOutOrderId=[]tranIP=[" + GetUserIp() + "]respCode=[]gopayServerTime=[" + gopayServerTime + "]VerficationCode=[" + VerficationCode + "]";

            string postForm = "<form name=\"frm1\" id=\"frm1\" method=\"post\" action=\"" + form_url + "\">";

            postForm += "<input type=\"hidden\" name=\"merchantID\" value=\"" + merchantID + "\" />";           //商户ID
            postForm += "<input type=\"hidden\" name=\"virCardNoIn\" value=\"" + virCardNoIn + "\" />";         //国付宝转入账户
            postForm += "<input type=\"hidden\" name=\"merOrderNum\" value=\"" + Billno + "\" />";              //订单号
            postForm += "<input type=\"hidden\" name=\"tranAmt\" value=\"" + Amount + "\" />";                  //交易金额
            postForm += "<input type=\"hidden\" name=\"tranDateTime\" value=\"" + BillDate + "\" />";           //交易时间
            postForm += "<input type=\"hidden\" name=\"frontMerUrl\" value=\"" + Merchanturl + "\" />";         //商户返回页面地址
            postForm += "<input type=\"hidden\" name=\"backgroundMerUrl\" value=\"" + asyurl + "\" />";         //商户后台通知地址
            postForm += "<input type=\"hidden\" name=\"signValue\" value=\"" + GuoFuBao.md5(plain) + "\" />";   //MD5加密报文

            postForm += "<input type=\"hidden\" name=\"tranIP\" value=\"" + GetUserIp() + "\" />";              //用户浏览器IP
            postForm += "<input type=\"hidden\" name=\"gopayServerTime\" value=\"" + gopayServerTime + "\" />"; //国付宝服务器时间
            postForm += "<input type=\"hidden\" name=\"version\" value=\"2.2\" />";                             //版本号
            postForm += "<input type=\"hidden\" name=\"charset\" value=\"1\" />";                               //字符集1:GBK,2:UTF-8(可空)
            postForm += "<input type=\"hidden\" name=\"language\" value=\"1\" />";                              // 语言种类 1:ZH,2:EN
            postForm += "<input type=\"hidden\" name=\"signType\" value=\"1\" />";                              //加密方式1:MD5,2:SHA(可空)
            postForm += "<input type=\"hidden\" name=\"tranCode\" value=\"8888\" />";                           //交易代码
            postForm += "<input type=\"hidden\" name=\"currencyType\" value=\"156\" />";                        //币种

            postForm += "</form>";

            //自动提交该表单到测试网关
            postForm += "<script type=\"text/javascript\" language=\"javascript\">setTimeout(\"document.getElementById('frm1').submit();\",100);</script>";

            Response.Write(postForm);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string signValue        = Request.Form["signValue"];
            string merchantID       = Request.Form["merchantID"];
            string merOrderNum      = Request.Form["merOrderNum"];
            string tranAmt          = Request.Form["tranAmt"];
            string feeAmt           = Request.Form["feeAmt"];
            string tranDateTime     = Request.Form["tranDateTime"];
            string frontMerUrl      = Request.Form["frontMerUrl"];
            string backgroundMerUrl = Request.Form["backgroundMerUrl"];
            string orderId          = Request.Form["orderId"];
            string gopayOutOrderId  = Request.Form["gopayOutOrderId"];
            string tranIP           = Request.Form["tranIP"];
            string respCode         = Request.Form["respCode"];

            //组织加密明文
            string plain = "version=[2.2]tranCode=[8888]merchantID=[" + merchantID + "]merOrderNum=[" + merOrderNum + "]tranAmt=[" + tranAmt + "]feeAmt=[" + feeAmt + "]tranDateTime=[" + tranDateTime + "]frontMerUrl=[" + frontMerUrl + "]backgroundMerUrl=[" + backgroundMerUrl + "]orderId=[" + orderId + "]gopayOutOrderId=[" + gopayOutOrderId + "]tranIP=[" + tranIP + "]respCode=[" + respCode + "]gopayServerTime=[]VerficationCode=[" + GuoFuBao.VerficationCode + "]";

            LogHelper.Log("国付宝异步", string.Format("signValue={0}--merOrderNum={1}---plain=", signValue, merOrderNum, GuoFuBao.md5(plain)), "gfb");
            if (GuoFuBao.md5(plain) == signValue)
            {
                if (!BLL.HKModel.tempList.Contains(merOrderNum))
                {
                    BLL.HKModel.tempList.Add(merOrderNum);
                    try
                    {
                        if (zx326.BLL.Member.ManageMember.SHPayHB(merOrderNum))
                        {
                            LogHelper.Log("国付宝异步", string.Format("执行成功merOrderNum={0}", merOrderNum), "gfb");
                            Response.Write("RespCode=0000|JumpURL=");
                            //Response.Write("交易成功!");
                        }
                        else
                        {
                            LogHelper.Log("国付宝异步", string.Format("执行失败merOrderNum={0}", merOrderNum), "gfb");
                            Response.Write("RespCode=9999|JumpURL=");
                            //Response.Write("交易失败!");
                        }
                    }
                    finally
                    {
                        if (BLL.HKModel.tempList.Contains(merOrderNum))
                        {
                            BLL.HKModel.tempList.Remove(merOrderNum);
                        }
                    }
                }
            }
            else
            {
                Response.Write("RespCode=9999|JumpURL=");
            }
            Response.End();
            //else
            //{
            //    Response.Write("交易失败");
            //    Response.End();
            //}
        }