* feat: redirect to new onboarding flow * Getting started * Brand details * Preview organization brands * Orgs team pages * Invite team steps * Move to global zustand store * Few darkmdoe fixes * Wip onboarding + stripe flow * Default plan state Server Action for gettting slug satus of org * Remove onboardingId * Confirmation prompt * Update old onboarding flow handlers to handle new fields * update onboarding hook * Filter out organization section for none -company emails * Match placeholders to users domain * Drop migration * Wip new onboarding intent * WIP flow for self-hosted. Same service call just split logic * WIP * Add TODO * Use onboarding user type instead of trpc session * WIP * WIP * pass role and team name from onboarding to save in schema * Add test to ensure role + name + team are persisted into onboarding table * migrate roles to enum values * Update ENUM * Fix type error * Redirect if flag is disabled * Remove web * WIP * WIP * Fix migration * Fix calls * User onboarding User types instead of trpc session * Fix factory tests * Fix flow for self hoste * Type error * More type fixes * Fix handler tests * Fix enum return type being different * Use consistant types across the oganization stuff * Fix * Use TEAM_BILLING for e2e test * Refactor is not company email and add tests * Fix * Fix * Refactor flow to submit after form complete * Fix flow with billing disabled * Fix tests * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Rename and move test files * WIP * Fix types * Update repo paths + tests * Move to service folder * Fix tests * Fix types * Remove old test files * Restore lock * Fix path * Fix tests with new paths and factory logic * Fix updaetdAt * WIP onboardingID isolation * Fix e2e test * verify test * Code rabbit * Rename SelfHostedOnboardongService -> SelfHostedOrganizationOnboardingService * Fix stores * Fix type error * Fix types * remove tsignore * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * NITS * Add the logic to auto complete admin org when billing enabled * Fix store being weird * We need to return the parsed value * fixes * sync from db always * Add onboardingSgtore tests * fix test * remove step and status --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara <[email protected]>
4.8 KiB
Organization Onboarding Setup
This document explains how the organization onboarding system works and how to configure it for different deployment scenarios.
Overview
The organization onboarding system supports two different flows:
- Billing-Enabled Flow (BillingEnabledOrgOnboardingService): Used on hosted Cal.com with Stripe integration
- Self-Hosted Flow (SelfHostedOrganizationOnboardingService): Used on self-hosted instances where admins can create organizations without payment
The system automatically selects the appropriate flow based on environment variables and user permissions.
Architecture
Factory Pattern
The OrganizationOnboardingFactory class determines which onboarding service to use:
OrganizationOnboardingFactory.create(user)
→ BillingEnabledOrgOnboardingService | SelfHostedOrganizationOnboardingService
Decision Logic
The factory uses the following logic to determine which service to instantiate:
IF process.env.NEXT_PUBLIC_IS_E2E is set:
→ Use SelfHostedOrganizationOnboardingService (E2E tests always skip billing)
ELSE IF IS_TEAM_BILLING_ENABLED is true:
→ Use BillingEnabledOrgOnboardingService (hosted environment with Stripe)
ELSE IF user.role is ADMIN:
→ Use SelfHostedOrganizationOnboardingService (self-hosted admins skip billing)
ELSE:
→ Use BillingEnabledOrgOnboardingService (non-admins need billing even on self-hosted)
Environment Variables
Required for Billing-Enabled Flow
# Stripe Configuration
STRIPE_CLIENT_ID=your_stripe_client_id
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=your_stripe_public_key
STRIPE_PRIVATE_KEY=your_stripe_private_key
# These enable IS_STRIPE_ENABLED and IS_TEAM_BILLING_ENABLED
Optional Configuration
# Force hosted features on self-hosted instances
NEXT_PUBLIC_HOSTED_CAL_FEATURES=true
# E2E testing (disables billing flow)
NEXT_PUBLIC_IS_E2E=1
# Organization pricing
NEXT_PUBLIC_ORGANIZATIONS_MIN_SELF_SERVE_SEATS=5
NEXT_PUBLIC_ORGANIZATIONS_SELF_SERVE_PRICE_NEW=37
Constants
The system relies on several computed constants from @calcom/lib/constants:
Server-Side Constants
-
IS_TEAM_BILLING_ENABLED:IS_STRIPE_ENABLED && HOSTED_CAL_FEATURES- Determines if billing is globally enabled
- Used in:
OrganizationOnboardingFactory
-
IS_STRIPE_ENABLED:!!(STRIPE_CLIENT_ID && NEXT_PUBLIC_STRIPE_PUBLIC_KEY && STRIPE_PRIVATE_KEY)- Checks if Stripe is properly configured
-
HOSTED_CAL_FEATURES:process.env.NEXT_PUBLIC_HOSTED_CAL_FEATURES || !IS_SELF_HOSTED- Enables hosted features (including billing)
-
IS_SELF_HOSTED:!CAL_DOMAINS.some(domain => WEBAPP_HOSTNAME.endsWith(domain))- Detects if running on official Cal.com domains
Client-Side Constants
IS_TEAM_BILLING_ENABLED_CLIENT:!!process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY && HOSTED_CAL_FEATURES- Client-safe version of billing check
- Used in:
onboardingStore.ts
Configuration Scenarios
Scenario 1: Hosted Cal.com (Official)
Environment:
# Domain: *.cal.com, *.cal.dev, etc.
STRIPE_CLIENT_ID=ca_xxx
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_live_xxx
STRIPE_PRIVATE_KEY=sk_live_xxx
Result:
IS_SELF_HOSTED=falseHOSTED_CAL_FEATURES=trueIS_TEAM_BILLING_ENABLED=true- All users → BillingEnabledOrgOnboardingService
Scenario 2: Self-Hosted with Billing (Optional)
Environment:
# Domain: custom.example.com
NEXT_PUBLIC_HOSTED_CAL_FEATURES=true
STRIPE_CLIENT_ID=ca_xxx
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_live_xxx
STRIPE_PRIVATE_KEY=sk_live_xxx
Result:
IS_SELF_HOSTED=trueHOSTED_CAL_FEATURES=true(forced)IS_TEAM_BILLING_ENABLED=true- All users → BillingEnabledOrgOnboardingService
Scenario 3: Self-Hosted without Billing (Default)
Environment:
# Domain: custom.example.com
# No Stripe configuration
Result:
IS_SELF_HOSTED=trueHOSTED_CAL_FEATURES=falseIS_TEAM_BILLING_ENABLED=false- Admin users → SelfHostedOrganizationOnboardingService
- Regular users → BillingEnabledOrgOnboardingService (will fail without Stripe)
Recommendation: In this scenario, only admins should be allowed to create organizations.
Scenario 4: E2E Testing
Environment:
NEXT_PUBLIC_IS_E2E=1
# Any other configuration
Result:
- All users → SelfHostedOrganizationOnboardingService
- Billing flow is completely bypassed
User Roles
The system differentiates between two user roles:
Admin Users (UserPermissionRole.ADMIN)
- Can create organizations without billing on self-hosted instances
- Can access self-hosted flow when
IS_TEAM_BILLING_ENABLEDis false
Regular Users (UserPermissionRole.USER)
- Always require billing flow
- Cannot create organizations on self-hosted without Stripe configured