price cards

This commit is contained in:
Alex Holliday committed 2025-12-02 20:52:27 +00:00
1 parent 07efd08837
commit 53355cad04
7 files changed
+155 -33

No files matched your search

+1 -3
View File
@@ -1,9 +1,7 @@
import type { Request, Response, NextFunction } from "express";
import { type IBillingService } from "@/services/system/BillingService.js";
import { Plans, type PlanKey } from "@/types/entitlements.js";
import { type PlanKey } from "@/types/entitlements.js";
import ApiError from "@/utils/ApiError.js";
import { config } from "@/config/index.js";
import { Org } from "@/db/models/index.js";
export interface IBillingController {
listPlans: (req: Request, res: Response, next: NextFunction) => Promise<void>;
+11 -1
View File
@@ -31,7 +31,17 @@ class BillingService implements IBillingService {
}
listPlans = async () => {
const order: PlanKey[] = ["free", "pro", "business", "enterprise"];
return order.map((key) => Plans[key]);
const prices = await this.stripeClient.prices.list({});
const plans = order.map((key) => {
const plan = Plans[key];
plan.price =
prices.data.find((p) => p.lookup_key === key)?.unit_amount || 0;
return plan;
});
console.log("Available plans:", plans);
return plans;
};
private buildSuccessUrl = (planKey: PlanKey) =>
+8 -7
View File
@@ -17,6 +17,7 @@ export interface Entitlements {
teamsMax: number;
notificationsEnabled: boolean;
retentionDays: number;
price?: number;
}
export const Plans: Record<PlanKey, Entitlements> = {
@@ -24,15 +25,15 @@ export const Plans: Record<PlanKey, Entitlements> = {
plan: "free",
monitorsMax: 3,
notificationChannelsMax: 2,
statusPagesMax: 2,
statusPagesMax: 1,
checksIntervalMsMin: 60_000,
teamsMax: 2,
teamsMax: 1,
notificationsEnabled: true,
retentionDays: 30,
},
pro: {
plan: "pro",
monitorsMax: 50,
monitorsMax: 25,
notificationChannelsMax: 5,
statusPagesMax: 5,
checksIntervalMsMin: 30_000,
@@ -42,8 +43,8 @@ export const Plans: Record<PlanKey, Entitlements> = {
},
business: {
plan: "business",
monitorsMax: 200,
notificationChannelsMax: 20,
monitorsMax: 50,
notificationChannelsMax: 10,
statusPagesMax: 20,
checksIntervalMsMin: 15_000,
teamsMax: 10,
@@ -52,8 +53,8 @@ export const Plans: Record<PlanKey, Entitlements> = {
},
enterprise: {
plan: "enterprise",
monitorsMax: 5000,
notificationChannelsMax: 100,
monitorsMax: 100,
notificationChannelsMax: 20,
statusPagesMax: 100,
checksIntervalMsMin: 10_000,
teamsMax: 20,