Download src/app/api/checkout/route.js from NeoPy/hugging-c-ai: direct link, hf CLI and curl.
- Browser
- Download file 881 Bytes
-
https://huggingface.co/NeoPy/hugging-c-ai/resolve/main/src/app/api/checkout/route.js
- Command line
-
hf download hf://NeoPy/hugging-c-ai/src/app/api/checkout/route.js
-
curl -L -o route.js https://huggingface.co/NeoPy/hugging-c-ai/resolve/main/src/app/api/checkout/route.js
881 Bytes
| 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 || !session.user) { | |
| return NextResponse.json({ error: "Unauthorized. Please sign in." }, { status: 401 }); | |
| } | |
| const { planId } = await req.json(); | |
| if (!planId) { | |
| return NextResponse.json({ error: "Missing planId parameter" }, { status: 400 }); | |
| } | |
| const checkoutUrl = await BillingService.createCheckoutSession(session.user.id, planId); | |
| return NextResponse.json({ url: checkoutUrl }); | |
| } catch (error) { | |
| console.error("Checkout route error:", error); | |
| return NextResponse.json({ error: error.message }, { status: 500 }); | |
| } | |
| } | |