/** * The publishable key, only when its mode matches the stack: `pk_live_` on production, `pk_test_` * everywhere else. A mismatch returns null, so checkout refuses to open rather than take a real card * on staging or a test card on production. The server refuses the secret key the same way. */ export function publishableKeyForStack(key: string, production: boolean): string | null { const required = production ? 'pk_live_' : 'pk_test_'; return key.startsWith(required) ? key : null; } /** The key-field hints for this stack's mode, so staging never invites a live key the server refuses. */ export function stripeKeyPlaceholders(production: boolean): { publishable: string; secret: string } { const mode = production ? 'live' : 'test'; return { publishable: `pk_${mode}_…`, secret: `sk_${mode}_…` }; }