public static bool SendConfirm(string PurchaseId, string Cashier, out string Message) { Message = ""; try { Utils.ToCardLog("SendConfirm PurchaseId: " + PurchaseId); RequestData PurchaseRequest = GetConfirmPurchaseRequestData(PurchaseId, Cashier); string PurchaseRequestStr = XMLSerializer.RequestSerializer(PurchaseRequest); string StatusDescription = ""; System.Net.HttpStatusCode StatusCode = System.Net.HttpStatusCode.OK; string CalcAnsw2 = FayRetailClient.SendDataToSrv(PurchaseRequestStr, out StatusDescription, out StatusCode); Utils.ToCardLog("SendConfirm FayRetailClient.SendDataToSrv end: StatusCode: " + StatusCode.ToString()); if (StatusCode == HttpStatusCode.OK) { ResponseData Aswer = XMLSerializer.ResponseDeSerializer(CalcAnsw2); if (Aswer.ErrorCode == 0) { Utils.ToCardLog("SendConfirm Ok"); return(true); } Message = "Ошибка в ответе от сервера: " + Aswer.ErrorMessage; return(false); } Message = "Ошибка сервера: " + StatusDescription; return(false); } catch (Exception e) { Message = "Error ApplyFayRetPaymentToCheck " + e.Message; Utils.ToCardLog("Error ApplyFayRetPaymentToCheck " + e.Message); return(false); } }
public static CalculateResponse ApplyCardToCheck(string CardTrack, FayRetailCheckInfo CheckInfo, string Cashier, out string ErrMessage) { ErrMessage = ""; try { Utils.ToCardLog("ApplyCardToCheck CardTrack: " + CardTrack); RequestData CalcRequest = GetCalculateRequestData(CardTrack, CheckInfo, Cashier); string CalcRequestStr = XMLSerializer.RequestSerializer(CalcRequest); string StatusDescription = ""; System.Net.HttpStatusCode StatusCode = System.Net.HttpStatusCode.OK; string CalcAnsw2 = FayRetailClient.SendDataToSrv(CalcRequestStr, out StatusDescription, out StatusCode); if (StatusCode == HttpStatusCode.OK) { ResponseData Aswer = XMLSerializer.ResponseDeSerializer(CalcAnsw2); if (Aswer.ErrorCode == 0) { if ((Aswer.Calculates != null) && (Aswer.Calculates.Count > 0)) { return(Aswer.Calculates[0]); } ErrMessage = "Не могу показать баланс по карте. Пустой ответ от сервера."; return(null); } ErrMessage = "Не могу показать баланс по карте. Ошибка в ответе от сервера: " + Aswer.ErrorMessage; return(null); } ErrMessage = "Не могу показать баланс по карте. Ошибка сервера: " + StatusDescription; return(null); } catch (Exception e) { Utils.ToCardLog("Error ApplyCardToCheck " + e.Message); return(null); } }
public static bool ApplyFayRetPaymentToCheck(string CardTrack, FayRetailCheckInfo CheckInfo, string Cashier, double Amount, out string Message) { Message = ""; try { Utils.ToCardLog("ApplyDiscount CardTrack: " + CardTrack); RequestData PaymentRequest = GetPaymentRequestData(CardTrack, CheckInfo, Cashier, Amount); string PaymentRequestStr = XMLSerializer.RequestSerializer(PaymentRequest); string StatusDescription = ""; System.Net.HttpStatusCode StatusCode = System.Net.HttpStatusCode.OK; string CalcAnsw2 = FayRetailClient.SendDataToSrv(PaymentRequestStr, out StatusDescription, out StatusCode); Utils.ToCardLog("ApplyDiscount FayRetailClient.SendDataToSrv end: StatusCode: " + StatusCode.ToString()); if (StatusCode == HttpStatusCode.OK) { ResponseData Aswer = XMLSerializer.ResponseDeSerializer(CalcAnsw2); if (Aswer.ErrorCode == 0) { if ((Aswer.Payments != null) && (Aswer.Payments.Count > 0)) { Message = Aswer.Payments[0].ChequeMessageDecript; return(true); } Message = "Пустой ответ от сервера."; return(false); } Message = "Ошибка в ответе от сервера: " + Aswer.ErrorMessage; return(false); } Message = "Ошибка сервера: " + StatusDescription; return(false); } catch (Exception e) { Message = "Error ApplyFayRetPaymentToCheck " + e.Message; Utils.ToCardLog("Error ApplyFayRetPaymentToCheck " + e.Message); return(false); } }
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); }
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); }