#chaimat

1 messages · Page 1 of 1 (latest)

worthy needleBOT
obtuse kraken
#

what does your actual /api/stripe/verification route code look like?

rough mortar
#

updated the message with the code

#

removed the switch statement for handling the webhook event, because I was hitting the character limit

obtuse kraken
#

please log the exact values of req.body, signature and webhookSecret and post them here

rough mortar
#

okay will do that

#

the above file is the request body

signature: t=1675078852,v1=0c77efff4aa8e1fe91960b5a1be321bf8c8c4ebae444677e4cd74708a152927b,v0=6f2a04a85d688562bc0bc14c0765d3f67759eeea6967e4463405cc1735fdd424

webhook secret :
whsec_865e7dda4c53cad975c90fca64acf2d232417b211363e1c0427969385bdba364

obtuse kraken
#

well that's not the raw body since it has e.g. customer_address: [Object], which means the variable is actually a JSON object and not a raw string

rough mortar
#

Right, how do I pass on the raw body. I have taken all the steps that were suggested in the github link. additionaly did read about it on stackoverflow as well

#

can't seem to figure out what is breaing

obtuse kraken
#

I would make sure you don't have app.use(express.json()); somewhere in your project as that will override things.

rough mortar
#

I do have that in my index.js file
but I made changes as the github link suggested

index.js (the main express/node file)

`app.use((req, res, next) => {
console.log(req.originalUrl);
if (req.originalUrl == "/api/stripe/verification") {
console.log("passed raw URL");
next();
} else {
express.json()(req, res, next);
}
});

require("./startup/routes")(app);`

obtuse kraken
#

I do have that in my index.js file
remove it

rough mortar
#

Okay, will try it with that. But I would need that with my other routes.

obtuse kraken
#

pass it to each one individually instead like router.post("/my_route", express.json(), async function(req, res, next) {

rough mortar
#

Okay, will try that.

obtuse kraken
#

it might also work if you change the ordering so app.use(express.json()) is after(or maybe before, you could try both) the snippet that checks the originalUrl to override

rough mortar
#

Okay, makes sense. Will do that

rough mortar