MCPcopy Create free account
hub / github.com/Source-Controller/eCommerce-Fullstack / handleCheckout

Function handleCheckout

pages/cart.js:13–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}>

Callers

nothing calls this directly

Calls 1

getStripeFunction · 0.85

Tested by

no test coverage detected