Actualizar server.js

This commit is contained in:
2026-03-29 17:01:34 +00:00
parent b42b1c6ba0
commit e1f53a3fe0

View File

@@ -4325,10 +4325,10 @@ app.post("/public/portal/:token/budget/:id/checkout", async (req, res) => {
}); });
// B) WEBHOOK DE STRIPE (El chivatazo invisible que avisa cuando el cliente YA ha pagado) // B) WEBHOOK DE STRIPE (El chivatazo invisible que avisa cuando el cliente YA ha pagado)
app.post("/webhook/stripe", express.raw({ type: 'application/json' }), async (req, res) => { app.post("/webhook/stripe", async (req, res) => {
try { try {
const body = req.body; // 🛑 FIX: Como usamos express.json() globalmente arriba, el body YA es un objeto, no hay que parsearlo.
const event = JSON.parse(body); const event = req.body;
if (event.type === 'checkout.session.completed') { if (event.type === 'checkout.session.completed') {
const session = event.data.object; const session = event.data.object;