Skip to content

AWS Lambda function code to receive Square webhook events and save them to AWS SQS (Simple Queue Service). Makes use of Square SDK and various AWS services internally.

License

Notifications You must be signed in to change notification settings

mohidmakhdoomi/aws-lambda-square-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript code for an AWS Lambda function which is receives Square webhook event notifications and saves them to an AWS SQS.

Flow:
API Gateway > Lambda function > SQS

  • The AWS HTTP API Gateway is what is used for the Square webhook notification URL
    • The gateway simply passes the request to the Lambda function through integration
  • Also using AWS Parameter Store to store the Square SIGNATURE_KEY and thus needed to use the extension "AWS Parameters and Secrets Lambda Extension"
  • Due to using Square SDK which is not available directly in AWS, need to zip up Square SDK with the JavaScript code and upload it to the AWS Lambda function

This Lambda function has a few uses:

  1. Receive the POST request (event) from the API gateway which was sent by Square
  2. Verify and Validate the Square Event Notification
  3. Get the Queue URL for an existing SQS and then send the request (event) body to the queue to be processed separately
  4. Send a response to the API gateway and thus to Square

to use clone, modify lambdaSquareDeploy.js as needed, and then run the following commands:
npm run build
npm run package

then you can push the new ZIP to an existing Lambda function using AWS CLI like so:
aws --profile <YOUR_PROFILE> lambda update-function-code --function-name <YOUR_FUNCTION> --zip-file fileb://lambdaSquareDeploy.zip
or can manually upload the lambdaSquareDeploy.zip through the AWS console.

About

AWS Lambda function code to receive Square webhook events and save them to AWS SQS (Simple Queue Service). Makes use of Square SDK and various AWS services internally.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published