From 6b0c263f885c091e81731230e012d33e223f0cfa Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 17 Oct 2023 08:32:41 +0200 Subject: [PATCH] =?UTF-8?q?:ambulance:=20(billing)=20Fix=20chats=20pricing?= =?UTF-8?q?=20tiers=20incremental=20flat=20amou=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../billing/components/ChatsProTiersModal.tsx | 10 +--- .../PricingPage/ChatsProTiersModal.tsx | 10 +--- .../emails/AlmostReachedChatsLimitEmail.tsx | 2 +- packages/lib/billing/constants.ts | 58 +++++++++---------- .../migrateSubscriptionsToUsageBased.ts | 8 +++ 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx b/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx index af7b210456a..a9960bda6c6 100644 --- a/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx +++ b/apps/builder/src/features/billing/components/ChatsProTiersModal.tsx @@ -46,13 +46,9 @@ export const ChatsProTiersModal = ({ isOpen, onClose }: Props) => { {proChatTiers.map((tier, index) => { const pricePerMonth = - proChatTiers - .slice(0, index + 1) - .reduce( - (acc, slicedTier) => - acc + (slicedTier.flat_amount ?? 0), - 0 - ) / 100 + (tier.flat_amount ?? + proChatTiers.at(-2)?.flat_amount ?? + 0) / 100 return ( diff --git a/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx b/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx index af7b210456a..a9960bda6c6 100644 --- a/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx +++ b/apps/landing-page/components/PricingPage/ChatsProTiersModal.tsx @@ -46,13 +46,9 @@ export const ChatsProTiersModal = ({ isOpen, onClose }: Props) => { {proChatTiers.map((tier, index) => { const pricePerMonth = - proChatTiers - .slice(0, index + 1) - .reduce( - (acc, slicedTier) => - acc + (slicedTier.flat_amount ?? 0), - 0 - ) / 100 + (tier.flat_amount ?? + proChatTiers.at(-2)?.flat_amount ?? + 0) / 100 return ( diff --git a/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx b/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx index fe9d6674c77..b503fcde499 100644 --- a/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx +++ b/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx @@ -54,7 +54,7 @@ export const AlmostReachedChatsLimitEmail = ({ As a reminder, your billing cycle ends on {readableResetDate}. If you'd like to learn more about the Enterprise plan for an - annual commitment, reach out to . + annual commitment, reach out to support@typebot.io. diff --git a/packages/lib/billing/constants.ts b/packages/lib/billing/constants.ts index 01c5f6e2550..8cf7f681f48 100644 --- a/packages/lib/billing/constants.ts +++ b/packages/lib/billing/constants.ts @@ -31,15 +31,15 @@ export const starterChatTiers = [ }, { up_to: 3000, - flat_amount: 1000, + flat_amount: 2000, }, { up_to: 3500, - flat_amount: 1000, + flat_amount: 3000, }, { up_to: 4000, - flat_amount: 1000, + flat_amount: 4000, }, { up_to: 'inf', @@ -58,107 +58,107 @@ export const proChatTiers = [ }, { up_to: 20000, - flat_amount: 4500, + flat_amount: 9500, }, { up_to: 30000, - flat_amount: 8500, + flat_amount: 18000, }, { up_to: 40000, - flat_amount: 8000, + flat_amount: 26000, }, { up_to: 50000, - flat_amount: 7500, + flat_amount: 33500, }, { up_to: 60000, - flat_amount: 7225, + flat_amount: 40700, }, { up_to: 70000, - flat_amount: 7000, + flat_amount: 47700, }, { up_to: 80000, - flat_amount: 6800, + flat_amount: 54500, }, { up_to: 90000, - flat_amount: 6600, + flat_amount: 61100, }, { up_to: 100000, - flat_amount: 6400, + flat_amount: 67500, }, { up_to: 120000, - flat_amount: 12400, + flat_amount: 79900, }, { up_to: 140000, - flat_amount: 12000, + flat_amount: 91900, }, { up_to: 160000, - flat_amount: 11800, + flat_amount: 103700, }, { up_to: 180000, - flat_amount: 11600, + flat_amount: 115300, }, { up_to: 200000, - flat_amount: 11400, + flat_amount: 126700, }, { up_to: 300000, - flat_amount: 55000, + flat_amount: 181700, }, { up_to: 400000, - flat_amount: 53000, + flat_amount: 234700, }, { up_to: 500000, - flat_amount: 51000, + flat_amount: 285700, }, { up_to: 600000, - flat_amount: 50000, + flat_amount: 335700, }, { up_to: 700000, - flat_amount: 49000, + flat_amount: 384700, }, { up_to: 800000, - flat_amount: 48000, + flat_amount: 432700, }, { up_to: 900000, - flat_amount: 47000, + flat_amount: 479700, }, { up_to: 1000000, - flat_amount: 46000, + flat_amount: 525700, }, { up_to: 1200000, - flat_amount: 91400, + flat_amount: 617100, }, { up_to: 1400000, - flat_amount: 90800, + flat_amount: 707900, }, { up_to: 1600000, - flat_amount: 90000, + flat_amount: 797900, }, { up_to: 1800000, - flat_amount: 89400, + flat_amount: 887300, }, { up_to: 'inf', diff --git a/packages/scripts/migrateSubscriptionsToUsageBased.ts b/packages/scripts/migrateSubscriptionsToUsageBased.ts index 21488126165..bafe72842c2 100644 --- a/packages/scripts/migrateSubscriptionsToUsageBased.ts +++ b/packages/scripts/migrateSubscriptionsToUsageBased.ts @@ -228,6 +228,14 @@ const migrateSubscriptionsToUsageBased = async () => { price: proPriceId, quantity: 1, }, + { + id: newSubscription.items.data.find( + (item) => + item.price.id === starterChatsPriceId || + item.price.id === proChatsPriceId + )?.id, + price: proChatsPriceId, + }, ], })