public void CreditCardPrintTicketEvent() { VPI_ERROR_CODE retCode; string errMsg = ""; if ((retCode = IntegratedPOS.PrintTicket(ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar Imprimir el Ticket\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Print Ticket operation failed:\r\n{errMsg}"); } else { OpsContext.ShowMessage("Operación exitosa.\r\n"); } }
public void CreditCardGetBatchCloseData() { VPI_ERROR_CODE retCode; string errMsg = ""; List <BATCHCLOSEDATA_OUT> batchList; if ((retCode = IntegratedPOS.GetBatchCloseData(out batchList, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar obtener los totales de Cierre de Lote\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Get Batch Close Data operation failed:\r\n{errMsg}"); return; } OpsContext.ShowTextList("Cierre de Lote", batchList.Select(batch => batch.DumpString())); }
public void CreditCardBatchCloseEvent() { VPI_ERROR_CODE retCode; BATCHCLOSE_OUT batchOut; string errMsg = ""; if ((retCode = IntegratedPOS.BatchClose(out batchOut, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar Cerrar el Lote.\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Batch Close operation failed:\r\n{batchOut.DumpString()}"); return; } OpsContext.ShowMessage(batchOut.DumpString()); }
private List <PLAN_OUT> DoCCGetPlan() { List <PLAN_OUT> retVal = new List <PLAN_OUT>(); VPI_ERROR_CODE retCode; string errMsg = ""; if ((retCode = IntegratedPOS.GetPlan(out retVal, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar obtener el Listado de Tarjetas\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Get Issuer operation failed:\r\n{errMsg}"); return(retVal); } OpsContext.ShowTextList("Listado de Planes", retVal.Select(plan => plan.DumpString())); return(retVal); }
public void SaveCustomerData() { if (EncryptionKey == null || EncryptionKey.Length <= 0) { string Error = "The Covid Customer Data Encryption Key is not configured."; OpsContext.ShowError(Error); base.Logger.LogAlways(Error); return; } string FullName = GetCustomerName(); string PhoneNumber; if (!string.IsNullOrEmpty(FullName)) { PhoneNumber = GetCustomerPhoneNumber(); if (!string.IsNullOrEmpty(PhoneNumber)) { try { var Success = SaveDataToFile($"{FullName},{PhoneNumber},{DateTime.Now.ToString("yyyyMMddHHmmss")}"); if (!Success) { OpsContext.ShowError("Failure saving customer records. Please check EGateway log file for further information. "); } else { OpsContext.ShowMessage("Successfully saved customer records"); // Potentially print chit. } } catch (Exception ex) { string Error = $"CovidCustomerData: Failed to save the customer data. {System.Environment.NewLine}Reason: {ex.Message}"; base.Logger.LogAlways(Error); OpsContext.ShowError(Error); } } } PurgeOldCustomerRecords(); }
private List <ISSUER_OUT> DoCCGetCards(bool showCards_ = true) { List <ISSUER_OUT> retVal = new List <ISSUER_OUT>(); VPI_ERROR_CODE retCode; string errMsg = ""; if ((retCode = IntegratedPOS.GetIssuer(out retVal, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar obtener el Listado de Tarjetas\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Get Issuer operation failed:\r\n{errMsg}"); return(retVal); } if (showCards_) { OpsContext.ShowTextList("Listado de Tarjetas", retVal.Select(card => card.DumpString())); } return(retVal); }
private VPI_ERROR_CODE TestLAPOSDevice(ref string errMsg) { VPI_ERROR_CODE posResp; //Check POS Device int retries = 0; do { posResp = IntegratedPOS.TestConnection(ref errMsg); if (posResp != 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 (posResp != VPI_ERROR_CODE.VPI_OK); return(posResp); }
private bool BeginPayment(decimal amount_, int tndrObjNum_) { LOG.Debug("ENTER"); bool retVal = false; string errMsg = ""; string ccCode = ""; VPI_ERROR_CODE posResp; bool fromTender = (tndrObjNum_ != 0); try { //ask for amount if no amount is received if (amount_ == 0.00m) { amount_ = OpsContext.RequestAmountEntry("Ingrese monto a abonar", "Pago con Tarjeta", OpsContext.Check.TotalDue) ?? 0.00m; } if (amount_ == 0.00m) { return(retVal); } string tip = "0"; if (amount_ > OpsContext.Check.TotalDue) { if (OpsContext.AskQuestion($"El monto sobrepasa el total de la cuenta.\r\n¿Desea utilizar los ${(amount_ - OpsContext.Check.TotalDue): N2} como propina?")) { tip = $"{OpsContext.Check.TotalDue - amount_: N2}"; } } //Find Credit Card Code (if we came from a Tender Media key) if (tndrObjNum_ != 0) { if (ConfigMgr.Instance.PrismaCCToSimphonyObjNumMap.Values.Contains(tndrObjNum_)) { ccCode = ConfigMgr.Instance.PrismaCCToSimphonyObjNumMap.Single(p => p.Value == tndrObjNum_).Key; } else { OpsContext.ShowError($"El medio de pago {tndrObjNum_} no está asociado a ninguna tarjeta de crédito en la configuración"); LOG.Error("{Message}", $"Couldn't find Tender Media Obj Num {tndrObjNum_} mapped to a PRISMA Credit Card"); return(retVal); } } //Test LAPOS Device Status posResp = TestLAPOSDevice(ref errMsg); //Get Card Type (if we came from Extensibility Key or tender not mapped properly) if (ccCode == "") { 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."); CARDDATA_OUT cardData; 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(retVal); } ccCode = cardData.CardCode.TrimStart('0'); OpsContext.ShowMessage("Remueva la tarjeta y cierre este diálogo para continuar"); } //Find Card obj num in Simphony (if we came from Extensibility Key) if (tndrObjNum_ == 0) { if (!ConfigMgr.Instance.PrismaCCToSimphonyObjNumMap.TryGetValue(ccCode, out tndrObjNum_)) { OpsContext.ShowError($"No se encuentra definida la tarjeta {ccCode} en la configuración"); LOG.Error("{Message}", $"Couldn't find PRISMA Card [{ccCode}] mapped to a Simphony tender Obj Num"); return(retVal); } } //Send payment order to pinpad int instalment = 1; PURCHASE_IN purchaseData = new PURCHASE_IN() { IssuerCode = ccCode, Amount = $"{ (int)(amount_ * 100.0m) }", Tip = tip, CUIT = ConfigMgr.Instance.LAPOSMerchantCUIT, MerchantCode = ConfigMgr.Instance.LAPOSMerchantCode, ReceiptNumber = $"{OpsContext.CheckNumber}", Linemode = (char)0x01, InstalmentCount = $"{instalment}", PlanCode = GetCardPlan(ccCode, instalment), MerchantName = ConfigMgr.Instance.LAPOSMerchantName, }; OpsContext.ShowMessage("Inserte o deslice la tarjeta cuando el POS lo solicite.\r\n\r\nCierre este diálogo para continuar."); TRX_OUT trxData; posResp = IntegratedPOS.Purchase(purchaseData, out trxData, ref errMsg); if (posResp != VPI_ERROR_CODE.VPI_OK || Int16.Parse(trxData.HostRespCode) != 0) { OpsContext.ShowError($"Error en la operación de pago.\r\nCódigo Error = {trxData.HostRespCode} {errMsg.Trim()}"); LOG.Error("{Message}", $"Error trying to purchase with CC[{ccCode}].\r\n Error Code = ({trxData.HostRespCode}) {errMsg.Trim()}.\r\n{trxData.HostMessage}"); return(retVal); } retVal = (posResp == VPI_ERROR_CODE.VPI_OK); LOG.Info("{Message}", $"LAPOS Purchase operation returned from host:\r\n{trxData.DumpString()}"); if (ConfigMgr.Instance.LAPOSShowPaymentResultDialog) { OpsContext.ShowMessage(trxData.DumpString()); } //Send Tender media if (!fromTender) { AddTender(tndrObjNum_, amount_, trxData.AuthCode); mTenderTriggeredByInterface = true; } } catch (Exception ex) { LOG.Fatal(ex, "{Message}", "Exception caught."); } finally { LOG.Debug("EXIT"); } return(retVal); }
public void CreditCardRefundVoidEvent() { VPI_ERROR_CODE posResp; string errMsg = ""; long voucherNum = OpsContext.RequestNumericEntry("Ingrese Nº de Cupón del Voucher de Tarjeta", "Cancelación de Pago con Tarjeta") ?? 0; if (voucherNum == 0) { return; } 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."); CARDDATA_OUT cardData; 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"); VOID_IN voidParam = new VOID_IN() { IssuerCode = cardData.CardCode.TrimStart('0'), OriginalTicket = $"{voucherNum}", CUIT = ConfigMgr.Instance.LAPOSMerchantCUIT, MerchantName = ConfigMgr.Instance.LAPOSMerchantName, }; TRX_OUT trxOut; //OpsContext.ShowMessage("Inserte o deslice la tarjeta cuando el POS lo solicite.\r\n\r\nCierre este diálogo para continuar"); if ((posResp = IntegratedPOS.RefundVoid(voidParam, out trxOut, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar anular la devolución.\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Refund Void 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 { posResp = IntegratedPOS.TestConnection(ref errMsg); if (posResp != 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 (posResp != VPI_ERROR_CODE.VPI_OK); }
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); }
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()}"); } }