Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            tenpayUser       = Request.Form["tenPayUser"] ?? string.Empty;
            tenpayMoney      = Request.Form["tenpayMoney"] ?? string.Empty;
            tenpayBank       = Request.Form["tenpayBankname"] ?? string.Empty;
            tenpayOtherMoney = Request.Form["selfMoney"] ?? string.Empty;
            if (tenpayMoney.Equals("0"))
            {
                tenpayMoney = "100";
            }
            if (!string.IsNullOrEmpty(tenpayOtherMoney))
            {
                tenpayMoney = tenpayOtherMoney;
            }
            if (!string.IsNullOrEmpty(tenpayUser) && !string.IsNullOrEmpty(tenpayMoney))
            {
                AccountsInfo accountsInfo = accountsfacade.GetAccountsByAccontsName(tenpayUser);
                if (accountsInfo == null)
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlDecode("用户名不存在");
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }

                try
                {
                    int.Parse(tenpayMoney);
                }
                catch (Exception)
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlDecode("充值金额不对");
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                    return;
                }
                tenpayOrder = "CFT-" + DateTime.Now.ToString("yyyyMMddhhmmss");  //用户订单

                OnLineOrder online = new OnLineOrder();
                online.Accounts    = tenpayUser;
                online.UserID      = accountsInfo.UserID;
                online.OrderAmount = decimal.Parse((Convert.ToInt32(tenpayMoney)).ToString());
                online.OrderID     = tenpayOrder;
                online.OrderStatus = 0;
                online.ShareID     = 20;
                online.CardTotal   = 1;
                online.CardTypeID  = 1;
                online.TelPhone    = "";
                online.IPAddress   = GameRequest.GetUserIP();
                Message msg = treasurefacade.RequestOrder(online);
                if (msg.Success)
                {
                    //创建RequestHandler实例
                    RequestHandler reqHandler = new RequestHandler(Context);
                    //初始化
                    reqHandler.init();
                    //设置密钥
                    reqHandler.setKey(TenpayUtil.tenpay_key);
                    reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm");

                    //-----------------------------
                    //设置支付参数
                    //-----------------------------
                    reqHandler.setParameter("partner", TenpayUtil.bargainor_id);                            //商户号
                    reqHandler.setParameter("out_trade_no", tenpayOrder);                                   //商家订单号
                    reqHandler.setParameter("total_fee", (Convert.ToDouble(tenpayMoney) * 100).ToString()); //商品金额,以分为单位
                    reqHandler.setParameter("return_url", TenpayUtil.tenpay_return);                        //交易完成后跳转的URL
                    reqHandler.setParameter("notify_url", TenpayUtil.tenpay_notify);                        //接收财付通通知的URL
                    reqHandler.setParameter("body", "789金币购买");                                             //商品描述
                    reqHandler.setParameter("bank_type", tenpayBank);                                       //银行类型(中介担保时此参数无效)
                    reqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress);              //用户的公网ip,不是商户服务器IP
                    reqHandler.setParameter("fee_type", "1");                                               //币种,1人民币
                    reqHandler.setParameter("subject", "789金币购买");                                          //商品名称(中介交易时必填)


                    //系统可选参数
                    reqHandler.setParameter("sign_type", "MD5");
                    reqHandler.setParameter("service_version", "1.0");
                    reqHandler.setParameter("input_charset", "UTF-8");
                    reqHandler.setParameter("sign_key_index", "1");

                    //业务可选参数

                    reqHandler.setParameter("attach", "");                                          //附加数据,原样返回
                    reqHandler.setParameter("product_fee", "0");                                    //商品费用,必须保证transport_fee + product_fee=total_fee
                    reqHandler.setParameter("transport_fee", "0");                                  //物流费用,必须保证transport_fee + product_fee=total_fee
                    reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //订单生成时间,格式为yyyymmddhhmmss
                    reqHandler.setParameter("time_expire", "");                                     //订单失效时间,格式为yyyymmddhhmmss
                    reqHandler.setParameter("buyer_id", "");                                        //买方财付通账号
                    reqHandler.setParameter("goods_tag", "");                                       //商品标记
                    reqHandler.setParameter("trade_mode", "1");                                     //交易模式,1即时到账(默认),2中介担保,3后台选择(买家进支付中心列表选择)
                    reqHandler.setParameter("transport_desc", "");                                  //物流说明
                    reqHandler.setParameter("trans_type", "1");                                     //交易类型,1实物交易,2虚拟交易
                    reqHandler.setParameter("agentid", "");                                         //平台ID
                    reqHandler.setParameter("agent_type", "");                                      //代理模式,0无代理(默认),1表示卡易售模式,2表示网店模式
                    reqHandler.setParameter("seller_id", "");                                       //卖家商户号,为空则等同于partner

                    //获取请求带参数的url
                    string requestUrl = reqHandler.getRequestURL();

                    //Get的实现方式
                    // string a_link = "<a target=\"_blank\" href=\"" + requestUrl + "\">" + "财付通支付" + "</a>";
                    Response.Redirect(requestUrl);


                    //post实现方式

                    /* Response.Write("<form method=\"post\" action=\""+ reqHandler.getGateUrl() + "\" >\n");
                     * Hashtable ht = reqHandler.getAllParameters();
                     * foreach(DictionaryEntry de in ht)
                     * {
                     *   Response.Write("<input type=\"hidden\" name=\"" + de.Key + "\" value=\"" + de.Value + "\" >\n");
                     * }
                     * Response.Write("<input type=\"submit\" value=\"财付通支付\" >\n</form>\n");*/


                    //获取debug信息,建议把请求和debug信息写入日志,方便定位问题
                    string debuginfo = reqHandler.getDebugInfo();
                    Response.Write("<br/>requestUrl:" + requestUrl + "<br/>");
                    Response.Write("<br/>debuginfo:" + debuginfo + "<br/>");
                }
                else
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode(msg.Content);
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }
            }
            else
            {
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Request.Cookies.Remove("ErrorMsg");

            payZfbUser    = Request.Form["payZfbUser"] ?? string.Empty;
            payZfbMoney   = Request.Form["payZfbMoney"] ?? string.Empty;
            payOtherMoney = Request.Form["selfMoney"] ?? string.Empty;
            if (payZfbMoney.Equals("0"))
            {
                payZfbMoney = "100";
            }
            if (!string.IsNullOrEmpty(payOtherMoney))
            {
                payZfbMoney = payOtherMoney;
            }
            if (!string.IsNullOrEmpty(payZfbUser) && !string.IsNullOrEmpty(payZfbMoney))
            {
                AccountsInfo accountsInfo = accountsfacade.GetAccountsByAccontsName(payZfbUser);
                if (accountsInfo == null)
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode("用户名不存在");
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }

                try
                {
                    int.Parse(payZfbMoney);
                }
                catch (Exception)
                {
                    return;
                }

                //商户订单号
                string out_trade_no = "ZFB-" + DateTime.Now.ToString("yyyyMMddhhmmss");


                HttpCookie UserCookie = new HttpCookie("PayOrder");
                UserCookie["order"]      = out_trade_no;
                UserCookie["orderMoney"] = Request["payZfbMoney"];
                UserCookie["orderUser"]  = HttpUtility.UrlEncode(payZfbUser);
                UserCookie.Expires       = DateTime.Now.AddMinutes(7);
                Response.Cookies.Add(UserCookie);

                OnLineOrder onlineOrder = new OnLineOrder();
                onlineOrder.Accounts    = payZfbUser;
                onlineOrder.UserID      = accountsInfo.UserID;
                onlineOrder.OrderAmount = decimal.Parse(Request["payZfbMoney"]);
                onlineOrder.OrderID     = out_trade_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)
                {
                    //支付类型
                    string payment_type = "1";
                    //服务器异步通知页面路径
                    string notify_url = ConfigurationManager.AppSettings["ailpayNotify"];
                    //页面跳转同步通知页面路径
                    string return_url = ConfigurationManager.AppSettings["ailpayCallback"];
                    //卖家支付宝帐户
                    string seller_email = ConfigurationManager.AppSettings["ailpayAccount"];
                    //订单名称
                    string subject = ConfigurationManager.AppSettings["shoppingInfo"];
                    //付款金额
                    string total_fee = Convert.ToString(decimal.Parse(payZfbMoney));
                    //订单描述
                    string body = ConfigurationManager.AppSettings["shoppingInfo"];
                    //商品展示地址
                    string show_url = "";
                    //防钓鱼时间戳
                    string anti_phishing_key = "";
                    //若要使用请调用类文件submit中的query_timestamp函数
                    //客户端的IP地址
                    string exter_invoke_ip = "";
                    //把请求参数打包成数组
                    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);

                    string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                    Response.Write(sHtmlText);
                }
                else
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode(msg.Content);
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }
            }
            else
            {
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Request.Cookies.Remove("ErrorMsg");
            webchartUser  = Request.Form["webchartUser"] ?? string.Empty;
            webchartMoney = Request.Form["webchartMoney"] ?? string.Empty;
            payOtherMoney = Request.Form["selfMoney"] ?? string.Empty;
            if (webchartMoney.Equals("0"))
            {
                webchartMoney = "100";
            }
            if (!string.IsNullOrEmpty(payOtherMoney))
            {
                webchartMoney = payOtherMoney;
            }
            if (!string.IsNullOrEmpty(webchartUser) && !string.IsNullOrEmpty(webchartMoney))
            {
                AccountsInfo accountsInfo = accountsfacade.GetAccountsByAccontsName(webchartUser);
                if (accountsInfo == null)
                {
                    Response.Write("-3");
                    return;
                }
                try
                {
                    int.Parse(webchartMoney);
                }
                catch (Exception)
                {
                    return;
                }
                //用户名
                string pay_username = webchartUser;
                //支付金额(单位以分为单位,插入数据库的不边,提交到支付的要*100)
                string PayMoney = webchartMoney;
                //订单号
                string outOrder_no = "WXZF-" + DateTime.Now.ToString("yyyyMMddhhmmss");

                HttpCookie UserCookie = new HttpCookie("PayOrder");
                UserCookie["order"]      = outOrder_no;
                UserCookie["orderMoney"] = PayMoney;
                UserCookie["orderUser"]  = HttpUtility.UrlEncode(pay_username);
                UserCookie.Expires       = DateTime.Now.AddMinutes(7);
                Response.Cookies.Add(UserCookie);

                OnLineOrder onlineOrder = new OnLineOrder();
                onlineOrder.Accounts    = pay_username;
                onlineOrder.UserID      = accountsInfo.UserID;
                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)
                {
                    //明文数据
                    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.Write(outOrder_no + '*' + message);
                    }
                    else
                    {
                        Response.Write("-1");
                    }
                }
                else
                {
                    Response.Write(msg.Content);
                }
            }
            else
            {
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Request.Cookies.Remove("ErrorMsg");
            //充值开始
            // 设置 Response编码格式为GB2312
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");

            payCardUser  = Request.Form["yeepayCardUser"] ?? string.Empty;
            payCardMoney = Request.Form["yeepayCardMoney"] ?? string.Empty;
            payCardName  = Request.Form["yeepayCardName"] ?? string.Empty;
            if (string.IsNullOrEmpty(payCardMoney))
            {
                payCardMoney = "10";
            }
            if (!string.IsNullOrEmpty(payCardUser) && !string.IsNullOrEmpty(payCardMoney) && !string.IsNullOrEmpty(payCardName))
            {
                AccountsInfo accountsInfo = accountsfacade.GetAccountsByAccontsName(payCardUser);
                if (accountsInfo == null)
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode("用户名不存在");
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }

                try
                {
                    int.Parse(payCardMoney);
                }
                catch (Exception)
                {
                    return;
                }

                switch (payCardName)
                {
                case "JUNNET-NET":       //骏网一卡通
                    payCardInfo = "2";
                    break;

                case "SNDACARD-NET":      //盛大卡
                    payCardInfo = "3";
                    break;

                case "SZX-NET":       //神州行
                    payCardInfo = "4";
                    break;

                case "ZHENGTU-NET":      //征途卡
                    payCardInfo = "5";
                    break;

                case "QQCARD-NET":      //Q币卡
                    payCardInfo = "6";
                    break;

                case "UNICOM-NET":    //联通卡
                    payCardInfo = "7";
                    break;

                case "JIUYOU-NET":     //久游卡
                    payCardInfo = "8";
                    break;

                case "YPCARD-NET":       //易宝e卡通
                    payCardInfo = "9";
                    break;

                case "NETEASE-NET":      // 网易卡
                    payCardInfo = "10";
                    break;

                case "WANMEI-NET":       //完美卡
                    payCardInfo = "11";
                    break;

                case "SOHU-NET":      //搜狐卡
                    payCardInfo = "12";
                    break;

                case "TELECOM-NET":      //电信卡
                    payCardInfo = "13";
                    break;

                case "ZONGYOU-NET":        //纵游一卡通
                    payCardInfo = "14";
                    break;

                case "TIANXIA-NET":       //天下一卡通
                    payCardInfo = "15";
                    break;

                case "TIANHONG-NET":       //天宏一卡通
                    payCardInfo = "16";
                    break;

                case "BESTPAY-NET":       //翼支付
                    payCardInfo = "17";
                    break;

                default:
                    payCardInfo = "18";
                    break;
                }

                p2_Order = "DKCZ-" + DateTime.Now.ToString("yyyyMMddhhmmss");  //用户订单

                HttpCookie UserCookie = new HttpCookie("PayOrder");
                UserCookie["order"]      = p2_Order;
                UserCookie["orderMoney"] = payCardMoney;
                UserCookie["orderUser"]  = HttpUtility.UrlEncode(payCardUser);
                UserCookie.Expires       = DateTime.Now.AddMinutes(7);
                Response.Cookies.Add(UserCookie);

                OnLineOrder onlineOrder = new OnLineOrder();
                onlineOrder.Accounts    = payCardUser;
                onlineOrder.UserID      = accountsInfo.UserID;
                onlineOrder.OrderAmount = decimal.Parse(payCardMoney);
                onlineOrder.OrderID     = p2_Order;
                onlineOrder.OrderStatus = 0;
                onlineOrder.ShareID     = Convert.ToInt32(payCardInfo);
                onlineOrder.CardTotal   = 1;
                onlineOrder.CardTypeID  = Convert.ToInt32(payCardInfo);//游戏点卡充值
                onlineOrder.TelPhone    = "";
                onlineOrder.IPAddress   = GameRequest.GetUserIP();
                Message msg = treasurefacade.RequestOrder(onlineOrder);
                if (msg.Success)
                {
                    //p3_Amt交易金额  精确两位小数,最小值为0.01,为持卡人实际要支付的金额.
                    p3_Amt = payCardMoney;
                    //交易币种,固定值"CNY".
                    p4_Cur = "CNY";
                    //商品名称
                    p5_Pid = ConfigurationManager.AppSettings["shoppingInfo"];// Request.Form["yeepayBankp5_Pid"];
                    //商品种类
                    p6_Pcat = "1";
                    //商品描述
                    p7_Pdesc = "1";
                    //商户接收支付成功数据的地址,支付成功后易宝支付会向该地址发送两次成功通知.
                    p8_Url = ConfigurationManager.AppSettings["yeepayBankAndCardCallback"].ToString();
                    //送货地址
                    //为“1”: 需要用户将送货地址留在易宝支付系统;为“0”: 不需要,默认为 ”0”.
                    p9_SAF = "0";
                    //商户扩展信息
                    //商户可以任意填写1K 的字符串,支付成功时将原样返回.
                    pa_MP = "";
                    //银行编码
                    //默认为"",到易宝支付网关.若不需显示易宝支付的页面,直接跳转到各银行、神州行支付、骏网一卡通等支付页面,该字段可依照附录:银行列表设置参数值.
                    pd_FrpId = payCardName;
                    //默认为"1": 需要应答机制;
                    pr_NeedResponse = "1";
                    hmac            = Buy.CreateBuyHmac(p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse);
                }
                else
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode(msg.Content);
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Request.Cookies.Remove("ErrorMsg");
            fastYeepayUser  = Request.Form["fastYeepayUser"] ?? string.Empty;
            fastYeepayMoney = Request.Form["fastYeepayMoney"] ?? string.Empty;
            payOtherMoney   = Request.Form["selfMoney"] ?? string.Empty;
            if (fastYeepayMoney.Equals("0"))
            {
                fastYeepayMoney = "100";
            }
            if (!string.IsNullOrEmpty(payOtherMoney))
            {
                fastYeepayMoney = payOtherMoney;
            }
            if (fastYeepayMoney.IndexOf(',') != -1)
            {
                fastYeepayMoney = fastYeepayMoney.Substring(0, fastYeepayMoney.Length - 1);
            }
            if (!string.IsNullOrEmpty(fastYeepayUser) && !string.IsNullOrEmpty(fastYeepayMoney))
            {
                AccountsInfo accountsInfo = accountsfacade.GetAccountsByAccontsName(fastYeepayUser);
                if (accountsInfo == null)
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode("用户名不存在");
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }
                try
                {
                    int.Parse(fastYeepayMoney);
                }
                catch (Exception)
                {
                    return;
                }
                //订单号
                string orderid = "KJZF-" + DateTime.Now.ToString("yyyyMMddhhmmss");

                HttpCookie UserCookie = new HttpCookie("PayOrder");
                UserCookie["order"]      = orderid;
                UserCookie["orderMoney"] = fastYeepayMoney;
                UserCookie["orderUser"]  = HttpUtility.UrlEncode(fastYeepayUser);
                UserCookie.Expires       = DateTime.Now.AddMinutes(7);
                Response.Cookies.Add(UserCookie);

                OnLineOrder online = new OnLineOrder();
                online.Accounts    = fastYeepayUser;
                online.UserID      = accountsInfo.UserID;
                online.OrderAmount = decimal.Parse((Convert.ToInt32(fastYeepayMoney)).ToString());
                online.OrderID     = orderid;
                online.OrderStatus = 0;
                online.ShareID     = 20;
                online.CardTotal   = 1;
                online.CardTypeID  = 1;
                online.TelPhone    = "";
                online.IPAddress   = GameRequest.GetUserIP();
                Message msg = treasurefacade.RequestOrder(online);
                if (msg.Success)
                {
                    //一键支付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(fastYeepayMoney) * 100;  //支付金额为分
                    int      currency       = 156;
                    string   identityid     = DateTime.Now.ToString("yyyyMMddhhmmss"); //用户身份标识
                    int      identitytype   = 0;
                    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["fastYeepayNotify"].ToString();
                    //商户提供的商户前台系统异步支付回调地址
                    string fcallbackurl = ConfigurationManager.AppSettings["fastYeepayCallback"].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);
                    string datastring  = payapi_mobile_demo.AES.Encrypt(wpinfo_json, merchantAesKey);
                    //将商户merchantAesKey用RSA算法加密
                    string encryptkey = RSAFromPkcs8.encryptData(merchantAesKey, yibaoPublickey, "UTF-8");
                    //打开浏览器访问一键支付网页支付链接地址,请求方式为get
                    string postParams = "data=" + HttpUtility.UrlEncode(datastring) + "&encryptkey=" + HttpUtility.UrlEncode(encryptkey) + "&merchantaccount=" + merchantAccount;
                    string url        = apiprefix + pcPayURI + "?" + postParams;
                    Response.Redirect(url);
                }
                else
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlEncode(msg.Content);
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //充值开始
            Request.Cookies.Remove("ErrorMsg");
            // 设置 Response编码格式为GB2312
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");

            payBankUser   = Request.Form["yeepayBankUser"] ?? string.Empty;
            payBankMoney  = Request.Form["yeepayBankMoney"] ?? string.Empty;
            payBankName   = Request.Form["yeepayBankName"] ?? string.Empty;
            payOtherMoney = Request.Form["selfMoney"] ?? string.Empty;
            if (payBankMoney.Equals("0"))
            {
                payBankMoney = "100";
            }
            if (!string.IsNullOrEmpty(payOtherMoney))
            {
                payBankMoney = payOtherMoney;
            }
            if (!string.IsNullOrEmpty(payBankUser) && !string.IsNullOrEmpty(payBankMoney) && !string.IsNullOrEmpty(payBankName))
            {
                AccountsInfo accountsInfo = accountsfacade.GetAccountsByAccontsName(payBankUser);
                if (accountsInfo == null)
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlDecode("用户名不存在");
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }

                try
                {
                    int.Parse(payBankMoney);
                }
                catch (Exception)
                {
                    return;
                }

                switch (payBankName)
                {
                case "ICBC-NET-B2C":       //工商银行
                    payBankInfo = "GSYH";
                    break;

                case "CMBCHINA-NET-B2C":      //招商银行
                    payBankInfo = "ZSYH";
                    break;

                case "ABC-NET-B2C":       //中国农业银行
                    payBankInfo = "NYYH";
                    break;

                case "CCB-NET-B2C":      //建设银行
                    payBankInfo = "JSYH";
                    break;

                case "BCCB-NET-B2C":      //北京银行
                    payBankInfo = "BJYH";
                    break;

                case "BOCO-NET-B2C":    //交通银行
                    payBankInfo = "JTYH";
                    break;

                case "CIB-NET-B2C":     //兴业银行
                    payBankInfo = "XYYH";
                    break;

                case "NJCB-NET-B2C":       //南京银行
                    payBankInfo = "NJYH";
                    break;

                case "CMBC-NET-B2C":      //中国民生银行
                    payBankInfo = "MSYH";
                    break;

                case "CEB-NET-B2C":       //光大银行
                    payBankInfo = "GDYH";
                    break;

                case "BOC-NET-B2C":      //中国银行
                    payBankInfo = "ZGYH";
                    break;

                case "PINGANBANK-NET":      //平安银行
                    payBankInfo = "PAYH";
                    break;

                case "CBHB-NET-B2C":        //渤海银行
                    payBankInfo = "BHYH";
                    break;

                case "ECITIC-NET-B2C":       //中兴银行
                    payBankInfo = "ZXYH";
                    break;

                case "SDB-NET-B2C":       //深圳发展银行
                    payBankInfo = "SZFZYH";
                    break;

                case "GDB-NET-B2C":       //广发银行
                    payBankInfo = "GFYH";
                    break;

                case "SPDB-NET-B2C":       //上海浦东发展银行
                    payBankInfo = "SHPDYH";
                    break;

                case "POST-NET-B2C":       //中国邮政
                    payBankInfo = "ZGYZYH";
                    break;

                case "HXB-NET-B2C":       //华夏银行
                    payBankInfo = "HXYH";
                    break;

                case "CZ-NET-B2C":       //浙商银行
                    payBankInfo = "ZSYH";
                    break;

                default:
                    payBankInfo = "WY";
                    break;
                }

                p2_Order = payBankInfo + "-" + DateTime.Now.ToString("yyyyMMddhhmmss");  //用户订单


                HttpCookie UserCookie = new HttpCookie("PayOrder");
                UserCookie["order"]      = p2_Order;
                UserCookie["orderMoney"] = payBankMoney;
                UserCookie["orderUser"]  = payBankUser;
                UserCookie.Expires       = DateTime.Now.AddMinutes(7);
                Response.Cookies.Add(UserCookie);

                OnLineOrder onlineOrder = new OnLineOrder();
                onlineOrder.Accounts    = payBankUser;
                onlineOrder.UserID      = accountsInfo.UserID;
                onlineOrder.OrderAmount = decimal.Parse(payBankMoney);
                onlineOrder.OrderID     = p2_Order;
                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)
                {
                    //p3_Amt交易金额  精确两位小数,最小值为0.01,为持卡人实际要支付的金额.
                    p3_Amt = payBankMoney;
                    //交易币种,固定值"CNY".
                    p4_Cur = "CNY";
                    //商品名称
                    p5_Pid = ConfigurationManager.AppSettings["shoppingInfo"];// Request.Form["yeepayBankp5_Pid"];
                    //商品种类
                    p6_Pcat = "1";
                    //商品描述
                    p7_Pdesc = "1";
                    //商户接收支付成功数据的地址,支付成功后易宝支付会向该地址发送两次成功通知.
                    p8_Url = ConfigurationManager.AppSettings["yeepayBankAndCardCallback"].ToString();
                    //送货地址
                    //为“1”: 需要用户将送货地址留在易宝支付系统;为“0”: 不需要,默认为 ”0”.
                    p9_SAF = "0";
                    //商户扩展信息
                    //商户可以任意填写1K 的字符串,支付成功时将原样返回.
                    pa_MP = "sdfdf";
                    //银行编码
                    //默认为"",到易宝支付网关.若不需显示易宝支付的页面,直接跳转到各银行、神州行支付、骏网一卡通等支付页面,该字段可依照附录:银行列表设置参数值.
                    pd_FrpId = payBankName;
                    //默认为"1": 需要应答机制;
                    pr_NeedResponse = "1";

                    string s = Buy.GetMerId();

                    hmac = Buy.CreateBuyHmac(p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse);
                }
                else
                {
                    HttpCookie UserCookie2 = new HttpCookie("ErrorMsg");
                    UserCookie2["error"] = HttpUtility.UrlDecode(msg.Content);
                    UserCookie2.Expires  = DateTime.Now.AddMinutes(7);
                    Response.Cookies.Add(UserCookie2);
                    Response.Redirect("/showpayInfo.html");
                }
            }
        }