#Mao
1 messages · Page 1 of 1 (latest)
Hi there!
Hi Soma !
This is a classic issue. And the 2 main causes are:
- Using the wrong webhook endpoint secret, so can you double check that?
- And not using the raw body
Are you using Node + Express?
For the secret I use the one that is returned in my terminal after running this command:
stripe listen --forward-to localhost:9002/stripe/webhook
I use NodeJS and Express exactly
I think the problem must come from my way of sending the payload
Could you try using something like this for your route:
xxx.post("/stripe/webhook", express.raw({ type: "application/json" }), async (req, res) => { ... });
This way req.body should be the raw body.
Currently I have that, it's same no ?
app.route("/stripe/webhook")
.post(CommandeController.webhook, bodyParser.raw({ type: 'application/json' }));
Because I can't access express function
Not sure, have you tried this? Is it working?
But in our documentation we recommend this approach https://stripe.com/docs/webhooks/quickstart?lang=node
I have a question, it looks like correct sig ?
t=1663322291,v1=c18928949b35b88655b410f6de1ed659d49a68dcf6507810fe624babb24e9951,v0=879bab0b9791aa036f0186d737452f66e6ca8f956ede89b61564766dd8fcea4
const sig = String(req.headers['stripe-signature']);
No I haven't tried, because I can't find the .raw function
I have only RawListeners
it looks like correct sig ?
Yes it looks okay to me.
No I haven't tried, because I can't find the .raw function
I recommend following what we do in the documentation withexpress.raw({ type: "application/json" }): https://stripe.com/docs/webhooks/quickstart?lang=node
Ok, I just have to find the raw function, and I'll see
Beacause I use that of my routes :
import { Application } from "express";
In the doc we use const express = require('express');