This is automatically synced with vercel
The following directories and their contents are Copyright Yannick Schutz. You may not reuse anything therein without my permission:
- content/
All other directories and files are MIT Licensed.
The shop uses Stripe Checkout
It is a set of 2 serverless functions running on Vercel, a data file and a template.
api/checkout.js: Responsible for creating a session on stripe checkout. It uses data/shop.json file to map the SKU invented code to the Stripeprice_id. Right now a lot is hardcoded in the function.api/success.js: Used to retrieve customer information on the callback after a sale. Goal is to show a banner thanking the user.
The template has a form handled by JS in main.js where we first post to the checkout serverless function. Then with the session_id, we redirect to stripe for the payment. We are not handling any money data down here.
The frontmatter of a shop item requires price_id which is the price code of a stripe product
The Configuration keys needed by the functions are:
STRIPE_SECRET_KEY: Key used to interact with the API from the functionSTRIPE_PUBLISHABLE_KEY: Key used by the frontend client to StripeSTRIPE_SHIPPING_RATE: Shipping rate code to use at checkout
The keys can be found at https://dashboard.stripe.com/apikeys
The flow for a payment is:
shop/single.htmlpage form gets a session_id fromapi/checkout.js- user gets redirected to stripe
- After payment, user is redirected back to the right slug
- page gets the payment information via
api/success.jsand thanks the user.