Esempio n. 1
0
        public PrismaInterfaceExtApp(IExecutionContext context)
            : base(context)
        {
            try
            {
                this.OpsInitEvent              += OnOpsInitEvent;
                this.OpsTmedPreviewEvent       += OnOpsTmedPreviewEvent;
                this.OpsTransactionCancelEvent += OnOpsTransactionCancelEvent;
                this.OpsErrorMessageEvent      += OnOpsErrorMessageEvent;

                string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\";
                ConfigMgr.Instance.Initialize(path + "\\bp.payment.config");

                if (ConfigMgr.Instance.ShowIFCVersion)
                {
                    OpsContext.ShowMessage("PRISMA PAYMENT Version: " + this.GetType().Assembly.GetName().Version.ToString());
                }

                LOG.Info("{Message}", "PRISMA PAYMENT Version: " + this.GetType().Assembly.GetName().Version.ToString());

                mCardPlanMap = GetCCPlanDef();

                IntegratedPOS.SetPortParameters(
                    new COM_PARAMS()
                {
                    COMName  = "COM" + ConfigMgr.Instance.LAPOSSerialPortNumber,
                    BaudRate = UInt16.Parse(ConfigMgr.Instance.LAPOSSerialPortBaudRate),
                    Parity   = (byte)(ConfigMgr.Instance.LAPOSSerialPortParity.Length == 1 ? ConfigMgr.Instance.LAPOSSerialPortParity[0] : 'N'),
                    ByteSize = UInt16.Parse(ConfigMgr.Instance.LAPOSSerialPortByteSize),
                    StopBits = UInt16.Parse(ConfigMgr.Instance.LAPOSSerialPortStopBits),
                });

                string errMsg = "";
                if (IntegratedPOS.GetIssuer(out mCardDefList, ref errMsg) != VPI_ERROR_CODE.VPI_OK)
                {
                    LOG.Error("{Message}", $"Error reading card list from POS\r\n{errMsg}");
                }

                //LOG.Instance.LogEvent("MP QR PAYMENT Version: " + this.GetType().Assembly.GetName().Version.ToString(), TWS.Log.Logger.VERBOSITY_LEVEL.INFO);

                /* FOR FUTURE USE
                 * //licensing
                 * LicenseMgr.Instance.Initialize(path, path, "TWS.Simphony.MP.Payment.dll", false);
                 *
                 * mHardID =   HardwareIdReader.GetHash(OpsContext.Product + "_" +
                 *          OpsContext.LocationId + "_" +
                 *          OpsContext.PropertyID + "_" +
                 *          OpsContext.WorkstationID);
                 *
                 * mLicensed = LicenseMgr.Instance.ValidateLicense("TWS.Simphony.MP.Payment.dll", mHardID, true);*/
            }
            catch (Exception ex)
            {
                OpsContext.ShowException(ex, "Exception creating MPQRInterfaceExtApp");
                throw ex;
            }
        }
Esempio n. 2
0
        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()));
        }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }