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 + "¬ify_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=生成订单出错。请重试"); } }
protected void Page_Load(object sender, EventArgs e) { //定义变量 userName = GameRequest.GetFormString("txtPayAccounts"); string reUserName = GameRequest.GetFormString("txtPayReAccounts"); money = GameRequest.GetFormInt("hdfSalePrice", 0); sendUrl = System.Configuration.ConfigurationSettings.AppSettings["DaySendUrl"]; //导向地址 notifyUrl = System.Configuration.ConfigurationSettings.AppSettings["DayNotifyUrl"]; //同步回调地址 string key = System.Configuration.ConfigurationSettings.AppSettings["DayKey"]; //密钥 merId = System.Configuration.ConfigurationSettings.AppSettings["DayMerId"]; //商户ID //验证参数 if (userName != reUserName) { ShowAndRedirect("两次输入的用户名不一致", "/Pay/PayDay.aspx"); return; } if (money == 0) { ShowAndRedirect("金额输入有误", "/Pay/PayDay.aspx"); return; } //生成订单 orderID = PayHelper.GetOrderIDByPrefix("Day"); //订单号 OnLineOrder onlineOrder = new OnLineOrder( ); onlineOrder.ShareID = 2; onlineOrder.OrderID = orderID; if (Fetch.GetUserCookie( ) == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie( ).UserID; } onlineOrder.Accounts = userName; onlineOrder.CardTotal = 1; onlineOrder.CardTypeID = money < 30 ? 1 : money < 60 ? 2 : money < 120 ? 3 : 4; onlineOrder.OrderAmount = money; onlineOrder.IPAddress = GameRequest.GetUserIP( ); TreasureFacade treasureFacade = new TreasureFacade( ); Message umsg = treasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } //生成sign签名 string signStr = merId + "|" + orderID + "|" + money + "|" + sendUrl + "|" + userName + "|" + key; sign = EncryptMD5(signStr, false, 32); }
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 { } }
protected void btnPay_Click(object sender, EventArgs e) { string strAccounts = CtrlHelper.GetText(txtPayAccounts); string strReAccounts = CtrlHelper.GetText(txtPayReAccounts); int salePrice = GameRequest.GetFormInt("rbSaleType", 0); string gamePayType = GameRequest.GetFormString("rbPayGType"); if (strAccounts == "") { RenderAlertInfo(true, "抱歉,请输入充值帐号。", 2); return; } if (strReAccounts != strAccounts) { RenderAlertInfo(true, "抱歉,两次输入的帐号不一致。", 2); return; } if (salePrice < 30) { RenderAlertInfo(true, "抱歉,充值金额必须大于30元", 2); return; } OnLineOrder onlineOrder = new OnLineOrder(); onlineOrder.ShareID = gamePayType == "C" ? 7 : gamePayType == "D" ? 8 : gamePayType == "M" ? 9 : gamePayType == "N" ? 10 : 11; onlineOrder.OrderID = gamePayType == "C" ? PayHelper.GetOrderIDByPrefix("SD") : gamePayType == "D" ? PayHelper.GetOrderIDByPrefix("ZT") : gamePayType == "M" ? PayHelper.GetOrderIDByPrefix("WY") : gamePayType == "N" ? PayHelper.GetOrderIDByPrefix("SH") : PayHelper.GetOrderIDByPrefix("WM"); #region 订单处理 if (Fetch.GetUserCookie() == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie().UserID; } onlineOrder.Accounts = strAccounts; onlineOrder.CardTotal = 1; onlineOrder.CardTypeID = salePrice < 30 ? 1 : salePrice < 60 ? 2 : salePrice < 120 ? 3 : 4; onlineOrder.OrderAmount = salePrice; onlineOrder.IPAddress = GameRequest.GetUserIP(); //生成订单 Message umsg = treasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } #endregion #region 提交给快钱支付网关 //商户号 string merchantAcctId = ApplicationSettings.Get("merchantIdGame"); //人民币网关密钥 ///区分大小写.请与快钱联系索取 string key = ApplicationSettings.Get("keyValueGame"); //商户订单号 string orderId = onlineOrder.OrderID.Trim(); //支付金额 string orderAmount = onlineOrder.OrderAmount.ToString(); //string orderAmount = "1.00"; //充值卡类型c 盛大一卡通d 征途游戏卡m网易一卡通n 搜狐一卡通u 完美一卡通 string payType = gamePayType; //前台接收并显示页面,公网地址 string pageUrl = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayShow.aspx"; //支付结果底层发送的接收页面 后台接收页面 string bgUrl = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayGameReceive.aspx"; //扩展字段1 string ext1 = "0"; //扩展字段2 string ext2 = ""; //MD5签名 MD5签名:把请求支付的部分参数与KEY(商户后台可自行修改)拼凑成字符串经过国际标准32位MD5加密转换成大写 String signMsgVal = ""; signMsgVal = AppendParam(signMsgVal, "merchantAcctId", merchantAcctId); signMsgVal = AppendParam(signMsgVal, "orderId", orderId); signMsgVal = AppendParam(signMsgVal, "orderAmount", orderAmount); signMsgVal = AppendParam(signMsgVal, "payType", payType); signMsgVal = AppendParam(signMsgVal, "pageUrl", pageUrl); signMsgVal = AppendParam(signMsgVal, "bgUrl", bgUrl); signMsgVal = AppendParam(signMsgVal, "ext1", HttpUtility.UrlEncode(ext1, Encoding.GetEncoding("gb2312")).Trim()); signMsgVal = AppendParam(signMsgVal, "ext2", HttpUtility.UrlEncode(ext2, Encoding.GetEncoding("gb2312")).Trim()); signMsgVal = AppendParam(signMsgVal, "key", key); string signMsg = TextEncrypt.EncryptPassword(signMsgVal).ToUpper(); #endregion RenderAlertInfo(false, "页面正跳转到支付平台,请稍候。。。", 2); #region 整理参数 string getData = ""; getData = AppendAllParam(getData, "merchantAcctId", merchantAcctId); getData = AppendAllParam(getData, "orderId", orderId); getData = AppendAllParam(getData, "orderAmount", orderAmount); getData = AppendAllParam(getData, "payType", payType); getData = AppendAllParam(getData, "pageUrl", HttpUtility.UrlEncode(pageUrl, Encoding.GetEncoding("gb2312")).Trim()); getData = AppendAllParam(getData, "bgUrl", HttpUtility.UrlEncode(bgUrl, Encoding.GetEncoding("gb2312")).Trim()); getData = AppendAllParam(getData, "ext1", HttpUtility.UrlEncode(ext1, Encoding.GetEncoding("gb2312")).Trim()); getData = AppendAllParam(getData, "ext2", HttpUtility.UrlEncode(ext2, Encoding.GetEncoding("gb2312")).Trim()); getData = AppendAllParam(getData, "signMsg", signMsg); string posturl = this.Page.Form.Action + "?" + getData; #endregion Response.Redirect(posturl); }
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()); } } }
protected void btnPay_Click(object sender, EventArgs e) { string strAccounts = CtrlHelper.GetText(txtPayAccounts); string strReAccounts = CtrlHelper.GetText(txtPayReAccounts); int salePrice = Utility.StrToInt(this.hdfSalePrice.Value, 0); if (strAccounts == "") { RenderAlertInfo(true, "抱歉,请输入充值帐号。", 2); return; } if (strReAccounts != strAccounts) { RenderAlertInfo(true, "抱歉,两次输入的帐号不一致。", 2); return; } if (salePrice < 10) { RenderAlertInfo(true, "抱歉,充值金额不足10元,无法充值。", 2); return; } OnLineOrder onlineOrder = new OnLineOrder(); onlineOrder.ShareID = 2; onlineOrder.OrderID = PayHelper.GetOrderIDByPrefix("KQ"); #region 订单处理 if (Fetch.GetUserCookie() == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie().UserID; } onlineOrder.Accounts = strAccounts; onlineOrder.CardTotal = 1; onlineOrder.CardTypeID = salePrice < 30 ? 1 : salePrice < 60 ? 2 : salePrice < 120 ? 3 : 4; onlineOrder.OrderAmount = salePrice; onlineOrder.IPAddress = GameRequest.GetUserIP(); //生成订单 Message umsg = treasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } #endregion #region 提交给快钱支付网关 //人民币网关账户号 ///请登录快钱系统获取用户编号,用户编号后加01即为人民币网关账户号。 string merchantAcctId = ApplicationSettings.Get("merchantIdRMB"); //人民币网关密钥 ///区分大小写.请与快钱联系索取 string key = ApplicationSettings.Get("keyValueRMB"); //服务器接受支付结果的后台地址.与[pageUrl]不能同时为空。必须是绝对地址。 ///快钱通过服务器连接的方式将交易结果发送到[bgUrl]对应的页面地址,在商户处理完成后输出的<result>如果为1,页面会转向到<redirecturl>对应的地址。 ///如果快钱未接收到<redirecturl>对应的地址,快钱将把支付结果GET到[pageUrl]对应的页面。 //bgUrl.Value = "http://www.yoursite.com/receive.aspx"; string bgUrl = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayReceive.aspx"; //字符集.固定选择值。可为空。 ///只能选择1、2、3. ///1代表UTF-8; 2代表GBK; 3代表gb2312 ///默认值为1 string inputCharset = "1"; //网关版本.固定值 ///快钱会根据版本号来调用对应的接口处理程序。 ///本代码版本号固定为v2.0 string version = "v2.0"; //语言种类.固定选择值。 ///只能选择1、2、3 ///1代表中文;2代表英文 ///默认值为1 string language = "1"; //签名类型.固定值 ///1代表MD5签名 ///当前版本固定为1 string signType = "1"; //支付人姓名 ///可为中文或英文字符 string payerName = onlineOrder.Accounts; //支付人联系方式类型.固定选择值 ///只能选择1 ///1代表Email string payerContactType = "1"; //支付人联系方式 ///只能选择Email或手机号 string payerContact = ""; //商户订单号 ///由字母、数字、或[-][_]组成 string orderId = onlineOrder.OrderID; //订单金额 ///以分为单位,必须是整型数字 ///比方2,代表0.02元 string orderAmount = (salePrice * 100).ToString("f0"); //订单提交时间 ///14位数字。年[4位]月[2位]日[2位]时[2位]分[2位]秒[2位] ///如;20080101010101 string orderTime = DateTime.Now.ToString("yyyyMMddHHmmss"); //商品名称 ///可为中文或英文字符 //productName.Value = "productName"; string productName = salePrice < 30 ? "蓝钻会员卡" : salePrice < 60 ? "黄钻会员卡" : salePrice < 120 ? "白钻会员卡" : "红钻会员卡"; //商品数量 ///可为空,非空时必须为数字 //productNum.Value = "1"; string productNum = "1"; //商品代码 ///可为字符或者数字 string productId = ""; //商品描述 string productDesc = ""; //扩展字段1 ///在支付结束后原样返回给商户 服务损耗比例(*1000) string ext1 = "0"; //扩展字段2 //在支付结束后原样返回给商户 string ext2 = ""; //支付方式.固定选择值 ///只能选择00、10、11、12、13、14 ///00:组合支付(网关支付页面显示快钱支持的各种支付方式,推荐使用)10:银行卡支付(网关支付页面只显示银行卡支付).11:电话银行支付(网关支付页面只显示电话支付).12:快钱账户支付(网关支付页面只显示快钱账户支付).13:线下支付(网关支付页面只显示线下支付方式) string payType = "00"; //同一订单禁止重复提交标志 //固定选择值: 1、0 //1代表同一订单号只允许提交1次;0表示同一订单号在没有支付成功的前提下可重复提交多次。默认为0建议实物购物车结算类商户采用0;虚拟产品类商户采用1 string redoFlag = "1"; //快钱的合作伙伴的账户号 ///如未和快钱签订代理合作协议,不需要填写本参数 string pid = ""; //生成加密签名串 ///请务必按照如下顺序和规则组成加密串! String signMsgVal = ""; signMsgVal = AppendParam(signMsgVal, "inputCharset", inputCharset); signMsgVal = AppendParam(signMsgVal, "bgUrl", bgUrl); signMsgVal = AppendParam(signMsgVal, "version", version); signMsgVal = AppendParam(signMsgVal, "language", language); signMsgVal = AppendParam(signMsgVal, "signType", signType); signMsgVal = AppendParam(signMsgVal, "merchantAcctId", merchantAcctId); signMsgVal = AppendParam(signMsgVal, "payerName", payerName); signMsgVal = AppendParam(signMsgVal, "payerContactType", payerContactType); signMsgVal = AppendParam(signMsgVal, "payerContact", payerContact); signMsgVal = AppendParam(signMsgVal, "orderId", orderId); signMsgVal = AppendParam(signMsgVal, "orderAmount", orderAmount); signMsgVal = AppendParam(signMsgVal, "orderTime", orderTime); signMsgVal = AppendParam(signMsgVal, "productName", productName); signMsgVal = AppendParam(signMsgVal, "productNum", productNum); signMsgVal = AppendParam(signMsgVal, "productId", productId); signMsgVal = AppendParam(signMsgVal, "productDesc", productDesc); signMsgVal = AppendParam(signMsgVal, "ext1", ext1); signMsgVal = AppendParam(signMsgVal, "ext2", ext2); signMsgVal = AppendParam(signMsgVal, "payType", payType); signMsgVal = AppendParam(signMsgVal, "redoFlag", redoFlag); signMsgVal = AppendParam(signMsgVal, "pid", pid); signMsgVal = AppendParam(signMsgVal, "key", key); string signMsg = GetMD5(signMsgVal, "utf-8").ToUpper(); #endregion #region 整理参数 RenderAlertInfo(false, "页面正跳转到支付平台,请稍候。。。", 2); StringBuilder builder = new StringBuilder(); builder.AppendLine(CreateInputHidden("inputCharset", inputCharset)); builder.AppendLine(CreateInputHidden("bgUrl", bgUrl)); builder.AppendLine(CreateInputHidden("version", version)); builder.AppendLine(CreateInputHidden("language", language)); builder.AppendLine(CreateInputHidden("signType", signType)); builder.AppendLine(CreateInputHidden("signMsg", signMsg)); builder.AppendLine(CreateInputHidden("merchantAcctId", merchantAcctId)); builder.AppendLine(CreateInputHidden("payerName", payerName)); builder.AppendLine(CreateInputHidden("payerContactType", payerContactType)); builder.AppendLine(CreateInputHidden("payerContact", payerContact)); builder.AppendLine(CreateInputHidden("orderId", orderId)); builder.AppendLine(CreateInputHidden("orderAmount", orderAmount)); builder.AppendLine(CreateInputHidden("orderTime", orderTime)); builder.AppendLine(CreateInputHidden("productName", productName)); builder.AppendLine(CreateInputHidden("productNum", productNum)); builder.AppendLine(CreateInputHidden("productId", productId)); builder.AppendLine(CreateInputHidden("productDesc", productDesc)); builder.AppendLine(CreateInputHidden("ext1", ext1)); builder.AppendLine(CreateInputHidden("ext2", ext2)); builder.AppendLine(CreateInputHidden("payType", payType)); builder.AppendLine(CreateInputHidden("redoFlag", redoFlag)); builder.AppendLine(CreateInputHidden("pid", pid)); lit99Bill.Text = builder.ToString(); #endregion this.Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "window.onload = function() { document.forms[0].submit(); }", true); }
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); } }
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"); } } }
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 + "¬ify_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 { } }
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(); }
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"); } } }
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"); } } }
protected void btnPay_Click(object sender, EventArgs e) { string strAccounts = CtrlHelper.GetText(txtPayAccounts); string strReAccounts = CtrlHelper.GetText(txtPayReAccounts); int salePrice = GameRequest.GetFormInt("rbSaleType", 0); int gamePayType = GameRequest.GetFormInt("rbPayMType", 1); if (strAccounts == "") { RenderAlertInfo(true, "抱歉,请输入充值帐号。", 2); return; } if (strReAccounts != strAccounts) { RenderAlertInfo(true, "抱歉,两次输入的帐号不一致。", 2); return; } if (salePrice < 30) { RenderAlertInfo(true, "抱歉,充值金额必须大于30元", 2); return; } OnLineOrder onlineOrder = new OnLineOrder(); onlineOrder.ShareID = gamePayType == 1 ? 4 : gamePayType == 2 ? 5 : 6; onlineOrder.OrderID = gamePayType == 1 ? PayHelper.GetOrderIDByPrefix("SZX") : gamePayType == 2 ? PayHelper.GetOrderIDByPrefix("LT") : PayHelper.GetOrderIDByPrefix("DX"); #region 订单处理 if (Fetch.GetUserCookie() == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie().UserID; } onlineOrder.Accounts = strAccounts; onlineOrder.CardTotal = 1; onlineOrder.CardTypeID = salePrice < 30 ? 1 : salePrice < 60 ? 2 : salePrice < 120 ? 3 : 4; onlineOrder.OrderAmount = salePrice; onlineOrder.IPAddress = GameRequest.GetUserIP(); //生成订单 Message umsg = treasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } #endregion #region 提交给快钱支付网关 //人民币网关账户号 ///请登录快钱系统获取用户编号,用户编号后加01即为人民币网关账户号。 string merchantAcctId = gamePayType == 1 ? ApplicationSettings.Get("merchantIdYD") : gamePayType == 2 ? ApplicationSettings.Get("merchantIdLT") : ApplicationSettings.Get("merchantIdDX"); //string merchantAcctId = ApplicationSettings.Get( "merchantIdMobile" ); //人民币网关密钥 ///区分大小写.请与快钱联系索取 string key = gamePayType == 1 ? ApplicationSettings.Get("keyValueYD") : gamePayType == 2 ? ApplicationSettings.Get("keyValueLT") : ApplicationSettings.Get("keyValueDX"); //string key = ApplicationSettings.Get( "keyValueMobile" ); //服务器接受支付结果的后台地址.与[pageUrl]不能同时为空。必须是绝对地址。 ///快钱通过服务器连接的方式将交易结果发送到[bgUrl]对应的页面地址,在商户处理完成后输出的<result>如果为1,页面会转向到<redirecturl>对应的地址。 ///如果快钱未接收到<redirecturl>对应的地址,快钱将把支付结果GET到[pageUrl]对应的页面。 //bgUrl.Value = "http://www.yoursite.com/receive.aspx"; string bgUrl = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayMobileReceive.aspx"; //接受支付结果的页面地址.与[bgUrl]不能同时为空。必须是绝对地址。 ////如果[bgUrl]为空,快钱将支付结果GET到[pageUrl]对应的地址。 ////如果[bgUrl]不为空,并且[bgUrl]页面指定的<redirecturl>地址不为空,则转向到<redirecturl>对应的地址 string pageUrl = ""; //字符集.固定选择值。可为空。 ////只能选择1、2、3、5 ////1代表UTF-8; 2代表GBK; 3代表gb2312; 5 代表big5 ////默认值为1 string inputCharset = "1"; //网关版本.固定值 ////快钱会根据版本号来调用对应的接口处理程序。 ////本代码版本号固定为v2.0 string version = "v2.0"; //语言种类.固定选择值。 ////只能选择1、2、3 ////1代表中文;2代表英文 ////默认值为1 string language = "1"; //签名类型.固定值 ////1代表MD5签名 ////当前版本固定为1 string signType = "1"; //支付人姓名 ///可为中文或英文字符 string payerName = HttpUtility.UrlEncode(onlineOrder.Accounts, Encoding.GetEncoding("UTF-8")).ToUpper(); //支付人联系方式类型.固定选择值 ////只能选择1 ////1代表Email string payerContactType = "1"; //支付人联系方式 ////只能选择Email或手机号 string payerContact = ""; //商户订单号 ///由字母、数字、或[-][_]组成 string orderId = onlineOrder.OrderID; //订单金额 ///以分为单位,必须是整型数字 ///比方2,代表0.02元 string orderAmount = (salePrice * 100).ToString("f0"); //支付方式.固定选择值 ////可选择00、41、42、52 ////00 代表快钱默认支付方式,目前为神州行卡密支付和快钱账户支付;41 代表快钱账户支付;42 代表神州行卡密支付和快钱账户支付;52 代表神州行卡密支付 string payType = "42"; //神州行卡序号 ////仅在商户定制了神州行卡密直连功能时填写 string cardNumber = ""; //神州行卡密码 ////仅在商户定制了神州行卡密直连功能时填写 string cardPwd = ""; //全额支付标志 ////只能选择数字 0 或 1 ////0代表非全额支付方式,支付完成后返回订单金额为商户提交的订单金额。如果预付费卡面额小于订单金额时,返回支付结果为失败;预付费卡面额大于或等于订单金额时,返回支付结果为成功; ////1 代表全额支付方式,支付完成后返回订单金额为用户预付费卡的面额。只要预付费卡销卡成功,返回支上海快钱信息服务有限公司 版权所有 第 6 页付结果都为成功。如果商户定制神州行卡密直连时,本参数固定值为1 string fullAmountFlag = "0"; //订单提交时间 ///14位数字。年[4位]月[2位]日[2位]时[2位]分[2位]秒[2位] ///如;20080101010101 string orderTime = DateTime.Now.ToString("yyyyMMddHHmmss"); //商品名称 ////可为中文或英文字符 string productName = HttpUtility.UrlEncode((salePrice < 30 ? "蓝钻会员卡" : salePrice < 60 ? "黄钻会员卡" : salePrice < 120 ? "白钻会员卡" : "红钻会员卡"), Encoding.GetEncoding("UTF-8")).ToUpper(); //商品数量 ////可为空,非空时必须为数字 string productNum = onlineOrder.CardTotal.ToString(); //商品代码 ///可为字符或者数字 string productId = ""; //商品描述 string productDesc = ""; //扩展字段1 ///在支付结束后原样返回给商户 服务损耗比例(*1000) string ext1 = "0"; //扩展字段2 //在支付结束后原样返回给商户 string ext2 = ""; //充值卡类型 ////固定选择值:0、1、3、4、9 ////0 代表神州行充值卡 ////1 代表联通充值卡 ////3 代表电信充值卡 ////4 代表骏网一卡通 ////9 代表已开通任一卡类型 string bossType = (gamePayType == 1 ? 0 : gamePayType == 2 ? 1 : 3).ToString().Trim(); //生成加密签名串 ///请务必按照如下顺序和规则组成加密串! string signMsgVal = ""; signMsgVal = AppendParam(signMsgVal, "inputCharset", inputCharset); signMsgVal = AppendParam(signMsgVal, "bgUrl", bgUrl); signMsgVal = AppendParam(signMsgVal, "pageUrl", pageUrl); signMsgVal = AppendParam(signMsgVal, "version", version); signMsgVal = AppendParam(signMsgVal, "language", language); signMsgVal = AppendParam(signMsgVal, "signType", signType); signMsgVal = AppendParam(signMsgVal, "merchantAcctId", merchantAcctId); signMsgVal = AppendParam(signMsgVal, "payerName", payerName); signMsgVal = AppendParam(signMsgVal, "payerContactType", payerContactType); signMsgVal = AppendParam(signMsgVal, "payerContact", payerContact); signMsgVal = AppendParam(signMsgVal, "orderId", orderId); signMsgVal = AppendParam(signMsgVal, "orderAmount", orderAmount); signMsgVal = AppendParam(signMsgVal, "payType", payType); signMsgVal = AppendParam(signMsgVal, "cardNumber", cardNumber); signMsgVal = AppendParam(signMsgVal, "cardPwd", cardPwd); signMsgVal = AppendParam(signMsgVal, "fullAmountFlag", fullAmountFlag); signMsgVal = AppendParam(signMsgVal, "orderTime", orderTime); signMsgVal = AppendParam(signMsgVal, "productName", productName); signMsgVal = AppendParam(signMsgVal, "productNum", productNum); signMsgVal = AppendParam(signMsgVal, "productId", productId); signMsgVal = AppendParam(signMsgVal, "productDesc", productDesc); signMsgVal = AppendParam(signMsgVal, "ext1", ext1); signMsgVal = AppendParam(signMsgVal, "ext2", ext2); signMsgVal = AppendParam(signMsgVal, "bossType", bossType); signMsgVal = AppendParam(signMsgVal, "key", key); string signMsg = FormsAuthentication.HashPasswordForStoringInConfigFile(signMsgVal, "MD5").ToUpper(); #endregion #region 整理参数 RenderAlertInfo(false, "页面正跳转到支付平台,请稍候。。。", 2); StringBuilder builder = new StringBuilder(); builder.AppendLine(CreateInputHidden("inputCharset", inputCharset)); builder.AppendLine(CreateInputHidden("bgUrl", bgUrl)); builder.AppendLine(CreateInputHidden("pageUrl", pageUrl)); builder.AppendLine(CreateInputHidden("version", version)); builder.AppendLine(CreateInputHidden("language", language)); builder.AppendLine(CreateInputHidden("signType", signType)); builder.AppendLine(CreateInputHidden("merchantAcctId", merchantAcctId)); builder.AppendLine(CreateInputHidden("payerName", payerName)); builder.AppendLine(CreateInputHidden("payerContactType", payerContactType)); builder.AppendLine(CreateInputHidden("payerContact", payerContact)); builder.AppendLine(CreateInputHidden("orderId", orderId)); builder.AppendLine(CreateInputHidden("orderAmount", orderAmount)); builder.AppendLine(CreateInputHidden("payType", payType)); builder.AppendLine(CreateInputHidden("cardNumber", cardNumber)); builder.AppendLine(CreateInputHidden("cardPwd", cardPwd)); builder.AppendLine(CreateInputHidden("fullAmountFlag", fullAmountFlag)); builder.AppendLine(CreateInputHidden("orderTime", orderTime)); builder.AppendLine(CreateInputHidden("productName", productName)); builder.AppendLine(CreateInputHidden("productNum", productNum)); builder.AppendLine(CreateInputHidden("productId", productId)); builder.AppendLine(CreateInputHidden("productDesc", productDesc)); builder.AppendLine(CreateInputHidden("ext1", ext1)); builder.AppendLine(CreateInputHidden("ext2", ext2)); builder.AppendLine(CreateInputHidden("bossType", bossType)); builder.AppendLine(CreateInputHidden("signMsg", signMsg)); lit99Bill.Text = builder.ToString(); #endregion this.Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "window.onload = function() { document.forms[0].submit(); }", true); }
protected void btnPay_Click(object sender, EventArgs e) { string strAccounts = CtrlHelper.GetText(txtPayAccounts); string strReAccounts = CtrlHelper.GetText(txtPayReAccounts); int salePrice = Utility.StrToInt(this.hdfSalePrice.Value, 0); if (strAccounts == "") { RenderAlertInfo(true, "抱歉,请输入充值帐号。", 2); return; } if (strReAccounts != strAccounts) { RenderAlertInfo(true, "抱歉,两次输入的帐号不一致。", 2); return; } if (salePrice < 10) { RenderAlertInfo(true, "抱歉,充值金额不足10元,无法充值。", 2); return; } OnLineOrder onlineOrder = new OnLineOrder(); onlineOrder.ShareID = 3; onlineOrder.OrderID = PayHelper.GetOrderIDByPrefix("YB"); #region 订单处理 if (Fetch.GetUserCookie() == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie().UserID; } onlineOrder.Accounts = strAccounts; onlineOrder.CardTotal = 1; onlineOrder.CardTypeID = salePrice < 30 ? 1 : salePrice < 60 ? 2 : salePrice < 120 ? 3 : 4; onlineOrder.OrderAmount = salePrice; onlineOrder.IPAddress = GameRequest.GetUserIP(); //生成订单 Message umsg = treasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } #endregion #region 提交给易宝处理 // 商户订单号,选填. //若不为"",提交的订单号必须在自身账户交易中唯一;为""时,易宝支付会自动生成随机的商户订单号. string p2_Order = onlineOrder.OrderID; // 支付金额,必填. //单位:元,精确到分. string p3_Amt = salePrice.ToString("f0"); //交易币种,固定值"CNY". string p4_Cur = "CNY"; //商品名称 //用于支付时显示在易宝支付网关左侧的订单产品信息. string p5_Pid = salePrice < 30 ? "蓝钻会员卡" : salePrice < 60 ? "黄钻会员卡" : salePrice < 120 ? "白钻会员卡" : "红钻会员卡"; //商品种类 string p6_Pcat = ""; //商品描述 string p7_Pdesc = ""; //商户接收支付成功数据的地址,支付成功后易宝支付会向该地址发送两次成功通知. string p8_Url = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayYBReceive.aspx"; //送货地址 //为“1”: 需要用户将送货地址留在易宝支付系统;为“0”: 不需要,默认为 ”0”. string p9_SAF = "0"; //商户扩展信息 //商户可以任意填写1K 的字符串,支付成功时将原样返回. string pa_MP = onlineOrder.Accounts; //银行编码 //默认为"",到易宝支付网关.若不需显示易宝支付的页面,直接跳转到各银行、神州行支付、骏网一卡通等支付页面,该字段可依照附录:银行列表设置参数值. string pd_FrpId = ""; //应答机制 //默认为"1": 需要应答机制; string pr_NeedResponse = "1"; string url = Buy.CreateBuyUrl(p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse); Response.Redirect(url); #endregion }
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 { } }
protected void btnPay_Click(object sender, EventArgs e) { string strAccounts = CtrlHelper.GetText(txtPayAccounts); string strReAccounts = CtrlHelper.GetText(txtPayReAccounts); int salePrice = GameRequest.GetFormInt("rbSaleType", 0); if (strAccounts == "") { RenderAlertInfo(true, "抱歉,请输入充值帐号。", 2); return; } if (strReAccounts != strAccounts) { RenderAlertInfo(true, "抱歉,两次输入的帐号不一致。", 2); return; } if (salePrice < 10) { RenderAlertInfo(true, "抱歉,充值金额必须大于10元", 2); return; } OnLineOrder onlineOrder = new OnLineOrder(); onlineOrder.ShareID = 12; onlineOrder.OrderID = PayHelper.GetOrderIDByPrefix("SX"); #region 订单处理 if (Fetch.GetUserCookie() == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie().UserID; } onlineOrder.Accounts = strAccounts; onlineOrder.CardTotal = 1; onlineOrder.CardTypeID = salePrice < 30 ? 1 : salePrice < 60 ? 2 : salePrice < 120 ? 3 : 4; onlineOrder.OrderAmount = salePrice; onlineOrder.IPAddress = GameRequest.GetUserIP(); //生成订单 Message umsg = treasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } #endregion #region 提交给V币网关 string spid = ApplicationSettings.Get("spId"); //换成商户sp号码 长度5位 string sppwd = ApplicationSettings.Get("spKeyValue"); //换成商户sp校验密钥 长度18位 string spreq = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayVB.aspx"; //换成商户请求地址 string sprec = "http://" + HttpContext.Current.Request.Url.Authority + "/Pay/PayVBReceive.aspx"; //换成商户接收地址 string spname = Server.UrlEncode(ApplicationSettings.Get("spName")); //需要 Server.UrlEncode编码 string spcustom = onlineOrder.CardTotal.ToString("f0"); //需要 Server.UrlEncode编码 '客户自定义 30字符内 只能是数字、字母或数字字母的组合。不能用汉字。 string spversion = "vpay1001"; //此接口的版本号码 此版本是"vpay1001" string money = onlineOrder.OrderAmount.ToString("f0"); //接参数面值元 string userid = Server.UrlEncode(onlineOrder.Accounts); //接参数用户ID 需要 Server.UrlEncode编码 string urlcode = "utf-8"; //编码 gbk gb2312 utf-8 unicode big5(注意不能一个繁体和简体字交叉写) 你程序的编码 string orderId = onlineOrder.OrderID; //客户订单 请妥善管理客户的订单 长度:30字符以内(只能是数字、字母或数字字母的组合。不能用汉字订单) string post_key = orderId + spreq + sprec + spid + sppwd + spversion + money; // '网站订单号码+ 请求地址+ 接收地址 + 5位spid+ 18位SP密码+支付的版本号+面值 //'LCase函数是将字符转换为小写; Ucase函数是将字符转换为大写 //'全国声讯支付联盟全国声讯电话支付接口对MD5值只认大写字符串,所以小写的MD5值得转换为大写 string md5password = TextEncrypt.EncryptPassword(post_key).ToUpper();// '先MD532 然后转大写 md5password = md5(post_key, 32).ToUpper( ); string IpAddress = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null && HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != String.Empty) ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; #endregion #region 整理参数 RenderAlertInfo(false, "页面正跳转到支付平台,请稍候。。。", 2); HtmlGenericControl pnlSubmit = this.FindControl("pnlSubmit") as HtmlGenericControl; if (pnlSubmit != null) { pnlSubmit.Visible = true; } StringBuilder builder = new StringBuilder(); builder.AppendLine(CreateInputHidden("spid", spid)); builder.AppendLine(CreateInputHidden("spname", spname)); builder.AppendLine(CreateInputHidden("spoid", orderId)); builder.AppendLine(CreateInputHidden("spreq", spreq)); builder.AppendLine(CreateInputHidden("sprec", sprec)); builder.AppendLine(CreateInputHidden("userid", userid)); builder.AppendLine(CreateInputHidden("userip", IpAddress)); builder.AppendLine(CreateInputHidden("spmd5", md5password)); builder.AppendLine(CreateInputHidden("spcustom", spcustom)); builder.AppendLine(CreateInputHidden("spversion", spversion)); builder.AppendLine(CreateInputHidden("money", money)); builder.AppendLine(CreateInputHidden("urlcode", urlcode)); litVB.Text = builder.ToString(); #endregion //this.Page.ClientScript.RegisterStartupScript( this.GetType( ) , "message" , "window.onload = function() { document.forms[1].submit(); }" , true ); }
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); } } }