Esempio n. 1
0
        public async Task <Unit> Handle(UpdatePaymentStatusWithBankResponseCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var payment = await _paymentService.ValidateToUpdateStatusAsync(request.Response);

                if (payment.ValidationResult.IsValid)
                {
                    var acceptedEvent = new PaymentAcceptedEvent(payment.Id);
                    await _paymentRepository.UpdatePaymentReadModelStatusAsync(payment.Id, PaymentStatus.APPROVED);

                    await _mediator.Publish(acceptedEvent);
                }
                else
                {
                    _logger.LogWarning($"Payment with id: {payment.Id} validated by bank. Can't validate again.");
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error occured while trying to update payment status from bank response.");
            }

            return(Unit.Value);
        }
Esempio n. 2
0
 public IObservable <Unit> Handle(PaymentAcceptedEvent message)
 {
     _workflow.PaymentAccepted(message.SagaId).Wait();
     return(Observable.Return(new Unit()));
 }
Esempio n. 3
0
 public async Task Handle(PaymentAcceptedEvent notification, CancellationToken cancellationToken)
 {
     await SaveAsync <Event>(notification);
 }