Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Request["wxPayUser"]) && !string.IsNullOrEmpty(Request["wxPayMoney"]))
     {
         //用户名
         string pay_username = Request["wxPayUser"];
         //支付金额(单位以分为单位,插入数据库的不边,提交到支付的要*100)
         string PayMoney = Request["wxPayMoney"];
         //订单号
         string outOrder_no = "wxzf" + DateTime.Now.ToString("yyyyMMddhhmmss");
         //生成订单
         int         uid         = accountsFacade.GetAccountsId(pay_username);
         OnLineOrder onlineOrder = new OnLineOrder();
         onlineOrder.Accounts    = pay_username;
         onlineOrder.UserID      = uid;
         onlineOrder.OrderAmount = decimal.Parse(PayMoney);
         onlineOrder.OrderID     = outOrder_no;
         onlineOrder.OrderStatus = 0;
         onlineOrder.ShareID     = 20;
         onlineOrder.CardTotal   = 1;
         onlineOrder.CardTypeID  = 1;//卡类充值
         onlineOrder.TelPhone    = "";
         onlineOrder.IPAddress   = GameRequest.GetUserIP();
         Message msg = treasureFacade.RequestOrder(onlineOrder);
         if (!msg.Success)
         {
             Response.Redirect("/Tips.aspx?msg=" + msg.Content);
         }
         else
         {   //明文数据
             string param = "mId=" + mId + "&notify_url=" + notify_url + "&outOrder_no=" + outOrder_no + "&total_fee=" + (Convert.ToInt32(PayMoney) * 100).ToString();
             //加密后生成的sign
             string sign = weixindes.Encrypt(param, pwd);
             //传递到支付那边的param
             string realparam = "agCode=" + agCode + "&sign=" + sign;
             //post支付信息过去,获取传递回来的数据,json格式
             string ReturnVal = PostDataGetHtml(url, realparam);
             //解析json
             JObject json   = JObject.Parse(ReturnVal);
             string  result = json["result"].ToString();
             result = result.Replace("\"", "");
             string message = json["message"].ToString();
             message = message.Replace("\"", "");
             //解析result和message,只有当result=0000是才是订单成功,才允许支付,否则,则提交失败到tips.aspx页面
             if (result.Equals("0000"))
             {
                 Response.Redirect(message);
             }
             else
             {
                 Response.Redirect("/Tips.aspx?msg=" + message);
             }
         }
     }
     //当输入信息不正确是跳到该页面
     else
     {
         Response.Redirect("/Tips.aspx?msg=生成订单出错。请重试");
     }
 }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 设置 Response编码格式为GB2312
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            if (!string.IsNullOrEmpty(Request.Form["Cuserspay"]) && !string.IsNullOrEmpty(Request.Form["inputMoney"]))
            {
                string pay_username = Request.Form["Cuserspay"];
                string PayMoney     = Request.Form["inputMoney"];
                string payBank      = Request.Form["CpayBank"];
                string rtypeBank    = Request.Form["yx_bank"];

                string payTel = string.IsNullOrEmpty(Request.Form["txt_telphone"]) == true? "" : Request.Form["txt_telphone"];

                if (rtypeBank != "BANKSEL")
                {
                    payBank = rtypeBank;
                }

                p3_Amt          = Convert.ToString(decimal.Parse(PayMoney));
                p4_verifyAmt    = "false";
                p5_Pid          = "金币";
                p6_Pcat         = "1";
                p7_Pdesc        = "1";
                p8_Url          = ConfigurationManager.AppSettings["CallBackC"].ToString();
                pa_MP           = pay_username;
                pa7_cardAmt     = Request.Form["inputMoney"];
                pa8_cardNo      = Request.Form["pa8_cardNo"];
                pa9_cardPwd     = Request["pa9_cardPwd"];
                pd_FrpId        = payBank;
                pr_NeedResponse = "1";
                pz_userId       = Convert.ToString(DateTime.Now.ToString("yyyyMMddhhmmss"));
                pz1_userRegTime = DateTime.Now.ToString();

                p2_Order = "CYC" + DateTime.Now.ToString("yyyyMMddhhmmss");
                //非银行卡专业版正式使用
                try
                {
                    int payType = 0;
                    switch (payBank)
                    {
                    case "JUNNET":
                        payType = 2;
                        break;

                    case "SNDACARD":
                        payType = 3;
                        break;

                    case "SZX":
                        payType = 4;
                        break;

                    case "ZHENGTU":
                        payType = 5;
                        break;

                    case "QQCARD":
                        payType = 6;
                        break;

                    case "UNICOM":
                        payType = 7;
                        break;

                    case "JIUYOU":
                        payType = 8;
                        break;

                    case "NETEASE":
                        payType = 9;
                        break;

                    case "WANMEI":
                        payType = 10;
                        break;

                    case "SOHU":
                        payType = 11;
                        break;

                    case "TELECOM":
                        payType = 12;
                        break;

                    case "TIANXIA":
                        payType = 13;
                        break;

                    case "TIANHONG":
                        payType = 14;
                        break;

                    case "YPCARD":
                        payType = 16;
                        break;

                    case "ZONGYOU":
                        payType = 17;
                        break;
                    }

                    DataSet     ds          = new DataSet();
                    int         uid         = accountsFacade.GetAccountsId(pay_username);
                    OnLineOrder onlineOrder = new OnLineOrder();
                    onlineOrder.Accounts    = pay_username;
                    onlineOrder.UserID      = uid;
                    onlineOrder.OrderAmount = decimal.Parse(PayMoney);
                    onlineOrder.OrderID     = p2_Order;
                    onlineOrder.OrderStatus = 0;
                    onlineOrder.ShareID     = payType;
                    onlineOrder.CardTotal   = 1;
                    onlineOrder.CardTypeID  = payType;//卡类充值
                    onlineOrder.TelPhone    = payTel;
                    onlineOrder.IPAddress   = GameRequest.GetUserIP();
                    Message msg = treasureFacade.RequestOrder(onlineOrder);


                    if (!msg.Success)
                    {
                        Response.Redirect("/Tips.aspx?msg=" + msg.Content);
                    }
                    else
                    {
                        //非银行卡专业版正式使用
                        SZXResult result = SZX.AnnulCard(onlineOrder.OrderID, p3_Amt, p4_verifyAmt, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url,
                                                         pa_MP, pa7_cardAmt, pa8_cardNo, pa9_cardPwd, pd_FrpId, pr_NeedResponse, pz_userId, pz1_userRegTime);
                        if (result.R1_Code == "1")
                        {
                            Response.Redirect("/WiteNetCard.html?OID=" + onlineOrder.OrderID);
                        }
                        else
                        {
                            Response.Redirect("/WiteNetCard.html?OID=" + onlineOrder.OrderID);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.ToString());
                }
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // string apiprefix = APIURLConfig.apiprefix;

            //网页支付地址
            // string creditpayURI = APIURLConfig.webpayURI;

            //一键支付URL前缀
            string apiprefix = APIURLConfig.payWebPrefix;

            //网页支付地址
            string pcPayURI = APIURLConfig.pcwebURI;

            //商户账户编号
            string merchantAccount = Config.merchantAccount;

            //商户公钥(该商户公钥需要在易宝一键支付商户后台报备)
            string merchantPublickey = Config.merchantPublickey;

            //商户私钥(商户公钥对应的私钥)
            string merchantPrivatekey = Config.merchantPrivatekey;

            //易宝支付分配的公钥(进入商户后台公钥管理,报备商户的公钥后分派的字符串)
            string yibaoPublickey = Config.yibaoPublickey;

            //随机生成商户AESkey
            string merchantAesKey = payapi_mobile_demo.AES.GenerateAESKey();

            int    amount         = Convert.ToInt32(Request["p3_Amt1"].ToString()) * 100; //支付金额为分
            int    currency       = 156;
            string identityid     = DateTime.Now.ToString("yyyyMMddhhmmss");              //用户身份标识
            int    identitytype   = 0;
            Random ra             = new Random();
            string orderid        = "kjzf789123456" + 50 * ra.Next();
            string other          = "00-23-5A-15-99-42"; //mac地址
            string productcatalog = "1";                 //商品类别码,商户支持的商品类别码由易宝支付运营人员根据商务协议配置
            string productdesc    = "789游戏中心";
            string productname    = "金币";

            DateTime t1        = DateTime.Now;
            DateTime t2        = new DateTime(1970, 1, 1);
            double   t         = t1.Subtract(t2).TotalSeconds;
            int      transtime = (int)t;

            string userip = GameRequest.GetUserIP();
            //商户提供的商户后台系统异步支付回调地址
            string callbackurl = ConfigurationManager.AppSettings["yibao_Notify"].ToString();
            //商户提供的商户前台系统异步支付回调地址
            string fcallbackurl = ConfigurationManager.AppSettings["yibao_CallBack"].ToString();
            //用户浏览器ua
            string userua = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1";


            SortedDictionary <string, object> sd = new SortedDictionary <string, object>();

            sd.Add("merchantaccount", merchantAccount);
            sd.Add("amount", amount);
            sd.Add("currency", currency);
            sd.Add("identityid", identityid);
            sd.Add("identitytype", identitytype);
            sd.Add("orderid", orderid);
            sd.Add("other", other);
            sd.Add("productcatalog", productcatalog);
            sd.Add("productdesc", productdesc);
            sd.Add("productname", productname);
            sd.Add("transtime", transtime);
            sd.Add("userip", userip);
            sd.Add("callbackurl", callbackurl);
            sd.Add("fcallbackurl", fcallbackurl);
            sd.Add("userua", userua);

            //生成RSA签名
            string sign = EncryptUtil.handleRSA(sd, merchantPrivatekey);

            //Console.WriteLine("生成的签名为:" + sign);

            sd.Add("sign", sign);

            //将网页支付对象转换为json字符串
            string wpinfo_json = Newtonsoft.Json.JsonConvert.SerializeObject(sd);
            // Console.WriteLine("网页支付明文数据json格式为:" + wpinfo_json);
            string datastring = payapi_mobile_demo.AES.Encrypt(wpinfo_json, merchantAesKey);
            //Console.WriteLine("网页支付业务数据经过AES加密后的值为:" + datastring);

            //将商户merchantAesKey用RSA算法加密
            // Console.WriteLine("merchantAesKey为:" + merchantAesKey);
            string encryptkey = RSAFromPkcs8.encryptData(merchantAesKey, yibaoPublickey, "UTF-8");
            // Console.WriteLine("encryptkey为:" + encryptkey);

            //打开浏览器访问一键支付网页支付链接地址,请求方式为get
            string postParams = "data=" + HttpUtility.UrlEncode(datastring) + "&encryptkey=" + HttpUtility.UrlEncode(encryptkey) + "&merchantaccount=" + merchantAccount;
            string url        = apiprefix + pcPayURI + "?" + postParams;

            OnLineOrder online = new OnLineOrder();
            int         uid    = accountsfacade.GetAccountsId(Request["yijianAccountNo"].ToString());

            online.Accounts    = Request["yijianAccountNo"].ToString();
            online.UserID      = uid;
            online.OrderAmount = decimal.Parse((Convert.ToInt32(amount) / 100).ToString());
            online.OrderID     = orderid;
            online.OrderStatus = 0;
            online.ShareID     = 19;
            online.CardTotal   = 1;
            online.CardTypeID  = 1;
            online.TelPhone    = "";
            online.IPAddress   = GameRequest.GetUserIP();
            Message msg = treasurefacade.RequestOrder(online);

            if (!msg.Success)
            {
                Response.Redirect("/Tips.aspx?msg=" + msg.Content);
            }
            else
            {
                Response.Redirect(url);
            }
            // Console.WriteLine("网页支付链接地址为:" + url);
            // Console.WriteLine("网页支付链接地址长度为:" + url.Length);
            // System.Diagnostics.Process.Start("firefox.exe", url);//打开firefox浏览器
            // System.Diagnostics.Process.Start(url);

            //Console.ReadLine();
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ////////////////////////////////////////////请求参数////////////////////////////////////////////
            //支付类型
            string payment_type = "1";
            //必填,不能修改
            //服务器异步通知页面路径
            string notify_url = ConfigurationManager.AppSettings["ailpayNotify"];
            //需http://格式的完整路径,不能加?id=123这类自定义参数

            //页面跳转同步通知页面路径
            string return_url = ConfigurationManager.AppSettings["ailpayCallback"];
            //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/

            //卖家支付宝帐户
            string seller_email = ConfigurationManager.AppSettings["ailpayAccount"];
            //必填

            //商户订单号
            string out_trade_no = "zfb" + DateTime.Now.ToString("yyyyMMddhhmmss");
            //商户网站订单系统中唯一订单号,必填

            //订单名称
            string subject = "幸运豆";
            //必填

            //付款金额
            string aa        = Request["p3_Amt1"];
            string total_fee = Convert.ToString(decimal.Parse(Request["p3_Amt1"].Equals("0.125") == true ? Request["otherzfb"] : Request["p3_Amt1"]));
            //必填

            //订单描述

            string body = "幸运豆";
            //商品展示地址
            string show_url = "";
            //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html

            //防钓鱼时间戳
            string anti_phishing_key = "";
            //若要使用请调用类文件submit中的query_timestamp函数

            //客户端的IP地址
            string exter_invoke_ip = "";
            //非局域网的外网IP地址,如:221.0.0.1


            ////////////////////////////////////////////////////////////////////////////////////////////////

            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "create_direct_pay_by_user");
            sParaTemp.Add("payment_type", payment_type);
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("return_url", return_url);
            sParaTemp.Add("seller_email", seller_email);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("subject", subject);
            sParaTemp.Add("total_fee", total_fee);
            sParaTemp.Add("body", body);
            sParaTemp.Add("show_url", show_url);
            sParaTemp.Add("anti_phishing_key", anti_phishing_key);
            sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);

            //建立请求

            int         uid         = accountsFacade.GetAccountsId(Request.Form["zfbuserspay"]);
            OnLineOrder onlineOrder = new OnLineOrder();

            onlineOrder.Accounts    = Request["zfbuserspay"];
            onlineOrder.UserID      = uid;
            onlineOrder.OrderAmount = decimal.Parse(Request["p3_Amt1"].Equals("0.125") ? Request["otherzfb"] : Request["p3_Amt1"]);
            onlineOrder.OrderID     = out_trade_no;
            onlineOrder.OrderStatus = 0;
            onlineOrder.ShareID     = 20;
            onlineOrder.CardTotal   = 1;
            onlineOrder.CardTypeID  = 1;//支付宝充值
            onlineOrder.TelPhone    = "";
            onlineOrder.IPAddress   = GameRequest.GetUserIP();
            //onlineOrder.Otype = payBank;

            Message msg = treasureFacade.RequestOrder(onlineOrder);

            if (!msg.Success)
            {
                Response.Redirect("/Tips.aspx?msg=" + msg.Content);
                //reqURL_onLine = "PayBank.aspx";
                //  Label1.Text = msg.Content;
                //ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('" + msg.Content + "');location.href='PayIndex.aspx';</script>");
            }
            else
            {
                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                Response.Write(sHtmlText);
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 设置 Response编码格式为GB2312

            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

            if (!string.IsNullOrEmpty(Request["userspay"]) && !string.IsNullOrEmpty(Request["p3_Amt"]))
            {
                string pay_username = Request["userspay"];
                string PayMoney     = Request["p3_Amt"].Equals("0.125") == true?Request["otherbank"]:Request["p3_Amt"];
                string rtypeBank    = Request["bank"];
                string payBank      = Request["bank"];
                string payTel       = string.IsNullOrEmpty(Request["txt_telphone"]) == true ? "" : Request["txt_telphone"];
                string onlyBank     = "WY";
                if (rtypeBank != "BANKSEL")
                {
                    payBank = rtypeBank;  //其他
                }
                if (PayMoney == "0")
                {
                    PayMoney = string.IsNullOrEmpty(Request["p3_Amt2"]) == true ? "10" : Request["p3_Amt2"];
                }

                switch (payBank)
                {
                case "ICBC-NET":
                    onlyBank = "GS";
                    break;

                case "ABC-NET":
                    onlyBank = "NH";
                    break;

                case "CMBCHINA-NET":
                    onlyBank = "ZS";
                    break;

                case "BOCO-NET":
                    onlyBank = "JT";
                    break;

                case "GDB-NET":
                    onlyBank = "GF";
                    break;

                case "GNXS-NET":
                    onlyBank = "GZ";
                    break;

                case "HXB-NET":
                    onlyBank = "HX";
                    break;

                case "CCB-NET":
                    onlyBank = "JH";
                    break;

                case "CEB-NET":
                    onlyBank = "GD";
                    break;

                case "CMBC-NET":
                    onlyBank = "MS";
                    break;

                case "NJCB-NET":
                    onlyBank = "NJ";
                    break;

                case "CBHB-NET":
                    onlyBank = "BH";
                    break;

                case "SPDB-NET":
                    onlyBank = "PF";
                    break;

                case "SDB-NET":
                    onlyBank = "SZ";
                    break;

                case "CIB-NET":
                    onlyBank = "XY";
                    break;

                case "BCCB-NET":
                    onlyBank = "BJ";
                    break;

                case "BOC-NET":
                    onlyBank = "ZG";
                    break;

                case "ECITIC-NET":
                    onlyBank = "ZX";
                    break;

                default:
                    onlyBank = "WY";
                    break;
                }
                p3_Amt          = PayMoney;//价格"0.01"  PayMoney
                p4_Cur          = "CNY";
                p5_Pid          = "金币";
                p6_Pcat         = "1";
                p7_Pdesc        = "1";
                p8_Url          = ConfigurationManager.AppSettings["CallBack"].ToString();
                p9_SAF          = "0";
                pa_MP           = pay_username;
                pd_FrpId        = payBank;
                pr_NeedResponse = "1";
                p2_Order        = onlyBank + "-YCQP" + DateTime.Now.ToString("yyyyMMddhhmmss");
                DataSet     ds          = new DataSet();
                int         uid         = accountsFacade.GetAccountsId(pay_username);
                OnLineOrder onlineOrder = new OnLineOrder();
                onlineOrder.Accounts    = pay_username;
                onlineOrder.UserID      = uid;
                onlineOrder.OrderAmount = decimal.Parse(PayMoney);
                onlineOrder.OrderID     = p2_Order;
                onlineOrder.OrderStatus = 0;
                onlineOrder.ShareID     = 19;
                onlineOrder.CardTotal   = 1;
                onlineOrder.CardTypeID  = 1;//易宝充值
                onlineOrder.TelPhone    = payTel;
                onlineOrder.IPAddress   = GameRequest.GetUserIP();
                //onlineOrder.Otype = payBank;

                Message msg = treasureFacade.RequestOrder(onlineOrder);
                if (!msg.Success)
                {
                    Response.Redirect("/Tips.aspx?msg=" + msg.Content);
                    // reqURL_onLine = "Tips.aspx";
                    //  Label1.Text = msg.Content;
                    //ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('" + msg.Content + "');location.href='PayIndex.aspx';</script>");
                }
                else
                {
                    hmac = Web.Pay.YbBuy.Buy.CreateBuyHmac(onlineOrder.OrderID, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse);
                }
            }
        }