#ELIZZER
1 messages · Page 1 of 1 (latest)
👋 Hi there, Happy to help!
Could you please provide more details about this ?
i was trying to implement webhook signature check and this happend
Could you please share the part of the code that is throwing this ? this looks like nodejs ?
You can follow/run this sample example https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing and test webhook signature verification
sry, that was a dumb mistake
const sig = req.headers['stripe-signature']
const endpointsecret='whsec_63d6696d8e652a61500a19d9a576f847cf02655d2d242f5eb6ca9c2596914844'
let type;
try{
type=stripe.webhooks.constructEvent(req.body,sig,endpointsecret)
}catch(e){
console.log('[+]Error in received webhook ',e)
res.status(500)
res.send("not a valid request")
}
now i am getting this error
Are. you parsing the body of the request, it looks like you have a middelware that is parsing/changing the raw body request
Try first running the sample project I shared with you in order to understand the webhook signature first
could this be the problem?
yes
You need to do something like this:
https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/node-express/express.js#L10
yeah no its fine, thankyou
and do you recommend any best practices to handle stripe errors across my application
Yes you can refer to this guide:
https://stripe.com/docs/error-handling?lang=node