Ejemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <Payment> BuildOnlinePaymentAsync(CreateOnlinePaymentDto model)
        {
            model.CheckArgumentIsNull(nameof(model));
            var customer = await _customerRepository.FindAsync(model.CustomerId);

            if (customer == null)
            {
                throw new CustomerNotFoundException();
            }

            var result = new Payment {
                Amount        = model.Amount,
                CallbackUrl   = model.CallbackUrl,
                CreateDate    = _dateService.UtcNow(),
                CustomerId    = model.CustomerId,
                CustomerTitle = customer.FullName,
                Description   = model.Description,
                GatewayUrl    = model.GatewayUrl,
                Method        = PaymentMethod.Online,
                ModifyDate    = _dateService.UtcNow(),
                Status        = PaymentStatus.Created,
                Paid          = false,
                InvoiceId     = model.InvoiceId
            };

            return(await Task.FromResult(result));
        }
Ejemplo n.º 2
0
        public async Task <bool> ValidateCreateOnlinePaymentAsync(
            CreateOnlinePaymentDto model)
        {
            model.CheckArgumentIsNull(nameof(model));
            if (model.Amount <= 0 || model.Amount == decimal.MaxValue)
            {
                throw new PaymentAmountNotValidException(model.Amount);
            }

            return(true);
        }