13 lines
402 B
TypeScript
13 lines
402 B
TypeScript
import Stripe from "stripe";
|
|
|
|
// Lazy, env-guarded Stripe client. Returns null when STRIPE_SECRET_KEY is unset
|
|
// so the app builds/runs without keys; payment routes 501 until configured.
|
|
let _stripe: Stripe | null = null;
|
|
|
|
export function getStripe(): Stripe | null {
|
|
const key = process.env.STRIPE_SECRET_KEY;
|
|
if (!key) return null;
|
|
if (!_stripe) _stripe = new Stripe(key);
|
|
return _stripe;
|
|
}
|