Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LogHelper.Log("数据回调", "kjhkjhkj");
            //异步返回
            string strvoid      = HttpContext.Current.Request.QueryString.Get("v_oid");
            string strpmode     = HttpContext.Current.Request.QueryString.Get("v_pmode");
            string strpastatus  = HttpContext.Current.Request.QueryString.Get("v_pstatus");
            string strpstring   = HttpContext.Current.Request.QueryString.Get("v_pstring");
            string strcount     = HttpContext.Current.Request.QueryString.Get("v_count");
            string strmac       = HttpContext.Current.Request.QueryString.Get("v_mac");
            string stramount    = HttpContext.Current.Request.QueryString.Get("v_amount");
            string strmoneytype = HttpContext.Current.Request.QueryString.Get("v_moneytype");
            string strmd5money  = HttpContext.Current.Request.QueryString.Get("v_md5money");
            string strsign      = HttpContext.Current.Request.QueryString.Get("v_sign");

            /*异步返回MD5验签mac*/
            ClassHmac2003.ClassHmac cc1 = new ClassHmac2003.ClassHmac();
            LogHelper.Log("订单号", string.Format("strvoid={0};strpmode={1};strpastatus={2}", strvoid, strpmode, strpastatus));

            string mac1 = strvoid + HttpUtility.UrlEncode(strpmode, System.Text.Encoding.UTF8).ToUpper() + strpastatus + HttpUtility.UrlEncode(strpstring, System.Text.Encoding.UTF8).ToUpper() + strcount;
            string mac  = cc1.hex_hmac_md5(mac1, ShouXinYi.MD5Key);

            /*异步返回MD5验签md5money*/
            ClassHmac2003.ClassHmac md1 = new ClassHmac2003.ClassHmac();
            string md51     = stramount + strmoneytype;
            string md5money = md1.hex_hmac_md5(md51, ShouXinYi.MD5Key);

            if (mac == strmac && md5money == strmd5money)
            {//成功
                if (strpastatus != "1")
                {
                    Response.Write("sent");
                    Response.End();
                }
                else
                {
                    if (!BLL.HKModel.tempList.Contains(strvoid))
                    {
                        BLL.HKModel.tempList.Add(strvoid);
                        try
                        {
                            if (yny_002.BLL.Member.ManageMember.SHPayHB(strvoid))
                            {
                                Response.Write("sent");
                                Response.End();
                            }
                            else
                            {
                                Response.Write("error");
                                Response.End();
                            }
                        }
                        finally
                        {
                            if (BLL.HKModel.tempList.Contains(strvoid))
                            {
                                BLL.HKModel.tempList.Remove(strvoid);
                            }
                        }
                    }
                }
            }
            else
            {
                Response.Write("error");
            }
        }
Exemplo n.º 2
0
        protected new void Page_Load(object sender, EventArgs e)
        {
            //商户号
            string  v_mid   = ShouXinYi.v_mid;
            HKModel hkModel = HKModel;


            hkModel.HKCode = DateTime.Now.ToString("yyyyMMdd") + "-" + v_mid + "-" + (new Random().Next(100000, 999999)).ToString();
            BLL.HKModel.Insert(hkModel);

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

            //提交地址
            string form_url = ShouXinYi.form_url;
            //姓名
            string v_rcvname = v_mid;
            //地址
            string v_rcvaddr = v_mid;
            //电话
            string v_rcvtel = v_mid;
            //邮编
            string v_rcvpost = v_mid;
            //商户配货状态
            string v_orderstatus = "1";
            //订货人姓名
            string v_ordername = v_mid;
            //支付币种//0为人民币,1为美元,2为欧元
            string v_moneytype = "0";
            //订单号
            string v_oid = hkModel.HKCode;
            //金额
            string v_amount = hkModel.RealMoney.ToString("F2");
            //订单生产日期
            string v_ymd = hkModel.HKCreateDate.ToString("yyyyMMdd");
            //支付完成后返回的页面地址
            string v_url = Merchanturl;
            //加密方式1:MD5,2:SHA(可空)
            string v_md5info = "";

            ClassHmac2003.ClassHmac mac = new ClassHmac2003.ClassHmac();
            string key = v_moneytype + v_ymd + v_amount + v_rcvname + v_oid + v_mid + v_url;

            v_md5info = mac.hex_hmac_md5(key, ShouXinYi.MD5Key);//test为默认秘钥。 正式上线时联系客服人员修改

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

            postForm += "<input type=\"hidden\" name=\"v_mid\" value=\"" + v_mid + "\" />";                 //商户号
            postForm += "<input type=\"hidden\" name=\"v_oid\" value=\"" + v_oid + "\" />";                 //订单号
            postForm += "<input type=\"hidden\" name=\"v_rcvname\" value=\"" + v_rcvname + "\" />";         //姓名
            postForm += "<input type=\"hidden\" name=\"v_rcvaddr\" value=\"" + v_rcvaddr + "\" />";         //地址
            postForm += "<input type=\"hidden\" name=\"rcvtel\" value=\"" + v_rcvtel + "\" />";             //电话
            postForm += "<input type=\"hidden\" name=\"v_rcvpost\" value=\"" + v_rcvpost + "\" />";         //邮编
            postForm += "<input type=\"hidden\" name=\"v_amount\" value=\"" + v_amount + "\" />";           //金额
            postForm += "<input type=\"hidden\" name=\"v_ymd\" value=\"" + v_ymd + "\" />";                 //订单生产日期
            postForm += "<input type=\"hidden\" name=\"v_orderstatus\" value=\"" + v_orderstatus + "\" />"; //商户配货状态
            postForm += "<input type=\"hidden\" name=\"v_ordername\" value=\"" + v_ordername + "\" />";     //订货人姓名
            postForm += "<input type=\"hidden\" name=\"v_moneytype\" value=\"" + v_moneytype + "\" />";     //支付币种//0为人民币,1为美元,2为欧元。。详见参考文档
            postForm += "<input type=\"hidden\" name=\"v_md5info\" value=\"" + v_md5info + "\" />";         //加密方式1:MD5,2:SHA(可空)
            postForm += "<input type=\"hidden\" name=\"v_url\" value=\"" + v_url + "\" />";                 //支付完成后返回的页面地址

            postForm += "</form>";

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

            Response.Write(postForm);
        }