#raulru
1 messages ยท Page 1 of 1 (latest)
hey there, can you share the code for your webhook handler?
it works fine in a indepent project
Can you explain more about this? I don't understand what you mean
There are a couple common issues here:
1/ Missing or incorrect webhook signing secret passed it
2/ Mutated request.body somewhere in your network stack, and signature verification requires the exact raw body string we originally sent
Sure, i moved the webhook to the server.js insted of being in a express.route controller to see if that works but nope
Yes, i tested and implemented the api in a new project and it was working fine, but now im trying to integrate it to my project and it gives me those errors
What changed between those two?
Have you verified all your parameters for
stripe.webhooks.constructEvent(
request.body,
signature,
endpointSecret
);
have values
And are you testing with a live/public endpoint, or using the CLI and forwarding?
Not much, basically the same code
Lemme check that
Im using ngrok
REQUEST BODY: [object Object]
SIGNATURE: t=1697123149,v1=ecf074b6e98XXXXXXXXXXd5b8de15af535c11
ENDPOINT SECRET: whsec_orfXXXXXXXX2gWEMDzt
Those snippets aren't the same, in particular the first one you shared does not have this piece from the second one:
app.use((req, res, next) => {
if (req.originalUrl === "/webhook") {
next();
} else {
express.json()(req, res, next);
}
});
This logic looks to be skipping json parsing for webhook requests, which preserves the raw body
Do you have equivalent logc in the new code?
I removed it just to see if get a different result but nope, the same, i added those lines again and still not working
And you provided a new signing secret from the new endpoint being tested?
yes, i dont think the endpoint secret is the issue, i think its something related to the request body
yes, like i said thats the other common issue, because it get mutated somewhere
Is there any other express-related config code for this endpoint or is this all of this?
Thats all the express-related code
Actually, this suggests something is happening:
REQUEST BODY: [object Object]
body should be a string
So something is parsing it to an object
yeah, i think thats the issue, i keep commenting lines to see if something is altering the request but i still getting an [object Object]
What about the express.urlencoded middleware?
I don't see anything else that looks a likely culprit
still the same error ๐ฅฒ
๐ hopping in here since synthrider had to head out
hi!
One key difference I see is that you seem to be using bodyParser in your new webhook handlr - that's likely causing issues here
I already commented all those lines but still no success