Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

account for LEGACY_PRICE_IDS

Steven Teyc4caaa534b0e
diff --git a/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-updated.ts b/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-updated.ts
index 692591a292..fb289369b6 100644
--- a/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-updated.ts
+++ b/apps/web/app/(ee)/api/stripe/webhook/customer-subscription-updated.ts
@@ -2,7 +2,7 @@ import { deleteWorkspaceFolders } from "@/lib/api/folders/delete-workspace-folde
import { tokenCache } from "@/lib/auth/token-cache";
import { webhookCache } from "@/lib/webhook/cache";
import { prisma } from "@dub/prisma";
-import { getPlanFromPriceId } from "@dub/utils";
+import { getPlanFromPriceId, LEGACY_PRICE_IDS } from "@dub/utils";
import { NextResponse } from "next/server";
import Stripe from "stripe";
import { sendCancellationFeedback } from "./utils";
@@ -70,11 +70,9 @@ export async function customerSubscriptionUpdated(event: Stripe.Event) {
const shouldDeleteFolders =
newPlanName === "free" && workspace.foldersUsage > 0;
- // If a workspace upgrades/downgrades their subscription, update their usage limit in the database.
- if (
- workspace.plan !== newPlanName ||
- workspace.payoutsLimit !== plan.limits.payouts
- ) {
+ // If a workspace upgrades/downgrades their subscription and it's not a legacy plan
+ // update their usage limit in the database
+ if (workspace.plan !== newPlanName && !LEGACY_PRICE_IDS.includes(priceId)) {
await Promise.allSettled([
prisma.project.update({
where: {
diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing.tsx
index 034b4cde2d..7407113455 100644
--- a/packages/utils/src/constants/pricing.tsx
+++ b/packages/utils/src/constants/pricing.tsx
@@ -10,6 +10,30 @@ export type PlanFeature = {
};
};
+export const LEGACY_PRO_PRICE_IDS = [
+ "price_1LodNLAlJJEpqkPVQSrt33Lc", // old monthly
+ "price_1LodNLAlJJEpqkPVRxUyCQgZ", // old yearly
+ "price_1OTcQBAlJJEpqkPViGtGEsbb", // new monthly (test)
+ "price_1OYJeBAlJJEpqkPVLjTsjX0E", // new monthly (prod)
+ "price_1OTcQBAlJJEpqkPVYlCMqdLL", // new yearly (test)
+ "price_1OYJeBAlJJEpqkPVnPGEZeb0", // new yearly (prod)
+];
+
+export const LEGACY_BUSINESS_PRICE_IDS = [
+ "price_1LodLoAlJJEpqkPV9rD0rlNL", // old monthly
+ "price_1LodLoAlJJEpqkPVJdwv5zrG", // oldest yearly
+ "price_1OZgmnAlJJEpqkPVOj4kV64R", // old yearly
+ "price_1OzNlmAlJJEpqkPV7s9HXNAC", // new monthly (test)
+ "price_1OzNmXAlJJEpqkPVYO89lTdx", // new yearly (test)
+ "price_1OzOFIAlJJEpqkPVJxzc9irl", // new monthly (prod)
+ "price_1OzOXMAlJJEpqkPV9ERrjjbw", // new yearly (prod)
+];
+
+export const LEGACY_PRICE_IDS = [
+ ...LEGACY_PRO_PRICE_IDS,
+ ...LEGACY_BUSINESS_PRICE_IDS,
+];
+
export const PLANS = [
{
name: "Free",
@@ -37,13 +61,7 @@ export const PLANS = [
monthly: 30,
yearly: 25,
ids: [
- "price_1LodNLAlJJEpqkPVQSrt33Lc", // old monthly
- "price_1LodNLAlJJEpqkPVRxUyCQgZ", // old yearly
- "price_1OTcQBAlJJEpqkPViGtGEsbb", // new monthly (test)
- "price_1OYJeBAlJJEpqkPVLjTsjX0E", // new monthly (prod)
- "price_1OTcQBAlJJEpqkPVYlCMqdLL", // new yearly (test)
- "price_1OYJeBAlJJEpqkPVnPGEZeb0", // new yearly (prod)
-
+ ...LEGACY_PRO_PRICE_IDS,
// 2025 pricing
"price_1R8XtyAlJJEpqkPV5WZ4c0jF", // yearly
"price_1R8XtEAlJJEpqkPV4opVvVPq", // monthly
@@ -123,14 +141,7 @@ export const PLANS = [
monthly: 90,
yearly: 75,
ids: [
- "price_1LodLoAlJJEpqkPV9rD0rlNL", // old monthly
- "price_1LodLoAlJJEpqkPVJdwv5zrG", // oldest yearly
- "price_1OZgmnAlJJEpqkPVOj4kV64R", // old yearly
- "price_1OzNlmAlJJEpqkPV7s9HXNAC", // new monthly (test)
- "price_1OzNmXAlJJEpqkPVYO89lTdx", // new yearly (test)
- "price_1OzOFIAlJJEpqkPVJxzc9irl", // new monthly (prod)
- "price_1OzOXMAlJJEpqkPV9ERrjjbw", // new yearly (prod)
-
+ ...LEGACY_BUSINESS_PRICE_IDS,
// 2025 pricing
"price_1R3j01AlJJEpqkPVXuG1eNzm", // yearly
"price_1R6JedAlJJEpqkPVMUkfjch4", // monthly