#luddilo-webhook-events
1 messages · Page 1 of 1 (latest)
I've seen various attempts using various Buffer methods but nothing seems to work for me..
Hi again 👋 I'm less familiar with handling these in a lambda function and would need to do some digging.
Sincere apologies for the delay. This seems to be the most relevant post that I was able to find regarding your scenario, but it looks very similar to what you already have, but they're using capital S's for Stripe-Signature. Maybe that's the cause of the behavior you're experiencing?
https://thomasstep.com/blog/stripe-webhook-integration-with-aws-lambda
Writing code to handle Stripe Webhooks in a Lambda function
What I found out is that in my deployed environment, the body is a Base64 encoded string. In my local dev environment I get a JSON. In order to get the same JSON in the deployed environment I can do:
event = JSON.parse(Buffer.from(lambdaEvent.body, 'base64').toString())
This gives the same error however
Hmm. Maybe I have to do the same for the sig from headers aswell.. I'll try that next
The signature verification takes three inputs: the request body, the signature header and the webhook secret
The latter two can be verified by debugging and checking config to ensure the correct values are passed in
but the body is tricky because it's critical to use the raw request body
You cannot pass in parsed json etc -- it must be the raw string from the request (whitespace and all)