Example #1
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            try
            {
                SortedDictionary <string, string> sPara = GetRequestPost();

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

                    bool verifyResult = aliNotify.Verify(sPara
                                                         , HttpContext.Current.Request.Form["notify_id"]
                                                         , HttpContext.Current.Request.Form["sign"]);

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


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

                        //批量付款数据中转账成功的详细信息

                        string batchNo = HttpContext.Current.Request.Form["batch_no"];

                        string success_details = HttpContext.Current.Request.Form["success_details"];

                        //批量付款数据中转账失败的详细信息
                        string fail_details = HttpContext.Current.Request.Form["fail_details"];

                        string[] success_arr = success_details.Split('|');
                        foreach (string item in success_arr)
                        {
                            string[] arr  = item.Split('^');
                            int      code = Withdrawal.Complete(SuppId
                                                                , arr[0]
                                                                , false
                                                                , 2
                                                                , arr[3]
                                                                , batchNo
                                                                , "AlipayBatchPayAPI");
                        }

                        string[] fail_arr = fail_details.Split('|');
                        foreach (string item in fail_arr)
                        {
                            string[] arr  = item.Split('^');
                            int      code = Withdrawal.Complete(SuppId
                                                                , arr[0]
                                                                , false
                                                                , 4
                                                                , "0"
                                                                , batchNo
                                                                , "AlipayBatchPayAPI");
                        }

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

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

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

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    }
                    else //验证失败
                    {
                        HttpContext.Current.Response.Write("fail");
                    }
                }
                else
                {
                    HttpContext.Current.Response.Write("无通知参数");
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
        }