This code implements a simple Stripe checkout sales page.
- Install dependencies
npm install
- Set environment variables. Create a local file called
.env
that contains the following:
STRIPE_API_KEY=sk_test_...
YOUR_DOMAIN=http://localhost:4242
- Run the server
npm start
- Open up http://localhost:4242/
Stripe Checkout is the fastest way to get started with payments. This template contains three important files:
/public
- these files are served directly as is and contain no secret information
- index.html: The actual form that users will see which initiates a post to the backend. Change this to alter how you sales page appears
- success.html: Displayed to users upon a successful purchase
- winback.html - Displayed to users if they return from the purchase screen without completing a purchase
/
- root files that run "on the server" and contain private information like API keys (these are stored in environment settings)
- server.js: exposes one endpoint called
/create-checkout-session
that answers the post request from the client facing form and forwards the user to a payment page