/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public async Task <BankResponsePayment> Handle(RequestPaymentCommand request, CancellationToken cancellationToken) { RequestPaymentAggregateValidator validator = new RequestPaymentAggregateValidator(); ValidationResult result = validator.Validate(request.RequestPayment); if (!result.IsValid) { throw new ArgumentValidationException("One or more fields are wrong", result.Errors); } else { //save payment var paymentCode = await this.paymentGatewayRepository.AddPaymentAsync(request.RequestPayment); //change status according to the call to the bank's API var response = await this.bankRepository.RequestPaymentAsync(request.RequestPayment); response.RequestCode = paymentCode; //update with the transaction code + status with what is returned from the bank and update entries in database await this.paymentGatewayRepository.UpdatePaymentAsync(paymentCode, response.PaymentStatus, response.BankRequestCode); return(response); } }
public InputValidations() { this.requestPaymentAggregateValidator = new RequestPaymentAggregateValidator(); }