コード例 #1
0
        public async Task <ObjectResource <PaymentResource> > ProcessAsync(PaymentPayload payload)
        {
            logger.LogInformation("Starting Unit Of Work For Payment Processing");
            await unitOfWork.StartAsync();

            var payment = PaymentMapper.ConvertFrom(payload);

            await unitOfWork.PaymentRepository.CreateNewAsync(payment);

            var paymentType = DerivePaymentType(payload);

            logger.LogInformation("Derived Payment Type of {0} for {1}", paymentType, payload.Amount);

            var result = await HandlePaymentProcessingAsync(payment, paymentType, payload);

            await HandlePaymentResponse(payment, result);

            return(result);
        }
コード例 #2
0
        public async Task <ObjectResource <PaymentResource> > GetPaymentByIdAsync(Guid paymentId)
        {
            var payment = await unitOfWork.PaymentRepository.GetByIdAsync(paymentId);

            if (payment is null)
            {
                return new ObjectResource <PaymentResource>
                       {
                           Message      = "Payment Could Not Be Found",
                           ResponseType = ResponseType.NoData, Status = false
                       }
            }
            ;

            return(new ObjectResource <PaymentResource>
            {
                Data = PaymentMapper.ConvertFrom(payment), Message = "Payment Successfully Retrieved",
                ResponseType = ResponseType.Success, Status = true
            });
        }
コード例 #3
0
        private async Task HandlePaymentResponse(Payment payment, ObjectResource <PaymentResource> result)
        {
            await unitOfWork.CommitAsync();

            result.Data = PaymentMapper.ConvertFrom(payment);
        }