예제 #1
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);
        }
예제 #2
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);
        }