#All3nn1ck

1 messages ยท Page 1 of 1 (latest)

steel hullBOT
silk socket
#

Hello ๐Ÿ‘‹
You may see this error for variety of reasons
1/ If your webhook endpoint secret is incorrect
2/ As the error suggests, you may not be passing in raw data to the constructEvent function

raw spindle
#

Where do I see the correct endpoint secret?

#

Is it in my dashboard under the voice "sign secret"?

#

Or is it the "API keys" section?

silk socket
raw spindle
#

Ok so that's the one

#

I'm already using it T.T

silk socket
#

Gotcha. Next step is to verify if your server parses the event body before it reaches the webhook code

raw spindle
#

This is the endpoint ```
app.post('/stripe/checkout/webhook',
express.raw({ type: 'application/json' }),
handleStripeEvents
)

#

handleStripeEvents is a function created by me

silk socket
#

ah, can you change
express.raw({ type: 'application/json' })
to express.raw({ type: '*/*' }) ?

raw spindle
#

Sure

#

Give me five minutes. Everytime I change something to this endpoint I need to deploy it because I can't test it locally

silk socket
#

Sure, np!

raw spindle
#

I had a question while I wait

#

I know that when a user creates a checkout a checkout events gets fired, what happens when a user closes the checkout page without finish the payment?

#

Is there any event that is immediatly fired?

#

Or I have to wait for the checkout.expire even?

#

event?*

silk socket
#

We don't fire an event when the customer closes the checkout page as such so yeah you'd want to wait/listen for expiration event

raw spindle
#

Ok

#

Cristal clear

#

the deploy is taking a long time

silk socket
#

NP! ๐Ÿ™‚ Take your time

raw spindle
#

Same error

#

Nothing changes

#

I really don't know what to do at this point

silk socket
#

can you print out the parameter your handleStripeEvents function receives?
It should be a buffer. If you see JSON that means something prior to this route is parsing the data already

raw spindle
#

Ok, let me add a console log

#

I get a json

#

Should I use the req.rawBody

#

?*

silk socket
#

yup that's the issue.
Seems like your server parses the raw data already
Yup I'd recommend giving it a try

raw spindle
#

Okay I give it a try

#

I will let you know tomorrow though because now I need to go

silk socket
#

I'd also recommend specifying something like
app.use('/stripe-events', express.raw({type: "*/*"})) to make sure no payload is parsed for that route

raw spindle
#

It fucking worked!!!!

#

Thank you soooooooo much

#

Hell yeah

silk socket
#

Awesome! Glad I could help