#RGRTHAT
1 messages · Page 1 of 1 (latest)
hello, running into a webhook signature verification issue with Node?
yes
im trying to do like so ```js
stripe listen --events=payment_intent.succeeded
I got my endpoint secret by doing ```js
stripe listen
route: ```js
router.post(
"/webhooks",
express.raw({ type: "application/json" }),
payment.webhook
);
This is where the error must come from I suppose```js
const signature = req.headers["stripe-signature"];
event = stripe.webhooks.constructEvent(
req.body,
signature,
endpointSecret
);
@shrewd vessel isnt that the right secret to pass to "constructEvent"?
this is a common issue with express frameworks
there are solutions in https://github.com/stripe/stripe-node/issues/341
that you can try
but basically, you pass the full raw request body to your /webhooks endpoint
I think you're doing that in your code, not fully sure, I'm not a node expert
I THINK I KNOW!
its this ```js
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
middleware
u have to send raw
but basically something liek https://github.com/stripe/stripe-node/issues/341#issuecomment-818708675 could work, or alternative
I use this middleware for ALL requests except this one request that requires raw
how am I suppose to solve this problem
you're allowlisting /webhooks for raw requests only
and everything else uses express.json() for example
@shrewd vessel This works!
great!
who, me?
node is super popular
for the Stripe integrations I have built in the past, I've used node, ruby as the two main ones