protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestGet(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 //string subject = Request.QueryString["subject"]; //商品名称、订单名称 //string trade_no = Request.QueryString["trade_no"]; //支付宝交易号 //string buyer_email = Request.QueryString["buyer_email"]; //买家支付宝账号 string order_no = Request.QueryString["out_trade_no"]; //获取订单号 string total_fee = Request.QueryString["total_fee"]; //获取总金额 string body = Request.QueryString["body"]; //商品描述、订单备注、描述 string trade_status = Request.QueryString["trade_status"]; //交易状态 string extra_common_param = Request.QueryString["extra_common_param"]; //商户回传参数 string sTranIP = ProvideCommon.GetRealIP(); string sFromUrl = Request.Url.ToString(); char cTranFrom = 't'; LastOfPayPointBLL.Add(sTranIP, cTranFrom, sFromUrl, order_no); if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { int iLen = extra_common_param.Split('|').Length; string sAccount = extra_common_param.Split('|')[0];//获取充值人账户 decimal dPrice = Convert.ToDecimal(total_fee); int j = TransPBLL.PointSalesCommit(order_no, sAccount, dPrice); //确认返回信息无误后提交此定单 if (j == 0) { //游戏直冲 if (iLen > 1) { TranQuickBLL.TranQuickUpdateP(order_no); string sGTranID = TranQuickBLL.TranQuickGTranIDSel(order_no); string sGame = extra_common_param.Split('|')[1]; string sGTRes = string.Empty; if (sGame.IndexOf("sq") == -1) { sGTRes = PayAll.GameQuickPay(sGame, sAccount, dPrice, sGTranID); } else { string sRoleID = extra_common_param.Split('|')[2]; sGTRes = PayAll.sqQuickPay(sGame, sAccount, dPrice, sGTranID, sRoleID); } if (sGTRes == "0") //游戏兑换成功 { TranQuickBLL.TranQuickUpdateG(sGTranID); Response.Redirect(string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sGTranID, sGame), false); } else { //sMsg = "<script>alert('充值武林币成功!游戏兑换失败!如有问题请与客服联系!');</script>"; Response.Redirect(string.Format("PayPErr.aspx?err=102>res={0}", sGTRes)); } } else if (1 == iLen) { Response.Redirect(string.Format("PayPSucc.aspx?TranID={0}", order_no)); //转向银行卡支付成功页面 } else { Response.Write(iLen); } } else { if (6 == j) { if (iLen > 1) { string sQuickState = TranQuickBLL.TransQuickStateSelByP(order_no); string sGTranID = TranQuickBLL.TranQuickGTranIDSel(order_no); string sGame = extra_common_param.Split('|')[1]; if (sQuickState == "2") { Response.Redirect(string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sGTranID, sGame), false); } else if (sQuickState == "1") { string sGTRes = string.Empty; if (sGame.IndexOf("sq") == -1) { sGTRes = PayAll.GameQuickPay(sGame, sAccount, dPrice, sGTranID); } else { string sRoleID = extra_common_param.Split('|')[2]; sGTRes = PayAll.sqQuickPay(sGame, sAccount, dPrice, sGTranID, sRoleID); } if (sGTRes == "0") //游戏兑换成功 { TranQuickBLL.TranQuickUpdateG(sGTranID); Response.Redirect(string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sGTranID, sGame), false); } else { //sMsg = "<script>alert('充值武林币成功!游戏兑换失败!如有问题请与客服联系!');</script>"; Response.Redirect(string.Format("PayPErr.aspx?err=102>res={0}", sGTRes)); } } } else if (1 == iLen) { Response.Redirect(string.Format("PayPSucc.aspx?TranID={0}", order_no)); } else { Response.Write(iLen); } } else { //sMsg = "<script>alert('订单提交失败!如有问题请与客服联系!');</script>"; Response.Redirect("PayPErr.aspx?err=101"); } } } else { //sMsg = "<script>alert('交易没有成功!如有问题请与客服联系!');</script>"; Response.Redirect("PayPErr.aspx?err=111"); } } else//验证失败 { //sMsg = "<script>alert('验证失败!如有问题请与客服联系!');</script>"; Response.Redirect("PayPErr.aspx?err=104"); } } else { //sMsg = "<script>alert('无返回参数!如有问题请与客服联系!');</script>"; Response.Redirect("PayPErr.aspx?err=103"); } }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); //StringBuilder sbText = new StringBuilder(); //sbText.Append(Server.MapPath("~/Log")); //sbText.Append("/Pay"); //string sPath = sbText.ToString(); //ProvideCommon pcObject = new ProvideCommon(); //sbText.Remove(0, sbText.Length); //foreach(KeyValuePair<string,string> kvpForm in sPara) //{ // sbText.Append(string.Format("{0}={1} ",kvpForm.Key,kvpForm.Value)); //} //string sFormUrl = sbText.ToString(); //sbText.Remove(0,sbText.Length); //sbText.AppendFormat("{0},{1}", sFormUrl, DateTime.Now.ToString()); //pcObject.WriteLogFile(sPath, "PayAliNotify", sbText.ToString()); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //string trade_no = Request.Form["trade_no"]; //支付宝交易号 //string buyer_email = Request.Form["buyer_email"]; //买家支付宝账号 string order_no = Request.Form["out_trade_no"]; //获取订单号 string total_fee = Request.Form["total_fee"]; //获取总金额 string subject = Request.Form["subject"]; //商品名称、订单名称 string body = Request.Form["body"]; //商品描述、订单备注、描述 string trade_status = Request.Form["trade_status"]; //交易状态 string extra_common_param = Request.Form["extra_common_param"]; //商户回传参数 string sTranIP = ProvideCommon.GetRealIP(); string sFromUrl = Request.Url.ToString(); char cTranFrom = 'y'; LastOfPayPointBLL.Add(sTranIP, cTranFrom, sFromUrl, order_no); if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 string sAccount = extra_common_param.Split('|')[0];//获取充值人账户 decimal dPrice = Convert.ToDecimal(total_fee); int iLen = extra_common_param.Split('|').Length; int j = TransPBLL.PointSalesCommit(order_no, sAccount, dPrice); //确认返回信息无误后提交此定单 if (j == 0) { if (iLen > 1) { //游戏直冲 TranQuickBLL.TranQuickUpdateP(order_no); string sGTranID = TranQuickBLL.TranQuickGTranIDSel(order_no); string sGame = extra_common_param.Split('|')[1]; string sGTRes = string.Empty; if (sGame.IndexOf("sq") == -1) { sGTRes = PayAll.GameQuickPay(sGame, sAccount, dPrice, sGTranID); } else { if (extra_common_param.Split('|').Length > 2) { string sRoleID = extra_common_param.Split('|')[2]; sGTRes = PayAll.sqQuickPay(sGame, sAccount, dPrice, sGTranID, sRoleID); } } if (sGTRes == "0") //游戏兑换成功 { TranQuickBLL.TranQuickUpdateG(sGTranID); } } } Response.Write("success"); //请不要修改或删除 } else { Response.Write("success"); //其他状态判断。普通即时到帐中,其他状态不用判断,直接打印success。有问题,这里需要判断吗? } } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }