import Stripe from "stripe";

/**
 * Stripe client -- server-side only.
 * Returns null when STRIPE_SECRET_KEY is not configured (dev mode without Stripe).
 */
function createStripeClient(): Stripe | null {
  const key = process.env.STRIPE_SECRET_KEY;
  if (!key) {
    return null;
  }
  return new Stripe(key, {
    typescript: true,
  });
}

export const stripe = createStripeClient();

// Re-export plans for backward compatibility in API routes
export { PLANS, type PlanKey } from "@/lib/plans";
