#Mr.oggy
1 messages · Page 1 of 1 (latest)
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?
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.
My code is base on this doc https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#webhooks
Yep, so that is constructEvent failing. Likely due to one of:
- The
req.bodyparameter 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?
stripe listen --forward-to localhost:3000/webhook
I use this command
to my CLI base on this doc https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#webhooks
Ok, great. And where did you get the whsec_xxx from that you're using in the code?
From CLI
Can you double check that it's the correct whsec_xxx that the CLI spits out when you run stripe listen?
I'm 100% sure that I enter exact whsec_xxx from CLI to my env. file
👋 stepping in here as ynnoj needs to step away
And my stripe webhook in CLI also throw status 500 when I make change in my customer subscription
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?
Yes I just tried to add log at the beginning of my route (req.body) and it show event Id perfectly
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
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
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
I found the solution this official doc is not working
https://stackoverflow.com/a/61351336
this comment from stack overflow solve it
Sorry I don't really know anything about Nest.js