/// <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)); }
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); }
/// <inheritdoc/> public async Task <OnlinePaymentResultDto> CreateOnlinePaymentAsync( CreateOnlinePaymentDto model) { await _paymentValidator.ValidateCreateOnlinePaymentAsync(model); var payment = await _paymentFactory.BuildOnlinePaymentAsync(model); await _paymentRepository.AddAndSaveAsync(payment); return(await Task.FromResult( payment.Adapt <OnlinePaymentResultDto>() )); }