I'm seeing the following error on my WebHook handler:
Webhook Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing
Following this example, I updated my code from req.body
to req.rawBody
.
Stripe Error: No signatures found matching the expected signature for payload
Here is my code:
app.post('/webhook', raw({ type: 'application/json' }), async (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(
req.rawBody,
sig,
stripeWebhookSigningKey
);
} catch (err) {
console.log(err);
}
if (event.type === 'checkout.session.completed') {
...
} else if (event.type === 'account.updated') {
...
} else {
...
}
})