private POSModel.Response DoPayment(POSModel.Purchase purchase) { int attempts = 0; bool file_exists = false; int timeout = 120000; //Check if a Redeban process is running and kill it List <Process> RedebanWinProcess = Process.GetProcesses().Where(s => s.ProcessName.Equals("Cajas5.2.3")).ToList();; foreach (Process Proc in RedebanWinProcess) { Proc.Kill(); } //Reset input and output files if (File.Exists(INPUT_FILE)) { File.Delete(INPUT_FILE); } if (File.Exists(OUTPUT_FILE)) { File.Delete(OUTPUT_FILE); } System.Threading.Thread.Sleep(2000); CreatePlainText(purchase.ToString()); ExecuteClient(); while (file_exists == false && attempts <= timeout / 1000) { file_exists = File.Exists(OUTPUT_FILE); System.Threading.Thread.Sleep(1000); attempts++; } if (!file_exists) { POSModel.Response response = new POSModel.Response { ResponseCode = "05", Success = false }; return(response); } string data = File.ReadAllText(OUTPUT_FILE); return(ProcessFileResponse(data)); }
public POSModel.Response RequestPayment(string amount) { POSModel.Response response = new POSModel.Response() { Success = false, Message = "Ha ocurrido un error interno." }; POSModel.Purchase purchase = new POSModel.Purchase() { OperationCode = "0", Amount = amount, Vat = "0", BasDev = "0", Invoice = "123456", ATMCode = "1", ConsumptionTax = "0" }; response = DoPayment(purchase); return(response); }