public void CallBack() { _log.Info("--start recieve notification--"); //UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config")); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); if (resp.ResponseCode == SrvResponse.RESP_SUCCESS) { var tradeNo = resp.Fields["orderNumber"]; var order = _uow.OrderService.Get(t => t.TradeNo == tradeNo); if (order == null) { return; } if (order.Status == (int)OrderState.Create) { OnAfterPay(order, resp); } } _log.Info("--notify success--"); }
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); }
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> /// 银联支付成功返回信息 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> /// 银联支付成功返回信息 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); }
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; }
/// <summary> /// 前台同步通知 /// </summary> /// <returns></returns> public ActionResult PayOk() { //UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config")); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); var tradeNo = resp.Fields["orderNumber"]; var order = _uow.OrderService.Get(t => t.TradeNo == tradeNo); if (order == null) { return(RedirectToAction("PayError")); } //if (order.Status == (int)OrderState.Create) //{ // OnAfterPay(order, resp); //} return(View(order)); }
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 override bool VerifyNotify(NameValueCollection form) { UPOPSrv.Config.securityKey = Config["unionpay_key"].Values.ToString(); try { // 使用Post过来的内容构造SrvResponse var resp = new SrvResponse(Util.NameValueCollection2StrDict(form)); if (resp.ResponseCode != SrvResponse.RESP_SUCCESS){ this.OnNotifyVerifyFaild(new PaymentOrder() { PaymentNo = resp.Fields["orderNumber"], Money = TrancMoney(resp.Fields["orderAmount"]), Description = "错误码[" + resp.Fields["respCode"] + "]" }); return false; } this.OnFinished(new PaymentOrder() { PaymentNo = resp.Fields["orderNumber"], Money = TrancMoney(resp.Fields["orderAmount"]),Description = "银联网银直连"}); return true; }catch(Exception ex) { Log.Error(ex); return false; } }
protected void Page_Load(object sender, EventArgs e) { try { string errmsg = ""; //卖家商户key key = so["OnlinePay_Tenpay_MD5Key"].Value.ToString(); //卖家商户号 bargainor_id = so["OnlinePay_Tenpay_UserNumber"].Value.ToString(); var resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); sp_billno = resp.Fields["orderNumber"]; transaction_id = resp.Fields["origQid"]; //判断签名及相关参数是否正确 if (true) { //认证签名成功 //支付判断 if (resp.ResponseCode == SrvResponse.RESP_SUCCESS) { //支付成功,同定单号md5pay.Transaction_id可能会多次通知,请务必注意判断订单是否重复的逻辑 //处理业务逻辑,处理db之类的 //errmsg = "支付成功"; //Response.Write(errmsg+"<br/>"); //Response.Write("财付通定单号:"+ md5pay.Transaction_id +"(请牢记定单号)"+"<br/>"); Users user; user = new Users(_Site.ID)[_Site.ID, userId]; if (user == null) { errmsg = "在线支付:异常用户数据!" + " 支付号:" + sp_billno; //new Log("System").Write(errmsg); Response.Write(errmsg + "<br/>"); return; } if (_User == null) { _User = new Users(_Site.ID)[_Site.ID, user.ID]; string ReturnDescription = ""; _User.LoginDirect(ref ReturnDescription); } WriteUserAccount("系统交易号:" + sp_billno + " 银联在线交易号:" + transaction_id); } else { //支付失败,请不要按成功处理 errmsg = "在线支付:验证出错!商户或者密串有误,错误代码:" + pay_result.ToString() + " 支付号:" + sp_billno; new Log("System").Write(errmsg); } } else { //认证签名失败 errmsg = "认证签名失败"; new Log("System").Write(errmsg); } } catch { //支付失败,请不要按成功处理 } }
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(); }
//后台回调页面 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); }
/// <summary> /// 支付成功的后续操作 /// </summary> private void OnAfterPay(Order order,SrvResponse resp) { var paylog = new PayLog(); paylog.OrderId = order.OrderId; paylog.TransactionId = resp.Fields["qid"]; paylog.UserId = order.UserId; paylog.PayWay = (int)PayWay.UnionPay; paylog.PayMoney = order.Total; paylog.PayUrl = resp.OrigPostString; paylog.BackUrl = Request.RawUrl; paylog.CreateTime = DateTime.Now; paylog.PayResult = "支付成功"; //如果支付失败 if (resp.ResponseCode != SrvResponse.RESP_SUCCESS) paylog.PayResult = "支付失败"; else { //账户操作 var acc = _uow.AccountService.Get(t => t.UserId == order.UserId); if (acc == null) { acc = new Account() { UserId = order.UserId, Amount = 0, IsStop = false, CreateTime = DateTime.Now, FrozenAmount = 0 }; //新增账户 _uow.AccountService.Add(acc); } //账户日志--充值 var acclog = new AccountLog(); acclog.UserId = order.UserId; acclog.OrderId = order.OrderId; acclog.Amount = order.Total; acclog.AccountWay = (int)AccountWay.In; acclog.Ip = Request.UserHostAddress; acclog.CreateTime = DateTime.Now; acclog.PayWay = (int)PayWay.UnionPay; _uow.AccountLogService.Add(acclog); //充值 acc.Amount += order.Total; //账户日志--扣款 var acclog2 = new AccountLog(); acclog2.UserId = order.UserId; acclog2.OrderId = order.OrderId; acclog2.Amount = order.Total; acclog2.AccountWay = (int)AccountWay.Out; acclog2.Ip = Request.UserHostAddress; acclog2.CreateTime = DateTime.Now; acclog2.PayWay = (int)PayWay.UnionPay; _uow.AccountLogService.Add(acclog2); //修改账户余额 acc.Amount -= order.Total; acc.UpdateTime = DateTime.Now; //写支付日志 _uow.PayLogService.Add(paylog); //修改订单状态 order.Status = (int)OrderState.Paid; order.UpdateTime = DateTime.Now; order.PayTime = DateTime.Now; } _uow.Commit(); }
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> /// 前台同步通知 /// </summary> /// <returns></returns> public ActionResult PayOk() { //UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config")); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); var tradeNo = resp.Fields["orderNumber"]; var order = _uow.OrderService.Get(t => t.TradeNo == tradeNo); if (order == null) return RedirectToAction("PayError"); //if (order.Status == (int)OrderState.Create) //{ // OnAfterPay(order, resp); //} return View(order); }
public void CallBack() { _log.Info("--start recieve notification--"); //UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config")); // 使用Post过来的内容构造SrvResponse SrvResponse resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); if (resp.ResponseCode == SrvResponse.RESP_SUCCESS) { var tradeNo = resp.Fields["orderNumber"]; var order = _uow.OrderService.Get(t => t.TradeNo == tradeNo); if (order == null) return; if (order.Status == (int)OrderState.Create) { OnAfterPay(order, resp); } } _log.Info("--notify success--"); }
/// <summary> /// 支付成功的后续操作 /// </summary> private void OnAfterPay(Order order, SrvResponse resp) { var paylog = new PayLog(); paylog.OrderId = order.OrderId; paylog.TransactionId = resp.Fields["qid"]; paylog.UserId = order.UserId; paylog.PayWay = (int)PayWay.UnionPay; paylog.PayMoney = order.Total; paylog.PayUrl = resp.OrigPostString; paylog.BackUrl = Request.RawUrl; paylog.CreateTime = DateTime.Now; paylog.PayResult = "支付成功"; //如果支付失败 if (resp.ResponseCode != SrvResponse.RESP_SUCCESS) { paylog.PayResult = "支付失败"; } else { //账户操作 var acc = _uow.AccountService.Get(t => t.UserId == order.UserId); if (acc == null) { acc = new Account() { UserId = order.UserId, Amount = 0, IsStop = false, CreateTime = DateTime.Now, FrozenAmount = 0 }; //新增账户 _uow.AccountService.Add(acc); } //账户日志--充值 var acclog = new AccountLog(); acclog.UserId = order.UserId; acclog.OrderId = order.OrderId; acclog.Amount = order.Total; acclog.AccountWay = (int)AccountWay.In; acclog.Ip = Request.UserHostAddress; acclog.CreateTime = DateTime.Now; acclog.PayWay = (int)PayWay.UnionPay; _uow.AccountLogService.Add(acclog); //充值 acc.Amount += order.Total; //账户日志--扣款 var acclog2 = new AccountLog(); acclog2.UserId = order.UserId; acclog2.OrderId = order.OrderId; acclog2.Amount = order.Total; acclog2.AccountWay = (int)AccountWay.Out; acclog2.Ip = Request.UserHostAddress; acclog2.CreateTime = DateTime.Now; acclog2.PayWay = (int)PayWay.UnionPay; _uow.AccountLogService.Add(acclog2); //修改账户余额 acc.Amount -= order.Total; acc.UpdateTime = DateTime.Now; //写支付日志 _uow.PayLogService.Add(paylog); //修改订单状态 order.Status = (int)OrderState.Paid; order.UpdateTime = DateTime.Now; order.PayTime = DateTime.Now; } _uow.Commit(); }
//前台回调页面 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); }
protected void Page_Load(object sender, EventArgs e) { try { string errmsg = ""; //卖家商户key key = so["OnlinePay_Tenpay_MD5Key"].Value.ToString(); //卖家商户号 bargainor_id = so["OnlinePay_Tenpay_UserNumber"].Value.ToString(); var resp = new SrvResponse(Util.NameValueCollection2StrDict(Request.Form)); sp_billno = resp.Fields["orderNumber"]; transaction_id = resp.Fields["origQid"]; //判断签名及相关参数是否正确 if (true) { //认证签名成功 //支付判断 if (resp.ResponseCode == SrvResponse.RESP_SUCCESS) { //支付成功,同定单号md5pay.Transaction_id可能会多次通知,请务必注意判断订单是否重复的逻辑 //处理业务逻辑,处理db之类的 //errmsg = "支付成功"; //Response.Write(errmsg+"<br/>"); //Response.Write("财付通定单号:"+ md5pay.Transaction_id +"(请牢记定单号)"+"<br/>"); Users user; user = new Users(_Site.ID)[_Site.ID, userId]; if (user == null) { errmsg = "在线支付:异常用户数据!" + " 支付号:" + sp_billno; //new Log("System").Write(errmsg); Response.Write(errmsg + "<br/>"); return; } if (_User == null) { _User = new Users(_Site.ID)[_Site.ID, user.ID]; string ReturnDescription = ""; _User.LoginDirect(ref ReturnDescription); } WriteUserAccount("系统交易号:" + sp_billno + " 银联在线交易号:" + transaction_id); } else { //支付失败,请不要按成功处理 errmsg = "在线支付:验证出错!商户或者密串有误,错误代码:" + pay_result.ToString() + " 支付号:" + sp_billno; new Log("System").Write(errmsg); } } else { //认证签名失败 errmsg = "认证签名失败"; new Log("System").Write(errmsg); } } catch { //支付失败,请不要按成功处理 } }