Files
yourwillyourwish/lib/stripe.ts
2026-02-06 21:44:04 -06:00

14 lines
425 B
TypeScript

import Stripe from "stripe";
import { loadSystemConfig } from "./system-config";
let stripe: Stripe | null = null;
export async function getStripe() {
if (stripe) return stripe;
const cfg = await loadSystemConfig();
const key = cfg.stripe?.secretKey || process.env.STRIPE_SECRET_KEY;
if (!cfg.stripe?.enabled || !key) return null;
stripe = new Stripe(key, { apiVersion: "2024-06-20" as any });
return stripe;
}