21 lines
433 B
TypeScript
21 lines
433 B
TypeScript
import Stripe from "stripe";
|
|
|
|
let stripeClient: Stripe | null = null;
|
|
|
|
export function getStripe(): Stripe {
|
|
if (!stripeClient) {
|
|
const secretKey = process.env.STRIPE_SECRET_KEY;
|
|
|
|
if (!secretKey) {
|
|
throw new Error("Missing STRIPE_SECRET_KEY environment variable.");
|
|
}
|
|
|
|
stripeClient = new Stripe(secretKey, {
|
|
apiVersion: "2026-04-22.dahlia",
|
|
typescript: true,
|
|
});
|
|
}
|
|
|
|
return stripeClient;
|
|
}
|