예제 #1
0
        public async Task <ActionResult> AlipayNotifyUrl()
        {
            var loger = LogManager.GetLogger("Alipay");

            SortedDictionary <string, string> sPara = GetRequestPost();
            //loger.Error("params:{0}", Request.Params.ToJsonString());
            bool verifyResult = new AlipayNotify(sPara).Verify(Request.Form["notify_id"], Request.Form["sign"]);

            if (sPara.Count > 0 && verifyResult)
            {
                //商户订单号
                string outTradeNo = Request.Form["out_trade_no"];
                //支付宝交易号
                string tradeNo = Request.Form["trade_no"];
                //交易状态
                string tradeStatus = Request.Form["trade_status"];

                //打日志
                //loger.Error("orderNo:{0};tradeStatus:{1};", outTradeNo, tradeStatus);
                if (tradeStatus == "TRADE_FINISHED" || tradeStatus == "TRADE_SUCCESS")
                {
                    //await OrderContract.PayOrder(outTradeNo, PayType.支付宝);
                    return(Content("success"));
                    //注意:
                    //该种交易状态只在两种情况下出现
                    //1、开通了普通即时到账,买家付款成功后。
                    //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。

                    //1、开通了高级即时到账,买家付款成功后。
                }
            }
            return(Content(""));
        }
예제 #2
0
        /// <summary>
        /// 通知调用
        /// </summary>
        public ActionResult Notify()
        {
            //string forms = "discount=0.00&payment_type=1&subject=%u9ed1%u7c73%u58f3&trade_no=2016111521001004630270573220&buyer_email=15670179992&gmt_create=2016-11-15+09%3a29%3a16&notify_type=trade_status_sync&quantity=1&out_trade_no=1115092904-1643&seller_id=2088421544580296&notify_time=2016-11-15+10%3a55%3a09&body=%u8bdd%u8d39%u5957%u9910&trade_status=TRADE_SUCCESS&is_total_fee_adjust=N&total_fee=0.01&gmt_payment=2016-11-15+09%3a29%3a17&seller_email=cbaohai%40126.com&price=0.01&buyer_id=2088012967203633&notify_id=53526949d59c9297c6641bd8e450a03kv2&use_coupon=N&sign_type=RSA&sign=WDJhrGG2kEgGvKtfPG3WoMn8mwleWbyDTR0scZ6HmSK39OZnlHKS8lSTkYM09ZY4y7%2bxTM1IeNmFsVcbK%2bVJK2jHYX43RyEIyBkCgJVuo0IpUDPYZidyrgEeGKoeV0FPutykbLIueQNSoAENkPsAmFWd1J1FQMYvF8akJL1R%2b5k%3d";
            //forms = HttpUtility.UrlDecode(forms, Encoding.UTF8);
            SortedDictionary <string, string> sPara = AlipayCore.GetRequestPost();

            //Dictionary<string, string> dic = CommonHelper.ParmsToDic(forms);
            //foreach (KeyValuePair<string, string> kv in dic)
            //{
            //    sPara[kv.Key] = kv.Value;
            //}
            //BSPLog.Instance.Write(Request.Form.ToString());
            if (sPara.Count > 0)//判断是否有带返回参数
            {
                bool verifyResult = AlipayNotify.AppVerify(sPara, sPara["notify_id"], sPara["sign"], AlipayConfig.AppSignType, AlipayConfig.PublicKey, AlipayConfig.AppInputCharset, AlipayConfig.AppVeryfyUrl, AlipayConfig.Partner);
                if (verifyResult && (sPara["trade_status"] == "TRADE_FINISHED" || sPara["trade_status"] == "TRADE_SUCCESS")) //验证成功
                {
                    string   out_trade_no = sPara["out_trade_no"];                                                           //商户订单号
                    string   tradeSN      = sPara["trade_no"];                                                               //支付宝交易号
                    decimal  tradeMoney   = TypeHelper.StringToDecimal(sPara["total_fee"]);                                  //交易金额
                    DateTime tradeTime    = TypeHelper.StringToDateTime(sPara["gmt_payment"]);                               //交易时间

                    return(Content(Recharge.UpdateRecharge(tradeMoney.ToString(), out_trade_no, sPara["gmt_payment"], tradeSN)));
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                return(Content("无通知参数"));
            }
        }
예제 #3
0
        /// <summary>
        /// 通知调用
        /// </summary>
        public ActionResult Notify()
        {
            SortedDictionary <string, string> sPara = AlipayCore.GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                bool verifyResult = AlipayNotify.AppVerify(sPara, Request.Form["notify_id"], Request.Form["sign"], AlipayConfig.AppSignType, AlipayConfig.PublicKey, AlipayConfig.AppInputCharset, AlipayConfig.AppVeryfyUrl, AlipayConfig.Partner);
                if (verifyResult && (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")) //验证成功
                {
                    string   out_trade_no = Request.Form["out_trade_no"];                                                                  //商户订单号
                    string   tradeSN      = Request.Form["trade_no"];                                                                      //支付宝交易号
                    decimal  tradeMoney   = TypeHelper.StringToDecimal(Request.Form["total_amount"]);                                      //交易金额
                    DateTime tradeTime    = TypeHelper.StringToDateTime(Request.Form["gmt_payment"]);                                      //交易时间

                    return(Content(Recharge.UpdateRecharge(tradeMoney.ToString(), out_trade_no, Request.Form["gmt_payment"], tradeSN)));
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                return(Content("无通知参数"));
            }
        }
예제 #4
0
파일: PayResult.cs 프로젝트: iampkm/ebs.pay
        /// <summary>
        /// 校验支付结果请求
        /// </summary>
        /// <param name="data">业务数据报文</param>
        /// <param name="resultInfo">支付结果记录</param>
        /// <returns></returns>
        public override ExecuteResult CheckRequest(string data, PayResultInfo resultInfo)
        {
            var result     = new ExecuteResult();
            var paramsData = new ParameterData();

            paramsData.FromUrl(data);
            var paramsDict = paramsData.GetValues();

            //判断是否有带返回参数
            if (paramsDict.Count == 0)
            {
                result.Status            = ResultStatus.Failure;
                result.Message           = resultInfo.ResultDesc = "支付结果无通知参数";
                resultInfo.ExecuteResult = (int)ResultStatus.Failure;
                PayResultDAL.Update(resultInfo);
                return(result);
            }

            //校验请求报文
            resultInfo.OrderId = paramsData.GetValue("out_trade_no");
            var  aliNotify    = new AlipayNotify();
            bool verifyResult = aliNotify.Verify(paramsDict, paramsData.GetValue("notify_id"), paramsData.GetValue("sign"));

            if (!verifyResult)
            {
                result.Status            = ResultStatus.Failure;
                result.Message           = resultInfo.ResultDesc = "verify failed";
                resultInfo.ExecuteResult = (int)ResultStatus.Failure;
                PayResultDAL.Update(resultInfo);
                return(result);
            }

            result.Status = ResultStatus.Success;
            return(result);
        }
예제 #5
0
        /// <summary>
        /// 阿里支付成功同步回调地址
        /// </summary>
        /// <returns></returns>
        public ActionResult CallBack()
        {
            SortedDictionary <string, string> sPara = GetRequestGet();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify();
                bool         verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]);

                if (verifyResult)//验证成功
                {
                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
                    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 trade_status = Request.QueryString["trade_status"];      //交易状态

                    if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序
                        BaseResponse br = DBOrderBLL.OrderPaySuccess(order_no, decimal.Parse(total_fee), buyer_email);
                        if (br.IsSuccess)
                        {
                            return(RedirectToAction("success", "order", new { ordercode = order_no }));
                        }
                        else
                        {
                            ViewBag.Msg = "对不起未能成功处理您的订单[" + order_no + "],原因是:" + br.Message;
                            return(View("error"));
                        }
                    }
                    else
                    {
                        ViewBag.Msg = "对不起您的订单[" + order_no + "]支付失败了,交易状态:" + trade_status;
                        Logger.Info(ViewBag.Msg);
                        return(View("error"));
                    }
                }
                else//验证失败
                {
                    ViewBag.Msg = "对不起您的订单[" + Request.QueryString["trade_no"] + "]支付失败了,支付返回数据异常";
                    Logger.Info(ViewBag.Msg);
                    return(View("error"));
                }
            }
            else
            {
                ViewBag.Msg = "对不起您的订单[" + Request.QueryString["trade_no"] + "]订单支付失败了,支付返回参数为空";
                Logger.Info(ViewBag.Msg);
                return(View("error"));
            }
        }
예제 #6
0
        /// <summary>
        /// 通知调用
        /// </summary>
        public ActionResult Notify()
        {
            SortedDictionary <string, string> paras = AlipayCore.GetRequestPost();

            if (paras.Count > 0)//判断是否有带返回参数
            {
                bool verifyResult = AlipayNotify.Verify(paras, Request.Form["notify_id"], Request.Form["sign"], AlipayConfig.SignType, AlipayConfig.Key, AlipayConfig.Code, AlipayConfig.VeryfyUrl, AlipayConfig.Partner);
                if (verifyResult && (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")) //验证成功
                {
                    string   out_trade_no = Request.Form["out_trade_no"];                                                                  //商户订单号
                    string   tradeSN      = Request.Form["trade_no"];                                                                      //支付宝交易号
                    decimal  tradeMoney   = TypeHelper.StringToDecimal(Request.Form["total_fee"]);                                         //交易金额
                    DateTime tradeTime    = TypeHelper.StringToDateTime(Request.Form["gmt_payment"]);                                      //交易时间

                    List <OrderInfo> orderList = new List <OrderInfo>();
                    foreach (string oid in StringHelper.SplitString(StringHelper.SubString(out_trade_no, out_trade_no.Length - 10)))
                    {
                        OrderInfo orderInfo = Orders.GetOrderByOid(TypeHelper.StringToInt(oid));
                        orderList.Add(orderInfo);
                    }
                    decimal allSurplusMoney = 0M;
                    foreach (OrderInfo orderInfo in orderList)
                    {
                        allSurplusMoney += orderInfo.SurplusMoney;
                    }

                    if (orderList.Count > 0 && allSurplusMoney <= tradeMoney)
                    {
                        foreach (OrderInfo orderInfo in orderList)
                        {
                            if (orderInfo.SurplusMoney > 0 && orderInfo.OrderState == (int)OrderState.WaitPaying)
                            {
                                Orders.PayOrder(orderInfo.Oid, OrderState.Confirming, tradeSN, DateTime.Now);
                                OrderActions.CreateOrderAction(new OrderActionInfo()
                                {
                                    Oid        = orderInfo.Oid,
                                    Uid        = orderInfo.Uid,
                                    RealName   = "本人",
                                    ActionType = (int)OrderActionType.Pay,
                                    ActionTime = tradeTime,
                                    ActionDes  = "你使用支付宝支付订单成功,支付宝交易号为:" + tradeSN
                                });
                            }
                        }
                    }

                    return(Content("success"));
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                return(Content("无通知参数"));
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                //Notify aliNotify = new Notify();
                AlipayNotify aliNotify = new AlipayNotify();

                //对异步通知进行验签
                bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);
                //对验签结果
                //bool isSign = Aop.Api.Util.AlipaySignature.RSACheckV2(sPara, Config.alipay_public_key ,Config.charset,Config.sign_type,false );

                if (verifyResult && CheckParams()) //验签成功 && 关键业务参数校验成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码


                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //商户订单号
                    string out_trade_no = Request.Form["out_trade_no"];


                    //支付宝交易号
                    string trade_no = Request.Form["trade_no"];

                    //交易状态
                    //在支付宝的业务通知中,只有交易通知状态为TRADE_SUCCESS或TRADE_FINISHED时,才是买家付款成功。
                    string trade_status = Request.Form["trade_status"];


                    //判断是否在商户网站中已经做过了这次通知返回的处理
                    //如果没有做过处理,那么执行商户的业务程序
                    //如果有做过处理,那么不执行商户的业务程序

                    Response.Write("success");  //请不要修改或删除

                    //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Game.Facade.Log.Write("房卡支付宝支付进来了。。。。");

            SortedDictionary <string, string> sPara = GetRequestPost();

            Game.Facade.Log.Write("参数长度:" + sPara.Count);

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify();
                bool         verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);

                Game.Facade.Log.Write("verifyResult:" + verifyResult);

                if (verifyResult)//验证成功
                {
                    //商户订单号
                    string out_trade_no = Request.Form["out_trade_no"];

                    Game.Facade.Log.Write("out_trade_no:" + out_trade_no);

                    //支付宝交易号
                    string trade_no = Request.Form["trade_no"];

                    //交易状态
                    string trade_status = Request.Form["trade_status"];

                    Game.Facade.Log.Write("trade_status:" + trade_status);

                    if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        ShareDetialInfo detailInfo = new ShareDetialInfo();
                        detailInfo.OrderID   = out_trade_no;
                        detailInfo.IPAddress = Utility.UserIP;
                        detailInfo.PayAmount = Convert.ToDecimal(Request.Form["total_fee"]);
                        Message msg = FacadeManage.aideTreasureFacade.FilliedOnlineFK(detailInfo, 0);

                        Game.Facade.Log.Write("msg:" + msg.Content);
                    }

                    Response.Write("success");  //请不要修改或删除
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
예제 #9
0
        /// <summary>
        /// 返回调用
        /// </summary>
        public ActionResult Return()
        {
            SortedDictionary <string, string> paras = AlipayCore.GetRequestGet();

            if (paras.Count > 0)//判断是否有带返回参数
            {
                bool verifyResult = AlipayNotify.Verify(paras, Request.QueryString["notify_id"], Request.QueryString["sign"], AlipayConfig.SignType, AlipayConfig.Key, AlipayConfig.Code, AlipayConfig.VeryfyUrl, AlipayConfig.Partner);
                if (verifyResult && (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")) //验证成功
                {
                    string   out_trade_no = Request.QueryString["out_trade_no"];                                                                         //商户订单号
                    string   tradeSN      = Request.QueryString["trade_no"];                                                                             //支付宝交易号
                    decimal  tradeMoney   = TypeHelper.StringToDecimal(Request.QueryString["total_fee"]);                                                //交易金额
                    DateTime tradeTime    = TypeHelper.StringToDateTime(Request.QueryString["notify_time"]);                                             //交易时间

                    int       oid       = TypeHelper.StringToInt(StringHelper.SubString(out_trade_no, out_trade_no.Length - 10));
                    OrderInfo orderInfo = Orders.GetOrderByOid(oid);
                    if (orderInfo != null && orderInfo.PayMode == 1 && orderInfo.PaySN.Length == 0 && orderInfo.SurplusMoney > 0 && orderInfo.SurplusMoney <= tradeMoney)
                    {
                        Orders.PayOrder(oid, OrderState.Confirming, tradeSN, "alipay", "支付宝", DateTime.Now);
                        OrderActions.CreateOrderAction(new OrderActionInfo()
                        {
                            Oid         = oid,
                            Uid         = orderInfo.Uid,
                            RealName    = "本人",
                            AdminGid    = 1,
                            AdminGTitle = "非管理员",
                            ActionType  = (int)OrderActionType.Pay,
                            ActionTime  = tradeTime,
                            ActionDes   = "你使用支付宝支付订单成功,支付宝交易号为:" + tradeSN
                        });

                        //邮件通知客户
                        if (!string.IsNullOrWhiteSpace(orderInfo.Email))
                        {
                            Emails.SendOrderPayEmail(orderInfo.Email, "支付宝", tradeMoney.ToString(), orderInfo.OSN);
                        }
                    }

                    return(RedirectToAction("payresult", "order", new RouteValueDictionary {
                        { "oid", oid }
                    }));
                }
                else//验证失败
                {
                    return(Content("支付失败"));
                }
            }
            else
            {
                return(Content("支付失败"));
            }
        }
예제 #10
0
        /// <summary>
        /// 阿里异步对账地址
        /// </summary>
        /// <returns></returns>
        public ActionResult Notify()
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify();
                bool         verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);

                if (verifyResult)//验证成功
                {
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
                    string trade_no     = Request.Form["trade_no"];     //支付宝交易号
                    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 buyer_email  = Request.Form["buyer_email"];  //买家支付宝账号
                    string trade_status = Request.Form["trade_status"]; //交易状态

                    if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序
                        BaseResponse br = DBOrderBLL.OrderPaySuccess(order_no, decimal.Parse(total_fee), buyer_email);
                        Logger.Info("Notify-1收到alipay的通知更新订单:" + order_no + "交易状态:" + trade_status);
                    }
                    else
                    {
                        Logger.Info("Notify-2收到alipay的通知更新订单:" + order_no + "交易状态:" + trade_status);
                    }
                    return(Content("success"));  //请不要修改或删除
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                Logger.Info("Notify-3收到alipay的通知更新订单参数为空");
                return(Content("无通知参数"));
            }
        }
예제 #11
0
        /// <summary>
        /// 通知调用
        /// </summary>
        public ActionResult Notify()
        {
            SortedDictionary <string, string> paras = AlipayCore.GetRequestPost();

            if (paras.Count > 0)//判断是否有带返回参数
            {
                bool verifyResult = AlipayNotify.Verify(paras, Request.Form["notify_id"], Request.Form["sign"], AlipayConfig.SignType, AlipayConfig.Key, AlipayConfig.Code, AlipayConfig.VeryfyUrl, AlipayConfig.Partner);
                if (verifyResult && (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")) //验证成功
                {
                    string   out_trade_no = Request.Form["out_trade_no"];                                                                  //商户订单号
                    string   tradeSN      = Request.QueryString["trade_no"];                                                               //支付宝交易号
                    decimal  tradeMoney   = TypeHelper.StringToDecimal(Request.QueryString["total_fee"]);                                  //交易金额
                    DateTime tradeTime    = TypeHelper.StringToDateTime(Request.QueryString["gmt_payment"]);                               //交易时间

                    int       oid       = TypeHelper.StringToInt(StringHelper.SubString(out_trade_no, out_trade_no.Length - 10));
                    OrderInfo orderInfo = Orders.GetOrderByOid(oid);
                    if (orderInfo != null && orderInfo.PayMode == 1 && orderInfo.PaySN.Length == 0 && orderInfo.SurplusMoney > 0 && orderInfo.SurplusMoney <= tradeMoney)
                    {
                        Orders.PayOrder(oid, OrderState.Confirming, tradeSN, DateTime.Now);
                        OrderActions.CreateOrderAction(new OrderActionInfo()
                        {
                            Oid         = oid,
                            Uid         = orderInfo.Uid,
                            RealName    = "本人",
                            AdminGid    = 1,
                            AdminGTitle = "非管理员",
                            ActionType  = (int)OrderActionType.Pay,
                            ActionTime  = tradeTime,
                            ActionDes   = "你使用支付宝支付订单成功,支付宝交易号为:" + tradeSN
                        });
                    }

                    return(Content("success"));
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                return(Content("无通知参数"));
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (!IsPostBack)
            {
                Dictionary <string, string> sPara = GetRequestGet();

                if (sPara.Count > 0)//判断是否有带返回参数
                {
                    AlipayNotify aliNotify    = new AlipayNotify();
                    bool         verifyResult = aliNotify.VerifyReturn(sPara, Request.QueryString["sign"]);

                    if (verifyResult)//验证成功
                    {
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        //请在这里加上商户的业务逻辑程序代码


                        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                        //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表

                        AliWapPayCallBackInfo info = new AliWapPayCallBackInfo();
                        info.sign          = Request.QueryString["sign"];
                        info.result        = Request.QueryString["result"];
                        info.out_trade_no  = Request.QueryString["out_trade_no"];
                        info.trade_no      = Request.QueryString["trade_no"];
                        info.request_token = Request.QueryString["request_token"];
                        OnPaySucceed(info);
                    }
                    else//验证失败
                    {
                        Response.Write("验证失败");
                    }
                }
                else
                {
                    Response.Write("无返回参数");
                }
            }
        }
예제 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestGet();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify();
                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"];

                    if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        Response.Write("支付完成<br />");
                    }
                    else
                    {
                        Response.Write("支付结束<br />");
                    }
                }
                else//验证失败
                {
                    Response.Write("验证失败");
                }
            }
            else
            {
                Response.Write("无返回参数");
            }
        }
예제 #14
0
        protected string orderid;      //订单编号

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "完成-组团预定/散拼-机票";
            SortedDictionary <string, string> sArrary = GetRequestGet();
            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            string partner       = AlipayParameters.Partner;       //合作身份者ID
            string key           = AlipayParameters.Key;           //安全检验码
            string input_charset = AlipayParameters.Input_Charset; //字符编码格式 目前支持 gbk 或 utf-8
            string sign_type     = AlipayParameters.SignType;      //加密方式 不需修改
            string transport     = "http";                         //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http

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

            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                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 = "Return_URL: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"];              //支付宝交易号
                    order_no  = Request.QueryString["out_trade_no"];                //获取订单号
                    total_fee = Request.QueryString["total_fee"];                   //获取总金额
                    string subject           = Request.QueryString["subject"];      //商品名称、订单名称
                    string body              = Request.QueryString["body"];         //商品描述、订单备注、描述
                    string buyer_email       = Request.QueryString["buyer_email"];  //买家支付宝账号
                    string trade_status      = Request.QueryString["trade_status"]; //交易状态
                    int    sOld_trade_status = 0;                                   //获取商户数据库中查询得到该笔交易当前的交易状态
                    proName      = string.Format("同业114机票平台(订单号:{0})", order_no);
                    buyerAccount = buyer_email;
                    string notify_id   = Request.QueryString["notify_id"];
                    string notify_time = Request.QueryString["notify_time"];
                    string buyer_id    = Request.QueryString["buyer_id"];

                    //打印页面
                    //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 = "验证成功";

                    //lblNotifyId.Text = notify_id;
                    //lblNotifyTime.Text = notify_time;
                    //lblBuyerID.Text = buyer_id;

                    //假设:
                    //sOld_trade_status="0"	表示订单未处理;
                    //sOld_trade_status="1"	表示交易成功(TRADE_FINISHED/TRADE_SUCCESS)

                    EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                    EyouSoft.Model.TicketStructure.OrderInfo   info     = orderBll.GetOrderInfoByNo(order_no);
                    orderid = info.OrderId;
                    if (info.FreightType == EyouSoft.Model.TicketStructure.FreightType.单程)
                    {
                        proDetail = string.Format("订单号:{0}/航程信息:单程 {1}/{2}至{3}/", order_no, info.LeaveTime.ToString("yyyy-MM-dd"), info.HomeCityName, info.DestCityName);
                    }
                    else
                    {
                        proDetail = string.Format("订单号:{0}/航程信息:去程 {1}/{2}至{3}/回程 {4}/{5}-{6}", order_no, info.LeaveTime.ToString("yyyy-MM-dd"), info.HomeCityName, info.DestCityName, info.ReturnTime, info.DestCityName, info.HomeCityName);
                    }
                    if (info.OrderState == EyouSoft.Model.TicketStructure.OrderState.审核通过)
                    {
                        IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(info.SupplierCId); //获取供应商所有账户
                        string sellAccount = "";                                                                                                                                                             //供应商账户
                        EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == EyouSoft.Model.TicketStructure.TicketAccountType.支付宝);                //获取供应商账户实体
                        if (accountModel != null)
                        {
                            sellAccount = accountModel.AccountNumber;//赋值供应商账户
                        }
                        string batchNo = "";
                        //decimal IntoRatio = EyouSoft.BLL.TicketStructure.TicketSupplierInfo.CreateInstance().GetSupplierInfo(info.SupplierCId).IntoRatio;
                        decimal IntoRatio = decimal.Parse(AlipayParameters.TongyeFee);
                        IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList(info.OrderId, EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单, order_no, null);


                        if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                        {
                            //为了保证不被重复调用,或重复执行数据库更新程序,请判断该笔交易状态是否是订单未处理状态
                            //string order_no="201011080010";
                            //string trade_no="2010110861004313";
                            //string total_fee="0.01";
                            //string buyer_email="*****@*****.**";
                            //string seller_mailer="*****@*****.**";

                            if (payList != null && payList.Count > 0)
                            {
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }

                            resultMess = "交易成功";
                            //if (sOld_trade_status < 1)
                            //{
                            //    //根据订单号更新订单,把订单状态处理成交易成功
                            //}
                        }
                        else
                        {
                            if (payList != null && payList.Count > 0)
                            {
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            //Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                            resultMess = "交易失败";
                        }
                    }
                    else
                    {
                        resultMess = info.OrderState.ToString();
                    }
                    // 请根据您的业务逻辑来编写程序(以上代码仅作参考)
                }
                else//验证失败
                {
                    resultMess = "验证失败";
                }
            }
            else
            {
                resultMess = "无返回参数";
            }
        }
예제 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sPara = GetRequestGet();

        if (sPara.Count > 0)//判断是否有带返回参数
        {
            AlipayNotify aliNotify    = new AlipayNotify();
            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"];

                OrderInfo orderInfo = OrderHelper.GetOrderInfo(out_trade_no);
                if ((Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS") && orderInfo != null)
                {
                    //判断该笔订单是否在商户网站中已经做过处理
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序
                    if (orderInfo.CheckAction(OrderActions.SELLER_CONFIRM_PAY))
                    {
                        if (OrderHelper.ConfirmPay(orderInfo))
                        {
                            Response.Write("<script>alert('订单付款成功');location.href='/Admin/productdl/AgentOrders.aspx'</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('订单付款失败');location.href='/Admin/productdl/AgentOrders.aspx'</script>");
                        }
                    }
                }
                else
                {
                    Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                }



                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                Response.Write("验证失败");
            }
        }
        else
        {
            Response.Write("无返回参数");
        }
    }
예제 #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sArrary = GetRequestGet();
        ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
        AlipayConfig con           = new AlipayConfig();
        string       partner       = con.Partner;
        string       key           = con.Key;
        string       input_charset = con.Input_charset;
        string       sign_type     = con.Sign_type;
        string       transport     = con.Transport;

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

        if (sArrary.Count > 0)//判断是否有带返回参数
        {
            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 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"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                {
                    //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序
                }
                else
                {
                    Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                }
                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                lbVerify.Text = "验证失败";
            }
        }
        else
        {
            lbVerify.Text = "无返回参数";
        }
    }
        public ActionResult RefundNotify(FormCollection form)
        {
            if (!(_paymentPluginManager.LoadPluginBySystemName("Nop.Plugin.Payments.AliPay") is AliPayPaymentProcessor processor) || !_paymentPluginManager.IsPluginActive(processor))
            {
                throw new NopException("插件无法加载");
            }
            var aliPayPaymentSettings = _settingService.LoadSetting <AliPayPaymentSettings>(_storeContext.CurrentStore.Id);

            var partner = aliPayPaymentSettings.Partner;

            if (string.IsNullOrEmpty(partner))
            {
                throw new Exception("合作身份者ID 不能为空");
            }

            var key = aliPayPaymentSettings.Key;

            if (string.IsNullOrEmpty(key))
            {
                throw new Exception("MD5密钥不能为空");
            }

            var sellerEmail = aliPayPaymentSettings.SellerEmail;

            if (string.IsNullOrEmpty(sellerEmail))
            {
                throw new Exception("卖家Email 不能为空");
            }

            ///↓↓↓↓↓↓↓ 获取支付宝POST过来通知消息,并以“参数名 = 参数值”的形式组成数组↓↓↓↓↓↓↓↓
            int i;
            var coll      = Request.Form;
            var sortedStr = coll.Keys.ToList();
            SortedDictionary <string, string> sPara = new SortedDictionary <string, string>();

            for (i = 0; i < sortedStr.Count; i++)
            {
                sPara.Add(sortedStr[i], Request.Form[sortedStr[i]]);
            }
            ///↑↑↑↑↑↑↑ 获取支付宝POST过来通知消息,并以“参数名 = 参数值”的形式组成数组↑↑↑↑↑↑↑↑
            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify(partner: partner, key: key, input_charset: "utf-8", sign_type: sPara["sign_type"]);
                var          notify_type  = Request.Form["notify_type"];
                var          notify_id    = Request.Form["notify_id"];
                var          sign         = Request.Form["sign"];
                bool         verifyResult = aliNotify.Verify(sPara, notify_id, sign);

                if (verifyResult)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

                    //批次号

                    string batch_no = Request.Form["batch_no"];

                    //批量退款数据中转账成功的笔数

                    string success_num = Request.Form["success_num"];

                    //批量退款数据中的详细信息
                    string result_details = Request.Form["result_details"];

                    //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓业务处理↓↓↓↓↓↓↓↓↓↓↓↓↓↓
                    try
                    {
                        string create_time = batch_no.Substring(0, 8);
                        var    refundInfo  = _refundInfoService.GetRefundInfoByBatch_no(batch_no);
                        if (refundInfo != null && refundInfo.OrderId > 0)
                        {
                            if (refundInfo.RefundStatus == RefundStatus.refund || notify_id == refundInfo.Notify_Id)
                            {
                                return(Content("success"));
                            }

                            var result_list = result_details.Split('#');
                            var item        = result_list[0];

                            refundInfo.Notify_Id   = notify_id;
                            refundInfo.Notify_Type = notify_type;

                            var obj            = item.Split('^');
                            var out_Trade_No   = obj[0];                //交易号
                            var AmountToRefund = decimal.Parse(obj[1]); //退款金额
                            var note           = obj[2];                //退款说明

                            var order       = _orderService.GetOrderById(refundInfo.OrderId);
                            var paymentInfo = _paymentInfoService.GetByOrderId(refundInfo.OrderId);
                            if (order != null)
                            {
                                if (note.ToUpper() == "SUCCESS")
                                {
                                    if (AmountToRefund >= 0 && AmountToRefund == refundInfo.AmountToRefund)
                                    {
                                        #region 成功
                                        order.OrderNotes.Add(new OrderNote
                                        {
                                            Note = string.Format("支付宝退款成功,退款编号:{0},退款金额:{1},交易号:{2},说明:{3}", batch_no, AmountToRefund, out_Trade_No, note),
                                            DisplayToCustomer = true,
                                            CreatedOnUtc      = DateTime.UtcNow
                                        });

                                        ////总退款
                                        decimal totalAmountRefunded = Math.Abs(order.RefundedAmount) + AmountToRefund;

                                        order.RefundedAmount = totalAmountRefunded;

                                        if (paymentInfo.Total > order.RefundedAmount)
                                        {
                                            order.PaymentStatus = PaymentStatus.PartiallyRefunded;
                                        }
                                        else
                                        {
                                            order.PaymentStatus = PaymentStatus.Refunded;
                                        }

                                        _orderService.UpdateOrder(order);

                                        ///改变订单状态
                                        _orderProcessingService.CheckOrderStatus(order);

                                        //修改退款记录为退款成功
                                        refundInfo.RefundStatusId = (int)RefundStatus.refund;
                                        refundInfo.RefundOnUtc    = DateTime.Now;
                                        refundInfo.Result_Details = result_details;
                                        _refundInfoService.Update(refundInfo);

                                        ///通知
                                        var orderRefundedStoreOwnerNotificationQueuedEmailId = _workflowMessageService.SendOrderRefundedStoreOwnerNotification(order, AmountToRefund, _localizationSettings.DefaultAdminLanguageId);
                                        if (orderRefundedStoreOwnerNotificationQueuedEmailId.Count > 0 && orderRefundedStoreOwnerNotificationQueuedEmailId[0] > 0)
                                        {
                                            order.OrderNotes.Add(new OrderNote
                                            {
                                                Note = string.Format("\"订单退款\" email (to store owner) has been queued. Queued email identifier: {0}.", orderRefundedStoreOwnerNotificationQueuedEmailId),
                                                DisplayToCustomer = false,
                                                CreatedOnUtc      = DateTime.UtcNow
                                            });
                                            _orderService.UpdateOrder(order);
                                        }
                                        var orderRefundedCustomerNotificationQueuedEmailId = _workflowMessageService.SendOrderRefundedCustomerNotification(order, AmountToRefund, order.CustomerLanguageId);
                                        if (orderRefundedCustomerNotificationQueuedEmailId.Count > 0 && orderRefundedCustomerNotificationQueuedEmailId[0] > 0)
                                        {
                                            order.OrderNotes.Add(new OrderNote
                                            {
                                                Note = string.Format("\"订单退款\" email (to customer) has been queued. Queued email identifier: {0}.", orderRefundedCustomerNotificationQueuedEmailId),
                                                DisplayToCustomer = false,
                                                CreatedOnUtc      = DateTime.UtcNow
                                            });
                                            _orderService.UpdateOrder(order);
                                        }

                                        //已退款事件
                                        _eventPublisher.Publish(new OrderRefundedEvent(order, AmountToRefund));
                                        return(Content("success"));

                                        #endregion
                                    }
                                    else
                                    {
                                        #region 错误
                                        //退款异常
                                        refundInfo.RefundStatusId = (int)RefundStatus.error;
                                        _refundInfoService.Update(refundInfo);
                                        order.OrderNotes.Add(new OrderNote
                                        {
                                            Note = string.Format("支付宝退款异常,退款编号:{0},退款金额:{1},交易号:{2},说明:{3}", batch_no, AmountToRefund, out_Trade_No, "退款金额错误"),
                                            DisplayToCustomer = false,
                                            CreatedOnUtc      = DateTime.UtcNow
                                        });
                                        _orderService.UpdateOrder(order);
                                        return(Content("success"));

                                        #endregion
                                    }
                                }
                            }
                        }
                        throw new Exception(string.Format("支付宝退款通知异常,退款编号:{0},退款金额:{1},交易号:{2},说明:{3}", batch_no, refundInfo.AmountToRefund, refundInfo.Out_Trade_No, "非正常处理"));
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex.Message);
                        return(Content("fail"));
                    }
                    //↑↑↑↑↑↑↑↑↑↑↑↑↑↑业务处理↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
                    ///结束业务处理
                    return(Content("success"));//请不要修改或删除
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    return(Content("fail"));
                }
            }
            else
            {
                return(Content("无通知参数"));
            }
            return(Content(""));
        }
        //[NonAction]
        //public override IList<string> ValidatePaymentForm(IFormCollection form)
        //{
        //    var warnings = new List<string>();

        //    return warnings;
        //}

        //[NonAction]
        //public override ProcessPaymentRequest GetPaymentInfo(IFormCollection form)
        //{
        //    var paymentInfo = new ProcessPaymentRequest();

        //    return paymentInfo;
        //}
        #endregion

        #region 支付请求
        /// <summary>
        /// 接收支付宝支付通知
        /// </summary>
        public ActionResult Notify(FormCollection form)
        {
            if (!(_paymentPluginManager.LoadPluginBySystemName("Nop.Plugin.Payments.AliPay") is AliPayPaymentProcessor processor) || !_paymentPluginManager.IsPluginActive(processor))
            {
                throw new NopException("插件无法加载");
            }
            var aliPayPaymentSettings = _settingService.LoadSetting <AliPayPaymentSettings>(_storeContext.CurrentStore.Id);
            var partner = aliPayPaymentSettings.Partner;

            if (string.IsNullOrEmpty(partner))
            {
                throw new Exception("合作身份者ID 不能为空");
            }
            var key = aliPayPaymentSettings.Key;

            if (string.IsNullOrEmpty(key))
            {
                throw new Exception("MD5密钥不能为空");
            }
            var sellerEmail = aliPayPaymentSettings.SellerEmail;

            if (string.IsNullOrEmpty(sellerEmail))
            {
                throw new Exception("卖家Email 不能为空");
            }
            ///↓↓↓↓↓↓↓ 获取支付宝POST过来通知消息,并以“参数名 = 参数值”的形式组成数组↓↓↓↓↓↓↓↓
            int i;
            var coll      = Request.Form;
            var sortedStr = coll.Keys.ToList();

            SortedDictionary <string, string> sPara = new SortedDictionary <string, string>();

            for (i = 0; i < sortedStr.Count; i++)
            {
                sPara.Add(sortedStr[i], Request.Form[sortedStr[i]]);
            }
            ///↑↑↑↑↑↑↑ 获取支付宝POST过来通知消息,并以“参数名 = 参数值”的形式组成数组↑↑↑↑↑↑↑↑
            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify(partner: partner, key: key, input_charset: "utf-8", sign_type: sPara["sign_type"]);
                var          sign         = Request.Form["sign"];
                var          notify_id    = Request.Form["notify_id"];
                bool         verifyResult = aliNotify.Verify(sPara, notify_id, 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 (coll["trade_status"] == "TRADE_FINISHED" || coll["trade_status"] == "TRADE_SUCCESS")
                    {
                        int orderId;

                        if (int.TryParse(out_trade_no, out orderId))
                        {
                            var order = _orderService.GetOrderById(orderId);

                            if (order != null && _orderProcessingService.CanMarkOrderAsPaid(order))
                            {
                                //修改订单状态
                                _orderProcessingService.MarkOrderAsPaid(order);
                                //添加付款信息
                                var paymentInfo = new PaymentInfo()
                                {
                                    OrderId       = orderId,
                                    Name          = processor.PluginDescriptor.SystemName,
                                    PaymentGuid   = Guid.NewGuid(),
                                    Trade_no      = trade_no,
                                    Total         = decimal.Parse(Request.Form["price"]),
                                    Trade_status  = Request.Form["trade_status"],
                                    Buyer_email   = Request.Form["buyer_email"],
                                    Buyer_id      = Request.Form["buyer_id"],
                                    Seller_email  = Request.Form["seller_email"],
                                    Seller_id     = Request.Form["seller_id"],
                                    Note          = Request.Form["subject"],
                                    Out_Trade_No  = Request.Form["trade_no"],
                                    CreateDateUtc = DateTime.Now,
                                };
                                _paymentInfoService.Insert(paymentInfo);
                            }
                        }
                    }
                    return(Content("success")); //请不要修改或删除
                }
                else //验证失败
                {
                    var logStr = string.Format("MD5:notify_id={0},sign={1}", notify_id, sign);
                    _logger.Error(logStr);
                    return(Content("fail"));
                }
            }
            return(Content("无通知参数"));
        }
예제 #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sArrary = GetRequestPost();
        ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
        AlipayConfig con           = new AlipayConfig();
        string       partner       = con.Partner;
        string       key           = con.Key;
        string       input_charset = con.Input_charset;
        string       sign_type     = con.Sign_type;
        string       transport     = con.Transport;

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

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

            //写日志记录(若要调试,请取消下面两行注释)
            string sWord = "responseTxt=" + responseTxt + "\n notify_url_log:sign=" + Request.Form["sign"] + "&mysign=" + mysign + "\n notify回来的参数:" + 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.Form["trade_no"];     //支付宝交易号
                string order_no     = Request.Form["out_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")
                {//该判断表示买家已在支付宝交易管理中产生了交易记录,但没有付款
                 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序

                    Response.Write("success");  //请不要修改或删除
                }
                else if (Request.Form["trade_status"] == "WAIT_SELLER_SEND_GOODS")
                {//该判断示买家已在支付宝交易管理中产生了交易记录且付款成功,但卖家没有发货
                 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序

                    Response.Write("success");  //请不要修改或删除
                }
                else if (Request.Form["trade_status"] == "WAIT_BUYER_CONFIRM_GOODS")
                {//该判断表示卖家已经发了货,但买家还没有做确认收货的操作
                 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序

                    Response.Write("success");  //请不要修改或删除
                }
                else if (Request.Form["trade_status"] == "TRADE_FINISHED")
                {//该判断表示买家已经确认收货,这笔交易完成
                 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序

                    Response.Write("success");  //请不要修改或删除
                }
                else
                {
                    Response.Write("success");  //其他状态判断。普通即时到帐中,其他状态不用判断,直接打印success。
                }
                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                Response.Write("fail");
            }
        }
        else
        {
            Response.Write("无通知参数");
        }
    }
예제 #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Error += new EventHandler(Page_Error);
        SortedDictionary <string, string> sArrary = GetRequestPost();
        ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
        string partner       = AlipayParameters.Partner;       //合作身份者ID
        string key           = AlipayParameters.Key;           //安全检验码
        string input_charset = AlipayParameters.Input_Charset; //字符编码格式 目前支持 gbk 或 utf-8
        string sign_type     = AlipayParameters.SignType;      //加密方式 不需修改
        string transport     = "http";                         //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http

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

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

            //写日志记录(若要调试,请取消下面两行注释)
            string sWord = "Get refund_Notify2_URL:responseTxt=" + responseTxt + "\n notify_url_log:sign=" + Request.Form["sign"] + "&mysign=" + mysign + "\n notify回来的参数:" + aliNotify.PreSignStr;


            //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
            //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
            //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
            if (responseTxt == "true" && sign == mysign)//验证成功
            {
                //请根据您的业务逻辑来编写程序(以下代码仅作参考)
                //获取支付宝的通知返回参数

                string notify_id   = Request.Form["notify_id"];
                string notify_time = Request.Form["notify_time"];

                string batch_no = Request.Form["batch_no"];

                sWord += "\n batch_no: " + batch_no;
                string success_num = Request.Form["success_num"];
                sWord += "\n success_num: " + success_num;
                string result_details = Request.Form["result_details"];
                sWord += "\n result_details: " + result_details;

                /*
                 * 平台退款格式:
                 * 原付款支付宝交易号^退款金额^处理结果码$被收费人Email^被收费人userId^退款金额^处理结果码
                 *
                 * */

                Refund_Platform_Result result = Refund_Platform_Result.Load(result_details);

                sWord += "\n RefundSuccess:" + result.IsRefundSuccess;
                sWord += "\n Refund_Charges_Success:" + result.IsRefund_ChargesSuccess;

                IList <EyouSoft.Model.TicketStructure.TicketPay> PayList = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().GetPayList(string.Empty, EyouSoft.Model.TicketStructure.ItemType.平台到采购商_变更, string.Empty, batch_no);
                if (result.IsRefund_ChargesSuccess && result.IsRefundSuccess)
                {
                    sWord += "\n paylist:" + PayList.Count;
                    if (PayList != null && PayList.Count > 0)
                    {
                        EyouSoft.Model.TicketStructure.TicketPay PayModel = PayList[0];

                        // 平台退款成功之后更新明细记录状态
                        EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().PayAfterCallBack(result.Trade_No, PayModel.PayPrice, EyouSoft.Model.TicketStructure.PayState.交易完成, PayModel.PayType, string.Empty, PayModel.Remark, PayModel.TradeNo, DateTime.Now, batch_no);
                        PayModel = null;
                    }
                    PayList = null;
                }
                else
                {
                    if (PayList != null && PayList.Count > 0)
                    {
                        EyouSoft.Model.TicketStructure.TicketPay PayModel = PayList[0];

                        EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().PayAfterCallBack(result.Trade_No, PayModel.PayPrice, EyouSoft.Model.TicketStructure.PayState.交易失败, PayModel.PayType, string.Empty, PayModel.Remark, PayModel.TradeNo, DateTime.Now, batch_no);
                        PayModel = null;
                    }
                    PayList = null;
                }

                Response.Write("success");
            }
            else//验证失败
            {
                sWord += "\n FAIL";
                Response.Write("fail");
            }

            AlipayFunction.log_result(Server.MapPath("../log/平台退款到采购商—" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord);
        }
        else
        {
            Response.Write("无通知参数");
        }
    }
예제 #21
0
        public string AlipayPayNotify()
        {
            LogHelper.SaveFileLog("AlipayPayNotify支付宝回调", "start");
            Dictionary <string, string> dicParam = GetRequestPost();

            //回调通知参数为空
            if (dicParam.Count == 0)
            {
                LogHelper.SaveFileLog("AlipayPayNotify支付宝回调", "无通知参数");
                return("fail");
            }
            AlipayNotify aliNotify = new AlipayNotify();
            //获取验签结果
            bool verifyResult = aliNotify.Verify(dicParam, dicParam["notify_id"], dicParam["sign"]);

            //验签失败
            if (!verifyResult)
            {
                LogHelper.SaveFileLog("AlipayPayNotify支付宝回调", "验签失败");
                return("fail");
            }

            //商户订单号
            string out_trade_no = dicParam["out_trade_no"];
            //支付宝交易号
            string trade_no = dicParam["trade_no"];
            //交易状态
            string trade_status = dicParam["trade_status"];

            if (trade_status == "TRADE_FINISHED")
            {
                LogHelper.SaveFileLog("AlipayPayNotify支付宝回调", "trade_status:" + trade_status);
                return("success");
                //判断该笔订单是否在商户网站中已经做过处理
                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                //如果有做过处理,不执行商户的业务程序

                //注意:
                //该种交易状态只在两种情况下出现
                //1、开通了普通即时到账,买家付款成功后。
                //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。
            }
            else if (trade_status == "TRADE_SUCCESS")
            {
                try
                {
                    //OrderService.PayOrderNotify(out_trade_no, trade_no);
                    return("success");
                }
                catch (Exception ex)
                {
                    LogHelper.SaveFileLog("AlipayPayNotify支付宝回调", "更新订单状态失败->Exception:" + ex.Message);
                    return("fail");
                }
            }
            else
            {
                LogHelper.SaveFileLog("AlipayPayNotify支付宝回调", "支付失败->trade_status:" + trade_status);
                return("fail");
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (!IsPostBack)
            {
                Dictionary <string, string> sPara = GetRequestPost();

                if (sPara.Count > 0)//判断是否有带返回参数
                {
                    bool verifyResult = false;

                    AlipayNotify aliNotify = new AlipayNotify();
                    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 trade_status      = xmlDoc.SelectSingleNode("/notify/trade_status").InnerText;
                            AliWapPayNotifyInfo info = new AliWapPayNotifyInfo();
                            info.trade_status = trade_status;
                            info.subject      = xmlDoc.SelectSingleNode("/notify/subject").InnerText;
                            info.trade_no     = xmlDoc.SelectSingleNode("/notify/trade_no").InnerText;
                            info.buyer_email  = xmlDoc.SelectSingleNode("/notify/buyer_email").InnerText;
                            info.gmt_create   = xmlDoc.SelectSingleNode("/notify/gmt_create").InnerText;
                            info.quantity     = xmlDoc.SelectSingleNode("/notify/quantity").InnerText;
                            info.out_trade_no = xmlDoc.SelectSingleNode("/notify/out_trade_no").InnerText;
                            info.notify_time  = xmlDoc.SelectSingleNode("/notify/notify_time").InnerText;
                            info.seller_id    = xmlDoc.SelectSingleNode("/notify/seller_id").InnerText;
                            info.total_fee    = xmlDoc.SelectSingleNode("/notify/total_fee").InnerText;
                            info.seller_email = xmlDoc.SelectSingleNode("/notify/seller_email").InnerText;
                            info.price        = xmlDoc.SelectSingleNode("/notify/price").InnerText;
                            //info.gmt_payment = xmlDoc.SelectSingleNode("/notify/gmt_payment").InnerText;
                            info.buyer_id   = xmlDoc.SelectSingleNode("/notify/buyer_id").InnerText;
                            info.notify_id  = xmlDoc.SelectSingleNode("/notify/notify_id").InnerText;
                            info.use_coupon = xmlDoc.SelectSingleNode("/notify/use_coupon").InnerText;
                            if (xmlDoc.SelectSingleNode("/notify/gmt_payment") != null)
                            {
                                info.gmt_payment = xmlDoc.SelectSingleNode("/notify/gmt_payment").InnerText;
                            }

                            if (trade_status == "TRADE_FINISHED")
                            {
                                //判断该笔订单是否在商户网站中已经做过处理
                                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                                //如果有做过处理,不执行商户的业务程序

                                //注意:
                                //该种交易状态只在两种情况下出现
                                //1、开通了普通即时到账,买家付款成功后。
                                //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。

                                //微商易业务逻辑
                                OnPaySucceed(info);

                                Response.Write("success");  //请不要修改或删除
                            }
                            else if (trade_status == "TRADE_SUCCESS")
                            {
                                //判断该笔订单是否在商户网站中已经做过处理
                                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                                //如果有做过处理,不执行商户的业务程序

                                //注意:
                                //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。

                                //微商易业务逻辑
                                OnPaySucceed(info);

                                Response.Write("success");  //请不要修改或删除
                            }
                            else
                            {
                                Response.Write(trade_status);
                            }
                        }
                        catch (Exception exc)
                        {
                            Response.Write(exc.ToString());
                        }



                        //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    }
                    else//验证失败
                    {
                        Response.Write("fail");
                    }
                }
                else
                {
                    Response.Write("无通知参数");
                }
            }
        }
예제 #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BaseService.WriteLog("页面跳转同步通知页面-----------------------AlipayWapTrade2/Call_Back.aspx");
            AlipayWapTradeResponseBLL alipayServer = new AlipayWapTradeResponseBLL(new Utility.BasicUserInfo());

            Dictionary <string, string> sPara = GetRequestGet();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify();
                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"];

                    //判断是否在商户网站中已经做过了这次通知返回的处理
                    //如果没有做过处理,那么执行商户的业务程序
                    //如果有做过处理,那么不执行商户的业务程序

                    BaseService.WriteLog("result:" + result);

                    if (!result.Equals("success"))
                    {
                        //交易失败
                        if (!string.IsNullOrEmpty(out_trade_no))
                        {
                            alipayServer.UpdateAlipayWapTradeStatus(Request["out_trade_no"], "3");
                            PostResult(alipayServer, "fail");

                            //推送交易结果集
                            BaseService.WriteLog("推送交易结果集");
                            PostResult(alipayServer, "fail");

                            BaseService.WriteLog("交易失败,更新支付宝交易状态");
                        }

                        Response.Write("fail");
                        return;
                    }
                    else //交易成功,请填写自己的业务代码
                    {
                        if (!string.IsNullOrEmpty(out_trade_no))
                        {
                            try
                            {
                                BaseService.WriteLog("out_trade_no:" + out_trade_no);
                                BaseService.WriteLog("交易成功");

                                //更新交易状态
                                BaseService.WriteLog("更新交易状态");
                                alipayServer.UpdateAlipayWapTradeStatus(out_trade_no, "2");

                                //处理分润业务
                                BaseService.WriteLog("处理分润业务");
                                //RoyaltyBusiness(out_trade_no, trade_no);

                                //推送交易结果集
                                BaseService.WriteLog("推送交易结果集");
                                PostResult(alipayServer, "success");
                            }
                            catch (Exception ex)
                            {
                                BaseService.WriteLog("异常信息: " + ex.ToString());
                            }
                        }
                        else
                        {
                            BaseService.WriteLog("out_trade_no is null!!!!! ");
                        }

                        Response.Redirect(AlipayConfig.Merchant_url);
                    }
                }
                else//验证失败
                {
                    if (Request["out_trade_no"] != null)
                    {
                        alipayServer.UpdateAlipayWapTradeStatus(Request["out_trade_no"], "4");
                        PostResult(alipayServer, "fail");

                        BaseService.WriteLog("验签出错,可能被别人篡改数据。");
                    }

                    Response.Write("验证失败");
                }
            }
            else
            {
                Response.Write("无返回参数");
            }
        }
예제 #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sPara = GetRequestPost();

        if (sPara.Count > 0)//判断是否有带返回参数
        {
            AlipayNotify aliNotify    = new AlipayNotify();
            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")
                {
                    //判断该笔订单是否在商户网站中已经做过处理
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
                    //如果有做过处理,不执行商户的业务程序

                    //注意:
                    //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
                }
                else if (Request.Form["trade_status"] == "TRADE_SUCCESS")
                {
                    //判断该笔订单是否在商户网站中已经做过处理
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
                    //如果有做过处理,不执行商户的业务程序

                    //注意:
                    //付款完成后,支付宝系统发送该交易状态通知
                }
                else
                {
                }

                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                Response.Write("success");  //请不要修改或删除

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                Response.Write("fail");
            }
        }
        else
        {
            Response.Write("无通知参数");
        }
    }
예제 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Error += new EventHandler(Page_Error);
            SortedDictionary <string, string> sArrary = GetRequestPost();
            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            string partner       = AlipayParameters.Partner;       //合作身份者ID
            string key           = AlipayParameters.Key;           //安全检验码
            string input_charset = AlipayParameters.Input_Charset; //字符编码格式 目前支持 gbk 或 utf-8
            string sign_type     = AlipayParameters.SignType;      //加密方式 不需修改
            string transport     = "http";                         //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http

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

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

                ////写日志记录(若要调试,请取消下面两行注释)
                string sWord = "Notify_URL:responseTxt=" + responseTxt + "\n notify_url_log:sign=" + Request.Form["sign"] + "&mysign=" + mysign + "\n notify回来的参数:" + aliNotify.PreSignStr;


                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                if (responseTxt == "true" && sign == mysign)//验证成功
                {
                    //请根据您的业务逻辑来编写程序(以下代码仅作参考)
                    //获取支付宝的通知返回参数
                    string trade_no     = Request.Form["trade_no"];     //支付宝交易号
                    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 buyer_email  = Request.Form["buyer_email"];  //买家支付宝账号
                    string trade_status = Request.Form["trade_status"]; //交易状态

                    sWord += "\n TRUE";
                    //表示交易成功(TRADE_FINISHED/TRADE_SUCCESS)
                    EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();

                    IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList("", EyouSoft.Model.TicketStructure.ItemType.供应商付款到平台_购买运价, order_no, "");

                    if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")
                    {
                        //为了保证不被重复调用,或重复执行数据库更新程序,请判断该笔交易状态是否是订单未处理状态
                        //string order_no="201011080010";
                        //string trade_no="2010110861004313";
                        //string total_fee="0.01";
                        //string buyer_email="*****@*****.**";
                        //string seller_mailer="*****@*****.**";
                        if (payList != null && payList.Count > 0)
                        {
                            if (payList[0].PayState != EyouSoft.Model.TicketStructure.PayState.交易完成)
                            {
                                EyouSoft.BLL.TicketStructure.FreightBuyLog.CreateInstance().PayAfter(trade_no, Utils.GetDecimal(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, order_no, DateTime.Now, "");
                            }
                        }
                    }
                    else
                    {
                        Response.Write("trade_status=" + Request.Form["trade_status"]);
                    }
                    AlipayFunction.log_result(Server.MapPath("../log/运价购买 " + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord);

                    Response.Write("success");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
예제 #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Error += new EventHandler(Page_Error);
            SortedDictionary <string, string> sArrary = GetRequestPost();
            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            string partner       = AlipayParameters.Partner;       //合作身份者ID
            string key           = AlipayParameters.Key;           //安全检验码
            string input_charset = AlipayParameters.Input_Charset; //字符编码格式 目前支持 gbk 或 utf-8
            string sign_type     = AlipayParameters.SignType;      //加密方式 不需修改
            string transport     = "http";                         //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http

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

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

                ////写日志记录(若要调试,请取消下面两行注释)
                string sWord = "Notify_URL:responseTxt=" + responseTxt + "\n notify_url_log:sign=" + Request.Form["sign"] + "&mysign=" + mysign + "\n notify回来的参数:" + aliNotify.PreSignStr;


                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                if (responseTxt == "true" && sign == mysign)//验证成功
                {
                    //请根据您的业务逻辑来编写程序(以下代码仅作参考)
                    //获取支付宝的通知返回参数
                    string trade_no     = Request.Form["trade_no"];     //支付宝交易号
                    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 buyer_email  = Request.Form["buyer_email"];  //买家支付宝账号
                    string trade_status = Request.Form["trade_status"]; //交易状态



                    //string notify_id = Request.QueryString["notify_id"];
                    //string notify_time = Request.QueryString["notify_time"];
                    //string buyer_id = Request.QueryString["buyer_id"];

                    //string gmt_create = Request.QueryString["gmt_create"];
                    //string gmt_payment = Request.QueryString["gmt_payment"];

                    sWord += "\n TRUE";


                    //表示交易成功(TRADE_FINISHED/TRADE_SUCCESS)
                    EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();

                    EyouSoft.Model.TicketStructure.OrderInfo info = orderBll.GetOrderInfoByNo(order_no);
                    if (info.OrderState == EyouSoft.Model.TicketStructure.OrderState.审核通过)
                    {
                        IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(info.SupplierCId); //获取供应商所有账户
                        string sellAccount = "";                                                                                                                                                             //供应商账户
                        EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == EyouSoft.Model.TicketStructure.TicketAccountType.支付宝);                //获取供应商账户实体
                        if (accountModel != null)
                        {
                            sellAccount = accountModel.AccountNumber;//赋值供应商账户
                        }
                        string  batchNo   = "";
                        decimal IntoRatio = decimal.Parse(AlipayParameters.TongyeFee);
                        IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList(info.OrderId, EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单, order_no, null);


                        if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")
                        {
                            sWord += "/n 交易成功";
                            //为了保证不被重复调用,或重复执行数据库更新程序,请判断该笔交易状态是否是订单未处理状态
                            //string order_no="201011080010";
                            //string trade_no="2010110861004313";
                            //string total_fee="0.01";
                            //string buyer_email="*****@*****.**";
                            //string seller_mailer="*****@*****.**";
                            if (payList != null && payList.Count > 0)
                            {
                                sWord += "/n you";
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                sWord += "/n meiyou";
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                        }
                        else
                        {
                            sWord += "/n 交易失败";
                            if (payList != null && payList.Count > 0)
                            {
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                        }

                        AlipayFunction.log_result(Server.MapPath("../log/" + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord);
                    }
                    Response.Write("success");
                }
                else//验证失败
                {
                    //sWord += "\n FAIL";
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
예제 #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sArrary = GetRequestPost();
        ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
        AlipayConfig con           = new AlipayConfig();
        string       partner       = con.Partner;
        string       key           = con.Key;
        string       input_charset = con.Input_charset;
        string       sign_type     = con.Sign_type;
        string       transport     = con.Transport;

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

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

            //写日志记录(若要调试,请取消下面两行注释)
            string sWord = "responseTxt=" + responseTxt + "\n notify_url_log:sign=" + Request.Form["sign"] + "&mysign=" + mysign + "\n notify回来的参数:" + 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 batch_no = Request.Form["batch_no"];

                //获取批量退款数据中转账成功的笔数
                string success_num = Request.Form["success_num"];

                //获取批量退款数据中的详细信息
                string result_details = Request.Form["result_details"];
                //格式:第一笔交易#第二笔交易#第三笔交易
                //第N笔交易格式:交易退款信息
                //交易退款信息格式:原付款支付宝交易号^退款总金额^处理结果码^结果描述



                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

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


                Response.Write("success");      //向支付宝反馈的成功标志,请不要修改或删除
            }
            else//验证失败
            {
                Response.Write("fail");
            }
        }
        else
        {
            Response.Write("无通知参数");
        }
    }
예제 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BaseService.WriteLog("服务器异步通知页面-----------------------AlipayWapTrade2/Notify.aspx");

            Dictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                BaseService.WriteLog("开始验证");

                AlipayNotify aliNotify    = new AlipayNotify();
                bool         verifyResult = aliNotify.VerifyNotify(sPara, Request.Form["sign"]);

                if (verifyResult)//验证成功
                {
                    BaseService.WriteLog("验证成功");
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码


                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //解密(如果是RSA签名需要解密,如果是MD5签名则下面一行清注释掉)
                    sPara = aliNotify.Decrypt(sPara);

                    //XML解析notify_data数据
                    try
                    {
                        BaseService.WriteLog("notify_data:" + sPara["notify_data"]);

                        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;

                        //交易成功,更新支付宝交易状态
                        UpdateAlipayWapTrade(xmlDoc, "2");

                        BaseService.WriteLog("交易状态trade_status:" + trade_status);

                        if (trade_status == "TRADE_FINISHED")
                        {
                            //判断该笔订单是否在商户网站中已经做过处理
                            //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                            //如果有做过处理,不执行商户的业务程序

                            if (!string.IsNullOrEmpty(out_trade_no))
                            {
                                try
                                {
                                    var alipayServer = new AlipayWapTradeResponseBLL(new Utility.BasicUserInfo());
                                    BaseService.WriteLog("out_trade_no:" + out_trade_no);
                                    BaseService.WriteLog("交易成功");

                                    //更新交易状态
                                    BaseService.WriteLog("更新交易状态");
                                    alipayServer.UpdateAlipayWapTradeStatus(out_trade_no, "2");

                                    //处理分润业务
                                    BaseService.WriteLog("处理分润业务");
                                    //RoyaltyBusiness(out_trade_no, trade_no);

                                    //推送交易结果集
                                    BaseService.WriteLog("推送交易结果集");
                                    PostResult(alipayServer, "success", out_trade_no);
                                }
                                catch (Exception ex)
                                {
                                    BaseService.WriteLog("异常信息: " + ex.ToString());
                                }
                            }
                            else
                            {
                                BaseService.WriteLog("out_trade_no is null!!!!! ");
                            }

                            //注意:
                            //该种交易状态只在两种情况下出现
                            //1、开通了普通即时到账,买家付款成功后。
                            //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。
                            Response.Write("success");  //请不要修改或删除
                        }
                        else if (trade_status == "TRADE_SUCCESS")
                        {
                            //判断该笔订单是否在商户网站中已经做过处理
                            //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                            //如果有做过处理,不执行商户的业务程序

                            if (!string.IsNullOrEmpty(out_trade_no))
                            {
                                try
                                {
                                    var alipayServer = new AlipayWapTradeResponseBLL(new Utility.BasicUserInfo());
                                    BaseService.WriteLog("out_trade_no:" + out_trade_no);
                                    BaseService.WriteLog("交易成功");

                                    //更新交易状态
                                    BaseService.WriteLog("更新交易状态");
                                    alipayServer.UpdateAlipayWapTradeStatus(out_trade_no, "2");

                                    //处理分润业务
                                    BaseService.WriteLog("处理分润业务");
                                    RoyaltyBusiness(out_trade_no, trade_no);

                                    //推送交易结果集
                                    BaseService.WriteLog("推送交易结果集");
                                    PostResult(alipayServer, "success", out_trade_no);
                                }
                                catch (Exception ex)
                                {
                                    BaseService.WriteLog("异常信息: " + ex.ToString());
                                }
                            }
                            else
                            {
                                BaseService.WriteLog("out_trade_no is null!!!!! ");
                            }

                            //注意:
                            //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。
                            Response.Write("success");  //请不要修改或删除
                        }
                        else
                        {
                            Response.Write(trade_status);
                        }
                    }
                    catch (Exception exc)
                    {
                        BaseService.WriteLog("异常信息:" + exc.ToString());
                        Response.Write(exc.ToString());
                    }
                }
                else//验证失败
                {
                    BaseService.WriteLog("验证失败");
                    Response.Write("fail");
                }
            }
            else
            {
                BaseService.WriteLog("无通知参数");
                Response.Write("无通知参数");
            }
        }
예제 #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sArrary = GetRequestGet();
        ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
        AlipayConfig con           = new AlipayConfig();
        string       partner       = con.Partner;
        string       key           = con.Key;
        string       input_charset = con.Input_charset;
        string       sign_type     = con.Sign_type;
        string       transport     = con.Transport;

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

        if (sArrary.Count > 0)//判断是否有带返回参数
        {
            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 user_id = Request.QueryString["user_id"];                        //获取支付宝用户唯一ID号

                //以下是示例——
                //判断获取到的user_id的值是否在商户会员数据库中存在(即:是否曾经做过支付宝会员通用登录)
                //	若不存在,则程序自动为会员快速注册一个会员,把信息插入商户网站会员数据表中,
                //	且把该会员的在商户网站上的登录状态,更改成“已登录”状态。并记录在商家网站会员数据表中记录登录信息,如登录时间、次数、IP等。
                //	若存在,判断该会员在商户网站上的登录状态是否是“已登录”状态
                //		若不是,则把该会员的在商户网站上的登录状态,更改成“已登录”状态。并记录在商家网站会员数据表中记录登录信息,如登录时间、次数、IP等。
                //		若是,则不做任何数据库业务逻辑处理。判定该次反馈信息为重复刷新返回链接导致。

                //打印页面
                StringBuilder sbHtml = new StringBuilder();
                sbHtml.Append("<table align=center width=350 cellpadding=5 cellspacing=0>");
                sbHtml.Append("<tr><td align=center class=font_title>亲爱的商城会员," + user_id + ":<br />您已经登录成功</td>");
                sbHtml.Append("</tr></table>");
                LblShow.Text = sbHtml.ToString();
                //请根据您的业务逻辑来编写程序(以上代码仅作参考)
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                LblShow.Text = "系统出错,验证失败";
            }
        }
        else
        {
            LblShow.Text = "无返回参数";
        }
    }
예제 #30
0
        // 同步调用,只发生一次
        // GET: Payment/AlipayReturn
        public ActionResult AlipayReturn()
        {
            SortedDictionary <string, string> sPara = GetRequestGet();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify    = new AlipayNotify();
                bool         verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]);

                if (true)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码

                    string notify_time  = Request.QueryString["notify_time"];                  //通知时间
                    string notify_type  = "";                                                  //Request.Form["notify_type"]; //通知类型
                    string notify_id    = Request.QueryString["notify_id"];                    //通知校验ID
                    string sign_type    = Request.QueryString["sign_type"];                    //签名方式
                    string sign         = Request.QueryString["sign"];                         //签名
                    string out_trade_no = Request.QueryString["out_trade_no"];                 //商户订单号
                    string subject      = Request.QueryString["subject"];                      //商品名称
                    string payment_type = Request.QueryString["payment_type"];                 //支付类型
                    string trade_no     = Request.QueryString["trade_no"];                     //支付宝交易号
                    string trade_status = Request.QueryString["trade_status"];                 //交易状态
                    string gmt_create   = DateTime.Now.ToString(CultureInfo.InvariantCulture); //交易创建时间

                    string gmt_payment = DateTime.Now.ToString(CultureInfo.InvariantCulture);  //交易付款时间

                    string gmt_close = DateTime.Now.ToString(CultureInfo.InvariantCulture);    //交易关闭时间

                    string  seller_email       = Request.QueryString["seller_email"];          //卖家支付宝账号
                    string  seller_id          = Request.QueryString["seller_id"];             //卖家支付宝账户号
                    string  buyer_email        = Request.QueryString["buyer_email"];           //买家支付宝账号
                    string  buyer_id           = Request.QueryString["buyer_id"];              //买家支付宝账户号
                    string  total_fee          = Request.QueryString["total_fee"];             //交易金额
                    string  body               = Request.QueryString["body"];                  //商品描述
                    string  discount           = Request.QueryString["discount"];              //折扣
                    string  business_scene     = Request.QueryString["business_scene"];        //是否扫码支付
                    string  extra_common_param = Request.QueryString["extra_common_param"];    //公用回传参数
                    JObject jo      = JObject.Parse(extra_common_param);
                    string  user_id = jo["UserId"].ToString();
                    string  exId    = jo["ExId"].ToString();
                    string  address = jo["Address"].ToString();
                    string  deposit = jo["Deposit"].ToString();
                    string  method  = jo["Method"].ToString();

                    if (subject.IndexOf("兑换订单", StringComparison.Ordinal) > -1)  //兑换订单
                    {
                        //ExchangeConfirm(user_id, exId, address, deposit, method);
                    }
                    else
                    {
                        Recharge(user_id, subject, total_fee, out_trade_no, body);
                    }


                    if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序
                        string message = "支付成功";
                    }
                    else
                    {
                        string message = "支付失败";
                    }

                    //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    string message = ("验证失败");
                }
            }
            else
            {
                string message = ("无返回参数");
            }
            return(View());
        }