import { NextRequest, NextResponse } from "next/server"; // Stripe webhook stub — wire up when adding Stripe // Verifies stripe-signature header (using raw body), handles: // - checkout.session.completed → upgrade user to pro // - customer.subscription.deleted → downgrade user to free export async function POST(req: NextRequest) { const body = await req.text(); const sig = req.headers.get("stripe-signature"); if (!sig || !process.env["STRIPE_WEBHOOK_SECRET"]) { return NextResponse.json({ error: "Stripe not configured" }, { status: 400 }); } // TODO: const event = stripe.webhooks.constructEvent(body, sig, process.env["STRIPE_WEBHOOK_SECRET"]); // For now just return 200 to acknowledge receipt console.log("[stripe-webhook] received event, sig:", sig.slice(0, 20)); return NextResponse.json({ received: true }); }