public void CreditCardRefundEvent() { VPI_ERROR_CODE retCode; int instalment = 1; VPI_ERROR_CODE posResp; string errMsg = ""; decimal amount = OpsContext.RequestAmountEntry("Ingrese monto a devolver", "Devolución de Pago con Tarjeta") ?? 0.00m; long voucherNum = OpsContext.RequestNumericEntry("Ingrese Nº de Cupón del Voucher de Tarjeta", "Devolución de Pago con Tarjeta") ?? 0; string date = OpsContext.RequestAlphaEntry("Ingrese fecha del Voucher de Tarjeta (dd/mm/yyyy)", "Devolución de Pago con Tarjeta") ?? ""; if (amount == 0.00m || date.Trim() == "") { OpsContext.ShowError("Se deben completar los 3 campos requeridos"); return; } if (!DateTime.TryParseExact(date.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out _)) { OpsContext.ShowError("Fecha ingresada inválida."); return; } CARDDATA_OUT cardData; cardData.CardCode = SelectCardFromList(); if (cardData.CardCode == "") { OpsContext.ShowMessage("Se obtendrá el tipo de tarjeta.\r\nInserte o deslice la tarjeta cuando el POS lo solicite.\r\n\r\nCierre este diálogo para continuar."); posResp = IntegratedPOS.GetCardData(out cardData, ref errMsg); if (posResp != VPI_ERROR_CODE.VPI_OK) { posResp = IntegratedPOS.ClosePort(ref errMsg); OpsContext.ShowError($"Error leyendo tipo de tarjeta.\r\n{errMsg}"); LOG.Error("{Message}", $"Error reading card data: [{posResp}] - {errMsg}"); return; } OpsContext.ShowMessage("Remueva la tarjeta cierre este diálogo para continuar y siga las instrucciones desde el POS"); } REFUND_IN refundParam = new REFUND_IN() { IssuerCode = cardData.CardCode.TrimStart('0'), Amount = $"{(int)(amount * 100.0m)}", OriginalTicket = $"{voucherNum}", OriginalDate = date.Trim(), PlanCode = GetCardPlan(cardData.CardCode.TrimStart('0'), instalment), ReceiptNumber = "", MerchantCode = ConfigMgr.Instance.LAPOSMerchantCode, InstalmentCount = instalment.ToString(), CUIT = ConfigMgr.Instance.LAPOSMerchantCUIT, MerchantName = ConfigMgr.Instance.LAPOSMerchantName, Linemode = (char)1, }; TRX_OUT trxOut; if ((retCode = IntegratedPOS.Refund(refundParam, out trxOut, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar la devolución.\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Refund operation failed:\r\n{trxOut.DumpString()}"); return; } OpsContext.ShowMessage("Espere a finalizar las dos impresiones de vouchers, y retire la tarjeta en caso de que el POS lo solicite.\r\n\r\nLuego acepte para continuar."); if (ConfigMgr.Instance.LAPOSShowPaymentResultDialog) { OpsContext.ShowMessage(trxOut.DumpString()); } int retries = 0; do { retCode = IntegratedPOS.TestConnection(ref errMsg); if (retCode != VPI_ERROR_CODE.VPI_OK) { Thread.Sleep(ConfigMgr.Instance.LAPOSWaitMs / 2); if (retries++ > 10) { OpsContext.ShowError("Verifique que no haya quedado una tarjeta insertada. Si el error persiste, reinicie el POS"); } } } while (retCode != VPI_ERROR_CODE.VPI_OK); }
private string GetCustomerPhoneNumber() { return(OpsContext.RequestAlphaEntry("Enter Customers Full Phone Number", "Enter Customers Full Phone Number")); }
public void ExportRecordsToCSV() { int SuccessCount = 0; int FailureCount = 0; StringBuilder AllCustomerRecords = new StringBuilder(); string RequestedEncryptionKey = OpsContext.RequestAlphaEntry("Enter Encryption Key", "Enter Encryption Key"); if (RequestedEncryptionKey == GetPassword()) // TODO: Fix the comparison to be safer. { bool Continue = OpsContext.AskQuestion("This will export all customer records to a CSV file on the disk. Are you sure?"); if (!Continue) { return; } } else { OpsContext.ShowError("Incorrect Encryption Key"); return; } if (Directory.Exists(StoragePath)) { foreach (var zipFile in Directory.GetFiles(StoragePath, $"{SaveFilePrefix}*.zip")) { using (var dailyZipFile = ZipFile.Read(zipFile)) { dailyZipFile.Encryption = EncryptionAlgorithm.WinZipAes256; dailyZipFile.Password = GetPassword(); foreach (var entry in dailyZipFile.Entries) { try { using (StreamReader sr = new StreamReader(entry.OpenReader())) { string CustomerRecord = sr.ReadToEnd(); AllCustomerRecords.AppendLine(CustomerRecord); SuccessCount++; } } catch (Exception ex) { base.Logger.LogAlways($"CovidCustomerData: Failure reading from file {dailyZipFile.Name} and entry name {entry.FileName} {System.Environment.NewLine} Reason: {ex.Message}"); FailureCount++; } } } } } else { OpsContext.ShowError($"Storage Path '{StoragePath}' cannot be found."); } try { string FilePath = WriteTextToDisk(AllCustomerRecords); OpsContext.ShowMessage($"Exported {SuccessCount} Customer Records to: '{FilePath}'{System.Environment.NewLine}Failed to export {FailureCount} Customer Records"); } catch (Exception ex) { OpsContext.ShowError($"Failed to export to disk. Reason {ex.ToString()}"); } }
private string GetCustomerName() { return(OpsContext.RequestAlphaEntry("Enter Customers Full Name", "Enter Customers Full Name")); }