protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sArrary = GetRequestGet();

            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            ZoomLa.BLL.B_PayPlat payBLL = new ZoomLa.BLL.B_PayPlat();
            DataTable            pay    = payBLL.GetPayPlatByClassid(12);

            ZoomLa.Model.M_Alipay_config con = new ZoomLa.Model.M_Alipay_config();
            if (pay == null || pay.Rows.Count < 1)
            {
                function.WriteErrMsg("请先配置支付平台信息!![系统设置-->支付平台-->在线支付平台]");
            }
            string partner       = pay.Rows[0]["AccountID"].ToString();
            string key           = pay.Rows[0]["MD5Key"].ToString();
            string input_charset = con.Input_charset;
            string sign_type     = con.Sign_type;
            string transport     = con.Transport;

            //////////////////////////////////////////////////////////////////////////////////////////////

            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                B_Alipay_notify aliNotify = new B_Alipay_notify(sArrary, Request.QueryString["notify_id"], partner, key, input_charset, sign_type, transport);
                //AlipayNotify aliNotify = new AlipayNotify(sArrary, Request.QueryString["notify_id"], partner, key, input_charset, sign_type, transport);
                string responseTxt = aliNotify.ResponseTxt;       //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
                string sign        = Request.QueryString["sign"]; //获取支付宝反馈回来的sign结果
                string mysign      = aliNotify.Mysign;            //获取通知返回后计算后(验证)的签名结果

                //写日志记录(若要调试,请取消下面两行注释)
                //string sWord = "responseTxt=" + responseTxt + "\n return_url_log:sign=" + Request.QueryString["sign"] + "&mysign=" + mysign + "\n return回来的参数:" + aliNotify.PreSignStr;
                //AlipayFunction.log_result(Server.MapPath("log/" + DateTime.Now.ToString().Replace(":", "")) + ".txt",sWord);

                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                if (responseTxt == "true" && sign == mysign)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码

                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
                    string trade_no    = Request.QueryString["trade_no"];           //支付宝交易号
                    string order_no    = Request.QueryString["out_trade_no"];       //获取订单号
                    string total_fee   = Request.QueryString["total_fee"];          //获取总金额
                    string subject     = Request.QueryString["subject"];            //商品名称、订单名称
                    string body        = Request.QueryString["body"];               //商品描述、订单备注、描述
                    string buyer_email = Request.QueryString["buyer_email"];        //买家支付宝账号
                                                                                    //string receive_name = Request["receive_name"];      //收货人姓名
                                                                                    //string receive_address = Request["receive_address"];//收货人地址
                                                                                    //string receive_zip = Request["receive_zip"];        //收货人邮编
                                                                                    //string receive_phone = Request["receive_phone"];    //收货人电话
                                                                                    //string receive_mobile = Request["receive_mobile"];  //收货人手机
                    string trade_status = Request.QueryString["trade_status"];      //交易状态

                    //打印页面
                    lbTrade_no.Text     = trade_no;
                    lbOut_trade_no.Text = order_no;
                    lbTotal_fee.Text    = total_fee;
                    lbSubject.Text      = subject;
                    lbBody.Text         = body;
                    lbBuyer_email.Text  = buyer_email;
                    lbTrade_status.Text = trade_status;
                    lbVerify.Text       = "验证成功";

                    if (Request.QueryString["trade_status"] == "WAIT_SELLER_SEND_GOODS" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")//买家已经付款,等待卖家发货
                    {
                        M_Payment   payMod = payBll.SelModelByPayNo(order_no);
                        M_OrderList omod   = orderBll.SelModelByOrderNo(payMod.PaymentNum.Split(',')[0]);
                        LbName.Text    = omod.Receiver;
                        LbAddress.Text = omod.Jiedao;
                        LbZip.Text     = omod.ZipCode;
                        LbPhone.Text   = omod.Phone;
                        LbMobile.Text  = omod.Mobile.ToString();
                        FinalStep(omod);
                    }
                    else if (Request.QueryString["trade_status"] == "TRADE_FINISHED")//交易成功结束
                    {
                        lbVerify.Text = "该交易已经成功结束!";
                    }
                    else
                    {
                        Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                    }
                }
                else//验证失败
                {
                    lbVerify.Text = "验证失败";
                }
            }
            else
            {
                lbVerify.Text = "无返回参数";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //DataTable pay = payPlatBll.GetPayPlatByClassid(12);
            M_PayPlat platMod = payPlatBll.SelModelByClass(M_PayPlat.Plat.Alipay_Instant);
            SortedDictionary <string, string> sArrary = GetRequestPost();

            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            ZoomLa.Model.M_Alipay_config con = new ZoomLa.Model.M_Alipay_config();
            string partner       = platMod.AccountID;
            string key           = platMod.MD5Key;
            string input_charset = con.Input_charset;
            string sign_type     = con.Sign_type;
            string transport     = con.Transport;

            //////////////////////////////////////////////////////////////////////////////////////////////
            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                B_Alipay_notify aliNotify   = new B_Alipay_notify(sArrary, Request.Form["notify_id"], partner, key, input_charset, sign_type, transport);
                string          responseTxt = aliNotify.ResponseTxt; //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
                string          sign        = Request.Form["sign"];
                string          mysign      = aliNotify.Mysign;      //获取通知返回后计算后(验证)的签名结果
                                                                     //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                                                                     //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                                                                     //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                string order_no = Request.Form["out_trade_no"];      //获取订单号
                ZLLog.L(ZLEnum.Log.pay, PayPlat + aliNotify.ResponseTxt + ":" + order_no + ":" + Request.Form["buyer_email"] + ":" + Request.Form["trade_status"] + ":" + Request.Form["price"] + ":" + Request.Form["subject"]);
                if (responseTxt == "true" && sign == mysign)         //验证成功
                {
                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取通知返回参数,可参考技术文档中服务器异步通知参数列表
                    string trade_no     = Request.Form["trade_no"];       //交易号
                    string total_fee    = Request.Form["price"];          //获取总金额
                    string subject      = Request.Form["subject"];        //商品名称、
                    string body         = Request.Form["body"];           //商品描述、订单备注、描述
                    string buyer_email  = Request.Form["buyer_email"];    //买家账号
                    string trade_status = Request.Form["trade_status"];   //交易状态
                    if (Request.Form["trade_status"] == "WAIT_BUYER_PAY") //没有付款
                    {
                    }
                    else if (trade_status.Equals("WAIT_SELLER_SEND_GOODS"))//付款成功,但是卖家没有发货
                    {
                    }
                    else if (trade_status.Equals("TRADE_SUCCESS"))//付款成功
                    {
                        try
                        {
                            M_Payment pinfo = payBll.SelModelByPayNo(order_no);
                            if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                            {
                                return;
                            }
                            pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                            pinfo.PlatformInfo = PayPlat;      //平台反馈信息
                            pinfo.SuccessTime  = DateTime.Now; //交易成功时间
                            pinfo.CStatus      = true;         //处理状态
                            pinfo.AlipayNO     = trade_no;     //保存支付宝交易号
                            pinfo.MoneyTrue    = Convert.ToDouble(total_fee);
                            payBll.Update(pinfo);
                            DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                            foreach (DataRow dr in orderDT.Rows)
                            {
                                M_Order_PayLog paylogMod = new M_Order_PayLog();
                                M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                                OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                                orderCOM.SendMessage(orderMod, paylogMod, "payed");
                            }
                            Response.Write("success");
                            ZLLog.L(ZLEnum.Log.pay, PayPlat + "成功!支付单:" + order_no);
                        }
                        catch (Exception ex)
                        {
                            ZLLog.L(ZLEnum.Log.pay, new M_Log()
                            {
                                Action  = "支付回调报错",
                                Message = PayPlat + ",支付单:" + order_no + ",原因:" + ex.Message
                            });
                        }
                    }
                    else if (Request.Form["trade_status"] == "WAIT_BUYER_CONFIRM_GOODS")//卖家已经发货,等待买家确认
                    {
                    }
                    else if (Request.Form["trade_status"] == "TRADE_FINISHED")
                    {
                    }
                    else//其他状态判断。普通即时到帐中,其他状态不用判断,直接打印success。
                    {
                        ZLLog.L(PayPlat + "付款未成功截获,单号:[" + trade_status + "]");
                    }
                }
                else//验证失败
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "支付验证失败",
                        Message = PayPlat + ",支付单:" + order_no
                    });
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("success");
            }
        }