public async Task Execute(ProcessPaymentInput input) { if (input is null) { _paymentOutputPort.BadRequest("input is null"); return; } Payment payment = Payment .CreateNewCardPayment ( input.Card, input.Amount, input.BeneficiaryAlias ) .RaiseEvents(); BankResult bankResult = await _bankService .SubmitCardPaymentAsync(payment) .ConfigureAwait(false); if (bankResult.PaymentStatus.Equals(PaymentStatus.Succeed)) { payment .Paid() .RaiseEvents(); } _paymentOutputPort.OK(bankResult.BuildOutput()); }
public async Task Execute(ProcessPaymentInput input) { if (input is null) { _paymentOutputPort.BadRequest("input is null"); return; } var payment = Payment.CreateNewCardPayment(input.Card, input.Amount, input.BeneficiaryAlias); await _paymentRepository.AddPaymentAsync(payment).ConfigureAwait(false); var bankResult = await _bankService.SubmitCardPaymentAsync(payment).ConfigureAwait(false); await _paymentRepository.UpdatePaymentStatusAsync(bankResult.PaymentId, bankResult.PaymentStatus).ConfigureAwait(false); _paymentOutputPort.OK(BuildOutput(bankResult)); }