public static bool AddBonustoCard(string CardTrack, FayRetailCheckInfo CheckInfo, string Cashier, out string Message)
 {
     Message = "";
     try
     {
         Utils.ToCardLog("AddBonustoCard CardTrack: " + CardTrack);
         RequestData DiscRequest              = GetDiscountRequestData(CardTrack, CheckInfo, Cashier);
         string      DiscRequestStr           = XMLSerializer.RequestSerializer(DiscRequest);
         string      StatusDescription        = "";
         System.Net.HttpStatusCode StatusCode = System.Net.HttpStatusCode.OK;
         string CalcAnsw2 = FayRetailClient.SendDataToSrv(DiscRequestStr, out StatusDescription, out StatusCode);
         if (StatusCode == HttpStatusCode.OK)
         {
             ResponseData Aswer = XMLSerializer.ResponseDeSerializer(CalcAnsw2);
             if (Aswer.ErrorCode == 0)
             {
                 if ((Aswer.Discounts != null) && (Aswer.Discounts.Count > 0))
                 {
                     Message = Aswer.Discounts[0].ChequeMessageDecript;
                     return(true);
                 }
                 Message = "Пустой ответ от сервера.";
                 return(false);
             }
             Message = "Ошибка в  ответе от сервера: " + Aswer.ErrorMessage;
             return(false);
         }
         Message = "Ошибка сервера: " + StatusDescription;
         return(false);
     }
     catch (Exception e)
     {
         Message = "Error AddBonustoCard " + e.Message;
         //Utils.ToCardLog("Error AddBonustoCard " + e.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
        public static string TestAddBonus(string PurchaseID)
        {
            FayRetailCheckInfo CheckInfo = new FayRetailCheckInfo()
            {
                Items        = GetTestChequeLines(),
                ChequeNumber = "10002",
                ChequeDate   = DateTime.Now
            };

            RequestData Data           = FayRetailClient.GetCalculateRequestData(CardTrack, CheckInfo, Cashier);
            string      CalcRequestStr = XMLSerializer.RequestSerializer(Data);
            string      CalcAnsw       = "";

            System.Net.HttpStatusCode StatusCode = System.Net.HttpStatusCode.OK;
            string CalcAnsw2 = FayRetailClient.SendDataToSrv(CalcRequestStr, out CalcAnsw, out StatusCode);

            RequestData DiscData        = FayRetailClient.GetDiscountRequestData(CardTrack, CheckInfo, Cashier);
            string      DiscRequestStr  = XMLSerializer.RequestSerializer(DiscData);
            string      DiscAnsw        = "";
            string      DiscAnsw2       = FayRetailClient.SendDataToSrv(DiscRequestStr, out DiscAnsw, out StatusCode);
            string      DiscRespMessage = "";

            if (StatusCode == System.Net.HttpStatusCode.OK)
            {
                ResponseData Aswer = XMLSerializer.ResponseDeSerializer(DiscAnsw2);
                if (Aswer.ErrorCode == 0)
                {
                    if ((Aswer.Discounts != null) && (Aswer.Discounts.Count > 0))
                    {
                        DiscRespMessage = Aswer.Discounts[0].ChequeMessageDecript;
                    }
                    else
                    {
                        DiscRespMessage = "Пустой ответ от сервера.";
                    }
                }
                else
                {
                    DiscRespMessage = "Ошибка в  ответе от сервера: " + Aswer.ErrorMessage;
                }
            }


            /*
             * RequestData PurcData = FayRetailClient.GetConfirmPurchaseRequestData(Cashier, PurchaseID);
             * string PurcRequestStr = XMLSerializer.RequestSerializer(PurcData);
             * string PurcAnsw = "";
             * string PurcAnsw2 = FayRetailClient.SendDataToSrv(PurcRequestStr, out PurcAnsw, out StatusCode);
             */
            string Resstr = "Calc:" + Environment.NewLine +
                            CalcRequestStr + Environment.NewLine +
                            "CalcResp:" + Environment.NewLine +
                            CalcAnsw + Environment.NewLine + CalcAnsw2 + Environment.NewLine +
                            "Disc:" + Environment.NewLine +
                            DiscRequestStr + Environment.NewLine + Environment.NewLine +
                            "DiscResp:" + Environment.NewLine +
                            DiscAnsw + Environment.NewLine + DiscAnsw2 + Environment.NewLine +
                            "DiscRespMessage:" + Environment.NewLine +
                            DiscRespMessage + Environment.NewLine;

            /*
             * "Purc:" + Environment.NewLine +
             * PurcRequestStr + Environment.NewLine + Environment.NewLine +
             * "PurcResp:" + Environment.NewLine +
             * PurcAnsw + Environment.NewLine + PurcAnsw2 + Environment.NewLine;
             * */
            return(Resstr);
        }
Ejemplo n.º 3
0
        public static string TestPayment(string PurchaseID, double PAmount)
        {
            FayRetailCheckInfo CheckInfo = new FayRetailCheckInfo()
            {
                Items        = GetTestChequeLines(),
                ChequeNumber = "10005",
                ChequeDate   = DateTime.Now
            };

            RequestData Data           = FayRetailClient.GetCalculateRequestData(CardTrack, CheckInfo, Cashier);
            string      CalcRequestStr = XMLSerializer.RequestSerializer(Data);
            string      CalcAnsw       = "";

            System.Net.HttpStatusCode StatusCode = System.Net.HttpStatusCode.OK;
            string CalcAnsw2 = FayRetailClient.SendDataToSrv(CalcRequestStr, out CalcAnsw, out StatusCode);

            RequestData PData        = FayRetailClient.GetPaymentRequestData(CardTrack, CheckInfo, Cashier, PAmount);
            string      PRequestStr  = XMLSerializer.RequestSerializer(PData);
            string      PAnsw        = "";
            string      PAnsw2       = FayRetailClient.SendDataToSrv(PRequestStr, out PAnsw, out StatusCode);
            string      PRespMessage = "";

            if (StatusCode == System.Net.HttpStatusCode.OK)
            {
                ResponseData Aswer = XMLSerializer.ResponseDeSerializer(PAnsw2);
                if (Aswer.ErrorCode == 0)
                {
                    if ((Aswer.Payments != null) && (Aswer.Payments.Count > 0))
                    {
                        PRespMessage = Aswer.Payments[0].ChequeMessageDecript;
                    }
                    else
                    {
                        PRespMessage = "Пустой ответ от сервера.";
                    }
                }
                else
                {
                    PRespMessage = "Ошибка в  ответе от сервера: " + Aswer.ErrorMessage;
                }
            }
            CheckInfo.Pays = new List <Pay>();
            //CheckInfo.Pays.Clear();

            CheckInfo.Pays.Add(new Pay()
            {
                Amount = PAmount.ToString(),
                Type   = "FAYRETAIL"
            });
            CheckInfo.Pays.Add(new Pay()
            {
                Amount = (CheckInfo.TotalSumm - PAmount).ToString(),
                Type   = "Cash"
            }
                               );
            RequestData DiscData        = FayRetailClient.GetDiscountRequestData(CardTrack, CheckInfo, Cashier);
            string      DiscRequestStr  = XMLSerializer.RequestSerializer(DiscData);
            string      DiscAnsw        = "";
            string      DiscAnsw2       = FayRetailClient.SendDataToSrv(DiscRequestStr, out DiscAnsw, out StatusCode);
            string      DiscRespMessage = "";

            if (StatusCode == System.Net.HttpStatusCode.OK)
            {
                ResponseData Aswer = XMLSerializer.ResponseDeSerializer(DiscAnsw2);
                if (Aswer.ErrorCode == 0)
                {
                    if ((Aswer.Discounts != null) && (Aswer.Discounts.Count > 0))
                    {
                        DiscRespMessage = Aswer.Discounts[0].ChequeMessageDecript;
                    }
                    else
                    {
                        DiscRespMessage = "Пустой ответ от сервера.";
                    }
                }
                else
                {
                    DiscRespMessage = "Ошибка в  ответе от сервера: " + Aswer.ErrorMessage;
                }
            }

            /*
             * RequestData PurcData = FayRetailClient.GetConfirmPurchaseRequestData(Cashier, PurchaseID);
             * string PurcRequestStr = XMLSerializer.RequestSerializer(PurcData);
             * string PurcAnsw = "";
             * string PurcAnsw2 = FayRetailClient.SendDataToSrv(PurcRequestStr, out PurcAnsw, out StatusCode);
             */
            string Resstr = "Calc:" + Environment.NewLine +
                            CalcRequestStr + Environment.NewLine +
                            "CalcResp:" + Environment.NewLine +
                            CalcAnsw + Environment.NewLine + CalcAnsw2 + Environment.NewLine +
                            "Disc:" + Environment.NewLine +
                            PRequestStr + Environment.NewLine + Environment.NewLine +
                            "DiscResp:" + Environment.NewLine +
                            PAnsw + Environment.NewLine + PAnsw2 + Environment.NewLine +
                            "DiscRespMessage:" + Environment.NewLine +
                            PRespMessage + Environment.NewLine +
                            "Disc:" + Environment.NewLine +
                            DiscRequestStr + Environment.NewLine + Environment.NewLine +
                            "DiscResp:" + Environment.NewLine +
                            DiscAnsw + Environment.NewLine + DiscAnsw2 + Environment.NewLine +
                            "DiscRespMessage:" + Environment.NewLine +
                            DiscRespMessage + Environment.NewLine;

            /*
             * "Purc:" + Environment.NewLine +
             * PurcRequestStr + Environment.NewLine + Environment.NewLine +
             * "PurcResp:" + Environment.NewLine +
             * PurcAnsw + Environment.NewLine + PurcAnsw2 + Environment.NewLine;
             * */
            return(Resstr);
        }