Skip to content

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

feat: added fix for only yearly recurring charge

=269fb56b4fc3
diff --git a/backend/src/ee/services/license-v2/license-v2-service.ts b/backend/src/ee/services/license-v2/license-v2-service.ts
index 59d6f4c689..bd0fedebac 100644
--- a/backend/src/ee/services/license-v2/license-v2-service.ts
+++ b/backend/src/ee/services/license-v2/license-v2-service.ts
@@ -347,6 +347,19 @@ const buildCheckoutItems = (
const item: TCheckoutLineItem = { productId: product.id, plan: plan.tier, cadence };
if (commitments && Object.keys(commitments).length > 0) {
+ // Commitment mode (prepaid annual units with monthly on-demand overage) only makes sense when the
+ // committed dimension is priced on BOTH cadences: annual for the commitment, monthly for the
+ // overage. Reject it for a single-cadence plan (annual-only or monthly-only).
+ const dimensionHasBothCadences = (dimensionKey: string): boolean => {
+ const prices = plan.prices.filter((price) => price.dimensionKey === dimensionKey && isKnownPriceKind(price.kind));
+ return prices.some((price) => price.cadence === "annual") && prices.some((price) => price.cadence === "monthly");
+ };
+ const unsupported = Object.keys(commitments).filter((dimensionKey) => !dimensionHasBothCadences(dimensionKey));
+ if (cadence !== "annual" || unsupported.length > 0) {
+ throw new BadRequestError({
+ message: "Commitment mode is only available when the plan has both monthly and annual pricing."
+ });
+ }
item.commitments = commitments;
}
return [item];
diff --git a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts
index cb14242586..bf518c9aa3 100644
--- a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts
+++ b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts
@@ -82,8 +82,10 @@ export const cadencePeriod = (cadence: BillingV2Cadence | null | undefined): str
cadence === "annual" ? "year" : "month";
// An annually-committed per_resource dimension: usage above `committed` is billed monthly on-demand.
+// Metered dimensions are usage-based (no buyer-selected quantity), so they are never "committed" even
+// if the server reports a committed value for them — this keeps commitment UI off usage-based pricing.
export const dimAnnualCommitted = (dim: BillingV2EntitlementDim): boolean =>
- dim.cadence === "annual" && dim.committed !== null;
+ dim.cadence === "annual" && !dim.metered && dim.committed !== null;
// A ceiling to fill a usage bar against: an annual commitment or a finite limit.
export const dimHasCeiling = (dim: BillingV2EntitlementDim): boolean =>
diff --git a/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx b/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx
index bd167ea715..fffb66d25c 100644
--- a/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx
@@ -29,8 +29,11 @@ type Props = {
onDone: () => void;
};
-// A per_resource dimension that can be committed annually (has an annual per-unit price).
-const isCommittable = (dim: BillingV2Dim): boolean => dim.annual > 0 && !dim.meteredAnnual;
+// A per_resource dimension that can be committed annually. Commitment mode is prepaid annual units
+// with monthly on-demand overage, so it requires BOTH cadences priced: the annual per-unit rate for
+// the commitment and a monthly rate for the overage. A single-cadence dimension is not committable.
+const isCommittable = (dim: BillingV2Dim): boolean =>
+ dim.annual > 0 && dim.monthly > 0 && !dim.meteredAnnual;
// The plan's monthly headline price (base fee, else the first priced dimension's monthly rate).
const monthlyHeadline = (plan: BillingV2Plan): number => {
@@ -82,7 +85,8 @@ export const ActivateView = ({
}: Props) => {
const committable = useMemo(() => plan.dims.filter(isCommittable), [plan.dims]);
const supportsAnnual = committable.length > 0 || Boolean(plan.base && plan.base.annual > 0);
- const supportsMonthly = plan.dims.some((d) => d.monthly > 0) || Boolean(plan.base);
+ const supportsMonthly =
+ plan.dims.some((d) => d.monthly > 0) || Boolean(plan.base && plan.base.monthly > 0);
const [cadence, setCadence] = useState<BillingV2Cadence>(supportsMonthly ? "monthly" : "annual");
const [commitments, setCommitments] = useState<Record<string, number>>(() =>
diff --git a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx
index 4872c796ae..1a25bfef24 100644
--- a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx
@@ -83,12 +83,22 @@ const PriceLineView = ({ line, headline }: { line: PriceLine; headline?: boolean
const PlanPricing = ({ plan, cadence }: { plan: BillingV2Plan; cadence: BillingV2Cadence }) => {
const dims = plan.dims ?? [];
+ // Render at a cadence the plan actually prices. A single-cadence plan (e.g. annual-only) shown at the
+ // sheet's default "monthly" would read "$0 / mo", so fall back to the cadence that has real pricing.
+ const pricesCadence = (cad: BillingV2Cadence): boolean =>
+ cad === "annual"
+ ? (plan.base?.annual ?? 0) > 0 || dims.some((dim) => dim.annual > 0)
+ : (plan.base?.monthly ?? 0) > 0 || dims.some((dim) => dim.monthly > 0);
+ const cad: BillingV2Cadence = pricesCadence(cadence)
+ ? cadence
+ : ((["monthly", "annual"] as const).find(pricesCadence) ?? cadence);
+
let headline: PriceLine | null = plan.base
- ? { amount: fmtMoney(unitPrice(plan.base, cadence)), unit: `/ ${cadenceWord(cadence)}` }
+ ? { amount: fmtMoney(unitPrice(plan.base, cad)), unit: `/ ${cadenceWord(cad)}` }
: null;
let usageDims = dims;
if (!headline && dims.length > 0) {
- headline = dimPriceLine(dims[0], cadence, `/ ${dims[0].noun} / ${cadenceWord(cadence)}`);
+ headline = dimPriceLine(dims[0], cad, `/ ${dims[0].noun} / ${cadenceWord(cad)}`);
usageDims = dims.slice(1);
}
@@ -98,7 +108,7 @@ const PlanPricing = ({ plan, cadence }: { plan: BillingV2Plan; cadence: BillingV
const usageLines = usageDims.map((dim) => ({
key: dim.key,
- line: dimPriceLine(dim, cadence, `per ${dim.noun} / ${cadenceWordShort(cadence)}`)
+ line: dimPriceLine(dim, cad, `per ${dim.noun} / ${cadenceWordShort(cad)}`)
}));
return (