⚡ (billing) Automatic usage-based billing (#924)
BREAKING CHANGE: Stripe environment variables simplified. Check out the new configs to adapt your existing system. Closes #906 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit **New Features:** - Introduced a usage-based billing system, providing more flexibility and options for users. - Integrated with Stripe for a smoother and more secure payment process. - Enhanced the user interface with improvements to the billing, workspace, and pricing pages for a more intuitive experience. **Improvements:** - Simplified the billing logic, removing additional chats and yearly billing for a more streamlined user experience. - Updated email notifications to keep users informed about their usage and limits. - Improved pricing and currency formatting for better clarity and understanding. **Testing:** - Updated tests and specifications to ensure the reliability of new features and improvements. **Note:** These changes aim to provide a more flexible and user-friendly billing system, with clearer pricing and improved notifications. Users should find the new system more intuitive and easier to navigate. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -10,12 +10,12 @@ import { Stack, VStack, Spinner, Text } from '@chakra-ui/react'
|
||||
import { Plan } from '@typebot.io/prisma'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { guessIfUserIsEuropean } from '@typebot.io/lib/pricing'
|
||||
import { DashboardHeader } from './DashboardHeader'
|
||||
import { FolderContent } from '@/features/folders/components/FolderContent'
|
||||
import { TypebotDndProvider } from '@/features/folders/TypebotDndProvider'
|
||||
import { ParentModalProvider } from '@/features/graph/providers/ParentModalProvider'
|
||||
import { trpc } from '@/lib/trpc'
|
||||
import { guessIfUserIsEuropean } from '@typebot.io/lib/billing/guessIfUserIsEuropean'
|
||||
|
||||
export const DashboardPage = () => {
|
||||
const scopedT = useScopedI18n('dashboard')
|
||||
@@ -33,13 +33,11 @@ export const DashboardPage = () => {
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const { subscribePlan, chats, isYearly, claimCustomPlan } =
|
||||
router.query as {
|
||||
subscribePlan: Plan | undefined
|
||||
chats: string | undefined
|
||||
isYearly: string | undefined
|
||||
claimCustomPlan: string | undefined
|
||||
}
|
||||
const { subscribePlan, claimCustomPlan } = router.query as {
|
||||
subscribePlan: Plan | undefined
|
||||
chats: string | undefined
|
||||
claimCustomPlan: string | undefined
|
||||
}
|
||||
if (claimCustomPlan && user?.email && workspace) {
|
||||
setIsLoading(true)
|
||||
createCustomCheckoutSession({
|
||||
@@ -53,9 +51,7 @@ export const DashboardPage = () => {
|
||||
setPreCheckoutPlan({
|
||||
plan: subscribePlan as 'PRO' | 'STARTER',
|
||||
workspaceId: workspace.id,
|
||||
additionalChats: chats ? parseInt(chats) : 0,
|
||||
currency: guessIfUserIsEuropean() ? 'eur' : 'usd',
|
||||
isYearly: isYearly === 'false' ? false : true,
|
||||
})
|
||||
}
|
||||
}, [createCustomCheckoutSession, router.query, user, workspace])
|
||||
|
||||
Reference in New Issue
Block a user