Stripe Checkout
Complete Stripe checkout flow with subscription management, webhook handling, and customer portal integration. Includes pricing page component and usage-based billing support.
Next.jsPaymentsBuilt with Claude
2.8k
Stars
13.6k
Installs
2
Deps
2
Comments
Install / Copy
npx create-freestack-module stripe-checkoutCode Preview
index.tsx
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
export async function POST(request: Request) {
const { priceId, customerId } = await request.json();
const session = await stripe.checkout.sessions.create({
customer: customerId,
line_items: [{ price: priceId, quantity: 1 }],
mode: "subscription",
success_url: `${process.env.NEXT_PUBLIC_URL}/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_URL}/pricing`,
});
return Response.json({ url: session.url });
}
export async function handleWebhook(event: Stripe.Event) {
switch (event.type) {
case "checkout.session.completed":
await activateSubscription(event.data.object);
break;
case "invoice.payment_failed":
await handleFailedPayment(event.data.object);
break;
}
}SA
saasbuilder2 days ago
The webhook handler covers all the edge cases I always forget about. Saved me a weekend.
FI
fintech-dev5 days ago
Added usage-based metering on top of this. The billing portal integration is seamless.
Related Modules
Dashboard Layout
Responsive admin dashboard shell with collapsible sidebar navigation, breadcrumbs, top bar with search, and theme switching. Ready to drop your content into.
3.2kNext.js
Magic Link Auth
Passwordless email authentication with Supabase. Includes login/signup pages, session management, protected route middleware, and email templates.
1.8kNext.js
RBAC System
Role-based access control with middleware enforcement, permission checking hooks, and admin UI for managing roles. Supports hierarchical roles and resource-level permissions.
1.6kNext.js