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

252
Views
Sigue recibiendo "No se encontraron firmas que coincidan con la firma esperada para la carga útil". para el webhook de Stripe (node.js)
app.use( express.json({ verify: (req, res, buf) => { req.rawBody = buf.toString(); }, }), ); app.post('/webhook', async (req, res, next) => { const sig = req.headers['stripe-signature']; let event; try { event = stripe.webhooks.constructEvent(req.rawBody, sig, endpoint_secret); } catch (err) { return console.log(err) } if (event.type === 'invoice.payment_succeeded') { //... } res.send(); });

Intenté seguir este enlace pero seguí obteniendo express.raw is not a function , también probé esto:

 app.use((req, res, next) => { if (req.originalUrl === '/webhook') { next(); } else { express.json()(req, res, next); } });

Y todavía tengo el mismo error, realmente agradecería si pudiera obtener ayuda.

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

0

Estoy usando Firebase Cloud Functions como mi API de webhook, así:

 import webhook_app_creator from "express"; import cors from "cors"; // This example uses Express to receive webhooks //the Cloud Function calls the webhook_app export const webhook_app = webhook_app_creator(); // The Firebase Admin SDK to access Cloud Firestore. //const cors = require("cors"); // Automatically allow cross-origin requests webhook_app.use(cors({ origin: true })); // build multiple CRUD interfaces: webhook_app.post("/direct", async (request, response) => { //send the response early - the only valid response is "received" await commonHandler(request, response, endpointDirectSecret); response.json({ received: true }); }); webhook_app.post("/connect", async (request, response) => { //send the response early - the only valid response is "received" await commonHandler(request, response, endpointSecret); response.json({ received: true }); }); const commonHandler = async (request, response, secret) => { const sig = request.headers["stripe-signature"]; try { request.fullEvent = stripe.webhooks.constructEvent( request.rawBody, sig, secret ); } catch (err) { logger(`Webhook Error: ${err.message}`); return; } return queue_event(request.fullEvent); };

La función de la nube no podría ser más sencilla:

 //import functions from "firebase-functions"; import { functions, webhook_app } from "../../../../services"; // Expose Express API as a single Cloud Function: export default functions.https.onRequest(webhook_app);
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!