This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Front-End: Let's pick our product, ask for a Session ID, and redirect to the checkout page. | |
import { useShoppingCart, formatCurrencyString } 'use-shopping-cart' | |
function Product({ product }) { | |
const { redirectToCheckout } = useShoppingCart() | |
const { name, image, description, currency } = product | |
const price = formatCurrencyString({ value: product.price, currency, language: 'en-US' }) | |
async function buyNow() { | |
const response = await fetch("/.netlify/functions/create-session", { |