Use Stripe's test card to complete checkout (4242 4242 4242 4242).
Also, this is based on the sapper-template.
Afther you clone and run this locally, you'll need to create a .env
file containing the following values:
STRIPE_PUBLISHABLE_KEY=<your-secrets>
STRIPE_SECRET_KEY=<your-secrets>
STRIPE_WEBHOOK_SECRET=<your-secrets>
SENDGRID_API_KEY=<your-secrets>
You'll need to send the checkout.session.completed webhook to <yourURL>/.netlify/functions/mark-sold
.
Use the Stripe-cli to test webhooks locally.
Stripe doc on webhooks
You'll need to follow faunaDB official documentation to hook it up with Netlify.
Create a new database, a new collection (mine is called "paintings"), documents in the collection and a new index (mine is called "all").
You'll also need to update the src/stores.js
file so that the products
array matches your databases entries. You could remove the products
array and load everything from the DB, but there is a performance trade-off for that.
Also, look for the // * MARK ITEMS AS SOLD HERE 🚨
comment and uncomment that code.
You can remove functions/get-products.js
entirely and the loadProducts()
funcion in src/routes/index.svelte
. Also, update the products
array in src/stores.js
so that the "sold"
property of products is set to true
or false
rather than "loading".
The easiest way to run this on localhost is with the netlify-cli.
npm install netlify-cli -g
cd
into your project folder and run ntl dev