()
| 11 | const {cartItems, totalPrice, totalQty, onRemove, toggleCartItemQuantity} = useStateContext(); |
| 12 | |
| 13 | const handleCheckout = async () => { |
| 14 | const stripe = await getStripe(); |
| 15 | |
| 16 | const response = await fetch('/api/stripe', { |
| 17 | method: 'POST', |
| 18 | headers: { |
| 19 | 'Content-Type': 'application/json', |
| 20 | }, |
| 21 | body: JSON.stringify(cartItems), |
| 22 | }); |
| 23 | |
| 24 | if(response.statusCode === 500) return; |
| 25 | |
| 26 | const data = await response.json(); |
| 27 | |
| 28 | toast.loading('Redirecting...'); |
| 29 | |
| 30 | stripe.redirectToCheckout({ sessionId: data.id }); |
| 31 | } |
| 32 | |
| 33 | return ( |
| 34 | <div className='cart-wrapper' ref={cartRef}> |
nothing calls this directly
no test coverage detected