#aquaspirit-webhook
1 messages ยท Page 1 of 1 (latest)
Are you listening to the forwarded event on local (http://localhost...) or directly with ngrok (https://xxxx.ngrok.io/) ?
directly with ngrok subdomain
This error is commonly due to two reasons:
- Wrong Webhook secret
- Request is not in raw form
While I'm checking Item (2), can you double check if the Webhook secret is correct? It should be under "Hosted endpoints" in https://dashboard.stripe.com/test/webhooks
aight i'll double check
Can you remove const payload = requestBuffer.toString(); [0] and use requestBuffer directly in stripe.webhooks.constructEvent(..)?
[0] https://github.com/aquaductape/test-nexjs-stripe/blob/main/pages/api/stripe/webhook/index.ts#L28
oh kk, so in stripe webhook dashboard I needed to add payment intent events, before it only had charge events, and now it works? strange
The error shouldn't be dependent on the event sequences
i forgot to mention, i wasn't using Test version of webhook, i was using production
so i switched to Test version and grabbed correct secret of webhook
Ah, it seems like the secret key is the issue
yeah it was the secret key issue, i swear i changed it to Test version a while ago and it showed the same error
aight last question, so am I using the most up to date and secure implimentation of reading stripe request in webhook file?? https://github.com/aquaductape/test-nexjs-stripe/blob/main/pages/api/stripe/webhook/index.ts
Yes, this looks correct. stripe.webhooks.constructEvent(..) [0] will do signature verification and ensure that the event is indeed sent from Stripe.
Awesome, so my issue is solved! Thank you so much
No problem! Happy to help ๐