Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(billing): add support for cloud trial preview mode
Victor Hugo dos Santos08f50de18a7a
diff --git a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsxindex f9ee29d41e..a56107ea2d 100644--- a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx+++ b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx@@ -32,9 +32,12 @@ import { catalogById } from "./billing-v2-format";import {asCloudOverview,asManagedCloudOverview,+ asTrialCloudOverview,PREVIEW_CATALOG,PREVIEW_MODE,previewEntitlements,+ TRIAL_CATALOG,+ trialEntitlements,usePreviewUsage} from "./billing-v2-local-preview";import { BillingV2RenderState } from "./billing-v2-view-types";@@ -98,11 +101,15 @@ export const BillingV2Page = () => {// substitutes the licence server's half of the data so the layout is reviewable. Switch views with// PREVIEW_MODE in billing-v2-local-preview.ts.const usePreview = PREVIEW_MODE !== "off" && realCatalog.length === 0;- const catalog = usePreview ? PREVIEW_CATALOG : realCatalog;+ const isTrialPreview = PREVIEW_MODE === "cloud-trial";+ const previewCatalog = isTrialPreview ? TRIAL_CATALOG : PREVIEW_CATALOG;+ const catalog = usePreview ? previewCatalog : realCatalog;// Real figures for the faked products, read off this instance's own database through the breakdown// endpoint, so picking an organization moves the meters the way it will in production.const previewUsage = usePreviewUsage(selectedOrgId, breakdownScope);- const previewedEntitlements = previewEntitlements(previewUsage);+ const previewedEntitlements = isTrialPreview+ ? trialEntitlements(previewUsage)+ : previewEntitlements(previewUsage);// Shadows the real overview for the whole component, so every branch keyed off it (subState, the// managed/self-serve copy, the payment and invoice cards) sees the faked shape too. Restore to// `const { data: overview, ... } = useGetBillingV2Overview(selectedOrgId)` when removing the preview.@@ -110,6 +117,8 @@ export const BillingV2Page = () => {if (usePreview && serverOverview) {if (PREVIEW_MODE === "cloud") {overview = asCloudOverview(serverOverview, previewedEntitlements);+ } else if (isTrialPreview) {+ overview = asTrialCloudOverview(serverOverview, previewedEntitlements);} else if (PREVIEW_MODE === "cloud-managed") {overview = asManagedCloudOverview(serverOverview, previewedEntitlements);} else {diff --git a/frontend/src/pages/organization/BillingV2Page/billing-v2-local-preview.ts b/frontend/src/pages/organization/BillingV2Page/billing-v2-local-preview.tsindex ba0fd06d65..e22585c482 100644--- a/frontend/src/pages/organization/BillingV2Page/billing-v2-local-preview.ts+++ b/frontend/src/pages/organization/BillingV2Page/billing-v2-local-preview.ts@@ -6,12 +6,14 @@// ONE SWITCH for reviewing the layout. Flip this, save, and the page re-renders://// "cloud" paying cloud customer: header tiles, payment card, invoices, no org picker+// "cloud-trial" self-serve cloud mid-trial: one trialing product, a card on file but nothing+// billed yet, and an available row mixing a sales-led product with a trialable one// "cloud-managed" enterprise-managed cloud: Managed Billing notice, no Stripe sections// "self-hosted" licensed instance: managed copy, instance-admin org picker, no Stripe cards// "offline" air-gapped licence: the standalone OfflineBillingPage (nothing from this feature)// "off" no faking at all; on a dev stack this shows "No products available"// The usage-export type PreviewMode = "cloud" | "cloud-managed" | "self-hosted" | "offline" | "off";+export type PreviewMode = "cloud" | "cloud-trial" | "cloud-managed" | "self-hosted" | "offline" | "off";export const PREVIEW_MODE: PreviewMode = "self-hosted";import { useMemo } from "react";@@ -27,7 +29,13 @@ import {BillingV2UsageBreakdown} from "@app/hooks/api";-const dim = (key: string, label: string, noun: string, used: number): BillingV2EntitlementDim => ({+const dim = (+ key: string,+ label: string,+ noun: string,+ used: number,+ rate?: number+): BillingV2EntitlementDim => ({key,label,noun,@@ -38,6 +46,7 @@ const dim = (key: string, label: string, noun: string, used: number): BillingV2Elimit: null,committed: null,commitAvailable: false,+ rate,onDemandAmount: 0});@@ -187,6 +196,70 @@ export const previewEntitlements = (usage: PreviewUsage = {}): Record<string, Biexport const PREVIEW_ENTITLEMENTS = previewEntitlements();+// "cloud-trial" is a self-serve cloud account partway through a trial, which the other cloud shapes do+// not reach: the plan badge and the Trial badge on one card, "Included" where a price would be, a card+// on file with nothing yet to charge, and an available row carrying both CTAs at once. Its own catalog,+// because PREVIEW_CATALOG is enterprise-shaped and every tile there is sales-led.+const plan = (+ tier: string,+ name: string,+ { selfServe = false, salesLed = false, trialDays = 0 } = {}+): BillingV2CatalogProduct["plans"][number] => ({+ tier,+ name,+ selfServe,+ salesLed,+ trialable: trialDays > 0,+ upgradeable: selfServe,+ trialDays,+ dims: []+});++export const TRIAL_CATALOG: BillingV2CatalogProduct[] = [+ {+ ...product(+ "secrets",+ "Secrets Management",+ "key_round",+ "#e0ed34",+ "Store, manage, and sync secrets across your stack."+ ),+ plans: [plan("pro", "Pro", { selfServe: true }), plan("enterprise", "Enterprise", { salesLed: true })]+ },+ product(+ "pki",+ "Certificate Management",+ "file_check",+ "#ed8c34",+ "Issue and manage X.509 certificates and private CAs."+ ),+ {+ ...product(+ "pam",+ "Privileged Access Management",+ "user_round_plus",+ "#ff3568",+ "Secure, broker, and audit privileged access."+ ),+ plans: [plan("pro", "Pro", { selfServe: true, trialDays: 14 })]+ }+];++// Only secrets is entitled, so the other two fall to the available row: pki sales-led ("Contact+// sales"), pam trialable ("Try free for 14 days").+export const trialEntitlements = (usage: PreviewUsage = {}): Record<string, BillingV2Entitlement> => ({+ secrets: {+ entitled: true,+ planTier: "pro",+ cadence: "monthly",+ isTrialing: true,+ trialEndsAt: "October 1, 2026",+ dimensions: [+ dim("secret_identities", "Secret Identities", "identity", usage.secret_identities ?? 0, 23)+ ]+ }+});+// One request per previewed dimension, keyed on the picked organization and scope, so switching the// picker refetches and the cards move with it.export const usePreviewUsage = (orgId: string, scope: BillingV2BreakdownScopeKind): PreviewUsage => {@@ -288,6 +361,29 @@ export const asCloudOverview = (]});+export const asTrialCloudOverview = (+ overview: BillingV2Overview,+ entitlements: Record<string, BillingV2Entitlement>+): BillingV2Overview => ({+ ...overview,+ ...CLOUD_BASE,+ entitlements,+ planName: "Pro",+ subState: "trialing",+ selfServe: true,+ // A trial charges nothing yet, so every figure in the header is empty while the card is on file.+ billing: { monthlyRecurring: 0, annualCommitted: 0, activeProductCount: 1, nextCharge: null },+ onDemandAmount: 0,+ payment: { brand: "mastercard", last4: "7002", expMonth: 2, expYear: 2029 },+ billingDetails: {+ name: "Personal Org",+ email: "[email protected]",+ address: null,+ taxIds: []+ },+ invoices: []+});+// "cloud-managed" is an enterprise-managed cloud org, which is what a real production account looked// like: contract-billed, so there is no Stripe subscription and none of those sections render. selfServe// false is what raises the Managed Billing notice.diff --git a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsxindex 3c2ad51b7f..95d4e75a17 100644--- a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx@@ -75,9 +75,27 @@ export const Overview = ({) : null;if (subState === "loading" || isReloading) {+ const isManagedShell = overview ? overview.mode === "managed" : !isInfisicalCloud();+ const hasHeaderTiles = overview ? overview.subState !== "no-subscription" : true;+ const keepsBillingHistory = Boolean(+ overview && (overview.payment || overview.billingDetails || overview.invoices.length > 0)+ );+ const hasBillingSection = overview+ ? overview.isCloud && (overview.subState !== "no-subscription" || keepsBillingHistory)+ : isInfisicalCloud();+return (<div className="flex flex-col gap-4">- <StatTilesSkeleton />+ {isManagedShell && (+ <Banner+ mode="managed"+ subState={subState}+ canManage={false}+ onUpdatePayment={onUpdatePayment}+ onManageSubscription={onManageSubscription}+ />+ )}+ {hasHeaderTiles && <StatTilesSkeleton />}<ProductsCardkey="products"overview={overview}@@ -90,7 +108,7 @@ export const Overview = ({onViewBreakdown={onViewBreakdown}onContact={onContact}/>- {(overview?.isCloud ?? isInfisicalCloud()) && <BillingSectionSkeleton />}+ {hasBillingSection && <BillingSectionSkeleton />}</div>);}diff --git a/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsx b/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsxindex 807b0406d4..46488985c3 100644--- a/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsx@@ -51,7 +51,7 @@ type StatTileProps = {};const StatTile = ({ title, tone, icon, value, footer }: StatTileProps) => (- <Card className="flex-1 gap-2 p-4 shadow-none">+ <Card className="flex-1 gap-2 p-4"><CardHeader><CardTitle className="text-xs font-medium text-muted capitalize">{title}</CardTitle><CardAction>diff --git a/frontend/src/pages/organization/BillingV2Page/components/states/OverviewSkeleton.tsx b/frontend/src/pages/organization/BillingV2Page/components/states/OverviewSkeleton.tsxindex db202708f3..4bc1587056 100644--- a/frontend/src/pages/organization/BillingV2Page/components/states/OverviewSkeleton.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/states/OverviewSkeleton.tsx@@ -7,7 +7,7 @@ export const StatTilesSkeleton = () => (<div className="flex flex-col gap-3"><div className="flex flex-col gap-4 lg:flex-row">{TILES.map((tile) => (- <Card key={tile} className="flex-1 gap-2 p-4 shadow-none">+ <Card key={tile} className="flex-1 gap-2 p-4"><CardHeader><CardTitle><div className="flex h-4 items-center">