Exemplo n.º 1
0
 private static CreatePayment GetCreatePayment(MakePaymentV1 model)
 {
     return(new CreatePayment(
                model.CardNumber,
                model.Cvv,
                (int)model.ExpiryYear,
                (int)model.ExpiryMonth,
                model.Amount,
                model.Currency));
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] MakePaymentV1 command)
        {
            logger.LogInformation("Start processing new payment.");
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var processingResult = await ProcessPayment(command)
                                   .Map(
                Faulted: ex =>
            {
                logger.LogError(ex, Errors.UnexpectedError.Message);
                return(StatusCode(500, Errors.UnexpectedError));
            },
                Completed: result => CreatedAtAction("Get", new { id = result.Key }, new PaymentProcessingResult(result.Key, result.IsPaymentSuccessful)));

            logger.LogInformation("Exit processing new payment.");
            return(processingResult);
        }
Exemplo n.º 3
0
 private Task <PaymentProcessingResult> ProcessPayment(MakePaymentV1 command)
 {
     return(processPaymentService.Process(GetCreatePayment(command)));
 }