foortex.codegen utility
Next.jsBackend 2180 45.2k

Next.js App Router Stripe Checkout & Webhook Subscription Handler

Production-ready Stripe integration for Next.js App Router applications. Includes server actions for initiating billing sessions, raw body signature verification for Stripe webhooks, and user subscription state updates.

Stripe Checkout creation via Next.js Server Action
Verified API route handler
Interactive Prompt & Options
Fully Editable

Appended directly to the LLM system prompt for tailored code output.

✨ OpenRouter LLM Engine (Llama-3.3-70B) Active

Generated Code

⚡ Instant Boilerplate
nextjs-stripe-checkout-webhook.ts
1import { headers } from 'next/headers';
2import { NextResponse } from 'next/server';
3import Stripe from 'stripe';
4
5const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || 'sk_test_mock', { apiVersion: '2023-10-16' });
6
7export async function POST(req: Request) {
8 const body = await req.text();
9 const signature = (await headers()).get('stripe-signature');
10 const event = stripe.webhooks.constructEvent(body, signature!, process.env.STRIPE_WEBHOOK_SECRET!);
11
12 if (event.type === 'checkout.session.completed') {
13 console.log('Subscription completed!');
14 }
15 return NextResponse.json({ received: true });
16}
17
17 lines • 614 bytesnext.js
Automated Sandbox

Deploy this boilerplate automatically in 1 click.

Deploy