public void Submit(ViewModel.PaymentViewModel model) { var order = _uow.OrderService.Get(t => t.OrderId == model.OrderId && t.TradeNo == model.TradeNo); if (order == null) { Response.Redirect("PayError"); } model.OrderModel = order; model.FrontCallbackUrl = Ichari.Common.WebUtils.GetAppSettingValue("FrontPayUrl"); model.BackCallbackUrl = Ichari.Common.WebUtils.GetAppSettingValue("BackPayUrl"); if (model.Source == Model.Enum.PaySource.Donation) { model.ProdUrl = Ichari.Common.WebUtils.GetAppSettingValue("DonateUrl"); model.ProdName = Ichari.Common.WebUtils.GetAppSettingValue("DonationName"); } switch (model.PayWayType) { case PayWay.UnionPay: // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config")); var p = GenParams(model); var srv = new FrontPaySrv(p); //写入订单支付记录 SavePayLog(model); Response.ContentEncoding = srv.Charset; _log.Info(srv.CreateHtml()); Response.Write(srv.CreateHtml()); break; } }
protected void Page_Load(object sender, EventArgs e) { // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(Server.MapPath("~/App_Data/conf.xml.config")); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); // 收到回应后做后续处理(这里写入文件,仅供演示) System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("~/notify_data.txt")); string sOP = ""; if (resp.ResponseCode != SrvResponse.RESP_SUCCESS) { sw.WriteLine("error in parsing response message! code:" + resp.ResponseCode); sOP = "error in parsing response message! code:" + resp.ResponseCode + Environment.NewLine; } else { foreach (string k in resp.Fields.Keys) { sw.WriteLine(k + "\t = " + resp.Fields[k]); sOP = k + "\t = " + resp.Fields[k] + Environment.NewLine; } } sw.Close(); Response.Write(sOP); }
/// <summary> /// 银联支付发送请求 /// </summary> /// <param name="upa"></param> /// <param name="writeEcoding"></param> /// <returns></returns> public string UPOPSendRequesWriter(UPOPPara upa, out Encoding writeEcoding) { // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(configPath); // 使用Dictionary保存参数 System.Collections.Generic.Dictionary <string, string> param = new System.Collections.Generic.Dictionary <string, string>(); // 填写参数 param["transType"] = UPOPSrv.TransType.CONSUME; // 交易类型,前台只支持CONSUME 和 PRE_AUTH param["commodityUrl"] = upa.showProUrl; // 商品URL param["commodityName"] = upa.proShowName; // 商品名称 param["commodityUnitPrice"] = AlipayConfig.MoneyFormatEco(upa.price); // 商品单价,分为单位 param["commodityQuantity"] = upa.count; // 商品数量 param["orderNumber"] = upa.orderNumber; // 订单号,必须唯一 param["orderAmount"] = AlipayConfig.MoneyFormatEco(upa.total); // 交易金额 param["orderCurrency"] = UPOPSrv.CURRENCY_CNY; // 币种 param["orderTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); // 交易时间 param["customerIp"] = ""; // 用户IP param["frontEndUrl"] = upa.returnUrl; // 前台回调URL param["backEndUrl"] = upa.notifyUrl; // 后台回调URL // 创建前台交易服务对象 FrontPaySrv srv = new FrontPaySrv(param); // 将前台交易服务对象产生的Html文档写入页面,从而引导用户浏览器重定向 writeEcoding = srv.Charset; // 指定输出编码 return(srv.CreateHtml()); }
public override string CreateUrl(ParameterInfo unionPay) { var info = unionPay as UnionPayParasInfo; if (info == null) { return(""); } UPOPSrv.LoadConf(HttpContext.Current.Server.MapPath("~/App_Data/xml/unionPay.config")); var paras = new Dictionary <string, string> { { "transType", "01" }, { "commodityUrl", Uri.EscapeUriString(info.ProductUrl) }, { "commodityName", info.ProductName }, { "commodityUnitPrice", info.UnitPrice.ToString() }, { "orderNumber", info.OrderNum }, { "orderAmount", (Math.Round(info.Amount, 2) * 100).ToString("F0") }, { "orderCurrency", info.Cur }, { "orderTime", DateTime.Now.ToString("yyyyMMddHHmmss") }, { "customerIp", Utils.GetRealIp() }, { "frontEndUrl", info.ReturnUrl }, { "backEndUrl", info.NotifyUrl } }; var srv = new FrontPaySrv(paras); return(srv.CreateHtml()); }
protected void Page_Load(object sender, EventArgs e) { double dMoney = double.Parse(Request.QueryString["m"].ToString()); double dFee = double.Parse(Request.QueryString["f"].ToString()); long NewPayNumber = -1; string ReturnDescription = ""; if (DAL.Procedures.P_GetNewPayNumber(_Site.ID, _User.ID, "UPOP", (dMoney - dFee), dFee, ref NewPayNumber, ref ReturnDescription) < 0) { PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName); return; } if ((NewPayNumber < 0) || (ReturnDescription != "")) { PF.GoError(ErrorNumber.Unknow, ReturnDescription, this.GetType().BaseType.FullName); return; } // **************演示前台交易的请求*********************** // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(Server.MapPath("~/App_Data/conf.xml.config")); // 使用Dictionary保存参数 System.Collections.Generic.Dictionary <string, string> param = new System.Collections.Generic.Dictionary <string, string>(); // 随机构造一个订单号(演示用) //Random rnd = new Random(); //string orderID = DateTime.Now.ToString("yyyyMMddHHmmss") + (rnd.Next(900) + 100).ToString().Trim(); // 填写参数 param["transType"] = UPOPSrv.TransType.CONSUME; // 交易类型,前台只支持CONSUME 和 PRE_AUTH param["commodityUrl"] = "http://emall.chinapay.com/product?name=商品"; // 商品URL param["commodityName"] = "帐户充值"; // 商品名称 param["commodityUnitPrice"] = (dMoney * 100).ToString(); // 商品单价,分为单位 param["commodityQuantity"] = "1"; // 商品数量 param["orderNumber"] = NewPayNumber.ToString(); // 订单号,必须唯一 param["orderAmount"] = (dMoney * 100 + dFee * 100).ToString(); // 交易金额 param["orderCurrency"] = UPOPSrv.CURRENCY_CNY; // 币种 param["orderTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); // 交易时间 param["customerIp"] = "172.17.136.34"; // 用户IP param["frontEndUrl"] = "http://219.143.228.243:81/Home/Room/OnlinePay/UnionPay/FrontRecieve.aspx"; // 前台回调URL // 后台回调URL(前台请求时可为空)used to recieve data from unionpay automatically, use this data as the primary source param["backEndUrl"] = ""; // 创建前台交易服务对象 FrontPaySrv srv = new FrontPaySrv(param); // 将前台交易服务对象产生的Html文档写入页面,从而引导用户浏览器重定向 Response.ContentEncoding = srv.Charset; // 指定输出编码 Response.Write(srv.CreateHtml()); // 写入页面 }
private string PayByUnion(string orderNo, decimal orderPrice) { UPOPSrv.LoadConf(UnionpayConfig.Path); Dictionary <string, string> param = new Dictionary <string, string>(); UnionpayConfigModel unionpayConfig = UnionpayConfig.GetParams(); //交易类型,前台只支持 CONSUME 和 PRE_AUTH param["transType"] = UPOPSrv.TransType.CONSUME; //商品URL param["commodityUrl"] = Common.ServiceUrl; //商品名称 string subject = unionpayConfig.CommodityName; //if (String.IsNullOrEmpty(subject)) subject = "订单 - " + orderNo; param["commodityName"] = subject; //商品单价(分为单位) param["commodityUnitPrice"] = (orderPrice * 100).ToString("F0"); //商品数量 param["commodityQuantity"] = "1"; //订单号(必须唯一) param["orderNumber"] = orderNo; //交易金额 param["orderAmount"] = param["commodityUnitPrice"]; //币种 param["orderCurrency"] = UPOPSrv.CURRENCY_CNY; //交易时间 param["orderTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); //用户IP param["customerIp"] = HttpContext.Request.UserHostAddress; //后台通知URL param["backEndUrl"] = "http://zaixian.abc.com.cn/PayNotice/NotifyUnion"; //前台返回URL param["frontEndUrl"] = "http://zaixian.abc.com.cn/PayNotice/NotifyUnion"; FrontPaySrv srv = new FrontPaySrv(param); return(srv.CreateHtml()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); //注册路由 RegisterRoutes(RouteTable.Routes); //去除不必要的ViewEnginee ViewEngines.Engines.RemoveAt(0); //Ioc var container = CreateUnityContainer(); DependencyResolver.SetResolver(new UnityDependencyResolver(container)); //注册银联配置 UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config")); }
/// <summary> /// 银联支付成功返回信息 post /// </summary> /// <param name="http">返回当前上下文状态</param> /// <returns></returns> public UPOPReturlPara UPOPCallBack(HttpContext http) { // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(configPath); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(http.Request.Form)); //订单编号 string orderNumber = resp.Fields["orderNumber"]; //订单支付金额 double payMoney = Math.Round(Convert.ToDouble(AlipayConfig.MoneyFormatDco(resp.Fields["orderAmount"].ToString())), 2); UPOPReturlPara upa = new UPOPReturlPara(); upa.isSuccessPay = (resp.ResponseCode == SrvResponse.RESP_SUCCESS) ? true : false; upa.orderNumber = orderNumber; upa.payMoney = payMoney; return(upa); }
/// <summary> /// 银联在线支付 /// </summary> void YinLian(Entity.DingDan info) { if (info != null) { //info.DanJia = (decimal)0.01; //info.DingDanJinE = (decimal)0.01; // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(HttpContext.Current.Server.MapPath("/App_Data/conf.xml.config")); // 使用Dictionary保存参数 System.Collections.Generic.Dictionary <string, string> param = new System.Collections.Generic.Dictionary <string, string>(); // 填写参数 param["transType"] = UPOPSrv.TransType.CONSUME; // 交易类型,前台只支持CONSUME 和 PRE_AUTH param["commodityUrl"] = "http://gaokao.gelunjiaoyu.com/Art/GouMai/ReturnUrl.aspx"; // 商品URL param["commodityName"] = "格伦高考报考网-“报考卡”"; // 商品名称 param["commodityUnitPrice"] = ((int)((info.DanJia) * 100)).ToString(); // 商品单价,分为单位 param["commodityQuantity"] = info.Count.ToString(); // 商品数量 param["orderNumber"] = info.DingDanHao; // 订单号,必须唯一 param["orderAmount"] = ((int)((info.DingDanJinE) * 100)).ToString(); // 交易金额 param["orderCurrency"] = UPOPSrv.CURRENCY_CNY; // 币种 param["orderTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); // 交易时间 param["customerIp"] = System.Web.HttpContext.Current.Request.UserHostAddress; // 用户IP param["frontEndUrl"] = "http://gaokao.gelunjiaoyu.com/Art/GouMai/YinLian/FontPay.aspx"; // 前台回调URL param["backEndUrl"] = "http://gaokao.gelunjiaoyu.com/Art/GouMai/YinLian/BackPay.aspx"; // 后台回调URL // 创建前台交易服务对象 FrontPaySrv srv = new FrontPaySrv(param); // 将前台交易服务对象产生的Html文档写入页面,从而引导用户浏览器重定向 Response.ContentEncoding = srv.Charset; // 指定输出编码 Response.Write(srv.CreateHtml()); // 写入页面 } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>artDialog11('该订单不存在...');return false;</script>"); return; } }
public override BaseResult VerifyCallBack(HttpRequest request) { var result = new UnionPayResult(); var coll = request.HttpMethod.ToLower() == "post" ? request.Form : request.QueryString; UPOPSrv.LoadConf(HttpContext.Current.Server.MapPath("~/App_Data/xml/unionPay.config")); var srv = new SrvResponse(Util.NameValueCollection2StrDict(coll)); if (srv.ResponseCode != SrvResponse.RESP_SUCCESS) { result.State = false; result.ErrMsg = "返回状态异常:" + srv.ResponseCode; return(result); } result.State = true; //金额,银联是以分为单位,故要除以100 result.Amount = Convert.ToInt32(srv.Fields["orderAmount"]) / 100M; result.TradeNum = srv.Fields["orderNumber"]; return(result); }
//后台回调页面 public string NotifyCallback_Back() { if (Request.HttpMethod == "POST") { // 要使用各种Srv必须先使用LoadConf载入配置 string url = Server.MapPath("/App_Data/conf.xml.config"); UPOPSrv.LoadConf(url); //拼接银联返回信息 Dictionary <string, string> dic = Util.NameValueCollection2StrDict(Request.Form); foreach (KeyValuePair <string, string> kvp in dic) { Console.WriteLine("key={0},value={1}", kvp.Key, kvp.Value); message += kvp.Key + ":" + kvp.Value + " | "; } SrvResponse resp = new SrvResponse(dic); //订单号 string orderNumber = resp.Fields["orderNumber"]; //订单交易状态 string respCode = resp.Fields["respCode"]; // int PayID = Convert.ToInt32(orderNumber.Replace(UnionConfig.UnionPayingPrefix, "")); //更新返回信息到数据库中 Entity.DingDan info = DAL.DingDan.DingDanEntityGetByDingDanHao(orderNumber); if (info != null) { //支付成功,且验证过了 if (info.State == 0) { switch (resp.ResponseCode) { case "00": //修改订单的状态为“已支付” info.State = 1; //00 支付成功 Basic.Email.sendMail("*****@*****.**", "艺术高考VIP卡购买付款成功", "订单号:" + info.DingDanHao + "<br />" + info.Body + "<br />联系电话:" + info.CellMobile); Basic.Email.sendMail("*****@*****.**", "艺术高考VIP卡购买付款成功", "订单号:" + info.DingDanHao + "<br />" + info.Body + "<br />联系电话:" + info.CellMobile); //TRADE_SUCCESS // 交易成功,且可对该交易做操作,如:多级分润、退款等。 if (DAL.GaoKaoCard.GaoKaoCardCount("DingDanHao = '" + info.DingDanHao + "'") < info.Count) { //分配高考卡,并发送短信 FenPeiGaoKaoCard.FenPeiCard(info, 1); } /*返回码200代表商铺已经成功收到并正确解析出后台的通知,其他的返回码则认为通知失败, * 返回给银联支付,若不返回此码,银联会重发通知,最多5次*/ Response.Write("200"); break; case "02": info.State = 2; //02 卡号无效 break; case "11": info.State = 3; //11 余额不足 break; default: info.State = 4; // 订单支付失败,请到您的订单列表中重新进行支付操作 break; } info.Memo = "艺考VIP卡_银联支付,返回的参数:" + message; DAL.DingDan.DingDanEdit(info); } else { // Basic.Email.sendMail("*****@*****.**", "银联支付", "又传过来一次了backpay"); } } } return(string.Empty); }
protected void Page_Load(object sender, EventArgs e) { //bool OnlinePay_Alipay_Status_ON = so["OnlinePay_Tenpay_Status_ON"].ToBoolean(false); Money = Shove._Convert.StrToDouble(Shove._Web.Utility.GetRequest("PayMoney"), 0); bankPay = Shove._Web.Utility.GetRequest("bankPay"); if (!IsPostBack) { //管理员和会员的充值的最低金额不一样 if (_User.Competences.CompetencesList.IndexOf(Competences.Administrator) > 0) { if (Money < 0.01) { Response.Write("<script type=\"text/javascript\">alert(\"请输入正确的充值金额!再提交,谢谢!\"); window.close();</script>"); return; } } else { if (Money < 1) { Response.Write("<script type=\"text/javascript\">alert(\"请输入正确的充值金额!再提交,谢谢!\"); window.close();</script>"); return; } } //Money = 0.01; //手续费用 double FormalitiesFeesScale = so["OnlinePay_ChinaUnion_CommissionScale"].ToDouble(0) / 100; double FormalitiesFees = Math.Round(Money * FormalitiesFeesScale, 2); //最后的充值额 Money += FormalitiesFees; //卖家商户号 bargainor_id = so["OnlinePay_ChinaUnion_UserName"].Value.ToString(); //卖家商户key key = so["OnlinePay_ChinaUnion_MD5"].Value.ToString(); //商品名称 desc = HttpUtility.UrlEncode("预付款", Encoding.GetEncoding("GBK")); //商品总金额,以分为单位(传过的是以元为单位). total_fee = long.Parse((Money * 100).ToString()); //买家帐号 purchaser_id = ""; //商户后台回调url return_url = Shove._Web.Utility.GetUrl() + "/Home/Room/OnlinePay/ChinaUnion/Receive.aspx"; //交易标识(用户ID+投注ID+充值方式编号) attach = Shove._Security.Encrypt.EncryptString(PF.GetCallCert(), _User.ID.ToString() + "|" + bankPay + "|" + Shove._Web.Utility.GetRequest("BuyID")); double PayMoney = Convert.ToDouble(Money.ToString()); long NewPayNumber = -1; string ReturnDescription = ""; //产生内部充值编号 if (DAL.Procedures.P_GetNewPayNumber(_Site.ID, _User.ID, "TENPAY_" + bankPay, (PayMoney - FormalitiesFees), FormalitiesFees, ref NewPayNumber, ref ReturnDescription) < 0) { PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName); return; } if ((NewPayNumber < 0) || (ReturnDescription != "")) { PF.GoError(ErrorNumber.Unknow, ReturnDescription, this.GetType().BaseType.FullName); return; } //商户订单号(内部充值编号) sp_billno = NewPayNumber.ToString(); //財付通交易号,需保证此订单号每天唯一,切不能重复! transaction_id = CreatePayNumber(NewPayNumber); //用户IP(暂停) spbill_create_ip = "";// Page.Request.UserHostAddress; #region 验证参数是否齐全 if (string.IsNullOrEmpty(bankPay) || string.IsNullOrEmpty(desc) || string.IsNullOrEmpty(bargainor_id) || string.IsNullOrEmpty(transaction_id) || string.IsNullOrEmpty(sp_billno) || string.IsNullOrEmpty(return_url) || string.IsNullOrEmpty(attach)) { Response.Write("<script type=\"text/javascript\">alert(\"参数不齐全,无法充值!\"); window.close();</script>"); return; } #endregion //string url = ""; //if (!GetPayUrl(out url)) //{ // Response.Write("<script type=\"text/javascript\">alert(\"" + url + "\"); window.close();</script>"); // return; //} //else //{ // this.Response.Write("<script language='javascript'>window.top.location.href='" + url + "'</script>"); //} UPOPSrv.LoadConf(Server.MapPath("conf.xml.config")); var srv = new FrontPaySrv(GenParams()); Response.ContentEncoding = srv.Charset; Response.Write(srv.CreateHtml()); } }
protected void Page_Load(object sender, EventArgs e) { // **************演示交易查询接口*********************** if (Request.HttpMethod == "POST") { // 要使用各种Srv必须先使用LoadConf载入配置 UPOPSrv.LoadConf(Server.MapPath("./App_Data/conf.xml.config")); //获取订单号和订单时间 string orderNumber = Request.Form["txtOrderID"]; DateTime orderTime = DateTime.Parse(Request.Form["txtOrderTime"]); // 使用Dictionary保存参数 System.Collections.Generic.Dictionary <string, string> param = new System.Collections.Generic.Dictionary <string, string>(); // 填写参数 param["transType"] = UPOPSrv.TransType.CONSUME; param["orderNumber"] = orderNumber; param["orderTime"] = orderTime.ToString("yyyyMMddHHmmss"); // 创建后台交查询务对象 QuerySrv srv = new QuerySrv(param); // 请求查询服务,得到SrvResponse回应对象 SrvResponse resp = srv.Request(); Response.Write("<h1>"); string queryStat = ""; if (resp.ResponseCode == SrvResponse.RESP_SUCCESS) { switch (resp.Fields["queryResult"].Trim()) // 根据queryResult字段来判断交易状态 { case QuerySrv.QUERY_SUCCESS: queryStat = "交易成功"; break; case QuerySrv.QUERY_WAIT: queryStat = "交易正在进行中"; break; default: queryStat = "未知状态"; break; } } else // respCode 不为 RESP_SUCCESS 时,则可能是交易失败,也可能是本次查询请求出错 { // queryResult == QUERY_FAIL 时,代表交易失败。此时ResponseCode表示失败原因 if (resp.HasField("queryResult") && resp.Fields["queryResult"].Trim() == QuerySrv.QUERY_FAIL) { queryStat = string.Format("交易失败 <h3>ErrorCode=[{0}]</h3>", resp.ResponseCode); } else // 否则则为本次查询请求出错 { string msg = resp.HasField("respMsg") ? resp.Fields["respMsg"] : ""; Response.Write(String.Format("Error [{0}] : {1} ", resp.Fields["respCode"], msg)); } } if (queryStat != "") { Response.Write("交易状态:" + queryStat); } Response.Write("</h1><br/>"); Response.Write("post string:" + resp.OrigPostString); } }
/// <summary> /// 实例化,默认UinonPay.config /// </summary> public Submit() { UPOPSrv.LoadConf(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UinonPay.config")); }
protected void Page_Load(object sender, EventArgs e) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("/unionpay/notify_data.txt")); sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); sw.Close(); // 要使用各种Srv必须先使用LoadConf载入配置 string strConfigPath = EyouSoft.Toolkit.ConfigHelper.ConfigClass.GetConfigString("UnionpayConfigFilepath"); UPOPSrv.LoadConf(Server.MapPath(strConfigPath)); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); #region 取得返回参数 string respCode = resp.Fields["respCode"]; string merId = resp.Fields["merId"]; string orderAmount = resp.Fields["orderAmount"]; string orderNumber = resp.Fields["orderNumber"]; string qid = resp.Fields["qid"]; string respTime = resp.Fields["respTime"]; string version = resp.Fields["version"]; string strOrderID = orderNumber.Substring(15, orderNumber.Length - 15); string strOrderTpye = orderNumber.Substring(14, 1); var dingDanLeiXing = (EyouSoft.Model.EnumType.YlStructure.DingDanLeiXing)Convert.ToInt32(strOrderTpye); string dingDanId = string.Empty; if (dingDanLeiXing == EyouSoft.Model.EnumType.YlStructure.DingDanLeiXing.兑换订单) { dingDanId = new EyouSoft.BLL.YlStructure.BDuiHuan().GetDingDanId(Utils.GetInt(strOrderID)); } else if (dingDanLeiXing == EyouSoft.Model.EnumType.YlStructure.DingDanLeiXing.航期订单) { dingDanId = new EyouSoft.BLL.YlStructure.BHangQiDingDan().GetDingDanId(Utils.GetInt(strOrderID)); } #endregion // 收到回应后做后续处理 string strMsg = "支付失败!"; if (resp.ResponseCode == SrvResponse.RESP_SUCCESS) { var info = new EyouSoft.Model.YlStructure.MZaiXianZhiFuInfo(); //在线支付实体 var onlinepay = new EyouSoft.BLL.YlStructure.BZaiXianZhiFu(); //在线支付BLL info.DingDanId = dingDanId; //订单ID info.DingDanLeiXing = dingDanLeiXing; //订单类型 bool ispay = onlinepay.IsZhiFu(info.DingDanId, info.DingDanLeiXing); //获取订单支付状态(成功/失败) if (!ispay) { info.JiaoYiHao = orderNumber; //流水号 info.ApiJiaoYiHao = qid; //支付流水号 info.JinE = Utils.GetDecimal(orderAmount); //支付金额 info.ZhiFuFangShi = EyouSoft.Model.EnumType.YlStructure.ZaiXianZhiFuFangShi.Unionpay; //支付方式 info.IsZhiFu = true; //是否已支付 info.ZhiFuTime = DateTime.Now; //支付时间 int bllRetCode = onlinepay.Insert(info); //添加支付记录 if (bllRetCode == 1) { //实现其它操作处理 switch (info.DingDanLeiXing) { case EyouSoft.Model.EnumType.YlStructure.DingDanLeiXing.兑换订单: HandlerJiFenDingDan(info.DingDanId); break; case EyouSoft.Model.EnumType.YlStructure.DingDanLeiXing.航期订单: HandlerHangQiDingDan(info.DingDanId); break; } } } strMsg = "支付成功"; } //支付接口回调通知 Response.Write(strMsg); Response.End(); }
/// <summary> /// 实例化 /// </summary> /// <param name="configPath">配置文件全路径</param> public Submit(string configPath) { UPOPSrv.LoadConf(configPath); }
/// <summary> /// 实例化 /// </summary> /// <param name="key">key</param> /// <param name="partner">partnetid</param> /// <param name="chairtyName">账户名称</param> public Submit(string key, string partner, string chairtyName) { var stream = new Config().SetConfig(key, partner, chairtyName); UPOPSrv.LoadConf(stream); }
//前台回调页面 public string NotifyCallback_Front() { if (Request.HttpMethod == "POST") { // 要使用各种Srv必须先使用LoadConf载入配置 string url = Server.MapPath("/App_Data/conf.xml.config"); UPOPSrv.LoadConf(url); //拼接银联返回信息 Dictionary <string, string> dic = Util.NameValueCollection2StrDict(Request.Form); foreach (KeyValuePair <string, string> kvp in dic) { Console.WriteLine("key={0},value={1}", kvp.Key, kvp.Value); message += kvp.Key + ":" + kvp.Value + " | "; } SrvResponse resp = new SrvResponse(dic); //订单号 string orderNumber = resp.Fields["orderNumber"]; //订单交易状态 string respCode = resp.Fields["respCode"]; // int PayID = Convert.ToInt32(orderNumber.Replace(UnionConfig.UnionPayingPrefix, "")); //更新返回信息到数据库中 Entity.DingDan info = DAL.tengxb.dingdan.DingDanEntityGet(orderNumber); if (info != null) { //支付成功,且验证过了 if (info.State == 0) { switch (resp.ResponseCode) { case SrvResponse.RESP_SUCCESS: { try { //string orderNumber = resp.Fields["orderNumber"]; //int PayID = Convert.ToInt32(orderNumber.Substring(14, orderNumber.Length - 14)); //修改订单的状态为“已支付” info.State = 1; //00 支付成功 //TRADE_SUCCESS // 交易成功,且可对该交易做操作,如:多级分润、退款等。 if (DAL.GaoKaoCard.GaoKaoCardCount("DingDanHao = '" + info.DingDanHao + "'") < info.Count) { //分配高考卡,并发送短信 FenPeiGaoKaoCard.FenPeiCard(info); //展示卡号 DataTable dt = DAL.GaoKaoCard.GaoKaoCardList("DingDanHao = '" + info.DingDanHao + "'"); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { strCardList += "<p>账号:" + dt.Rows[i]["KaHao"].ToString() + " 密码:" + dt.Rows[i]["MiMa"].ToString() + "</p>"; } } } else { //展示卡号 DataTable dt = DAL.GaoKaoCard.GaoKaoCardList("DingDanHao = '" + info.DingDanHao + "'"); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { strCardList += "<p>账号:" + dt.Rows[i]["KaHao"].ToString() + " 密码:" + dt.Rows[i]["MiMa"].ToString() + "</p>"; } } } /*返回码200代表商铺已经成功收到并正确解析出后台的通知,其他的返回码则认为通知失败, * 返回给银联支付,若不返回此码,银联会重发通知,最多5次*/ //Response.Write("200"); } catch { } finally { Basic.Email.sendMail("*****@*****.**", "高考报考卡购买付款成功", "订单号:" + info.DingDanHao + "<br />" + info.Body + "<br />联系电话:" + info.CellMobile + "<br />" + strCardList); Basic.Email.sendMail("*****@*****.**", "高考报考卡购买付款成功", "订单号:" + info.DingDanHao + "<br />" + info.Body + "<br />联系电话:" + info.CellMobile); } } break; case "02": info.State = 2; //02 卡号无效 break; case "11": info.State = 3; //11 余额不足 break; default: info.State = 4; //11 订单支付失败,请到您的订单列表中重新进行支付操作 break; } info.Memo = "高考报考卡_银联支付,返回的参数:" + message; DAL.DingDan.DingDanEdit(info); } else { //Basic.Email.sendMail("*****@*****.**", "银联支付", "又传过来一次了fontpay"); } strResult = info.State.ToString(); } } return(message); }
/// <summary> /// 初始化银联支付url /// </summary> /// <param name="dingDanId">订单编号</param> /// <param name="biaoTi">标题</param> /// <param name="miaoShu">描述</param> /// <param name="jinE">总金额</param> /// <param name="cpName">产品名称</param> /// <param name="cpUrl">产品URL</param> /// <param name="dingDanLeiXing">订单类型</param> /// <returns></returns> private string InitUnionpay(string dingDanId, string biaoTi, string miaoShu, decimal jinE, string cpName, string cpUrl, int dingDanLeiXing, int dingDanIdentityId) { string returnValue = string.Empty; if (jinE > 10000000) //支付金额不能超过10000000.00RMB { Response.Write("支付金额不能超过10000000.00"); Response.End(); } // 用户IP string ip = HttpContext.Current.Request.UserHostAddress; // 交易类型,前台只支持CONSUME 和 PRE_AUTH string strTransType = UPOPSrv.TransType.CONSUME; cpName = Regex.Replace(cpName, @"[~!@#\$%\^&\*\(\)\+=\|\\\}\]\{\[:“”,。!()‘’''"";<,>\?\/" + "\"]+", " "); // 商品单价,分为单位 string commodityUnitPrice = Convert.ToInt32(jinE * 100).ToString(); // 商品数量 string shuLiang = "1"; // 订单号,必须唯一 //string orderID = dingDanId + "_" + dingDanLeiXing; // 交易金额 string orderAmount = Convert.ToInt32(jinE * 100).ToString(); // 币种 string orderCurrency = UPOPSrv.CURRENCY_CNY; // 前台回调URL string returnUrl = "http://" + YuMingInfo.YuMing + EyouSoft.Toolkit.ConfigHelper.ConfigClass.GetConfigString("UnionpayReturnUrl"); // 后台回调URL(前台请求时可为空) string notifyUrl = "http://" + YuMingInfo.YuMing + EyouSoft.Toolkit.ConfigHelper.ConfigClass.GetConfigString("UnionpayNotifyUrl"); // 要使用各种Srv必须先使用LoadConf载入配置 string configFilepath = EyouSoft.Toolkit.ConfigHelper.ConfigClass.GetConfigString("UnionpayConfigFilepath"); UPOPSrv.LoadConf(Server.MapPath(configFilepath)); // 使用Dictionary保存参数 System.Collections.Generic.Dictionary <string, string> param = new System.Collections.Generic.Dictionary <string, string>(); // 订单号,必须唯一 string orderID1 = DateTime.Now.ToString("yyyyMMddHHmmss") + dingDanLeiXing.ToString() + dingDanIdentityId.ToString(); // 填写参数 param["transType"] = strTransType; param["commodityUrl"] = cpUrl; param["commodityName"] = cpName.Trim(); param["commodityUnitPrice"] = commodityUnitPrice; param["commodityQuantity"] = shuLiang; param["orderNumber"] = orderID1; param["orderAmount"] = orderAmount; param["orderCurrency"] = orderCurrency; // 交易时间 param["orderTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); param["customerIp"] = ip; param["frontEndUrl"] = returnUrl; param["backEndUrl"] = notifyUrl; // 创建前台交易服务对象 FrontPaySrv srv = new FrontPaySrv(param); // 将前台交易服务对象产生的Html文档写入页面,从而引导用户浏览器重定向 Response.ContentEncoding = srv.Charset; // 指定输出编码 returnValue = srv.CreateHtml(); return(returnValue); }