#warre002
1 messages · Page 1 of 1 (latest)
Hi there! It's pretty uncommon to verify webhook signatures manually.
Official Stripe SDKs do signature verification for you: https://stripe.com/docs/webhooks/signatures#verify-official-libraries
Yes, it is with the Stripe SDK?
This is the error it returned: StripeSignatureVerificationError: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
The route function starts like this: router.post('', express.raw({type: 'application/json'}), (request, response) => {
and in the main file I've this: app.use((req, res, next) => { if (req.originalUrl === '/webhooks') { next(); } else { express.json()(req, res, next); } });
So based on forum questions and documentation I've read this should work but it doesn't for some reason
ah, sorry about missing that!
No worries
Looking at this line:
event = stripe.webhooks.constructEvent(request.rawBody, sig, endpointSecret)
Do you still receive an error if you change this to:
event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret) ?
Also, I assume the value for endpointSecret matches the signing secret for this endpoint, as it's displayed in the Stripe Dashboard (Developers > Webhooks)?
ugh, thank you. a week of problems fixed in 2 minutes haha
Glad to hear it's fixed!