diff --git a/ui/lib/get-runtime-config.client.test.ts b/ui/lib/get-runtime-config.client.test.ts index d46b633d38..d788a01132 100644 --- a/ui/lib/get-runtime-config.client.test.ts +++ b/ui/lib/get-runtime-config.client.test.ts @@ -105,6 +105,8 @@ describe("getRuntimeConfigClient", () => { "reoDevClientId", "sentryDsn", "sentryEnvironment", + "stripePublishableKey", + "stripePublishableKeyV2", ].sort(), ); expect(config.apiBaseUrl).toBe("https://api.example.com/api/v1"); diff --git a/ui/lib/get-runtime-config.client.ts b/ui/lib/get-runtime-config.client.ts index 9aa4ea15c8..e1bcd2bf1a 100644 --- a/ui/lib/get-runtime-config.client.ts +++ b/ui/lib/get-runtime-config.client.ts @@ -21,6 +21,8 @@ const pickConfig = ( posthogHost: parsed.posthogHost ?? null, reoDevClientId: parsed.reoDevClientId ?? null, cloudBillingEnabled: parsed.cloudBillingEnabled ?? false, + stripePublishableKey: parsed.stripePublishableKey ?? null, + stripePublishableKeyV2: parsed.stripePublishableKeyV2 ?? null, }); // Reads the island once (memoized); all-null during SSR or if it's diff --git a/ui/lib/runtime-config.shared.ts b/ui/lib/runtime-config.shared.ts index e4fbbeceed..6e820296d9 100644 --- a/ui/lib/runtime-config.shared.ts +++ b/ui/lib/runtime-config.shared.ts @@ -10,6 +10,8 @@ export interface RuntimePublicConfig { posthogHost: string | null; // reserved reoDevClientId: string | null; // reserved cloudBillingEnabled: boolean; + stripePublishableKey: string | null; // reserved + stripePublishableKeyV2: string | null; // reserved } export const RUNTIME_CONFIG_SCRIPT_ID = "__PROWLER_RUNTIME_CONFIG__"; @@ -25,4 +27,6 @@ export const EMPTY_RUNTIME_PUBLIC_CONFIG: RuntimePublicConfig = { posthogHost: null, reoDevClientId: null, cloudBillingEnabled: false, + stripePublishableKey: null, + stripePublishableKeyV2: null, }; diff --git a/ui/lib/runtime-config.ts b/ui/lib/runtime-config.ts index eda71bc114..f1ef52900b 100644 --- a/ui/lib/runtime-config.ts +++ b/ui/lib/runtime-config.ts @@ -49,5 +49,13 @@ export async function getRuntimePublicConfig(): Promise { // server-side for V1/V2 routing). Default (unset) is off. cloudBillingEnabled: (readEnv("CLOUD_BILLING_ENABLED") ?? "false") !== "false", + stripePublishableKey: readEnv( + "UI_CLOUD_STRIPE_PUBLISHABLE_KEY", + "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY", + ), + stripePublishableKeyV2: readEnv( + "UI_CLOUD_STRIPE_PUBLISHABLE_KEY_V2", + "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY_V2", + ), }; } diff --git a/ui/tests/runtime-config/runtime-config-page.ts b/ui/tests/runtime-config/runtime-config-page.ts index dcdf3e546c..430033eba4 100644 --- a/ui/tests/runtime-config/runtime-config-page.ts +++ b/ui/tests/runtime-config/runtime-config-page.ts @@ -20,6 +20,8 @@ export const RUNTIME_CONFIG_KEYS = [ "posthogHost", "reoDevClientId", "cloudBillingEnabled", + "stripePublishableKey", + "stripePublishableKeyV2", ] as const satisfies ReadonlyArray; /** diff --git a/ui/types/env.d.ts b/ui/types/env.d.ts index 515d7a6c03..c4ec4d85a3 100644 --- a/ui/types/env.d.ts +++ b/ui/types/env.d.ts @@ -30,6 +30,15 @@ declare global { CLOUD_BILLING_ENABLED?: "legacy" | "metronome" | "false"; + // Cloud-only Stripe publishable keys (public; shipped to the browser). + // V1 = legacy billing, V2 = metronome. + /** @deprecated use UI_CLOUD_STRIPE_PUBLISHABLE_KEY */ + NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY?: string; + UI_CLOUD_STRIPE_PUBLISHABLE_KEY?: string; + /** @deprecated use UI_CLOUD_STRIPE_PUBLISHABLE_KEY_V2 */ + NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY_V2?: string; + UI_CLOUD_STRIPE_PUBLISHABLE_KEY_V2?: string; + // Build-time public config NEXT_PUBLIC_IS_CLOUD_ENV?: "true" | "false"; NEXT_PUBLIC_PROWLER_RELEASE_VERSION?: string;