# SaaS Configuration
This guide covers configuring the multi-tenant SaaS features: plans, limits, tenant onboarding, and subscription management.
# Understanding the SaaS Model
CloudPOS is a multi-tenant SaaS system, meaning:
- One installation serves multiple tenants (clients)
- Each tenant has isolated data
- Tenants subscribe to plans with different features/limits
- You manage everything from the Admin Panel
# Creating Subscription Plans
# Step 1: Access Plans Section
- Login to Admin Panel:
http://localhost:5173/admin/login - Navigate to Plans → Create Plan
# Step 2: Configure Plan Details
Fill in the form:
- Name: Plan name (e.g., "Basic", "Pro", "Enterprise")
- Description: Plan description (shown to tenants)
- Monthly Price: Price per month (e.g.,
29.99) - Yearly Price: Price per year (e.g.,
299.99) - Currency: ISO code (e.g.,
USD) - Billing Cycle: Default cycle (Monthly or Yearly)
- Is Active: Toggle to enable/disable plan
- Is Popular: Mark as featured plan
- Sort Order: Display order (lower = first)
# Step 3: Configure Plan Features
Add features list (JSON array format):
[
"Unlimited products",
"Up to 5 users",
"2 branches",
"Email support",
"Basic reports"
]
# Step 4: Configure Plan Limits
Set limits (JSON object format):
{
"users": 5,
"branches": 2,
"products": 1000,
"storage": 1073741824,
"api_calls": 10000
}
Common limits:
users: Maximum number of usersbranches: Maximum number of branchesproducts: Maximum number of productsstorage: Storage in bytes (e.g., 1GB = 1073741824)api_calls: API calls per month
# Step 5: Configure Stripe Price IDs (If Using Stripe)
If you're using Stripe for payments:
Get Price IDs from Stripe Dashboard:
- Go to Stripe Dashboard → Products
- Create products for each plan
- Copy Price IDs (e.g.,
price_1234567890)
Add to Plan:
- Stripe Price ID (Monthly):
price_xxxxx - Stripe Yearly Price ID:
price_xxxxx
- Stripe Price ID (Monthly):
Save Plan
# Plan Assignment Flow
# How Plans Are Assigned
Tenant Registers
- Tenant creates account via registration page
- Account created with no active plan
Tenant Subscribes
- Tenant navigates to Subscription page
- Selects a plan
- Completes payment (if Stripe configured)
- Plan is automatically assigned
Admin Manual Assignment
- Admin can manually assign plans via Admin Panel
- Useful for free trials or custom arrangements
# Verifying Plan Assignment
Check tenant subscription:
- Admin Panel → Tenants → Select tenant
- Go to Subscription tab
- View:
- Current plan
- Subscription status (ACTIVE, TRIAL, etc.)
- Start/end dates
- Payment history
# Subscription Statuses
| Status | Description |
|---|---|
| TRIAL | Free trial period active |
| ACTIVE | Subscription active and paid |
| SUSPENDED | Payment failed or past due |
| CANCELLED | Subscription cancelled |
| EXPIRED | Subscription expired |
# Plan Limits Enforcement
CloudPOS enforces plan limits automatically:
# How Limits Work
When tenant tries to create resource:
- System checks current count
- Compares to plan limit
- Blocks if limit exceeded
Error message shown:
Plan limit exceeded: You've reached your plan limit for users (5/5). Upgrade to continue.
# Common Limit Checks
- Users: When creating new user
- Branches: When creating new branch
- Products: When creating new product
- Storage: When uploading files
- API Calls: When making API requests
# Bypassing Limits (Admin)
Admins can:
- Manually assign higher plans
- Temporarily increase limits
- Override limits for specific tenants
# Tenant Onboarding Process
# Step 1: Tenant Registration
Option A: Self-Registration
- Tenant visits:
https://yourdomain.com/register - Fills registration form:
- Password (min 8 chars, uppercase, lowercase, number)
- First name, Last name
- Company name (tenant name)
- Subdomain (optional, if using subdomain routing)
- Submits form
- Receives email verification (if enabled)
Option B: Admin Creates Tenant
- Admin Panel → Tenants → Create Tenant
- Fill tenant details
- Create tenant
- Send login credentials to tenant
# Step 2: Email Verification (Optional)
If email verification is enabled:
- Tenant receives verification email
- Clicks verification link
- Account activated
# Step 3: Plan Selection
- Tenant logs in
- Sees "Subscribe to a Plan" prompt
- Navigates to Subscription → Plans
- Selects plan
- Completes payment (if Stripe configured)
# Step 4: Access Granted
After subscription:
- Tenant can access full system
- Can create users, branches, products
- Limited by plan limits
# Managing Tenant Subscriptions
# View All Subscriptions
- Admin Panel → Subscriptions
- View list of all subscriptions
- Filter by status, plan, date
# Manual Plan Assignment
- Admin Panel → Tenants → Select tenant
- Go to Subscription tab
- Click Assign Plan
- Select:
- Plan
- Billing cycle (Monthly/Yearly)
- Start date
- End date (optional)
- Click Assign
# Cancel Subscription
- Admin Panel → Subscriptions → Select subscription
- Click Cancel Subscription
- Choose:
- Cancel Immediately: Access revoked now
- Cancel at Period End: Access until current period ends
- Confirm cancellation
# Suspend Tenant
- Admin Panel → Tenants → Select tenant
- Click Suspend
- Tenant loses access immediately
- Can reactivate later
# Subscription Webhooks (Stripe)
If using Stripe, webhooks automatically update subscriptions:
# Webhook Events Handled
checkout.session.completed- Assigns plan after paymentcustomer.subscription.created- Creates subscriptioncustomer.subscription.updated- Updates subscription statuscustomer.subscription.deleted- Cancels subscriptioninvoice.payment_succeeded- Activates subscriptioninvoice.payment_failed- Suspends subscription
# Webhook Configuration
See Payment Gateway for Stripe webhook setup.
# Cron Jobs / Scheduled Tasks
CloudPOS uses NestJS Schedule for automated tasks:
# Subscription Expiry Check
Automatically checks and updates expired subscriptions:
- Runs: Daily at midnight
- Action: Marks expired subscriptions as EXPIRED
- Location:
server/src/subscriptions/(scheduled task)
# Email Notifications
Sends email notifications for:
- Subscription expiry warnings
- Payment failures
- Subscription renewals
# Testing the SaaS Flow
# Test Tenant Registration
- Go to:
http://localhost:5173/register - Fill registration form
- Submit
- Verify tenant created in Admin Panel
# Test Plan Assignment
- Login as tenant
- Navigate to Subscription page
- Select a plan
- Complete checkout (test mode)
- Verify plan assigned in Admin Panel
# Test Plan Limits
- Assign Basic plan (e.g., 5 users limit)
- Login as tenant
- Try to create 6th user
- Verify limit error appears
# Troubleshooting
# Plan Not Assigning After Payment
Issue: Payment succeeds but plan not assigned
Solutions:
Check webhook configuration:
- Verify webhook URL in Stripe Dashboard
- Check webhook secret in Admin Panel
- View webhook logs in Stripe Dashboard
Check subscription logs:
- Admin Panel → Subscriptions → Select subscription
- View Logs tab
- Look for errors
Manually assign plan:
- Admin Panel → Tenants → Select tenant
- Manually assign plan
# Plan Limits Not Enforcing
Issue: Tenant can exceed plan limits
Solutions:
Verify plan limits configured:
- Check plan JSON limits
- Ensure limits are numbers, not strings
Check subscription status:
- Subscription must be ACTIVE or TRIAL
- Expired subscriptions may not enforce limits
Review code:
- Limits enforced in backend guards
- Check server logs for errors
# Tenant Can't Access After Subscription
Issue: Tenant subscribed but can't login
Solutions:
Check subscription status:
- Must be ACTIVE or TRIAL
- Check subscription end date
Verify tenant is active:
- Admin Panel → Tenants → Check "Is Active"
Check user account:
- Verify user email is verified (if required)
- Check user is not deleted
Next: See Payment Gateway to set up Stripe payments.