public async Task <bool> CreateOrUpdatePaymentIntent(string userId) { StripeConfiguration.ApiKey = _config["StripeSettings:SecretKey"]; var carts = await _cartItemService.GetAll(userId); if (carts.Count == 0) { return(false); } var service = new PaymentIntentService(); int amount = 0; foreach (var item in carts) { amount += item.Quantity + item.ProductDetail.Product.Price; } var options = new PaymentIntentCreateOptions { Amount = amount * 100, Currency = "usd", PaymentMethodTypes = new List <string> { "card" } }; await service.CreateAsync(options); return(true); }
public IActionResult Get() { var cartItems = _cartItemService.GetAll(); var cartItemDtos = _mapper.Map <IList <CartItemDto> >(cartItems); return(Ok(cartItemDtos)); }
public async Task <ActionResult <CartItem> > GetAll() { var userId = HttpContext.User.Identity.Name; var order = await _cartItemService.GetAll(userId); return(Ok(order)); }
public IActionResult GetAll() { var result = _cartItemService.GetAll(); if (result.Success) { return(Ok()); } return(BadRequest()); }
public void GetCartItemsInvokesCartItemRepo_WhenGettingCartItems() { // Arrange _cartService = new CartItemService(_cartItemRepository); // Act var items = _cartService.GetAll(); // Assert Mock.Get(_cartItemRepository).Verify(pr => pr.GetCartItems(), Times.Once); }
public IActionResult GetAll() { return(Ok(cartItemService.GetAll())); }