protected string AliPayOrder() { string id = Utils.GetQueryStringValue("ids"); if (!string.IsNullOrEmpty(id)) { Eyousoft_yhq.BLL.Order OrderBll = new Eyousoft_yhq.BLL.Order(); Eyousoft_yhq.Model.Order OrderModel = OrderBll.GetModel(id); if(OrderModel!=null) { if (OrderModel.OrderState ==Eyousoft_yhq.Model.OrderState.待付款) { if (OrderModel.PayState ==Eyousoft_yhq.Model.PaymentState.未支付) { return UtilsCommons.AjaxReturnJson("1", "支付跳转中....."); } else { return UtilsCommons.AjaxReturnJson("2", "订单已经支付无需重复支付"); } } else { return UtilsCommons.AjaxReturnJson("2", "订单正在审核当中或已经完成支付请到订单中心查看"); } } else { return UtilsCommons.AjaxReturnJson("2", "订单不存在,请重新选择!"); } } else { return UtilsCommons.AjaxReturnJson("2", "订单不存在,请重新选择!"); } }
protected void InitBind(string orid) { Eyousoft_yhq.BLL.Order OrderBll = new Eyousoft_yhq.BLL.Order(); if (!string.IsNullOrEmpty(orid)) { Eyousoft_yhq.Model.Order OrderModel = OrderBll.GetModel(orid); if (OrderModel != null) { ProtudId = OrderModel.ProductID; lbName.Text = OrderModel.ProductName; lbSum.Text = OrderModel.PeopleNum.ToString(); lbPrice.Text = Convert.ToDecimal(OrderModel.OrderPrice / OrderModel.PeopleNum).ToString("C0"); lbOderPrice.Text = (OrderModel.OrderPrice).ToString("C0"); lbOderPrice2.Text = (OrderModel.OrderPrice).ToString("C0"); } } }
protected void InitBind(string orid) { Eyousoft_yhq.BLL.Order OrderBll = new Eyousoft_yhq.BLL.Order(); if (!string.IsNullOrEmpty(orid)) { Eyousoft_yhq.Model.Order OrderModel = OrderBll.GetModel(orid); if (OrderModel != null) { ProtudId = OrderModel.ProductID; lbName.Text = OrderModel.ProductName; lbSum.Text = OrderModel.PeopleNum.ToString(); lbPrice.Text = Convert.ToDecimal(OrderModel.OrderPrice / OrderModel.PeopleNum).ToString("C0"); lbOderPrice.Text = (OrderModel.OrderPrice).ToString("C0"); lbOderPrice2.Text = (OrderModel.OrderPrice).ToString("C0"); } } }
protected string AliPayOrder() { string id = Utils.GetQueryStringValue("ids"); if (!string.IsNullOrEmpty(id)) { Eyousoft_yhq.BLL.Order OrderBll = new Eyousoft_yhq.BLL.Order(); Eyousoft_yhq.Model.Order OrderModel = OrderBll.GetModel(id); if (OrderModel != null) { if (OrderModel.OrderState == Eyousoft_yhq.Model.OrderState.待付款) { if (OrderModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { return(UtilsCommons.AjaxReturnJson("1", "支付跳转中.....")); } else { return(UtilsCommons.AjaxReturnJson("2", "订单已经支付无需重复支付")); } } else { return(UtilsCommons.AjaxReturnJson("2", "订单正在审核当中或已经完成支付请到订单中心查看")); } } else { return(UtilsCommons.AjaxReturnJson("2", "订单不存在,请重新选择!")); } } else { return(UtilsCommons.AjaxReturnJson("2", "订单不存在,请重新选择!")); } }
protected void Page_Load(object sender, EventArgs e) { #region 订单信息 string tmpOrderId = Request.QueryString["OrderId"]; Eyousoft_yhq.BLL.Order OrderInfo = new Eyousoft_yhq.BLL.Order(); Eyousoft_yhq.Model.Order OrderModel = null; if (!string.IsNullOrEmpty(tmpOrderId)) { OrderModel = OrderInfo.GetModel(tmpOrderId); if (OrderModel != null) { if (OrderModel.OrderPrice <= 0) { Response.Write("支付金额必须大于0才能支付!"); Response.End(); } else if (OrderModel.OrderState != Eyousoft_yhq.Model.OrderState.待付款) { Response.Write("订单状态不符合请稍候支付"); Response.End(); } else if (OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.未支付) { Response.Write("订单已支付"); Response.End(); } } } else { Response.Write("订单错误"); Response.End(); } #endregion #region 手机支付宝 支付 //支付宝网关地址 string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?"; ////////////////////////////////////////////调用授权接口alipay.wap.trade.create.direct获取授权码token//////////////////////////////////////////// //返回格式 string format = "xml"; //必填,不需要修改 //返回格式 string v = "2.0"; //必填,不需要修改 //请求号 string req_id = DateTime.Now.ToString("yyyyMMddHHmmss"); //必填,须保证每次请求都是唯一 //req_data详细信息 //服务器异步通知页面路径 string notify_url = AlipayLibrary.Config.GetConfigString("Alipay", "app_notify_url");// "http://www.xxx.com/Alipay/notify_url.aspx"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 string call_back_url = AlipayLibrary.Config.GetConfigString("Alipay", "app_callback_url");// "http://127.0.0.1:64704/Alipay/call_back_url.aspx"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 string merchant_url = AlipayLibrary.Config.GetConfigString("Alipay", "app_return_url"); //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 #region 订单信息|卖家帐号 //卖家支付宝帐户 string seller_email = AlipayLibrary.Config.GetConfigString("appSettings", "AlipayAccount"); //必填 //商户订单号 string out_trade_no = OrderModel.OrderID; //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = "产品名称:" + OrderModel.ProductName; //必填 //付款金额 string total_fee = OrderModel.OrderPrice.ToString(); //必填 #endregion //请求业务参数详细 string req_dataToken = "<direct_trade_create_req><notify_url>" + notify_url + "</notify_url><call_back_url>" + call_back_url + "</call_back_url><seller_account_name>" + seller_email + "</seller_account_name><out_trade_no>" + out_trade_no + "</out_trade_no><subject>" + subject + "</subject><total_fee>" + total_fee + "</total_fee><merchant_url>" + merchant_url + "</merchant_url></direct_trade_create_req>"; //必填 //把请求参数打包成数组 Dictionary <string, string> sParaTempToken = new Dictionary <string, string>(); sParaTempToken.Add("partner", Config.Partner); sParaTempToken.Add("_input_charset", Config.Input_charset.ToLower()); sParaTempToken.Add("sec_id", Config.Sign_type.ToUpper()); sParaTempToken.Add("service", "alipay.wap.trade.create.direct"); sParaTempToken.Add("format", format); sParaTempToken.Add("v", v); sParaTempToken.Add("req_id", req_id); sParaTempToken.Add("req_data", req_dataToken); //建立请求 string sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken); //URLDECODE返回的信息 Encoding code = Encoding.GetEncoding(Config.Input_charset); sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code); //解析远程模拟提交后返回的信息 Dictionary <string, string> dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken); //获取token string request_token = dicHtmlTextToken["request_token"]; ////////////////////////////////////////////根据授权码token调用交易接口alipay.wap.auth.authAndExecute//////////////////////////////////////////// //业务详细 string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>"; //必填 //把请求参数打包成数组 Dictionary <string, string> sParaTemp = new Dictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("sec_id", Config.Sign_type.ToUpper()); sParaTemp.Add("service", "alipay.wap.auth.authAndExecute"); sParaTemp.Add("format", format); sParaTemp.Add("v", v); sParaTemp.Add("req_data", req_data); //建立请求 string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认"); Response.Write(sHtmlText); #endregion }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.QueryString["out_trade_no"]; //支付宝交易号 string trade_no = Request.QueryString["trade_no"]; //交易状态 string trade_status = Request.QueryString["trade_status"]; Eyousoft_yhq.BLL.Order OrderType = new Eyousoft_yhq.BLL.Order(); var OrderModel = new Eyousoft_yhq.Model.Order(); string res = string.Empty; if (trade_status == "TRADE_FINISHED") { } else if (Request.QueryString["trade_status"] == "TRADE_SUCCESS") { OrderModel = OrderType.GetModel(out_trade_no); if (OrderModel != null && OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.已支付) { Eyousoft_yhq.Model.MConDetaile jilu = new Eyousoft_yhq.Model.MConDetaile() { HuiYuanID = OrderModel.MemberID, XFway = Eyousoft_yhq.Model.XFfangshi.消费, DingDanBianHao = OrderModel.OrderCode, JiaoYiHao = DateTime.Now.ToString("yyyyMMddHHmm") + Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(5), JiaoYiShiJian = DateTime.Now, DDCarrtes = Eyousoft_yhq.Model.DDleibie.旅游订单, JinE = OrderModel.OrderPrice }; new Eyousoft_yhq.BLL.BConDetaile().Add(jilu);//消费记录 string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderType.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } Eyousoft_yhq.Model.Order OrderInfo = new Eyousoft_yhq.Model.Order() { OrderID = out_trade_no, PayState = Eyousoft_yhq.Model.PaymentState.已支付, ConfirmCode = Ra, OrderState = Eyousoft_yhq.Model.OrderState.已成交 }; int Sum = OrderType.UpdatePayState(OrderInfo); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList <Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); code = string.Format("下单成功,确认码:{0}!【惠旅游】", Ra); Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out res);//发送 #endregion #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = res }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion } } } var chongzhiModel = new Eyousoft_yhq.BLL.BChongZhi().GetModel(out_trade_no); if (chongzhiModel != null && chongzhiModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { var member = new Eyousoft_yhq.BLL.Member().GetModel(chongzhiModel.OperatorID); if (member != null) { member.YuE = member.YuE + chongzhiModel.OptMoney; bool result = new Eyousoft_yhq.BLL.Member().Update(member); } new Eyousoft_yhq.BLL.BChongZhi().SheZhiZhiFus(out_trade_no, Eyousoft_yhq.Model.PaymentState.已支付); } } else { } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— Response.Write("success"); //请不要修改或删除 Response.Redirect("/Huiyuan/OrderList.aspx"); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary<string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.QueryString["out_trade_no"]; //支付宝交易号 string trade_no = Request.QueryString["trade_no"]; //交易状态 string trade_status = Request.QueryString["trade_status"]; Eyousoft_yhq.BLL.Order OrderType = new Eyousoft_yhq.BLL.Order(); var OrderModel = new Eyousoft_yhq.Model.Order(); string res = string.Empty; if (trade_status == "TRADE_FINISHED") { } else if (Request.QueryString["trade_status"] == "TRADE_SUCCESS") { OrderModel = OrderType.GetModel(out_trade_no); if (OrderModel != null && OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.已支付) { Eyousoft_yhq.Model.MConDetaile jilu = new Eyousoft_yhq.Model.MConDetaile() { HuiYuanID = OrderModel.MemberID, XFway = Eyousoft_yhq.Model.XFfangshi.消费, DingDanBianHao = OrderModel.OrderCode, JiaoYiHao = DateTime.Now.ToString("yyyyMMddHHmm") + Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(5), JiaoYiShiJian = DateTime.Now, DDCarrtes = Eyousoft_yhq.Model.DDleibie.旅游订单, JinE = OrderModel.OrderPrice }; new Eyousoft_yhq.BLL.BConDetaile().Add(jilu);//消费记录 string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderType.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } Eyousoft_yhq.Model.Order OrderInfo = new Eyousoft_yhq.Model.Order() { OrderID = out_trade_no, PayState = Eyousoft_yhq.Model.PaymentState.已支付, ConfirmCode = Ra, OrderState = Eyousoft_yhq.Model.OrderState.已成交 }; int Sum = OrderType.UpdatePayState(OrderInfo); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList<Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); code = string.Format("下单成功,确认码:{0}!【惠旅游】", Ra); Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out res);//发送 #endregion #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = res }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion } } } var chongzhiModel = new Eyousoft_yhq.BLL.BChongZhi().GetModel(out_trade_no); if (chongzhiModel != null && chongzhiModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { var member = new Eyousoft_yhq.BLL.Member().GetModel(chongzhiModel.OperatorID); if (member != null) { member.YuE = member.YuE + chongzhiModel.OptMoney; bool result = new Eyousoft_yhq.BLL.Member().Update(member); } new Eyousoft_yhq.BLL.BChongZhi().SheZhiZhiFus(out_trade_no, Eyousoft_yhq.Model.PaymentState.已支付); } } else { } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— Response.Write("success"); //请不要修改或删除 Response.Redirect("/Huiyuan/OrderList.aspx"); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { Dictionary <string, string> sPara = GetRequestGet(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.VerifyReturn(sPara, Request.QueryString["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 //商户订单号 string out_trade_no = Request.QueryString["out_trade_no"]; //支付宝交易号 string trade_no = Request.QueryString["trade_no"]; //交易状态 string result = Request.QueryString["result"]; Eyousoft_yhq.BLL.Order OrderType = new Eyousoft_yhq.BLL.Order(); var OrderModel = new Eyousoft_yhq.Model.Order(); string res = string.Empty; if (result == "success") { //纪录充值消费纪录 try { string price = Request.QueryString["price"]; Eyousoft_yhq.BLL.BConDetaile service = new Eyousoft_yhq.BLL.BConDetaile(); Eyousoft_yhq.Model.MConDetaile con = new Eyousoft_yhq.Model.MConDetaile(); con.JiaoYiHao = trade_no; con.DingDanBianHao = out_trade_no; con.JinE = Decimal.Parse(price); con.JiaoYiShiJian = DateTime.Now; con.XFway = Eyousoft_yhq.Model.XFfangshi.消费; EyouSoft.Model.SSOStructure.MUserInfo userInfo = Session["HuiYuanInfo"] as EyouSoft.Model.SSOStructure.MUserInfo; con.HuiYuanID = userInfo.UserID; service.Add(con); } catch (Exception) { } OrderModel = OrderType.GetModel(out_trade_no); if (OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.已支付) { string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderType.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } Eyousoft_yhq.Model.Order OrderInfo = new Eyousoft_yhq.Model.Order() { OrderID = out_trade_no, PayState = Eyousoft_yhq.Model.PaymentState.已支付, ConfirmCode = Ra, OrderState = Eyousoft_yhq.Model.OrderState.已成交 }; int Sum = OrderType.UpdatePayState(OrderInfo); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList <Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); //code = CreateZxingCode(Ra) + string.Format("下单成功,确认码:{0}!【惠旅游】", Ra);//生成二维码,发送彩信 Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out res);//发送 #endregion #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = res }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion } } } } Response.Redirect("/AppPage/orderlist.aspx"); //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("验证失败"); } } else { Response.Write("无返回参数"); } }
protected void Page_Load(object sender, EventArgs e) { Dictionary<string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.VerifyNotify(sPara, Request.Form["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //解密(如果是RSA签名需要解密,如果是MD5签名则下面一行清注释掉) sPara = aliNotify.Decrypt(sPara); //XML解析notify_data数据 try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sPara["notify_data"]); //商户订单号 string out_trade_no = xmlDoc.SelectSingleNode("/notify/out_trade_no").InnerText; //支付宝交易号 string trade_no = xmlDoc.SelectSingleNode("/notify/trade_no").InnerText; //交易状态 string trade_status = xmlDoc.SelectSingleNode("/notify/trade_status").InnerText; if (trade_status == "TRADE_FINISHED")//交易成功 { Response.Write("success"); } else if (trade_status == "TRADE_SUCCESS")//支付成功 { Eyousoft_yhq.BLL.Order OrderType = new Eyousoft_yhq.BLL.Order(); var OrderModel = new Eyousoft_yhq.Model.Order(); OrderModel = OrderType.GetModel(out_trade_no); string res = string.Empty; if (OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.已支付) { string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderType.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } Eyousoft_yhq.Model.Order OrderInfo = new Eyousoft_yhq.Model.Order() { OrderID = out_trade_no, PayState = Eyousoft_yhq.Model.PaymentState.已支付, ConfirmCode = Ra, OrderState = Eyousoft_yhq.Model.OrderState.已成交, JIESUAN = Eyousoft_yhq.Model.JSfangshi.预付 }; int Sum = OrderType.UpdatePayState(OrderInfo); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList<Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); code = string.Format("下单成功,确认码:{0}!【惠旅游】", Ra); Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out res);//发送 #endregion #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = res }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion } } } Response.Redirect("/AppPage/orderlist.aspx"); } else { Response.Write(trade_status); } } catch (Exception exc) { Response.Write(exc.ToString()); } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { Dictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.VerifyNotify(sPara, Request.Form["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //解密(如果是RSA签名需要解密,如果是MD5签名则下面一行清注释掉) sPara = aliNotify.Decrypt(sPara); //XML解析notify_data数据 try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sPara["notify_data"]); //商户订单号 string out_trade_no = xmlDoc.SelectSingleNode("/notify/out_trade_no").InnerText; //支付宝交易号 string trade_no = xmlDoc.SelectSingleNode("/notify/trade_no").InnerText; //交易状态 string trade_status = xmlDoc.SelectSingleNode("/notify/trade_status").InnerText; if (trade_status == "TRADE_FINISHED")//交易成功 { Response.Write("success"); } else if (trade_status == "TRADE_SUCCESS")//支付成功 { Eyousoft_yhq.BLL.Order OrderType = new Eyousoft_yhq.BLL.Order(); var OrderModel = new Eyousoft_yhq.Model.Order(); OrderModel = OrderType.GetModel(out_trade_no); string res = string.Empty; if (OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.已支付) { string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderType.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } Eyousoft_yhq.Model.Order OrderInfo = new Eyousoft_yhq.Model.Order() { OrderID = out_trade_no, PayState = Eyousoft_yhq.Model.PaymentState.已支付, ConfirmCode = Ra, OrderState = Eyousoft_yhq.Model.OrderState.已成交, JIESUAN = Eyousoft_yhq.Model.JSfangshi.预付 }; int Sum = OrderType.UpdatePayState(OrderInfo); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList <Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); code = string.Format("下单成功,确认码:{0}!【惠旅游】", Ra); Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out res);//发送 #endregion #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = res }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion } } } Response.Redirect("/AppPage/orderlist.aspx"); } else { Response.Write(trade_status); } } catch (Exception exc) { Response.Write(exc.ToString()); } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.Form["out_trade_no"]; //支付宝交易号 string trade_no = Request.Form["trade_no"]; //交易状态 string trade_status = Request.Form["trade_status"]; if (Request.Form["trade_status"] == "TRADE_FINISHED") { Response.Write("success"); } else if (Request.Form["trade_status"] == "TRADE_SUCCESS") { var OrderModel = new Eyousoft_yhq.Model.Order(); var OrderBll = new Eyousoft_yhq.BLL.Order(); OrderModel = OrderBll.GetModel(out_trade_no); if (OrderModel != null && OrderModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { string result = string.Empty; string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderBll.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } OrderModel.OrderID = out_trade_no; OrderModel.PayState = Eyousoft_yhq.Model.PaymentState.已支付; OrderModel.OrderState = Eyousoft_yhq.Model.OrderState.已成交; OrderModel.ConfirmCode = Ra; int Sum = OrderBll.UpdatePayState(OrderModel); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList <Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); code = string.Format("下单成功,确认码:{0}!【惠旅游】", Ra); Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out result);//发送 #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = result }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion #endregion } } } var chongzhiModel = new Eyousoft_yhq.BLL.BChongZhi().GetModel(out_trade_no); if (chongzhiModel != null && chongzhiModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { var member = new Eyousoft_yhq.BLL.Member().GetModel(chongzhiModel.OperatorID); if (member != null) { member.YuE = member.YuE + chongzhiModel.OptMoney; bool result = new Eyousoft_yhq.BLL.Member().Update(member); } new Eyousoft_yhq.BLL.BChongZhi().SheZhiZhiFus(out_trade_no, Eyousoft_yhq.Model.PaymentState.已支付); } } else { } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— Response.Write("success"); //请不要修改或删除 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { #region 订单信息 string tmpOrderId = Request.QueryString["OrderId"]; Eyousoft_yhq.BLL.Order OrderInfo = new Eyousoft_yhq.BLL.Order(); Eyousoft_yhq.Model.Order OrderModel = null; if (!string.IsNullOrEmpty(tmpOrderId)) { OrderModel = OrderInfo.GetModel(tmpOrderId); if (OrderModel != null) { if (OrderModel.OrderPrice <= 0) { Response.Write("支付金额必须大于0才能支付!"); Response.End(); } else if (OrderModel.OrderState != Eyousoft_yhq.Model.OrderState.待付款) { Response.Write("订单状态不符合请稍候支付"); Response.End(); } else if (OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.未支付) { Response.Write("订单已支付"); Response.End(); } } } else { Response.Write("订单错误"); Response.End(); } #endregion #region 手机支付宝 支付 //支付宝网关地址 string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?"; ////////////////////////////////////////////调用授权接口alipay.wap.trade.create.direct获取授权码token//////////////////////////////////////////// //返回格式 string format = "xml"; //必填,不需要修改 //返回格式 string v = "2.0"; //必填,不需要修改 //请求号 string req_id = DateTime.Now.ToString("yyyyMMddHHmmss"); //必填,须保证每次请求都是唯一 //req_data详细信息 //服务器异步通知页面路径 string notify_url = AlipayLibrary.Config.GetConfigString("Alipay", "app_notify_url");// "http://www.xxx.com/Alipay/notify_url.aspx"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 string call_back_url = AlipayLibrary.Config.GetConfigString("Alipay", "app_callback_url");// "http://127.0.0.1:64704/Alipay/call_back_url.aspx"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 string merchant_url = AlipayLibrary.Config.GetConfigString("Alipay", "app_return_url"); //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 #region 订单信息|卖家帐号 //卖家支付宝帐户 string seller_email =AlipayLibrary.Config.GetConfigString("appSettings", "AlipayAccount"); //必填 //商户订单号 string out_trade_no = OrderModel.OrderID; //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = "产品名称:" + OrderModel.ProductName; //必填 //付款金额 string total_fee = OrderModel.OrderPrice.ToString(); //必填 #endregion //请求业务参数详细 string req_dataToken = "<direct_trade_create_req><notify_url>" + notify_url + "</notify_url><call_back_url>" + call_back_url + "</call_back_url><seller_account_name>" + seller_email + "</seller_account_name><out_trade_no>" + out_trade_no + "</out_trade_no><subject>" + subject + "</subject><total_fee>" + total_fee + "</total_fee><merchant_url>" + merchant_url + "</merchant_url></direct_trade_create_req>"; //必填 //把请求参数打包成数组 Dictionary<string, string> sParaTempToken = new Dictionary<string, string>(); sParaTempToken.Add("partner", Config.Partner); sParaTempToken.Add("_input_charset", Config.Input_charset.ToLower()); sParaTempToken.Add("sec_id", Config.Sign_type.ToUpper()); sParaTempToken.Add("service", "alipay.wap.trade.create.direct"); sParaTempToken.Add("format", format); sParaTempToken.Add("v", v); sParaTempToken.Add("req_id", req_id); sParaTempToken.Add("req_data", req_dataToken); //建立请求 string sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken); //URLDECODE返回的信息 Encoding code = Encoding.GetEncoding(Config.Input_charset); sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code); //解析远程模拟提交后返回的信息 Dictionary<string, string> dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken); //获取token string request_token = dicHtmlTextToken["request_token"]; ////////////////////////////////////////////根据授权码token调用交易接口alipay.wap.auth.authAndExecute//////////////////////////////////////////// //业务详细 string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>"; //必填 //把请求参数打包成数组 Dictionary<string, string> sParaTemp = new Dictionary<string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("sec_id", Config.Sign_type.ToUpper()); sParaTemp.Add("service", "alipay.wap.auth.authAndExecute"); sParaTemp.Add("format", format); sParaTemp.Add("v", v); sParaTemp.Add("req_data", req_data); //建立请求 string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认"); Response.Write(sHtmlText); #endregion }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary<string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.Form["out_trade_no"]; //支付宝交易号 string trade_no = Request.Form["trade_no"]; //交易状态 string trade_status = Request.Form["trade_status"]; if (Request.Form["trade_status"] == "TRADE_FINISHED") { Response.Write("success"); } else if (Request.Form["trade_status"] == "TRADE_SUCCESS") { var OrderModel = new Eyousoft_yhq.Model.Order(); var OrderBll = new Eyousoft_yhq.BLL.Order(); OrderModel = OrderBll.GetModel(out_trade_no); if (OrderModel != null && OrderModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { string result = string.Empty; string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderBll.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } OrderModel.OrderID = out_trade_no; OrderModel.PayState = Eyousoft_yhq.Model.PaymentState.已支付; OrderModel.OrderState = Eyousoft_yhq.Model.OrderState.已成交; OrderModel.ConfirmCode = Ra; int Sum = OrderBll.UpdatePayState(OrderModel); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList<Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); code = string.Format("下单成功,确认码:{0}!【惠旅游】", Ra); Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out result);//发送 #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = result }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion #endregion } } } var chongzhiModel = new Eyousoft_yhq.BLL.BChongZhi().GetModel(out_trade_no); if (chongzhiModel != null && chongzhiModel.PayState == Eyousoft_yhq.Model.PaymentState.未支付) { var member = new Eyousoft_yhq.BLL.Member().GetModel(chongzhiModel.OperatorID); if (member != null) { member.YuE = member.YuE + chongzhiModel.OptMoney; bool result = new Eyousoft_yhq.BLL.Member().Update(member); } new Eyousoft_yhq.BLL.BChongZhi().SheZhiZhiFus(out_trade_no, Eyousoft_yhq.Model.PaymentState.已支付); } } else { } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— Response.Write("success"); //请不要修改或删除 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { Dictionary<string, string> sPara = GetRequestGet(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.VerifyReturn(sPara, Request.QueryString["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 //商户订单号 string out_trade_no = Request.QueryString["out_trade_no"]; //支付宝交易号 string trade_no = Request.QueryString["trade_no"]; //交易状态 string result = Request.QueryString["result"]; Eyousoft_yhq.BLL.Order OrderType = new Eyousoft_yhq.BLL.Order(); var OrderModel = new Eyousoft_yhq.Model.Order(); string res = string.Empty; if (result == "success") { //纪录充值消费纪录 try { string price = Request.QueryString["price"]; Eyousoft_yhq.BLL.BConDetaile service = new Eyousoft_yhq.BLL.BConDetaile(); Eyousoft_yhq.Model.MConDetaile con = new Eyousoft_yhq.Model.MConDetaile(); con.JiaoYiHao = trade_no; con.DingDanBianHao = out_trade_no; con.JinE = Decimal.Parse(price); con.JiaoYiShiJian = DateTime.Now; con.XFway = Eyousoft_yhq.Model.XFfangshi.消费; EyouSoft.Model.SSOStructure.MUserInfo userInfo = Session["HuiYuanInfo"] as EyouSoft.Model.SSOStructure.MUserInfo; con.HuiYuanID = userInfo.UserID; service.Add(con); } catch (Exception) { } OrderModel = OrderType.GetModel(out_trade_no); if (OrderModel.PayState != Eyousoft_yhq.Model.PaymentState.已支付) { string Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); while (OrderType.Exists(Ra)) { Ra = Eyousoft_yhq.SQLServerDAL.Utils.GetRandomString(12); } Eyousoft_yhq.Model.Order OrderInfo = new Eyousoft_yhq.Model.Order() { OrderID = out_trade_no, PayState = Eyousoft_yhq.Model.PaymentState.已支付, ConfirmCode = Ra, OrderState = Eyousoft_yhq.Model.OrderState.已成交 }; int Sum = OrderType.UpdatePayState(OrderInfo); if (Sum > 0) { Eyousoft_yhq.BLL.Member UM = new Eyousoft_yhq.BLL.Member(); bool Mo = UM.GetModel(OrderModel.MemberID).valiUser; if (!Mo) { #region 短信发送 string code = string.Empty; IList<Eyousoft_yhq.Model.SMSChannel> channel = Eyousoft_yhq.Web.BsendMsg.CommonProcess.GetSMSChannels(); //code = CreateZxingCode(Ra) + string.Format("下单成功,确认码:{0}!【惠旅游】", Ra);//生成二维码,发送彩信 Eyousoft_yhq.Web.BsendMsg.CommonProcess.SendSMS(OrderModel.MemberTel, code, channel[0], out res);//发送 #endregion #region 短信日志 Eyousoft_yhq.Model.MsgLog MsLog = new Eyousoft_yhq.Model.MsgLog { TelCode = OrderModel.MemberTel, MsgText = code, ReResult = res }; new Eyousoft_yhq.BLL.MsgLog().Add(MsLog); #endregion } } } } Response.Redirect("/AppPage/orderlist.aspx"); //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("验证失败"); } } else { Response.Write("无返回参数"); } }