#Mr.oggy

1 messages · Page 1 of 1 (latest)

glossy hollowBOT
quick kelp
#

What are you able to log? Are there any errors thrown by your code?

#

If you remove the webhook signing (via constructEvent), does it work?

cosmic burrow
#

I found it now I just forget to import my webhook module to app module

#

Hi I got another error it says
raw: { message: 'No webhook payload was provided.' },
⚠️ Webhook signature verification failed.
⚠️ Check the env file and enter the correct webhook secret.

quick kelp
#

Yep, so that is constructEvent failing. Likely due to one of:

  • The req.body parameter isn't the raw payload.
  • You're using the wrong signing secret.
#

Oh, wait. It says right there in the error:
Check the env file and enter the correct webhook secret.

#

How are you generating these events? From the CLI?

cosmic burrow
#

stripe listen --forward-to localhost:3000/webhook
I use this command

quick kelp
#

Ok, great. And where did you get the whsec_xxx from that you're using in the code?

cosmic burrow
#

From CLI

quick kelp
#

Can you double check that it's the correct whsec_xxx that the CLI spits out when you run stripe listen?

glossy hollowBOT
cosmic burrow
#

I'm 100% sure that I enter exact whsec_xxx from CLI to my env. file

soft vine
#

👋 stepping in here as ynnoj needs to step away

cosmic burrow
#

And my stripe webhook in CLI also throw status 500 when I make change in my customer subscription

soft vine
#

So a 500 typically isn't going to be a webhook verification error

#

Unless your code is explicitly returning a 500

#

Have you added a log to the very beginning of your Webhook handler route to ensure that route is getting hit?

#

Can you alos log out the body that you are passing to constructEvent and let me know exactly what you see?

cosmic burrow
#

Yes I just tried to add log at the beginning of my route (req.body) and it show event Id perfectly

soft vine
#

So then that is likely your issue

#

req.body should not be the JSON event itself

#

It should be a buffer data type

#

Which looks like a bunch of binary

#

That is what the actual raw body looks like

#

So it seems like your framework is still manipulating the raw body

cosmic burrow
#

https://docs.nestjs.com/faq/raw-body I have apply to Access raw body according this official doc and try to log req.rawBody as the doc suggested somehow it return undefined

soft vine
#

Sorry I don't really know anything about Nest.js