public ActionResult Checkout(int orderId, string creditCardToken) { if (!Startup.Orders.Any(o => o.OrderId == orderId)) { return(Conflict(new { message = "Order not found" })); } var order = Startup.Orders.Where(o => o.OrderId == orderId).SingleOrDefault(); var paymentDTO = new PaymentDTO() { UserId = order.User.Id, CreditCardToken = creditCardToken, Value = order.Basket.Total }; var paymentResponse = creditCardService.Pay(paymentDTO); if (paymentResponse.StatusCode != HttpStatusCode.OK) { return(Conflict(paymentResponse.ErrorMessage)); } var transacao = new Transacao() { Data = DateTime.Now, PedidoId = order.OrderId, UsuarioId = order.User.Id, Valor = (decimal)(order.Basket.Total) }; var transaction = transactionLogService.Log(transacao); if (transaction.StatusCode != HttpStatusCode.OK) { return(Conflict(transaction.ErrorMessage)); } order.OrderStatus = OrderStatus.ReadyForShip; return(Ok()); }