#A7U-signature-verification

1 messages ยท Page 1 of 1 (latest)

sand wolf
#

Are you using any middleware that could be modifying the raw body of the request?

ocean glade
#

Hm I don't think so, let me recheck

#

Nope, I'm using NextJS but I don't think it does anything to the raw body in the background. Does the body come beautified already from stripe or no?

#

here's how I'm getting the body and signature

#

bottom is sig

#

wait

// Use body-parser to retrieve the raw body as a buffer
const bodyParser = require('body-parser');``` as a buffer, that might be it ๐Ÿค”
sand wolf
#

ah that's definitely it

ocean glade
#

will check it out thanks, and I've just noticed something. Verifying signature shouldn't be written in my webhook code ๐Ÿค”

sand wolf
#

What do you mean?

ocean glade
#
app.post('/webhook', bodyParser.raw({type: 'application/json'}), (request, response) => {```
it's sending a post request to `/webhook`
#

or am I reading this in a wrong way

sand wolf
#

Signature verification is happening when you call stripe.webhooks.constructEvent(req.body, sig, endpointSecret); - which I assume it being called when you hit /webhook

ocean glade
#

I think I got it

#

yup I got it, the 2nd link that u sent me on github helped

#

thank you!

sand wolf
#

๐Ÿ‘ happy to help!

ocean glade
#

so now when the request was sent from a party other than stripe, const event will give an error right?

sand wolf
#

yup! that's the idea ๐Ÿ™‚