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); }
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 }); }
private async Task HandlePaymentResponse(Payment payment, ObjectResource <PaymentResource> result) { await unitOfWork.CommitAsync(); result.Data = PaymentMapper.ConvertFrom(payment); }