Comprehensive admin + user dashboards (production-ready)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { prisma } from "@/lib/db";
|
||||
|
||||
/** True if we've already handled this provider event (idempotency). */
|
||||
export async function alreadyProcessed(eventId: string): Promise<boolean> {
|
||||
const existing = await prisma.webhookEvent.findUnique({ where: { eventId } });
|
||||
return !!existing;
|
||||
}
|
||||
|
||||
/** Record a webhook delivery for the admin log (best-effort; unique on eventId). */
|
||||
export async function logWebhook(
|
||||
provider: "stripe" | "paypal",
|
||||
eventId: string,
|
||||
type: string,
|
||||
status: "processed" | "failed" | "skipped",
|
||||
error?: string
|
||||
): Promise<void> {
|
||||
await prisma.webhookEvent
|
||||
.upsert({
|
||||
where: { eventId },
|
||||
create: { provider, eventId, type, status, error },
|
||||
update: { status, error },
|
||||
})
|
||||
.catch((e) => console.error("[webhook-log] write failed", e));
|
||||
}
|
||||
Reference in New Issue
Block a user