Beispiel #1
0
        public string EmpresaNewPayment(Payment newPayment)
        {
            try
            {
                var transactionManager = new TransactionManager();
                var lineaManager       = new LineaManager();

                var linea = lineaManager.GetLineById(new Linea {
                    LineaId = newPayment.LineaId
                });

                if (linea == null)
                {
                    throw new BusinessException(306);
                }

                var chargeOptions = new StripeChargeCreateOptions()
                {
                    Amount      = newPayment.AmoutCrc,
                    Currency    = "usd",
                    Description = $"{newPayment.Description} - {DateTime.Now.ToLongTimeString()}",
                    SourceTokenOrExistingSourceId = newPayment.CardToken // obtained with Stripe.js
                };
                var chargeService = new StripeChargeService();
                var charge        = chargeService.Create(chargeOptions);

                transactionManager.RealizarPagoParqueoBus(new Transaccion
                {
                    LineaId = linea.LineaId,
                    Usuario = new Usuario {
                        Email = newPayment.UserMail
                    },
                    Charge      = newPayment.AmoutCrc,
                    Description = newPayment.Description,
                    Terminal    = linea.Terminal,
                    Type        = "Pago",
                    Status      = "Activo"
                });

                var pagosManager = new PagosPendientesManager();
                pagosManager.UpdatePagosPorEmpresa(new PagoPendiente {
                    IdPago = newPayment.IdPago
                });

                return(charge.StripeResponse.ObjectJson);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(string.Empty);
        }
Beispiel #2
0
        public void Create(int empresaId)
        {
            try
            {
                var pagosResalizados = ObtenerPagosPorEmpresa(empresaId);
                var pagoCreado       = false;

                pagosResalizados.ForEach(p =>
                {
                    var mes = DateTime.Parse(p.Fecha);
                    var now = DateTime.Now;

                    if (mes.Month == now.Month)
                    {
                        pagoCreado = true;
                    }
                });

                if (pagoCreado)
                {
                    return;
                }

                var lineaManager          = new LineaManager();
                var configuracionTerminal = new ConfiguracionManager();
                var lineas = lineaManager.GetAllLines(0, empresaId);
                var pagos  = new List <PagoPendiente>();
                lineas.ForEach(l =>
                {
                    var termialConfig = configuracionTerminal.RetrieveConfiguracionTerminal(l.Terminal.Id);
                    pagos.Add(new PagoPendiente
                    {
                        LineaId   = l.LineaId,
                        EmpresaId = l.Empresa.CedulaJuridica,
                        Monto     = Convert.ToInt32(l.EspaciosParqueo * termialConfig.CostoParqueoBusMes)
                    });
                });

                pagos.ForEach(p => _crudFactory.Create(p));
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
        }
Beispiel #3
0
 public List <PagoPendiente> ObtenerPagosPorEmpresa(int empresaId)
 {
     try
     {
         var lineaManager = new LineaManager();
         var lista        = _crudFactory.RetrieveAllByEmpresa <PagoPendiente>(new PagoPendiente {
             EmpresaId = empresaId
         });
         lista.ForEach(l => { l.Linea = lineaManager.GetLineById(new Linea {
                 LineaId = l.LineaId
             }); });
         return(lista);
     }
     catch (Exception e)
     {
         ExceptionManager.GetInstance().Process(e);
     }
     return(new List <PagoPendiente>());
 }
Beispiel #4
0
        public List <Transaccion> GetAllTransactions()
        {
            try
            {
                var terminalManager  = new TerminalManager();
                var listTransactions = _crudFactory.RetrieveAll <Transaccion>();
                var lineaManager     = new LineaManager();
                listTransactions.ForEach(x =>
                {
                    if (x.Terminal.Id != -1)
                    {
                        x.Terminal = terminalManager.RetrieveById(x.Terminal);
                    }
                    else
                    {
                        x.Terminal.TerminalName = "No hay terminal asociada";
                    }

                    if (x.LineaId != -1)
                    {
                        x.Linea = lineaManager.GetLineById(new Linea {
                            LineaId = x.LineaId
                        });
                        x.Usuario.Email = $"Empresa {x.Linea.Empresa.NombreEmpresa} - Linea {x.Linea.NombreLinea}";
                    }
                });

                return(listTransactions);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(new List <Transaccion>());
        }