import Stripe from "stripe";

let client: Stripe | null = null;

// Absichtlich lazy statt beim Modul-Import: der Server soll auch dann
// normal starten/laufen, wenn noch kein Stripe-Key hinterlegt ist (Feature
// ist per Schalter deaktivierbar, siehe Settings.paymentSettings).
export function getStripeClient(): Stripe | null {
  const key = process.env.STRIPE_SECRET_KEY;
  if (!key) return null;
  if (!client) client = new Stripe(key);
  return client;
}

export function isStripeConfigured(): boolean {
  return Boolean(process.env.STRIPE_SECRET_KEY);
}
