This is a Lambda function that charges a Stripe account based on the API Gateway request data. Supports CORS. Written in Node.js. It's a Nuts & Bolts application component for AWS Serverless Application Repository.
- Create a Stripe account
- Get your Stripe API Keys (both public and secret)
- Store your Stripe Secret Key into AWS SSM as a SecureString by running the following, but be sure to replace the
lambda-stripe-charge/stripe-secret-key
with your preferred SSM Parameter Path (though it can be justlambda-stripe-charge/stripe-secret-key
):
aws ssm put-parameter --name /lambda-stripe-charge/stripe-secret-key --value YOUR_STRIPE_SECURE_KEY --type SecureString --overwrite
- Want to use Stripe's Checkout ? - https://stripe.com/docs/checkout (most likely others are supported too, but can't guarantee, need to check)
- Set your frontend part as specified in the https://stripe.com/docs/checkout#integration
- Extend your form with hidden input HTML elements for amount and currency. Those fields you will need to populate with the values chosen by the user. If not familiar with that approach I recommend this StackOverflow post - https://stackoverflow.com/questions/37798593/stripe-checkout-how-to-pass-a-value-through-to-webhook
Will provide a video link on YouTube soon, as I will stream using this AWS App Repo template.
A new release with a AWS X-Ray Instrumentation enabled!
A new release with a new feature to also do charge and capture of payments:
- Added Active X-Ray Tracing for the API Gateway and the Lambdas CreateStripeCharge, CreateRefund and CaptureStripeCharge
- Added Regional Endpoints for the API Gateway, which should improve latencies