#Scheggia-webhook-signature
1 messages · Page 1 of 1 (latest)
Hi
What's the issue exactly
This is my error: 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
in my code:
const endpointSecret = "copied from website";
app.post('/stripe/webhook', express.raw({type: 'application/json'}), (request, response) => {
const sig = request.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret);
} catch (err) {
response.status(400).send(`Webhook Error: ${err.message}`);
return;
}
// Handle the event
I need to send event id?
Nope, one sec.
What does your Express initialization look like?
Are you using app.use(express.json())?
var express = require('express');
var session = require('express-session');
var bodyParser = require('body-parser');
var path = require('path');
var app = express();
app.use(session({secret: 'secret',resave: true,saveUninitialized: true}));
app.use(bodyParser.urlencoded({extended : true}));
app.use(bodyParser.json());
I try with this
Okay try changing that to app.use((req, res, next) => { if (req.originalUrl === '/stripe/webhook') { next(); // Do nothing with the body because I need it in a raw state. } else { app.use(session({secret: 'secret',resave: true,saveUninitialized: true})); app.use(bodyParser.urlencoded({extended : true})); app.use(bodyParser.json()); } });
okay
anyway only with this i get the same error
now i try
nice, thank you!
Working
🎉
Nice day!
You too!
Sure
please check this
From webhook i get disabled reason, ok but i don't see the details_submitted
"requirements": {
"alternatives": [
],
"current_deadline": null,
"currently_due": [
],
"disabled_reason": null,
"errors": [
],
"eventually_due": [
],
"past_due": [
],
"pending_verification": [
]
},
My code is
if (account.requirements.disabled_reason === null && account.requirements.details_submitted === true) {