Use Stripe Checkout with AWS Lambda Functions to sell your products online. This is based on a similar demo for netlify.
From the original netlify demo:
- https://checkout-netlify-serverless.netlify.com
- Written tutorial
- Video lessons on egghead
- Live coding session on learnwithjason.dev
- Load products from a JSON product catalogue
- Create Checkout Sessions with AWS Lambda Functions
- Process Stripe webhook events with AWS Lambda Functions to handle fulfillment
- Node >= 14
- AWS SAM CLI
- Stripe CLI
Follow the steps below to run locally.
1. Clone and configure the sample
git clone https://github.com/zoellner/stripe-checkout-lambda-serverless
Copy the .env.json.example file into a file named .env.json in the functions folder. For example:
cp .env.json.example .env.json
You will need a Stripe account in order to run the demo. Once you set up your account, go to the Stripe developer dashboard to find your API keys.
"STRIPE_PUBLISHABLE_KEY": "<replace-with-your-publishable-key>"
"STRIPE_SECRET_KEY": "<replace-with-your-secret-key>"
2. Run AWS Lambda Functions locally:
You can run the AWS Lambda Functions locally with SAM:
npm start
Then open http://localhost:3000/index.html in your browser
3. [Optional] Run a webhook locally:
If you want to test the using-webhooks
integration with a local webhook on your machine, you can use the Stripe CLI to easily spin one up.
Make sure to install the CLI and link your Stripe account.
In a separate tab run
stripe listen --forward-to localhost:3000/handle-purchase
Or use the shorthand npm run webhook
The CLI will print a webhook secret key to the console. Set STRIPE_WEBHOOK_SECRET
to this value in your .env file.
You should see events logged in the console where the CLI is running.
When you are ready to create a live webhook endpoint, follow our guide in the docs on configuring a webhook endpoint in the dashboard.
coming soon
If you found a bug or want to suggest a new [feature/use case/sample], please file an issue.
If you have questions, comments, or need help with code that is related to Stripe, reach out to them:
- on Discord
- on Twitter at @StripeDev
- on Stack Overflow at the stripe-payments tag
- by email
In addition jlengstorf for the original netlify demo and thorsten-stripe from Stripe.