#Kugyan-webhook-signature

1 messages ยท Page 1 of 1 (latest)

terse seal
#

Hello ๐Ÿ‘‹
What have you tried so far? What language are you using for your server-side code?

severe crypt
#

Nodejs

#

It gives this error in dash

terse seal
#

Normally when you see this error, it means that, either the HTTP request body Stripe sent to your webhook handler has been altered in some way or You may not be using the correct webhook secret.

#

Can you double check if your server is configured with the correct webhook secret?

severe crypt
#

Sure

terse seal
#

Gotcha. So the most likely reason it may be throwing an error here is if your app is parsing body as JSON.

constructEvent function in your handler requires the raw, unparsed body you receive from the request to verify the signature.

To verify you have the raw body you can print it out and see if you get something like <Buffer 28 72 10..>

severe crypt
#

Mhm

terse seal
#

Also can you share a snippet of your router code?

severe crypt
#

That's very possible

#

Since i use json parser

terse seal
#

Ah yeah that might be the issue here

severe crypt
#

Let me check what it recives

#

I'll log it

terse seal
#

You can try setting following for the route (if you're using express)

app.use('/webhook', express.raw({type: "*/*"}))

severe crypt
#

Alr

#

Indeed

#

Ur right

#

Is that supposed to have *?

terse seal
#

yes

#

for some reason my edit took it out ๐Ÿ˜ฎโ€๐Ÿ’จ

#

ah its discord formatting

#

there we go, fixed it

severe crypt
#

Alr

#

It sill parsed the json

#

Can't i use JSON.stringify to make it a json and send it?

terse seal
#

No, it has to be untouched raw body.

severe crypt
#

Mhm

terse seal
#

can you restart the server for good luck and try again? Maybe that'd fix it

severe crypt
#

I did like 5 times-

#

I think its because in my default config it parses json