import Stripe from "stripe"

// Check if we're in a browser environment
const isBrowser = typeof window !== "undefined"

// Only throw if we're in a server environment and the key is missing
if (!isBrowser && !process.env.STRIPE_SECRET_KEY) {
  console.warn("STRIPE_SECRET_KEY is not set in environment variables")
}

export const stripe =
  !isBrowser && process.env.STRIPE_SECRET_KEY
    ? new Stripe(process.env.STRIPE_SECRET_KEY, {
        apiVersion: "2025-08-27.basil",
      })
    : null
