Skip to content

50+ open-source generative AI apps you can clone, deploy, and monetize — image generators, video tools, virtual try-ons, AI SaaS templates, and platform integrations. One-click Vercel deploy on every template.

Restore: src/app/api/stripe/checkout/route.js

Anil Chandra Naidu Matchaa0d0418dab02
diff --git a/src/app/api/stripe/checkout/route.js b/src/app/api/stripe/checkout/route.js
new file mode 100644
index 0000000..de4b13d
--- /dev/null
+++ b/src/app/api/stripe/checkout/route.js
@@ -0,0 +1,29 @@
+import { NextResponse } from "next/server";
+import { getServerSession } from "next-auth/next";
+import { authOptions } from "@/lib/auth";
+import { BillingService } from "@/lib/services/billing";
+
+export async function POST(req) {
+ try {
+ const session = await getServerSession(authOptions);
+
+ if (!session?.user) {
+ return new NextResponse("Unauthorized", { status: 401 });
+ }
+
+ const { planId } = await req.json();
+ if (!planId) {
+ return new NextResponse("Missing planId", { status: 400 });
+ }
+
+ const checkoutUrl = await BillingService.createCheckoutSession(
+ session.user.id,
+ planId
+ );
+
+ return NextResponse.json({ url: checkoutUrl });
+ } catch (error) {
+ console.error("[STRIPE_CHECKOUT]", error);
+ return new NextResponse(error.message || "Internal Checkout Error", { status: 500 });
+ }
+}