Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Stripe Webhook error 400 con funciones de netlify

Configuré pagos con stripe usando la función Netlify siguiendo este artículo https://www.netlify.com/blog/2020/04/22/automate-order-fulfillment-w/stripe-webhooks-netlify-functions/ y en mi panel de Stripe me sale un error que dice que: Error de webhook: No se encontraron firmas que coincidan con la firma esperada para la carga útil. ¿Estás pasando el cuerpo de la solicitud sin procesar que recibiste de Stripe? https://github.com/stripe/stripe-node#webhook-signing

Ahora no estoy seguro de si el usuario recibe un correo electrónico de confirmación, Sendgrid no muestra ninguna actividad, sin embargo, no mostró ninguna cuando estaba probando este flujo anteriormente, y aunque recibí un correo electrónico de confirmación. Desafortunadamente, en ese entonces presioné reenviar por los detalles de actividad de mi webhook en el panel de control de Stripe, y no estoy seguro de si debería reenviarlos o si se procesan. ¿Alguien podría decirme qué está mal con mi código?

 const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY); const sgMail = require("@sendgrid/mail"); sgMail.setApiKey(process.env.SENDGRID_API_KEY); exports.handler = async ({ body, headers }) => { try { const stripeEvent = stripe.webhooks.constructEvent( body, headers["stripe-signature"], process.env.STRIPE_WEBHOOK_SECRET ); if (stripeEvent.type === "charge.succeeded") { const emailTo = stripeEvent.data.object.billing_details.email; const msg = { to: emailTo, from: process.env.FROM_EMAIL_ADDRESS, subject: `Thanks!`, html: `elox`, }; await sgMail.send(msg); } return { statusCode: 200, body: JSON.stringify({ received: true }), }; } catch (err) { console.log(`Stripe webhook failed with ${err}`); return { statusCode: 400, body: `Webhook Error: ${err.message}`, }; } };

¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tengo el mismo problema. Localmente con stripes-cli todo funciona bien. Parece que la lambda no entregó el cuerpo sin procesar a stripes.webhook.constructEvent.

Por lo tanto, mi solución fue cambiar la firma del método a la siguiente y usar el objeto event.body .

 exports.handler = async(event, context ) => { try { const stripeEvent = stripe.webhooks.constructEvent( event.body, event.headers['stripe-signature'], endpointSecret );....
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!