Files
property-management-network/lib/stripe/plans.ts
T

78 lines
1.7 KiB
TypeScript
Raw Normal View History

import type { Plan, PlanLimits } from "@/types"
export const PLAN_LIMITS: Record<Plan, PlanLimits> = {
starter: {
maxProperties: 1,
maxTenants: 3,
maxAiCalls: 0,
maxStorageMB: 100,
hasTeamAccess: false,
hasWhiteLabel: false,
},
pro: {
maxProperties: 10,
maxTenants: Infinity,
maxAiCalls: 50,
maxStorageMB: 5120,
hasTeamAccess: false,
hasWhiteLabel: false,
},
landlord: {
maxProperties: Infinity,
maxTenants: Infinity,
maxAiCalls: 200,
maxStorageMB: 25600,
hasTeamAccess: true,
hasWhiteLabel: true,
},
lifetime: {
maxProperties: Infinity,
maxTenants: Infinity,
maxAiCalls: 200,
maxStorageMB: 25600,
hasTeamAccess: true,
hasWhiteLabel: true,
},
}
export const PLAN_PRICES: Record<string, { plan: Plan; priceId: string; amount: number; interval: string }> = {
pro: {
plan: "pro",
priceId: process.env.STRIPE_PRO_MONTHLY_PRICE_ID!,
amount: 29,
interval: "month",
},
landlord: {
plan: "landlord",
priceId: process.env.STRIPE_LANDLORD_MONTHLY_PRICE_ID!,
amount: 59,
interval: "month",
},
lifetime: {
plan: "lifetime",
priceId: process.env.STRIPE_LIFETIME_PRICE_ID!,
amount: 199,
interval: "one_time",
},
}
export function checkLimit(
plan: Plan,
resource: keyof PlanLimits,
currentCount: number
): boolean {
const limit = PLAN_LIMITS[plan][resource]
if (typeof limit === "boolean") return limit
return currentCount < (limit as number)
}
export function getPlanLabel(plan: Plan): string {
const labels: Record<Plan, string> = {
starter: "Starter",
pro: "Pro",
landlord: "Landlord",
lifetime: "Lifetime",
}
return labels[plan]
}