Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

679
Vistas
Stripe Construct Event: No signatures found matching the expected signature for payload. Javascript, Express

I get an error whenever I try to construct the stripe webhook event:

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

Cannot figure out how to solve this, already lot of json parsing methods but no one worked.

Here's my code:

app.post('/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
    const signature = req.headers['stripe-signature'];
    console.log(signature);
    const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET;

    let event;

    try {
        event = stripe.webhooks.constructEvent(req.body, signature, endpointSecret);
    } catch (err) {
        res.status(400).send(`Webhook Error: ${err.message}`);
        console.log(`Webhook Error: ${err.message}`);
        return;
    }

    switch (event.type) {
        case 'payment_intent.succeeded':
            const paymentIntent = event.data.object;
            console.log(paymentIntent);
            break;
        case 'payment_intent.payment_failed':
            console.log('Payment Failed');
    }

    res.status(200);

});

and these are my express uses:

app.use((req, res, next) => {
    if (req.originalUrl === '/webhook') {
        next();
    } else {
        express.json()(req, res, next);
    }
});
app.use(express.urlencoded({ extended: false }));
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The issue here is almost always not using the RAW BODY in the constructEvent. Stripe doesn't encode the "signature" in the JSON; they use "steganography" to encode the matching signature in the non-coding part of the JSON payload: extra spaces, line breaks, and other characters that are ignored by a JSON parser. The resulting payload can be parseed as JSON for the webhook object, but the "signature" part needs the raw body before any parser has removed the non-coding steganography.

specifically:

event = stripe.webhooks.constructEvent(req.rawbody, signature, endpointSecret)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda