oneuptime/Common/UI/Utils/PricingPlan.ts

117 lines
2.9 KiB
TypeScript

import { env } from "../Config";
import BadDataException from "Common/Types/Exception/BadDataException";
import PricingPlanType from "Common/Types/PricingPlan";
export default class PricingPlan {
public static getPlans(): Array<PricingPlanType> {
if (
env("STRIPE_PUBLIC_KEY") &&
env("STRIPE_PUBLIC_KEY").startsWith("pk_test")
) {
return [
{
category: "Startup",
planId: "plan_GoWIYiX2L8hwzx",
type: "month",
amount: 25,
details: "$25 / Month / User",
},
{
category: "Startup",
planId: "plan_GoWIqpBpStiqQp",
type: "annual",
amount: 264,
details: "$22/mo per user paid annually. ",
},
{
category: "Growth",
planId: "plan_GoWKgxRnPPBJWy",
type: "month",
amount: 59,
details: "$59 / Month / User",
},
{
category: "Growth",
planId: "plan_GoWKiTdQ6NiQFw",
type: "annual",
amount: 588,
details: "$49/mo per user paid annually. ",
},
{
category: "Scale",
planId: "plan_H9Iox3l2YqLTDR",
type: "month",
amount: 99,
details: "$120 / Month / User",
},
{
category: "Scale",
planId: "plan_H9IlBKhsFz4hV2",
type: "annual",
amount: 1188,
details: "$99/mo per user paid annually. ",
},
];
}
return [
{
category: "Startup",
planId: "plan_GoVgVbvNdbWwlm",
type: "month",
amount: 25,
details: "$25 / Month / User",
},
{
category: "Startup",
planId: "plan_GoVgJu5PKMLRJU",
type: "annual",
amount: 264,
details: "$22/mo per user paid annually. ",
},
{
category: "Growth",
planId: "plan_GoVi9EIa6MU0fG",
type: "month",
amount: 59,
details: "$59 / Month / User",
},
{
category: "Growth",
planId: "plan_GoViZshjqzZ0vv",
type: "annual",
amount: 588,
details: "$49/mo per user paid annually. ",
},
{
category: "Scale",
planId: "plan_H9Ii6Qj3HLdtty",
type: "month",
amount: 99,
details: "$120 / Month / User",
},
{
category: "Scale",
planId: "plan_H9IjvX2Flsvlcg",
type: "annual",
amount: 1188,
details: "$99/mo per user paid annually. ",
},
];
}
public static getPlanById(id: string): PricingPlanType {
const plans: Array<PricingPlanType> = this.getPlans();
const plan: PricingPlanType | undefined = plans.find(
(plan: PricingPlanType) => {
return plan.planId === id;
},
);
if (plan) {
return plan;
}
throw new BadDataException(`Plan with id ${id} not found`);
}
}