import "server-only";
import Stripe from "stripe";

if (!process.env.STRIPE_SECRET_KEY) {
  // Don't throw at import time in dev without keys configured — routes that
  // actually use Stripe will fail loudly and clearly instead.
  console.warn(
    "[tidyly] STRIPE_SECRET_KEY is not set. Stripe-backed routes will fail until it is configured in .env.local."
  );
}

export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? "sk_test_placeholder", {
  apiVersion: "2024-06-20",
  typescript: true
});
