feat(webhooks): outbound webhooks with HMAC-SHA256 signing and API key auth
Webhook registration/management. HMAC-signed delivery with retry. Events: recipe.created/updated, comment.created, follower.new. REST API key creation for programmatic access.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user