Skip to content

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

feat: added banner for subscription payment

=b10b4cb3f9b1
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index 2889f5d4a1..ae68b59d7c 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -28,6 +28,15 @@ export type TOfflineLicense = {
entitlements?: TEntitlementsResponse;
};
+export type TPlanNotice = {
+ type: "trial_payment_failed";
+ productKey: string;
+ trialPlanKey: string | null;
+ accessEndsAt: string;
+ nextAttemptAt: string | null;
+ cause: string | null;
+};
+
export type TOrgSeatUsage = {
membersUsed: number;
identitiesUsed: number;
@@ -43,6 +52,7 @@ export type TFeatureSet = {
trialPlanKey: string | null;
trialEndsAt: string | null;
}[];
+ notices?: TPlanNotice[];
// True when features are sourced from an offline (air-gapped) license; the billing UI renders a
// read-only offline banner instead of the live billing surface.
isOffline?: boolean;
diff --git a/backend/src/services/license-client/entitlement-projection.test.ts b/backend/src/services/license-client/entitlement-projection.test.ts
index 73e0c885f4..171da7e4ba 100644
--- a/backend/src/services/license-client/entitlement-projection.test.ts
+++ b/backend/src/services/license-client/entitlement-projection.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, test } from "vitest";
import { TFeatureSet } from "@app/ee/services/license/license-types";
import { projectV2ToFeatureSet } from "./entitlement-projection";
-import { TEntitlementsResponse } from "./license-client-types";
+import { entitlementsResponseSchema, TEntitlementsResponse } from "./license-client-types";
const makeBase = (overrides: Partial<Record<keyof TFeatureSet, unknown>>): TFeatureSet =>
({ rateLimits: { readLimit: 0, writeLimit: 0, secretsLimit: 0 }, ...overrides }) as TFeatureSet;
@@ -41,3 +41,52 @@ describe("projectV2ToFeatureSet", () => {
expect(base.rbac).toBe(false);
});
});
+
+describe("projectV2ToFeatureSet notices", () => {
+ const trialPaymentFailed = {
+ type: "trial_payment_failed",
+ product_key: "secrets_management",
+ trial_plan_key: "enterprise",
+ access_ends_at: "2026-11-04T10:00:00Z",
+ next_attempt_at: "2026-10-08T10:00:00Z",
+ cause: "payment_action_required"
+ };
+
+ const projectNotices = (notices: unknown[]) =>
+ projectV2ToFeatureSet(makeBase({}), { features: {}, notices } as unknown as TEntitlementsResponse).notices;
+
+ test("projects a trial_payment_failed notice into camelCase", () => {
+ expect(projectNotices([trialPaymentFailed])).toEqual([
+ {
+ type: "trial_payment_failed",
+ productKey: "secrets_management",
+ trialPlanKey: "enterprise",
+ accessEndsAt: "2026-11-04T10:00:00Z",
+ nextAttemptAt: "2026-10-08T10:00:00Z",
+ cause: "payment_action_required"
+ }
+ ]);
+ });
+
+ test("keeps a null next_attempt_at and absent optional fields as null", () => {
+ const { type, product_key: productKey, access_ends_at: accessEndsAt } = trialPaymentFailed;
+ const minimalNotice = { type, product_key: productKey, access_ends_at: accessEndsAt, next_attempt_at: null };
+ expect(projectNotices([minimalNotice])).toEqual([
+ expect.objectContaining({ trialPlanKey: null, nextAttemptAt: null, cause: null })
+ ]);
+ });
+
+ test("drops unknown and malformed notices without failing the rest", () => {
+ const notices = projectNotices([
+ { type: "usage_over_limit", product_key: "pam" },
+ { ...trialPaymentFailed, access_ends_at: "not-a-date" },
+ trialPaymentFailed
+ ]);
+ expect(notices).toHaveLength(1);
+ });
+
+ test("a non-array notices payload parses as no notices", () => {
+ const parsed = entitlementsResponseSchema.parse({ features: {}, notices: "oops" });
+ expect(parsed.notices).toEqual([]);
+ });
+});
diff --git a/backend/src/services/license-client/entitlement-projection.ts b/backend/src/services/license-client/entitlement-projection.ts
index 4b86ab5994..4e867e6726 100644
--- a/backend/src/services/license-client/entitlement-projection.ts
+++ b/backend/src/services/license-client/entitlement-projection.ts
@@ -1,7 +1,26 @@
-import { TFeatureSet } from "@app/ee/services/license/license-types";
+import { TFeatureSet, TPlanNotice } from "@app/ee/services/license/license-types";
import { FEATURE_MAPPINGS } from "./feature-mapping";
-import { TEntitlementsResponse } from "./license-client-types";
+import { TEntitlementsResponse, trialPaymentFailedNoticeSchema } from "./license-client-types";
+
+// Unknown notice types are expected (the License Server adds them ahead of us), so they are dropped silently.
+const projectNotices = (rawNotices: unknown[]): TPlanNotice[] =>
+ rawNotices.flatMap((rawNotice) => {
+ const parsed = trialPaymentFailedNoticeSchema.safeParse(rawNotice);
+ if (!parsed.success) {
+ return [];
+ }
+ return [
+ {
+ type: parsed.data.type,
+ productKey: parsed.data.product_key,
+ trialPlanKey: parsed.data.trial_plan_key ?? null,
+ accessEndsAt: parsed.data.access_ends_at,
+ nextAttemptAt: parsed.data.next_attempt_at ?? null,
+ cause: parsed.data.cause ?? null
+ }
+ ];
+ });
// Builds a plan-shaped TFeatureSet from the License Server entitlement set so getPlan can serve it
// without changing its callers. Starts from the passed base (free-tier defaults) and overlays each
@@ -17,6 +36,7 @@ export const projectV2ToFeatureSet = (base: TFeatureSet, entitlements: TEntitlem
trialPlanKey: product.trial_plan_key ?? null,
trialEndsAt: product.trial_ends_at ?? null
}));
+ plan.notices = projectNotices(entitlements.notices ?? []);
FEATURE_MAPPINGS.forEach((mapping) => {
if (mapping.v1Field === null) {
diff --git a/backend/src/services/license-client/license-client-types.ts b/backend/src/services/license-client/license-client-types.ts
index d5b7f25baf..f6474669a1 100644
--- a/backend/src/services/license-client/license-client-types.ts
+++ b/backend/src/services/license-client/license-client-types.ts
@@ -21,13 +21,24 @@ const entitlementProductSchema = z
})
.passthrough();
+export const trialPaymentFailedNoticeSchema = z.object({
+ type: z.literal("trial_payment_failed"),
+ product_key: z.string(),
+ trial_plan_key: z.string().nullish(),
+ access_ends_at: z.string().datetime({ offset: true }),
+ next_attempt_at: z.string().datetime({ offset: true }).nullish(),
+ cause: z.string().nullish()
+});
+
// `features` and `products` are load-bearing; passthrough tolerates the rest of the payload so
-// cloud/self-hosted version skew doesn't break reads.
+// cloud/self-hosted version skew doesn't break reads. Notices stay unknown here and are validated one
+// at a time in the projection, so a new or malformed notice can't fail the parse and drop the org to free.
export const entitlementsResponseSchema = z
.object({
slug: z.string().nullish(),
features: z.record(z.string(), entitlementFeatureSchema),
- products: z.array(entitlementProductSchema).default([])
+ products: z.array(entitlementProductSchema).default([]),
+ notices: z.array(z.unknown()).optional().catch([])
})
.passthrough();
diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts
index 63f3b8621a..575bdc2c1e 100644
--- a/frontend/src/hooks/api/subscriptions/types.ts
+++ b/frontend/src/hooks/api/subscriptions/types.ts
@@ -10,6 +10,15 @@ export enum SubscriptionPlanTypes {
OnPremEnterprise = "one-prem-enterprise"
}
+export type SubscriptionPlanNotice = {
+ type: "trial_payment_failed";
+ productKey: string;
+ trialPlanKey: string | null;
+ accessEndsAt: string;
+ nextAttemptAt: string | null;
+ cause: string | null;
+};
+
export type SubscriptionPlan = {
productPlans?: {
productKey: string;
@@ -18,6 +27,7 @@ export type SubscriptionPlan = {
trialPlanKey: string | null;
trialEndsAt: string | null;
}[];
+ notices?: SubscriptionPlanNotice[];
id: string;
memberLimit: number;
identityLimit: number;
diff --git a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx
index dbfef41916..e0ef0dcdbc 100644
--- a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx
+++ b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx
@@ -19,6 +19,7 @@ import { NetworkHealthBanner } from "./components/NetworkHealthBanner";
import { OrgSidebar } from "./components/OrgSidebar";
import { RedisBanner } from "./components/RedisBanner";
import { SmtpBanner } from "./components/SmtpBanner";
+import { TrialPaymentFailedBanner } from "./components/TrialPaymentFailedBanner";
export const OrganizationLayout = () => {
const { config } = useServerConfig();
@@ -51,6 +52,7 @@ export const OrganizationLayout = () => {
className={`dark ${containerHeight} flex !min-h-0 w-full flex-col overflow-hidden bg-page transition-all`}
>
<PageBannerStack>
+ <TrialPaymentFailedBanner />
{(isInsideProject || implicitProduct) && <AssumePrivilegeModeBanner />}
{isCertManagerOverview && <CertManagerInstanceBanner />}
{!isLoading && !isInsideProject && !serverDetails?.redisConfigured && <RedisBanner />}
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgAlertBanner/OrgAlertBanner.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgAlertBanner/OrgAlertBanner.tsx
index ffb4bf66b7..0d52ba1875 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgAlertBanner/OrgAlertBanner.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgAlertBanner/OrgAlertBanner.tsx
@@ -7,11 +7,20 @@ import { useToggle } from "@app/hooks";
type Props = {
text: ReactNode;
link?: string;
+ action?: ReactNode;
role?: "status" | "alert";
+ isDismissible?: boolean;
onDismiss?: () => void;
};
-export const OrgAlertBanner = ({ text, link, role = "status", onDismiss }: Props) => {
+export const OrgAlertBanner = ({
+ text,
+ link,
+ action,
+ role = "status",
+ isDismissible = true,
+ onDismiss
+}: Props) => {
const [isDismissed, setIsDismissed] = useToggle(false);
if (isDismissed) return null;
@@ -36,15 +45,18 @@ export const OrgAlertBanner = ({ text, link, role = "status", onDismiss }: Props
</a>
)}
</p>
- <IconButton
- className="-my-1 -mr-1"
- aria-label="Dismiss warning"
- variant="ghost-muted"
- size="xs"
- onClick={onDismiss ?? setIsDismissed.on}
- >
- <XIcon />
- </IconButton>
+ {action && <div className="-my-1 shrink-0">{action}</div>}
+ {isDismissible && (
+ <IconButton
+ className="-my-1 -mr-1"
+ aria-label="Dismiss warning"
+ variant="ghost-muted"
+ size="xs"
+ onClick={onDismiss ?? setIsDismissed.on}
+ >
+ <XIcon />
+ </IconButton>
+ )}
</div>
);
};
diff --git a/frontend/src/layouts/OrganizationLayout/components/TrialPaymentFailedBanner/TrialPaymentFailedBanner.tsx b/frontend/src/layouts/OrganizationLayout/components/TrialPaymentFailedBanner/TrialPaymentFailedBanner.tsx
new file mode 100644
index 0000000000..e4ab0b8408
--- /dev/null
+++ b/frontend/src/layouts/OrganizationLayout/components/TrialPaymentFailedBanner/TrialPaymentFailedBanner.tsx
@@ -0,0 +1,88 @@
+import { Link } from "@tanstack/react-router";
+import { format } from "date-fns";
+
+import { Button } from "@app/components/v3";
+import {
+ OrgPermissionBillingActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useOrgPermission,
+ useSubscription
+} from "@app/context";
+import { SubscriptionPlanNotice } from "@app/hooks/api/subscriptions/types";
+
+import { OrgAlertBanner } from "../OrgAlertBanner";
+
+const PRODUCT_LABELS: Record<string, string> = {
+ secrets_management: "Secrets Management",
+ cert_management: "Certificate Management",
+ pam: "PAM",
+ kms: "KMS"
+};
+
+const humanizeKey = (key: string) =>
+ key
+ .replace(/^legacy_/, "")
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+const productLabel = (notice: SubscriptionPlanNotice) => {
+ const product = PRODUCT_LABELS[notice.productKey] ?? humanizeKey(notice.productKey);
+ return notice.trialPlanKey ? `${product} ${humanizeKey(notice.trialPlanKey)}` : product;
+};
+
+const listFormatter = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
+
+const buildMessage = (notices: SubscriptionPlanNotice[]) => {
+ const products = listFormatter.format(notices.map(productLabel));
+ const accessEndsAt = format(
+ Math.min(...notices.map((notice) => new Date(notice.accessEndsAt).getTime())),
+ "MMM d"
+ );
+ const isUpgradeOnly = notices.every((notice) => notice.trialPlanKey);
+
+ return isUpgradeOnly
+ ? `Your ${products} upgrade will end on ${accessEndsAt} due to a failed payment.`
+ : `${products} access will be suspended on ${accessEndsAt} due to a failed payment.`;
+};
+
+export const TrialPaymentFailedBanner = () => {
+ const { subscription } = useSubscription();
+ const { currentOrg, isRootOrganization } = useOrganization();
+ const { permission } = useOrgPermission();
+
+ const now = Date.now();
+ // The plan is cached server-side, so a notice can outlive its deadline by a few minutes.
+ const notices = (subscription.notices ?? []).filter(
+ (notice) =>
+ notice.type === "trial_payment_failed" && new Date(notice.accessEndsAt).getTime() > now
+ );
+ if (!notices.length) return null;
+
+ // Billing lives on the root organization, and a sub-org role grants nothing there.
+ const canResolve =
+ isRootOrganization &&
+ permission.can(OrgPermissionBillingActions.ManageBilling, OrgPermissionSubjects.Billing);
+ return (
+ <OrgAlertBanner
+ role="alert"
+ isDismissible={false}
+ text={
+ <>
+ <span className="font-medium">Action needed:</span> {buildMessage(notices)}
+ {!canResolve && " Ask an organization admin to update payment."}
+ </>
+ }
+ action={
+ canResolve && (
+ <Link to="/organizations/$orgId/billing" params={{ orgId: currentOrg.id }}>
+ <Button variant="outline" size="xs">
+ Complete Payment
+ </Button>
+ </Link>
+ )
+ }
+ />
+ );
+};
diff --git a/frontend/src/layouts/OrganizationLayout/components/TrialPaymentFailedBanner/index.ts b/frontend/src/layouts/OrganizationLayout/components/TrialPaymentFailedBanner/index.ts
new file mode 100644
index 0000000000..67d7291224
--- /dev/null
+++ b/frontend/src/layouts/OrganizationLayout/components/TrialPaymentFailedBanner/index.ts
@@ -0,0 +1 @@
+export * from "./TrialPaymentFailedBanner";