Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge branch 'main' of github.com:Infisical/infisical into feat/license-v2-fix

=9ee13c338cdd
diff --cc backend/src/ee/services/license-v2/license-v2-service.ts
index e49ce81fdd,b9a09a9ba2..6fb1c9ce93
--- a/backend/src/ee/services/license-v2/license-v2-service.ts
+++ b/backend/src/ee/services/license-v2/license-v2-service.ts
@@@ -147,17 -152,34 +153,32 @@@ const planHasPricing = (plan: TCatalogP
const findPaidSelfServePlan = (product: TCatalogProduct) =>
product.plans.find((plan) => plan.selfServe === true && plan.tier !== "free" && planHasPricing(plan));
-const toCatalogProduct = (product: TCatalogProduct): BillingV2CatalogProduct => {
- const paidSelfServePlan = findPaidSelfServePlan(product);
- const salesLedPlan = product.plans.find((plan) => plan.salesLed === true);
-
- // Fold the plan's per-dimension/per-cadence prices into the dim view the UI renders. metered is
- // tracked per cadence so a dimension priced per_unit on one cadence and metered on the other
- // doesn't mislabel both.
+// Project a single catalog plan into the UI shape: fold its per-dimension/per-cadence prices into the
+// dim view, and surface its base fee when it has one. Each plan carries its own pricing, so a product
- // with several tiers (pro, advanced, pro+) maps each tier independently.
++// with several tiers (pro, advanced, pro+) maps each tier independently. metered is tracked per cadence
++// so a dimension priced per_unit on one cadence and metered on the other doesn't mislabel both.
+const toPlan = (product: TCatalogProduct, plan: TCatalogProduct["plans"][number]): BillingV2Plan => {
- const priceByDim = new Map<string, { monthly: number; annual: number; included: number }>();
+ const priceByDim = new Map<
+ string,
+ { monthly: number; annual: number; included: number; meteredMonthly: boolean; meteredAnnual: boolean }
+ >();
- (paidSelfServePlan?.prices ?? []).forEach((price) => {
+ plan.prices.forEach((price) => {
- const entry = priceByDim.get(price.dimensionKey) ?? { monthly: 0, annual: 0, included: 0 };
+ if (!isKnownPriceKind(price.kind)) {
+ return;
+ }
+ const entry = priceByDim.get(price.dimensionKey) ?? {
+ monthly: 0,
+ annual: 0,
+ included: 0,
+ meteredMonthly: false,
+ meteredAnnual: false
+ };
if (price.cadence === "annual") {
entry.annual = centsToDollars(price.unitAmountCents);
+ entry.meteredAnnual = price.kind === METERED_KIND;
} else {
entry.monthly = centsToDollars(price.unitAmountCents);
+ entry.meteredMonthly = price.kind === METERED_KIND;
}
if (price.includedQuantity !== null && price.includedQuantity !== undefined) {
entry.included = price.includedQuantity;
@@@ -232,39 -254,38 +255,44 @@@ const toCatalogProduct = (product: TCat
};
};
- // Translates a catalog product into the line items the checkout endpoint expects: its paid
- // self-serve plan plus the primary priced dimension for the chosen cadence at quantity 1. A base-only
- // product (a base fee with no metered dimensions, e.g. the NHI add-on) checks out with no quantities.
-// Builds the checkout line items: only per_unit dimensions carry a quantity (metered and base lines
-// are added server-side), so a metered-only or base-only plan checks out with no quantities.
-const buildCheckoutItems = (product: TCatalogProduct, cadence: "monthly" | "annual"): TCheckoutLineItem[] | null => {
- const paidSelfServePlan = findPaidSelfServePlan(product);
- if (!paidSelfServePlan) {
++// Translates a catalog product into the line items the checkout endpoint expects: the chosen plan's
++// per_unit dimensions at quantity 1. Metered and base lines are added server-side, so a metered-only
++// or base-only plan (e.g. the NHI add-on) checks out with no quantities.
+const buildCheckoutItems = (
+ product: TCatalogProduct,
+ cadence: "monthly" | "annual",
+ planTier?: string
+): TCheckoutLineItem[] | null => {
+ // A requested tier must resolve to a self-serve plan; with none requested, fall back to the first
+ // paid self-serve plan (the legacy single-"pro" behaviour).
+ const plan = planTier
+ ? product.plans.find((candidate) => candidate.tier === planTier && candidate.selfServe === true)
+ : findPaidSelfServePlan(product);
+ if (!plan) {
return null;
}
- const price = plan.prices.find((candidate) => candidate.cadence === cadence && candidate.unitAmountCents > 0);
-
- const baseCents = cadence === "annual" ? plan.basePriceAnnualCents : plan.basePriceMonthlyCents;
- const hasBasePrice = baseCents !== null && baseCents !== undefined;
+ const quantities: Record<string, number> = {};
- const perUnitPrice = paidSelfServePlan.prices.find(
++ const perUnitPrice = plan.prices.find(
+ (candidate) => candidate.cadence === cadence && candidate.kind === PER_UNIT_KIND && candidate.unitAmountCents > 0
+ );
+ if (perUnitPrice) {
+ quantities[perUnitPrice.dimensionKey] = 1;
+ }
- // Neither a metered price nor a base fee for this cadence means there's nothing to charge.
- if (!price && !hasBasePrice) {
- const hasMetered = paidSelfServePlan.prices.some(
- (candidate) => candidate.cadence === cadence && candidate.kind === METERED_KIND
- );
- const baseForCadence =
- cadence === "annual" ? paidSelfServePlan.basePriceAnnualCents : paidSelfServePlan.basePriceMonthlyCents;
++ const hasMetered = plan.prices.some((candidate) => candidate.cadence === cadence && candidate.kind === METERED_KIND);
++ const baseForCadence = cadence === "annual" ? plan.basePriceAnnualCents : plan.basePriceMonthlyCents;
+ const hasBase = baseForCadence !== null && baseForCadence !== undefined;
+ if (!perUnitPrice && !hasMetered && !hasBase) {
return null;
}
return [
{
productId: product.id,
- plan: paidSelfServePlan.tier,
+ plan: plan.tier,
cadence,
- quantities: price ? { [price.dimensionKey]: 1 } : {}
+ quantities
}
];
};
diff --cc backend/src/ee/services/license-v2/license-v2-types.ts
index 3162a8bb51,7204473757..0ab81c226d
--- a/backend/src/ee/services/license-v2/license-v2-types.ts
+++ b/backend/src/ee/services/license-v2/license-v2-types.ts
@@@ -13,25 -13,15 +13,28 @@@ export type BillingV2Dim =
monthly: number;
annual: number;
included: number;
+ // When true, the matching cadence's price is a usage overage rate, not a buyer-selected quantity.
+ meteredMonthly?: boolean;
+ meteredAnnual?: boolean;
};
+// A comparison row's cells are keyed by plan tier ("pro" | "advanced" | "enterprise" | ...) so the UI
+// can render one column per plan instead of a fixed pro/enterprise pair.
export type BillingV2CompareRow = {
label: string;
- pro: string | boolean | number;
- ent: string | boolean | number;
+ cells: Record<string, string | boolean | number>;
+};
+
+// A single purchasable (or sales-led) plan within a product. A product exposes an ordered list of
+// these — the free tier is implicit and never listed.
+export type BillingV2Plan = {
+ tier: string;
+ name: string;
+ selfServe: boolean;
+ salesLed: boolean;
+ feature?: string;
+ base?: { monthly: number; annual: number };
+ dims: BillingV2Dim[];
};
export type BillingV2CatalogProduct = {
diff --cc frontend/src/hooks/api/billingV2/types.ts
index 9f0a93824e,9fd5a19d4e..20d719be41
--- a/frontend/src/hooks/api/billingV2/types.ts
+++ b/frontend/src/hooks/api/billingV2/types.ts
@@@ -9,24 -9,15 +9,27 @@@ export type BillingV2Dim =
monthly: number;
annual: number;
included: number;
+ // When true, the matching cadence's price is a usage overage rate, not a buyer-selected quantity.
+ meteredMonthly?: boolean;
+ meteredAnnual?: boolean;
};
+// A comparison row's cells are keyed by plan tier ("pro" | "advanced" | "enterprise" | ...) so the
+// table can render one column per plan.
export type BillingV2CompareRow = {
label: string;
- pro: string | boolean;
- ent: string | boolean;
+ cells: Record<string, string | boolean | number>;
+};
+
+// A single purchasable (or sales-led) plan of a product. The free tier is implicit and never listed.
+export type BillingV2Plan = {
+ tier: string;
+ name: string;
+ selfServe: boolean;
+ salesLed: boolean;
+ feature?: string;
+ base?: { monthly: number; annual: number };
+ dims: BillingV2Dim[];
};
export type BillingV2CatalogProduct = {
diff --cc frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx
index 319ef741db,ebb1b5e9d3..2df70af339
--- a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx
@@@ -20,38 -19,77 +20,64 @@@ import
import {
BillingV2Cadence,
BillingV2CatalogProduct,
+ BillingV2CompareRow,
+ BillingV2Dim,
- BillingV2Entitlement
+ BillingV2Entitlement,
+ BillingV2Plan
} from "@app/hooks/api";
- import { cadenceWord, cadenceWordShort, fmtMoney, unitPrice } from "../billing-v2-data";
+ import {
+ cadenceWord,
+ cadenceWordShort,
+ fmtMoney,
+ isMeteredCadence,
+ pluralizeUnit,
+ unitPrice
+ } from "../billing-v2-data";
import { ActiveBadge, ProductIcon } from "./shared";
- type PriceLine = { amount: string; unit: string };
+ // prefix/metered carry the usage-based framing for metered dims; absent for per_unit and base prices.
+ type PriceLine = { amount: string; unit: string; prefix?: string; metered?: boolean };
+
-// The plan's flat/base fee for the active cadence, when it has one (e.g. "$20 / month").
-const proBaseLine = (
- prod: BillingV2CatalogProduct,
- cadence: BillingV2Cadence
-): PriceLine | null => {
- const base = prod.pro?.base;
- if (!base) {
- return null;
- }
- return { amount: fmtMoney(unitPrice(base, cadence)), unit: `/ ${cadenceWord(cadence)}` };
-};
-
+ // A priced dimension as a display line. A metered dimension reads as usage-based: an optional "First
+ // N included, then" prefix and a flag to badge the line, instead of a fixed per-unit charge.
+ const dimPriceLine = (dim: BillingV2Dim, cadence: BillingV2Cadence, unit: string): PriceLine => {
+ const metered = isMeteredCadence(dim, cadence);
+ const line: PriceLine = { amount: fmtMoney(unitPrice(dim, cadence), 2), unit, metered };
+ if (metered && dim.included > 0) {
+ line.prefix = `First ${dim.included.toLocaleString()} ${pluralizeUnit(dim.noun)} included, then`;
+ }
+ return line;
+ };
+
+ const PriceLineView = ({ line, headline }: { line: PriceLine; headline?: boolean }) => (
+ <div className="flex flex-col gap-0.5">
+ {line.prefix && <span className="text-xs text-muted">{line.prefix}</span>}
+ <div className="flex flex-wrap items-baseline gap-1.5">
+ <span className={`font-medium text-foreground ${headline ? "text-2xl" : "text-sm"}`}>
+ {line.amount}
+ </span>
+ <span className="text-xs text-muted">{line.unit}</span>
+ {line.metered && <Badge variant="neutral">Usage-based</Badge>}
+ </div>
+ </div>
+ );
- // A plan's price is a base fee plus any number of metered dimensions, and any combination is valid:
+ // A plan's price is a base fee plus any number of priced dimensions, and any combination is valid:
// base only, meter only, or both. The base fee leads as the headline; every priced dimension is then
// listed below (e.g. "$5 per MCP / mo", "$3 per Agent / mo"). When there's no base fee the first
--// dimension is promoted to the headline so the card always opens with a price.
-const ProPricing = ({
- prod,
- cadence
-}: {
- prod: BillingV2CatalogProduct;
- cadence: BillingV2Cadence;
-}) => {
- const dims = prod.pro?.dims ?? [];
++// dimension is promoted to the headline so the card always opens with a price. A metered dimension
++// renders with its usage-based framing (included allowance + "Usage-based" badge).
+const PlanPricing = ({ plan, cadence }: { plan: BillingV2Plan; cadence: BillingV2Cadence }) => {
+ const dims = plan.dims ?? [];
- const dimLines = dims.map((dim) => ({
- key: dim.key,
- amount: fmtMoney(unitPrice(dim, cadence), 2),
- unit: `per ${dim.noun} / ${cadenceWordShort(cadence)}`
- }));
- let headline = proBaseLine(prod, cadence);
+ let headline: PriceLine | null = plan.base
+ ? { amount: fmtMoney(unitPrice(plan.base, cadence)), unit: `/ ${cadenceWord(cadence)}` }
+ : null;
- let usageLines = dimLines;
+ let usageDims = dims;
if (!headline && dims.length > 0) {
- headline = {
- amount: fmtMoney(unitPrice(dims[0], cadence), 2),
- unit: `/ ${dims[0].noun} / ${cadenceWord(cadence)}`
- };
- usageLines = dimLines.slice(1);
+ headline = dimPriceLine(dims[0], cadence, `/ ${dims[0].noun} / ${cadenceWord(cadence)}`);
+ usageDims = dims.slice(1);
}
if (!headline) {