#teevee_14010
1 messages · Page 1 of 1 (latest)
You should check your server logs to determine what causes the 400 errors.
sometimes it says no payload other times it just says 400
Do you have an event ID that I can take a look?
I believe this is an event ID
req_S8qTXcjsTnU7Qg
I just checked the webhook endpoint that you hosted in smee.io, and I don't see any recent errors
Correct, but on my server it cannot receive/process the payload
What's the error?
Is there something wrong with server code for receiving the payload:
returning a 400 error code. This is my endpoint code:
router.post('/webhook', bodyParser.raw({ type: 'application/json' }), async (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
const buf = Buffer.from(req.body);
event = stripe.webhooks.constructEvent(buf, sig, endpointSecret);
} catch (err) {
return res.status(400).send(Webhook Error: ${err.message});
}
But based on what I saw in your Dashboard, your server is returning 200, which means your server is processing the webhook events successfully
Yeah I am confused. This is what server log returns everytime I run a test transaction:
POST http://localhost:3000/webhook - 400
I think its something wrong with the way the server is parsing the body of the payload.
This is a previous a server log message:
Webhook Error: Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the raw request body.Payload was provided as a parsed JavaScript object instead.
Signature verification is impossible without access to the original signed material.
Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing
POST http://localhost:3000/webhook - 400
The webhook secrets on the local server and the one in Dashboard are different. Can you ensure that you use the correct Webhook secret?
How are you listening to the event in http://localhost:3000/webhook ? Is it using CLI?
I am using smee.io
And it is connected and working properly. I am not using CLI with this endpoint.
This is what smee.io is forwarding to http://localhost:3000/webhook
This is a public channel and sensitive information such as webhook secret shouldn't be shared. I've removed the screenshot above.
Does your node middleware configure parse all the requests to JSON somewhere? For example,
app.use(express.json());
Yes in my server.js file
If you have this, it'll parse the requests in all JSON, not in raw form before reaching to your webhook function
Can you remove it can and see if it solves the problem?
I removed the code and ran another transaction. I still got a 400 error in my server log
this was response:
Webhook Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing
POST http://localhost:3000/webhook - 400
Are you using the webhook secret generated by the stripe listen command?
I am using the webhook secret from the webhook dashboard
No. If you running the webhook locally, you should use the secret generated from Stripe CLI
Ok thank you, where is that located? Also I am using smee.io so the webhook payloads are being forwarded from the smee address to my local server at the endpoint localhost:3000/webhook
Did i lose you?
Thanks for waiting. discord is busy today
If you are not using Stripe CLI, then you should use the webhook secret from your Dashboard
When I use the webhook secret and run a transaction this is what my server log returns:
Webhook Error: No webhook payload was provided.
POST http://localhost:3000/webhook - 400
Wha'ts the webhook event ID?
evt_3Obdy7KqO403i8Jl1aYQL0fz
There is something wrong with how the raw request body is being handled by my server code but I cant figure out what.
https://dashboard.stripe.com/test/events/evt_3Obdy7KqO403i8Jl1aYQL0fz I don't see any error based on the Dashboard log
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Your endpoint responded with 200
Stripe is sending the code and my server is receiving it but its not able to convert the payload
What do you mean by "not able to convert the payload" ?
the body of the json file being sent in the webhook is not being read by my server.
Do you see any errors in server log?
Yes
Webhook Error: No webhook payload was provided.
POST http://localhost:3000/webhook - 400
Hmm, can you do a console.log(req.body) and see what it prints out?
Yes this is what the console printed:
<Buffer 7b 22 69 64 22 3a 22 65 76 74 5f 33 4f 62 65 44 50 4b 71 4f 34 30 33 69 38 4a 6c 30 48 77 70 42 79 4f 50 22 2c 22 6f 62 6a 65 63 74 22 3a 22 65 76 65 ... 1309 more bytes>
Webhook Error: No webhook payload was provided.
POST http://localhost:3000/webhook - 400
That's very strange
This is going to require a bit more investigation. Sorry to redirect you, but can you write in to https://support.stripe.com/contact/email with a test proejct that we can run and reprouce the problem? We'll respond via email/ticket after looking into it further.
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Sure thank you for your time, this is a great service/feature.