Actualizar server.js
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user