/// <summary> /// Deliberate Decision: Omit "Async" suffix (see link, best practice) from Aggregate methods to not blur the /// Ubiquitous language with technical implementation details /// </summary> /// <param name="merchantCreditCardInformation"></param> /// <param name="bankConnectorDS"></param> /// <returns></returns> public async Task <bool> AttemptPayment(CreditCardInformation merchantCreditCardInformation, IBankConnectorDomainService bankConnectorDS) { var result = await bankConnectorDS.TransmitPaymentOrderAsync(Amount.Amount, Amount.CurrencyCode, CreditCardInformation, merchantCreditCardInformation); PaymentOrderUniqueIdentifier = result.OrderUniqueIdentifier; switch (result.ResultStatus) { case PaymentOrderResultStatus.Successful: CurrentState = PaymentState.PaymentSuccessful; PaidDate = DateTime.UtcNow; break; case PaymentOrderResultStatus.FailedDueToRejectedCreditCard: case PaymentOrderResultStatus.FailedDueToUnknownReason: CurrentState = PaymentState.PaymentFailed; break; default: throw new ArgumentOutOfRangeException(); } return(CurrentState == PaymentState.PaymentSuccessful); }
public PaymentsController(ILogger <PaymentsController> logger, IPaymentRepository paymentRepository, IMerchantRepository merchantRepository, IBankConnectorDomainService bankConnectorDS, ModelMapper modelMapper) { _logger = logger; _paymentRepository = paymentRepository; _merchantRepository = merchantRepository; _bankConnectorDS = bankConnectorDS; _modelMapper = modelMapper; }