* feat: adds user plan info in `useHasPaidPlan` for intercom * add to support api route * Update constants.ts * sql migration to backfill plans and create/change plans on upgrade/downgrade/create of teams and orgs * fix: breaking unit tests * test: add comprehensive tests for billing plan service and team/org flows - Add unit tests for BillingPlanService.getUserPlanByMemberships() covering all plan determination scenarios - Add tests for team creation handler verifying TEAMS vs ORGANIZATIONS plan assignment - Add tests for hasTeamPlan handler integration with BillingPlanService - Add tests for MembershipRepository.findAllMembershipsByUserIdForBilling() data fetching - Add tests for InternalTeamBilling upgrade/downgrade flows with proper mocking - All tests follow existing vitest patterns with proper Prisma and service mocking - Covers both self-serve and platform billing scenarios with comprehensive edge cases Co-Authored-By: amit@cal.com <samit91848@gmail.com> * Revert "test: add comprehensive tests for billing plan service and team/org flows" This reverts commit 58e511f15caf8757c3ec45f6d026caf96ee1a75e. * fix: make `BillingPlanService` instantiable and use `TeamRepository` * Revert "fix: make `BillingPlanService` instantiable and use `TeamRepository`" This reverts commit ae1ff8f15b725566b828864a217d8d0e308b520f. * revert to runtime calculations. review fixes * remove uneccessary changes and logs * review fixes * review fixes * fix: type check --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/**
|
|
* Stripe checkout session metadata types
|
|
* Used to identify the type of subscription/purchase in webhook handlers
|
|
*/
|
|
export const CHECKOUT_SESSION_TYPES = {
|
|
PHONE_NUMBER_SUBSCRIPTION: "phone_number_subscription",
|
|
} as const;
|
|
|
|
export type CheckoutSessionType = (typeof CHECKOUT_SESSION_TYPES)[keyof typeof CHECKOUT_SESSION_TYPES];
|
|
|
|
export enum BillingPlan {
|
|
INDIVIDUALS = "INDIVIDUALS",
|
|
TEAMS = "TEAMS",
|
|
ORGANIZATIONS = "ORGANIZATIONS",
|
|
ENTERPRISE = "ENTERPRISE",
|
|
PLATFORM_STARTER = "PLATFORM_STARTER",
|
|
PLATFORM_ESSENTIALS = "PLATFORM_ESSENTIALS",
|
|
PLATFORM_SCALE = "PLATFORM_SCALE",
|
|
PLATFORM_ENTERPRISE = "PLATFORM_ENTERPRISE",
|
|
UNKNOWN = "Unknown",
|
|
}
|
|
|
|
export const PLATFORM_PLANS_MAP: Record<string, BillingPlan> = {
|
|
FREE: BillingPlan.PLATFORM_STARTER,
|
|
STARTER: BillingPlan.PLATFORM_STARTER,
|
|
ESSENTIALS: BillingPlan.PLATFORM_ESSENTIALS,
|
|
SCALE: BillingPlan.PLATFORM_SCALE,
|
|
ENTERPRISE: BillingPlan.PLATFORM_ENTERPRISE,
|
|
};
|
|
|
|
export const PLATFORM_ENTERPRISE_SLUGS = process.env.PLATFORM_ENTERPRISE_SLUGS?.split(",") ?? [];
|
|
export const ENTERPRISE_SLUGS = process.env.ENTERPRISE_SLUGS?.split(",") ?? [];
|