feat: limit free teams to 1 for platform plan
This commit is contained in:
@@ -5,7 +5,7 @@ import type { Document, Subscription } from '@documenso/prisma/client';
|
|||||||
|
|
||||||
import { getPlatformPlanPriceIds } from '../stripe/get-platform-plan-prices';
|
import { getPlatformPlanPriceIds } from '../stripe/get-platform-plan-prices';
|
||||||
|
|
||||||
export type IsDocumentPlatformOptions = Pick<Document, 'id' | 'userId' | 'teamId'>;
|
export type IsDocumentPlatformOptions = Pick<Document, 'userId' | 'teamId'>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user is platform, or has permission to use platform features on
|
* Whether the user is platform, or has permission to use platform features on
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { z } from 'zod';
|
|||||||
import { createTeamCustomer } from '@documenso/ee/server-only/stripe/create-team-customer';
|
import { createTeamCustomer } from '@documenso/ee/server-only/stripe/create-team-customer';
|
||||||
import { getTeamRelatedPrices } from '@documenso/ee/server-only/stripe/get-team-related-prices';
|
import { getTeamRelatedPrices } from '@documenso/ee/server-only/stripe/get-team-related-prices';
|
||||||
import { mapStripeSubscriptionToPrismaUpsertAction } from '@documenso/ee/server-only/stripe/webhook/on-subscription-updated';
|
import { mapStripeSubscriptionToPrismaUpsertAction } from '@documenso/ee/server-only/stripe/webhook/on-subscription-updated';
|
||||||
|
import { isDocumentPlatform as isUserPlatformPlan } from '@documenso/ee/server-only/util/is-document-platform';
|
||||||
import { IS_BILLING_ENABLED } from '@documenso/lib/constants/app';
|
import { IS_BILLING_ENABLED } from '@documenso/lib/constants/app';
|
||||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||||
import { subscriptionsContainsActivePlan } from '@documenso/lib/utils/billing';
|
import { subscriptionsContainsActivePlan } from '@documenso/lib/utils/billing';
|
||||||
@@ -60,6 +61,11 @@ export const createTeam = async ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isPlatformPlan = await isUserPlatformPlan({
|
||||||
|
userId: user.id,
|
||||||
|
teamId: null,
|
||||||
|
});
|
||||||
|
|
||||||
let isPaymentRequired = IS_BILLING_ENABLED();
|
let isPaymentRequired = IS_BILLING_ENABLED();
|
||||||
let customerId: string | null = null;
|
let customerId: string | null = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user