#Spica
1 messages ยท Page 1 of 1 (latest)
Hello ๐
The error usually suggests that the event payload that you are passing to constructEvent has been modified (most likely parsed to json)
Do you have a middleware that parses the incoming requests automatically?
I am using express.raw({ type: 'application/json' }),
I did use body parser too but the same results
const sig = req.headers['stripe-signature'];
const endpointSecret = process.env.STRIPE_WEBHOOK_KEY
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
console.log('Event ================>' + event)
} catch (err) {
console.log('Error ================>' + err.message)
res.status(400).send(Webhook Error: ${err.message});
return;
}
this is my. code
try express.raw({ type: '*/*' })
I tried it but still not working
do you have any other code like app.use(...) OR express.use(...) setting the parser outside the function?
Yes
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.use(express.raw({ type: '/' }))
Can you try commenting that out?
Yes sure
you can also try adding something like following
app.use( "/webhook",express.raw({ type: "*/*" }))
where /webhook would be your route path instead
I did comment the user(body parser and it worked )
thank you very much
I will try to figure out how to use it without commenting those lines noz
w
Glad that worked! ๐ Happy to help