Generated handler code for each destination. Drop in, set the env var, you're done.
STRIPE_SECRET_KEY=sk_live_… WHOOKHOUND_SECRET=whsec_8X9Lq2vBqXfP4nM7sR3tY6kZ8wL2cV5x WHOOKHOUND_URL=https://ingress.whookhound.dev/whk/tnt_3kQy
1// app/api/stripe/route.ts2import { headers } from 'next/headers';3import Stripe from 'stripe';45const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);67export async function POST(req: Request) {8 const body = await req.text();9 const sig = headers().get('stripe-signature')!;1011 let event: Stripe.Event;12 try {13 // Verifies the Whookhound-resigned signature with your destination secret.14 event = stripe.webhooks.constructEvent(body, sig, process.env.WHOOKHOUND_SECRET!);15 } catch (err) {16 return new Response(`Webhook error: ${(err as Error).message}`, { status: 400 });17 }1819 switch (event.type) {20 case 'checkout.session.completed':21 // ...your logic22 break;23 case 'customer.subscription.updated':24 // ...your logic25 break;26 }27 return Response.json({ received: true });28}Send a sample checkout.session.completed through this route to verify your handler.
npx whookhound listen \ --route rt_a1b \ --forward http://localhost:3000/api/stripe