This is a collection of lambda functions and DynamoDb tables that can be run locally using the Serverless framework
Developers with AWS experience can also deploy this to their AWS account to add a custom domain name, deploy Lambda functions, store DynamoDB data and use CloudFront CDN.
- A Serverless Framework account
- Serverless
- Stripe CLI
- Java
This project relies heavily on the Serverless framework.
You will need
- A Serverless account
- The Serverless CLI
- An app in serverless (eg.
stripe-training
)
Follow this guide to get started: https://serverless.com/framework/docs/getting-started/
Update the serverless.yml file:
# app and org for use with dashboard.serverless.com
app: example_app #CHANGE THIS to the name of the App you created in Serverless
org: example_org #CHANGE THIS
...
environment:
...
STRIPE_API_KEY: "sk_test_OD123456" # CHANGE THIS Your Stripe "Secret key"
- Clone this repo
npm install
sls dynamodb install
npm run local
Test using Postman/Insomnia, note the url at the end of the deploy script and the Routes for each lambda.
...
Serverless: Routes for getOrder:
Serverless: GET /orders/getOrder
Serverless: POST /{apiVersion}/functions/stripe-react-frontend-dev-getOrder/invocations
Serverless: Routes for createTerminalConnection:
Serverless: GET /terminal/connect
Serverless: POST /{apiVersion}/functions/stripe-react-frontend-dev-createTerminalConnection/invocations
Serverless: Routes for capturePaymentIntent:
Serverless: POST /terminal/capture
Serverless: POST /{apiVersion}/functions/stripe-react-frontend-dev-capturePaymentIntent/invocations
Serverless: Offline [HTTP] listening on http://localhost:15001
Serverless: Enter "rp" to replay the last request
You can recieve webhooks from Stripe to your local development environment using Stripe CLI
Follow the instructions at https://stripe.com/docs/stripe-cli
Listen for webhooks and redirect to your local development API.
stripe listen --forward-to localhost:15001/webhook/listen
Any webhooks sent by Stripe should now show in the terminal and be picked up by src/api/webhook/listen.ts
https://stripe.com/docs/stripe-cli/webhooks
- Write then
- Run them
- Create a pull request
- Much thanks!
This is an optional step for advanced AWS users who want to deploy the application remotely.
Upload to AWS and run from your own domain, or the AWS domain provided.
npm run deploy
Populate your Catalog with Items. As DynamoDb is dynamic - there's a lot of latitude for the type of items you have in your catalog.
- Ken Easson - Initial work - Rangle.io
This project is licensed under the MIT License - see the LICENSE file for details
- Dave McDonald - Overall project support
- José Guillén - Serverless and AWS assistance
- Jason Santos - Typescript and Code Review
- The many others at Rangle.io that have helped me learn all this tech!