Example #1
0
        //前台回调页面
        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() + " &nbsp;&nbsp; 密码:" + 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() + " &nbsp;&nbsp; 密码:" + 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);
        }
Example #2
0
        //交易状态,
        //只是生成订单的话,默认为0
        //返回的状态值,以此对应如下:
        //1.WAIT_BUYER_PAY:1       交易创建,等待买家付款。
        //2.TRADE_CLOSED:2       (1)在指定时间段内未支付时关闭的交易;(2)在交易完成全额退款成功时关闭的交易。
        //3.TRADE_SUCCESS:3    交易成功,且可对该交易做操作,如:多级分润、退款等。
        //4.TRADE_PENDING:4    等待卖家收款(买家付款后,如果卖家账号被冻结)。
        //5.TRADE_FINISHED:5    交易成功且结束,即不可再做任何操作
        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"];

                    //更新返回信息到数据库中
                    Entity.DingDan info = DAL.tengxb.dingdan.DingDanEntityGet(out_trade_no);
                    if (info != null)
                    {
                        //更新数据库中的状态值
                        info.State = 3;
                        switch (Request.Form["trade_status"])
                        {
                        case "WAIT_BUYER_PAY":
                            info.State = 1;
                            break;

                        case "TRADE_CLOSED":
                            info.State = 2;
                            break;

                        case "TRADE_SUCCESS":
                            info.State = 3;
                            break;

                        case "TRADE_PENDING":
                            info.State = 4;
                            break;

                        case "TRADE_FINISHED":
                            info.State = 5;
                            break;

                        default:
                            break;
                        }

                        info.Memo = "支付宝交易号:" + trade_no;
                        DAL.DingDan.DingDanEdit(info);
                    }


                    if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")
                    {
                        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);
                        }
                    }
                    else
                    {
                        //付款失败
                        // Basic.SendMobile.SendMobileMsg("18500525896", "付款失败");
                    }

                    Response.Write("success");  //请不要修改或删除
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
Example #3
0
        //后台回调页面
        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);
        }
Example #4
0
        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 out_trade_no = Request.QueryString["out_trade_no"];
                    //支付宝交易号
                    string trade_no = Request.QueryString["trade_no"];
                    //交易状态
                    string trade_status = Request.QueryString["trade_status"];
                    //更新返回信息到数据库中
                    Entity.DingDan info = DAL.tengxb.dingdan.DingDanEntityGet(out_trade_no);
                    if (info != null)
                    {
                        strMobile = info.CellMobile;
                        strMobile = strMobile.Substring(0, 3) + "****" + strMobile.Substring(6);
                        if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                        {
                            //TRADE_SUCCESS
                            // 交易成功,且可对该交易做操作,如:多级分润、退款等。
                            strResult = "success";
                            if (DAL.GaoKaoCard.GaoKaoCardCount("DingDanHao = '" + info.DingDanHao + "'") < info.Count)
                            {
                                //分配高考卡,并发送短信
                                FenPeiGaoKaoCard.FenPeiCard(info, 1);
                                //展示卡号
                                DataTable dt = DAL.GaoKaoCard.GaoKaoCardList("DingDanHao = '" + info.DingDanHao + "'");
                                if (dt != null)
                                {
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        strCardList += "<tr><td style=\"color: #ff8c00\">" + dt.Rows[i]["KaHao"].ToString() + "</td><td style=\"color: #ff8c00\">" + dt.Rows[i]["MiMa"].ToString() + "</td><td><a href=\"/art/goumai/art.aspx?kh=" + dt.Rows[i]["KaHao"].ToString() + "\" style=\"color: #0185D9\">完善信息</a></td></tr>";
                                    }
                                }
                            }
                            else
                            {
                                //展示卡号
                                DataTable dt = DAL.GaoKaoCard.GaoKaoCardList("DingDanHao = '" + info.DingDanHao + "'");
                                if (dt != null)
                                {
                                    for (int i = 0; i < dt.Rows.Count; i++)
                                    {
                                        strCardList += "<tr><td style=\"color: #ff8c00\">" + dt.Rows[i]["KaHao"].ToString() + "</td><td style=\"color: #ff8c00\">" + dt.Rows[i]["MiMa"].ToString() + "</td><td><a href=\"/art/goumai/art.aspx?kh=" + dt.Rows[i]["KaHao"].ToString() + "\" style=\"color: #0185D9\">完善信息</a></td></tr>";
                                    }
                                }
                            }
                        }
                        else
                        {
                            //付款失败
                            // Basic.SendMobile.SendMobileMsg("15810621454", "付款失败");
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    strResult = "fail";
                    Response.Write("fail");
                }
            }
            else
            {
                strResult = "无通知参数";
                // Response.Write("无通知参数");
            }
        }