private static CreatePayment GetCreatePayment(MakePaymentV1 model) { return(new CreatePayment( model.CardNumber, model.Cvv, (int)model.ExpiryYear, (int)model.ExpiryMonth, model.Amount, model.Currency)); }
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); }
private Task <PaymentProcessingResult> ProcessPayment(MakePaymentV1 command) { return(processPaymentService.Process(GetCreatePayment(command))); }