Separate YouTube video titles from on-video song/artist fields with Pro gating, serve curated fonts and watermark assets for 1:1 preview parity, and include billing/API/docs/deploy stack for self-hosted release.
31 lines
886 B
TypeScript
31 lines
886 B
TypeScript
import Stripe from "stripe";
|
|
|
|
let stripe: Stripe | null = null;
|
|
|
|
export function getStripe(): Stripe {
|
|
const key = process.env.STRIPE_SECRET_KEY;
|
|
if (!key) {
|
|
throw new Error("STRIPE_SECRET_KEY is not configured");
|
|
}
|
|
if (!stripe) {
|
|
stripe = new Stripe(key);
|
|
}
|
|
return stripe;
|
|
}
|
|
|
|
export function isStripeConfigured(): boolean {
|
|
return Boolean(process.env.STRIPE_SECRET_KEY);
|
|
}
|
|
|
|
/**
|
|
* Bypass Stripe Checkout when:
|
|
* - BILLING_DEV_MOCK=true, or
|
|
* - development and no STRIPE_SECRET_KEY (so UI still works without stripe listen)
|
|
* Set BILLING_DEV_MOCK=false to force real Stripe even without keys (will 503).
|
|
*/
|
|
export function isBillingDevMock(): boolean {
|
|
if (process.env.BILLING_DEV_MOCK === "true") return true;
|
|
if (process.env.BILLING_DEV_MOCK === "false") return false;
|
|
return process.env.NODE_ENV === "development" && !process.env.STRIPE_SECRET_KEY;
|
|
}
|