コード例 #1
0
        public static void Callback_Notify(string payingGateway)
        {
            PayingCallbackEntity entity = new PayingCallbackEntity();

            entity.IOC_Class_Alias = payingGateway;
            new BankFacade().Callback_Return(entity);
        }
コード例 #2
0
        public void Callback_Notify(PayingCallbackEntity entity)
        {
            HttpRequest  Request  = HttpContext.Current.Request;
            HttpResponse Response = HttpContext.Current.Response;

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

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

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

                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
                    string 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 (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序
                        IAClass.Bussiness.Payment.CheckIn(order_no, trade_no);
                        Response.Write("success");  //请不要修改或删除
                    }
                    else
                    {
                        Response.Write("success");  //其他状态判断。普通即时到帐中,其他状态不用判断,直接打印success。
                    }

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

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
コード例 #3
0
        public void Callback_Notify(PayingCallbackEntity entity)
        {
            try
            {
                //注入实例
                instance = container.Resolve <IBank>(entity.IOC_Class_Alias);
            }
            catch (Exception e)
            {
                Common.LogIt(e.ToString());
                throw;
            }

            instance.Callback_Notify(entity);
        }
コード例 #4
0
        public void Callback_Return(PayingCallbackEntity entity)
        {
            HttpRequest  Request  = HttpContext.Current.Request;
            HttpResponse Response = HttpContext.Current.Response;

            //Common.LogIt(Request.Url.ToString());
            SortedDictionary <string, string> sPara = GetRequestGet();

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

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

                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
                    string 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 (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序
                        if (IAClass.Bussiness.Payment.CheckIn(order_no, trade_no))
                        {
                            Response.Write("付款成功");
                        }
                        else
                        {
                            Response.Write("订单确认失败,请联系管理员进行人工核对!");
                        }
                    }
                    else
                    {
                        Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                        Response.Write("trade_no=" + trade_no);
                    }

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

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("验证失败");
                }
            }
            else
            {
                Response.Write("无返回参数");
            }
        }
コード例 #5
0
        public void Callback_Notify(PayingCallbackEntity entity)
        {
            HttpRequest  Request  = HttpContext.Current.Request;
            HttpResponse Response = HttpContext.Current.Response;

            //接收数据
            string billno        = Request["billno"];
            string amount        = Request["amount"];
            string currency_type = Request["Currency_type"];
            string mydate        = Request["date"];
            string succ          = Request["succ"];
            string msg           = Request["msg"];
            string attach        = Request["attach"];
            string ipsbillno     = Request["ipsbillno"];
            string retEncodeType = Request["retencodetype"];
            string signature     = Request["signature"];

            if (succ != "Y")
            {
                Response.Write("交易失败!");
            }
            else
            {
                //签名原文 billno{订单编号}currencytype{币种}amount{订单金额}date{订单日期}succ{成功标志}ipsbillno{IPS订单编号}retencodetype{交易返回签名方式}{商户内部证书字符串}
                string toBeSigned = "billno{0}currencytype{1}amount{2}date{3}succ{4}ipsbillno{5}retencodetype{6}{7}";
                toBeSigned = string.Format(toBeSigned, billno, currency_type, amount, mydate, succ, ipsbillno, retEncodeType, config[1]);

                //签名是否正确
                Boolean verify = false;

                //验证方式:16-md5withRSA  17-md5
                //if (retEncodeType == "16")
                //{
                //    string pubfilename = "C:\\PubKey\\publickey.txt";
                //    RSAMD5Class m_RSAMD5Class = new RSAMD5Class();
                //    int result = m_RSAMD5Class.VerifyMessage(pubfilename, toBeSigned, signature);

                //    //result=0   表示签名验证成功
                //    //result=-1  表示系统错误
                //    //result=-2  表示文件绑定错误
                //    //result=-3  表示读取公钥失败
                //    //result=-4  表示签名长度错
                //    //result=-5  表示签名验证失败
                //    //result=-99 表示系统锁定失败
                //    if (result == 0)
                //    {
                //        verify = true;
                //    }
                //}
                //else if (retEncodeType == "17")
                {
                    //Md5摘要
                    string signature1 = FormsAuthentication.HashPasswordForStoringInConfigFile(toBeSigned, "MD5").ToLower();

                    if (signature1 == signature)
                    {
                        verify = true;
                    }
                }

                //判断签名验证是否通过
                if (verify == true)
                {
                    //判断交易是否成功
                    if (succ != "Y")
                    {
                        Response.Write("交易失败!");
                        Response.End();
                    }
                    else
                    {
                        IAClass.Bussiness.Payment.CheckIn(billno, ipsbillno);
                        Response.Write("ipscheckok");
                        Response.End();

                        /****************************************************************
                        *  //比较返回的订单号和金额与您数据库中的金额是否相符
                        *  if(不等)
                        *  {
                        *   Response.Write("从IPS返回的数据和本地记录的不符合,失败!");
                        *   Response.End();
                        *  }
                        *  else
                        *  {
                        *   '***注:由于使用server to server的方式和browser两种方式一起使用,在数据库处理上面,需要对接收到的订单做状态判断,判断下是否已经对这笔订单做过处理了,如果处理过了就不再处理了,如果没有的话,就进行确认。
                        *   '***注:处理您的数据库的时候,请仔细参阅<<环迅IPS3.0系统接口手册>>中关于<<附录2. 交易返回方式>>的说明
                        *   'Response.Write "交易成功,处理您的数据库!"
                        *    'If 若您确认接收,并且交易处理完成 then
                        *       '请务必发送 ipscheckok(小写)给 ips,否则 IPS 将不断发送该笔定单信息给商户
                        *        'Response.Write("ipscheckok");
                        *        'Response.End();
                        *    'Else
                        *       'Response.End
                        *    'End If
                        *  }
                        ****************************************************************/
                    }
                }
                else
                {
                    Response.Write("签名不正确!");
                }
            }
        }
コード例 #6
0
        public void Callback_Return(PayingCallbackEntity entity)
        {
            HttpRequest  Request  = HttpContext.Current.Request;
            HttpResponse Response = HttpContext.Current.Response;

            //接收数据
            string billno        = Request["billno"];
            string amount        = Request["amount"];
            string currency_type = Request["Currency_type"];
            string mydate        = Request["date"];
            string succ          = Request["succ"];
            string msg           = Request["msg"];
            string attach        = Request["attach"];
            string ipsbillno     = Request["ipsbillno"];
            string retEncodeType = Request["retencodetype"];
            string signature     = Request["signature"];

            if (succ != "Y")
            {
                Response.Write("交易失败!");
            }
            else
            {
                //签名原文 billno{订单编号}currencytype{币种}amount{订单金额}date{订单日期}succ{成功标志}ipsbillno{IPS订单编号}retencodetype{交易返回签名方式}{商户内部证书字符串}
                string toBeSigned = "billno{0}currencytype{1}amount{2}date{3}succ{4}ipsbillno{5}retencodetype{6}{7}";
                toBeSigned = string.Format(toBeSigned, billno, currency_type, amount, mydate, succ, ipsbillno, retEncodeType, config[1]);

                //签名是否正确
                Boolean verify = false;

                //验证方式:16-md5withRSA  17-md5
                //if (retEncodeType == "16")
                //{
                //    string pubfilename = "C:\\PubKey\\publickey.txt";
                //    RSAMD5Class m_RSAMD5Class = new RSAMD5Class();
                //    int result = m_RSAMD5Class.VerifyMessage(pubfilename, toBeSigned, signature);

                //    //result=0   表示签名验证成功
                //    //result=-1  表示系统错误
                //    //result=-2  表示文件绑定错误
                //    //result=-3  表示读取公钥失败
                //    //result=-4  表示签名长度错
                //    //result=-5  表示签名验证失败
                //    //result=-99 表示系统锁定失败
                //    if (result == 0)
                //    {
                //        verify = true;
                //    }
                //}
                //else if (retEncodeType == "17")
                {
                    //Md5摘要
                    string signature1 = FormsAuthentication.HashPasswordForStoringInConfigFile(toBeSigned, "MD5").ToLower();

                    if (signature1 == signature)
                    {
                        verify = true;
                    }
                }

                //判断签名验证是否通过
                if (verify == true)
                {
                    //判断交易是否成功
                    if (succ != "Y")
                    {
                        Response.Write("交易失败!");
                        Response.End();
                    }
                    else
                    {
                        /****************************************************************
                        *  //比较返回的订单号和金额与您数据库中的金额是否相符
                        *  if(不等)
                        *  {
                        *   Response.Write("从IPS返回的数据和本地记录的不符合,失败!");
                        *   Response.End();
                        *  }
                        *  else
                        *  {
                        *   Reponse.Write("交易成功,处理您的数据库!");
                        *  }
                        ****************************************************************/

                        if (IAClass.Bussiness.Payment.CheckIn(billno, ipsbillno))
                        {
                            Response.Write("付款成功");
                        }
                        else
                        {
                            Response.Write("订单确认失败,请联系管理员进行人工核对!");
                        }
                    }
                }
                else
                {
                    Response.Write("签名不正确!");
                }
            }
        }