Initial commit
This commit is contained in:
13
lib/stripe.ts
Normal file
13
lib/stripe.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user