From 6bb86944f7b30ddfbf0c6970bf644accf6240b17 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Mon, 10 Jun 2024 20:28:50 +1000 Subject: [PATCH] fix: remove price id --- .env.example | 1 - packages/lib/constants/billing.ts | 5 ----- .../lib/server-only/profile/get-public-profile-by-url.ts | 8 ++++---- turbo.json | 1 - 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index 82a5150a8..4919f0053 100644 --- a/.env.example +++ b/.env.example @@ -100,7 +100,6 @@ NEXT_PUBLIC_DOCUMENT_SIZE_UPLOAD_LIMIT=5 # [[STRIPE]] NEXT_PRIVATE_STRIPE_API_KEY= NEXT_PRIVATE_STRIPE_WEBHOOK_SECRET= -NEXT_PUBLIC_STRIPE_COMMUNITY_PLAN_PRODUCT_ID= NEXT_PUBLIC_STRIPE_COMMUNITY_PLAN_MONTHLY_PRICE_ID= NEXT_PUBLIC_STRIPE_ENTERPRISE_PLAN_MONTHLY_PRICE_ID= diff --git a/packages/lib/constants/billing.ts b/packages/lib/constants/billing.ts index f57e752cd..0d8dee6e2 100644 --- a/packages/lib/constants/billing.ts +++ b/packages/lib/constants/billing.ts @@ -1,5 +1,3 @@ -import { env } from 'next-runtime-env'; - export enum STRIPE_CUSTOMER_TYPE { INDIVIDUAL = 'individual', TEAM = 'team', @@ -10,6 +8,3 @@ export enum STRIPE_PLAN_TYPE { COMMUNITY = 'community', ENTERPRISE = 'enterprise', } - -export const STRIPE_COMMUNITY_PLAN_PRODUCT_ID = () => - env('NEXT_PUBLIC_STRIPE_COMMUNITY_PLAN_PRODUCT_ID'); diff --git a/packages/lib/server-only/profile/get-public-profile-by-url.ts b/packages/lib/server-only/profile/get-public-profile-by-url.ts index 87417903e..00d97f1be 100644 --- a/packages/lib/server-only/profile/get-public-profile-by-url.ts +++ b/packages/lib/server-only/profile/get-public-profile-by-url.ts @@ -1,3 +1,4 @@ +import { getCommunityPlanPriceIds } from '@documenso/ee/server-only/stripe/get-community-plan-prices'; import { prisma } from '@documenso/prisma'; import type { Template, TemplateDirectLink } from '@documenso/prisma/client'; import { @@ -8,7 +9,6 @@ import { } from '@documenso/prisma/client'; import { IS_BILLING_ENABLED } from '../../constants/app'; -import { STRIPE_COMMUNITY_PLAN_PRODUCT_ID } from '../../constants/billing'; import { AppError, AppErrorCode } from '../../errors/app-error'; export type GetPublicProfileByUrlOptions = { @@ -127,13 +127,13 @@ export const getPublicProfileByUrl = async ({ }; } - const earlyAdopterProductId = STRIPE_COMMUNITY_PLAN_PRODUCT_ID(); + if (IS_BILLING_ENABLED()) { + const earlyAdopterPriceIds = await getCommunityPlanPriceIds(); - if (IS_BILLING_ENABLED() && earlyAdopterProductId) { const activeEarlyAdopterSub = user.Subscription.find( (subscription) => subscription.status === SubscriptionStatus.ACTIVE && - earlyAdopterProductId === subscription.planId, + earlyAdopterPriceIds.includes(subscription.priceId), ); if (activeEarlyAdopterSub) { diff --git a/turbo.json b/turbo.json index 4f42d9d5e..2b84e14ae 100644 --- a/turbo.json +++ b/turbo.json @@ -54,7 +54,6 @@ "NEXT_PUBLIC_MARKETING_URL", "NEXT_PUBLIC_POSTHOG_KEY", "NEXT_PUBLIC_FEATURE_BILLING_ENABLED", - "NEXT_PUBLIC_STRIPE_COMMUNITY_PLAN_PRODUCT_ID", "NEXT_PUBLIC_STRIPE_COMMUNITY_PLAN_MONTHLY_PRICE_ID", "NEXT_PUBLIC_STRIPE_ENTERPRISE_PLAN_MONTHLY_PRICE_ID", "NEXT_PUBLIC_DISABLE_SIGNUP",