Comprehensive admin + user dashboards (production-ready)

This commit is contained in:
Leon Serfaty
2026-06-07 17:54:30 -04:00
parent 155507f21a
commit f033f00379
122 changed files with 7878 additions and 805 deletions
+8 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest } from "next/server";
import { verifyPaypalWebhook } from "@/lib/billing/paypal";
import { handlePaypalEvent } from "@/lib/billing/webhooks/paypal";
import { alreadyProcessed, logWebhook } from "@/lib/billing/webhook-log";
export const dynamic = "force-dynamic";
@@ -23,10 +24,16 @@ export async function POST(req: NextRequest) {
return new Response("Invalid signature", { status: 400 });
}
const event = JSON.parse(body) as { id?: string; event_type?: string };
const eventId = event.id ?? `paypal_${Date.now()}`;
if (event.id && (await alreadyProcessed(eventId))) return new Response("ok (duplicate)");
try {
await handlePaypalEvent(JSON.parse(body));
await handlePaypalEvent(event as Parameters<typeof handlePaypalEvent>[0]);
await logWebhook("paypal", eventId, event.event_type ?? "unknown", "processed");
} catch (err) {
console.error("[paypal webhook] handler error", err);
await logWebhook("paypal", eventId, event.event_type ?? "unknown", "failed", err instanceof Error ? err.message : String(err));
return new Response("Handler error", { status: 500 });
}
return new Response("ok");