#Crawl
1 messages · Page 1 of 1 (latest)
Hello! Can you provide more details? What's the specific error you're seeing?
⚠️ Webhook signature verification failed. No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Code :
let signature = req.headers['stripe-signature'];
let body = req.rawBody.toString('utf8'); // Convert raw body to utf8 string
if (endpointSecret) {
try {
event = stripe.webhooks.constructEvent(body, signature, endpointSecret);
} catch (err) {
console.log(`⚠️ Webhook signature verification failed.`, err.message);
return res.sendStatus(400);
}
}```
On local when I trigger events it's working
This is very likely the problem: let body = req.rawBody.toString('utf8');
Where is rawBody coming from?
but when deploying and trying on test server it's not working
While I setup my webhook endopoint on the stripe dashboard
rawBody come from
express.json({
verify: (req, res, buffer) => (req['rawBody'] = buffer),
})
);```
but this is working
I think I got the env var wrong or I'm missing something
Usually I add to stripe listen and forward on the path to my localhost
but on a deployed server I just registered my webhook to
maybe the key need to be changed too ?
That could be. Are you using the webhook signing secret from your Dashboard for that specific Webhook Endpoint?
On local I'm using
STRIPE_ENDPOINT=whsec_5c.......
coming from the forward
but I didnt do it for the deployed server, thinking that the dashboard setup would be enough
Hi, stepping in and catching up
Yeap, I'd want to use the webhook secret key from the Dashboard. Can you try that?
Nope, you'd go here https://dashboard.stripe.com/test/webhooks > Click on the webhook endpoint you just created, and click on 'Reveal'.