Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@ NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard
# -----------------------------
# Stripe
# -----------------------------
# Stripe API Keys (server-side only)
STRIPE_SECRET_KEY=sk_test_placeholder
STRIPE_WEBHOOK_SECRET=whsec_placeholder

# Stripe Price IDs (create in Stripe Dashboard)
STRIPE_SOLO_MONTHLY_PRICE_ID=price_placeholder
STRIPE_SOLO_ANNUAL_PRICE_ID=price_placeholder
STRIPE_SOLO_LIFETIME_PRICE_ID=price_placeholder
STRIPE_PRO_MONTHLY_PRICE_ID=price_placeholder
STRIPE_PRO_ANNUAL_PRICE_ID=price_placeholder
STRIPE_PRO_LIFETIME_PRICE_ID=price_placeholder
STRIPE_TEAM_MONTHLY_PRICE_ID=price_placeholder
STRIPE_TEAM_ANNUAL_PRICE_ID=price_placeholder

# Stripe Publishable Key (client-side)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_placeholder

# Note: Price IDs are configured in src/config/pricing.ts
# The pricing config automatically uses Test IDs for Preview/Dev
# and Live IDs for Production (based on VERCEL_ENV)

# -----------------------------
# App URLs
# -----------------------------
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Backend API URL (for license fetching)
NEXT_PUBLIC_API_URL=http://localhost:8787
86 changes: 64 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@radix-ui/react-toggle": "1.1.1",
"@radix-ui/react-toggle-group": "1.1.1",
"@radix-ui/react-tooltip": "1.1.6",
"@stripe/stripe-js": "^8.6.1",
"@types/mdx": "^2.0.13",
"@vercel/analytics": "1.3.1",
"autoprefixer": "^10.4.20",
Expand All @@ -61,6 +62,8 @@
"react-resizable-panels": "^2.1.7",
"recharts": "2.15.4",
"sonner": "^1.7.4",
"stripe": "^20.1.2",
"swr": "^2.3.8",
"tailwind-merge": "^3.3.1",
"tailwindcss-animate": "^1.0.7",
"vaul": "^1.1.2",
Expand Down
35 changes: 35 additions & 0 deletions src/app/api/billing-portal/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@clerk/nextjs/server";
import { stripe } from "@/lib/stripe";

export async function POST(req: NextRequest) {
try {
const { userId } = await auth();

if (!userId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const { customerId } = await req.json();

if (!customerId) {
return NextResponse.json(
{ error: "No Stripe customer ID provided" },
{ status: 400 }
);
}

const session = await stripe.billingPortal.sessions.create({
customer: customerId,
return_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard`,
});

return NextResponse.json({ url: session.url });
} catch (error) {
console.error("Billing portal error:", error);
return NextResponse.json(
{ error: "Failed to open billing portal" },
{ status: 500 }
);
}
}
Loading