feat: add annual plans for teams/organizations (#27896)

* wip: add annual plan priceId support

* fix type errors

* type cast
This commit is contained in:
sean-brydon authored and GitHub committed 2026-02-12 14:05:24 +00:00
1 parent d52e2d9fad
commit 98ec38aeaa
9 files changed
+297 -11

No files matched your search

@@ -13,6 +13,7 @@ import { createHandler } from "./createWithPaymentIntent.handler";
vi.stubEnv("STRIPE_PRIVATE_KEY", "test-stripe-private-key");
vi.stubEnv("STRIPE_ORG_MONTHLY_PRICE_ID", "test-stripe-org-monthly-price-id");
vi.stubEnv("STRIPE_ORG_ANNUAL_PRICE_ID", "test-stripe-org-annual-price-id");
vi.stubEnv("STRIPE_ORG_PRODUCT_ID", "test-stripe-org-product-id");
vi.stubEnv("NEXT_PUBLIC_ORGANIZATIONS_SELF_SERVE_PRICE_NEW", "37");
@@ -9,6 +9,7 @@ import { getTrackingFromCookies } from "@calcom/lib/tracking";
import type { TrackingData } from "@calcom/lib/tracking";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
import type { BillingPeriod as BillingPeriodEnum } from "@calcom/prisma/zod-utils";
import { TRPCError } from "@trpc/server";
@@ -28,12 +29,14 @@ const generateCheckoutSession = async ({
teamName,
userId,
isOnboarding,
billingPeriod,
tracking,
}: {
teamSlug: string;
teamName: string;
userId: number;
isOnboarding?: boolean;
billingPeriod?: "MONTHLY" | "ANNUALLY";
tracking?: TrackingData;
}) => {
if (!IS_TEAM_BILLING_ENABLED) {
@@ -46,6 +49,7 @@ const generateCheckoutSession = async ({
teamName,
userId,
isOnboarding,
billingPeriod: billingPeriod as BillingPeriodEnum | undefined,
tracking,
});
@@ -59,7 +63,7 @@ const generateCheckoutSession = async ({
export const createHandler = async ({ ctx, input }: CreateOptions) => {
const { user } = ctx;
const { slug, name, bio, isOnboarding } = input;
const { slug, name, bio, isOnboarding, billingPeriod } = input;
const isOrgChildTeam = !!user.profile?.organizationId;
// For orgs we want to create teams under the org
@@ -94,6 +98,7 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
teamName: name,
userId: user.id,
isOnboarding,
billingPeriod,
tracking,
});
@@ -1,6 +1,7 @@
import { z } from "zod";
import slugify from "@calcom/lib/slugify";
import type { BillingPeriod } from "@calcom/prisma/enums";
export type TCreateInputSchema = {
name: string;
@@ -8,6 +9,7 @@ export type TCreateInputSchema = {
logo?: string | null;
bio?: string;
isOnboarding?: boolean;
billingPeriod?: BillingPeriod;
};
export const ZCreateInputSchema: z.ZodType<TCreateInputSchema> = z.object({
@@ -20,4 +22,5 @@ export const ZCreateInputSchema: z.ZodType<TCreateInputSchema> = z.object({
.transform((v) => v || null),
bio: z.string().optional(),
isOnboarding: z.boolean().optional(),
billingPeriod: z.enum(["MONTHLY", "ANNUALLY"]).optional(),
});