Beispiel #1
0
        /// <inheritdoc />
        public async Task <ProcessPaymentRequest> Handle(ProcessPaymentRequest request,
                                                         CancellationToken cancellationToken)
        {
            var payment = request.Adapt <ProcessPaymentRequest, Payment>();

            var paymentStatus = await initialGateway.ProcessPayment(payment);

            payment.UpdateState(paymentStatus);

            await paymentsRepository.SavePayment(payment, cancellationToken);

            payment.Adapt(request);

            return(request);
        }
Beispiel #2
0
        public async Task <ServiceResponse <Payment> > Submit(Payment payment)
        {
            var result = new ServiceResponse <Payment>();

            try
            {
                var savePaymentTask   = _repo.SavePayment(payment);
                var submitPaymentTask = _queue.Send(payment);
                await Task.WhenAll(savePaymentTask, submitPaymentTask);

                result.Data = savePaymentTask.Result;
            }
            catch (Exception ex)
            {
                result.Exception = ex;
            }

            return(result);
        }