public async Task AutorizePayment(GetPaymentInput input)
        {
            var userId = GetUserId();
            var user   = await _userManager.FindByIdAsync(userId.ToString());

            Logger.Debug(String.Format("SendToSap({0})", input.Id));
            string url      = String.Format("{0}api/payments/{1}", ConfigurationManager.AppSettings["SAPEndpoint"], input.Id);
            var    response = await AppConsts.Instance.GetClient().GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                Logger.Info("Success to send to SAP");

                /*aqui manda email de que se ejecuto correctamente o ocurrio algun error*/
            }

            /*
             * await _backgroundJobManager.EnqueueAsync<PaymentJob, PaymentJobArgs>(
             * new PaymentJobArgs
             * {
             *     Id = input.Id,
             *     UserId = GetUserId(),
             *     To = user.EmailAddress
             * });*/
        }
        public PaymentOutput GetPayment(GetPaymentInput input)
        {
            var payment = _paymentManager.GetPayment(input.Id);

            return(new PaymentOutput()
            {
                Id = payment.Id,
                DocEntry = payment.DocEntry,
                UserId = payment.UserId,
                GeneralAccount = payment.Bank.GeneralAccount,
                BankName = payment.Bank.Name,
                Status = ((PaymentStatus)payment.Status).ToString(),
                Type = ((PaymentType)payment.Type).ToString(),
                Comment = payment.Comment,
                PayedAmount = payment.PayedAmount,
                ReferenceNumber = payment.ReferenceNumber,
                LastErrorMessage = payment.LastMessage,
                CreationTime = payment.CreationTime,
                DebtCollectorId = payment.User.CollectId
            });
        }
        public async Task <PaymentOutput> DeclinePayment(GetPaymentInput input)
        {
            var entity = _paymentManager.GetPayment(input.Id);

            entity.Status = PaymentStatus.CanceladoPorFinanzas;

            var payment = _paymentManager.UpdatePayment(entity);

            /*
             * _backgroundJobManager.Enqueue<EmailJob, EmailArgs>(new EmailArgs()
             * {
             *  To = entity.User.EmailAddress,
             *  Subject = String.Format("Notificacion Pago Cancelado Por Finanzas, Id: {0}", entity.Id),
             *  Body = String.Format("Pago Id: {0}, Factura: {1}, Fue Cancelado Por Finanzas", entity.Id, entity.Invoice.DocumentCode),
             * });*/

            var result = await new EmailHelper().Send(new EmailArgs()
            {
                To      = entity.User.EmailAddress,
                Subject = String.Format("Notificacion Pago Cancelado Por Finanzas, Id: {0}", entity.Id),
                Body    = String.Format("Pago Id: {0}, Fue Cancelado Por Finanzas", entity.Id),
            });

            return(new PaymentOutput()
            {
                Id = payment.Id,
                DocEntry = payment.DocEntry,
                UserId = payment.UserId,
                GeneralAccount = payment.Bank.GeneralAccount,
                BankName = payment.Bank.Name,
                Status = ((PaymentStatus)payment.Status).ToString(),
                Type = ((PaymentType)payment.Type).ToString(),
                Comment = payment.Comment,
                PayedAmount = payment.PayedAmount,
                ReferenceNumber = payment.ReferenceNumber,
                LastErrorMessage = payment.LastMessage,
                CreationTime = payment.CreationTime,
                DebtCollectorId = payment.User.CollectId
            });
        }