Ejemplo n.º 1
0
        public virtual async Task CompleteRefundAsync(Payment payment, Refund refund)
        {
            using var uow = _unitOfWorkManager.Begin(isTransactional: true);

            payment.CompleteRefund();

            await _paymentRepository.UpdateAsync(payment, true);

            refund.CompleteRefund(_clock.Now);

            await _refundRepository.UpdateAsync(refund, true);

            var paymentEto = _objectMapper.Map <Payment, PaymentEto>(payment);
            var refundEto  = _objectMapper.Map <Refund, RefundEto>(refund);

            uow.OnCompleted(async() =>
                            await _distributedEventBus.PublishAsync(new PaymentRefundCompletedEto(paymentEto, refundEto)));

            await uow.CompleteAsync();
        }