Pricing Models
Pay4SaaS includes 4 built-in pricing models that can be switched with a single environment variable — no code changes needed.
Overview
| Mode | Env Value | Use Case | How Users Pay |
|---|---|---|---|
| Credits | credits | Pay-per-use tools | Buy credit packs, purchase more when used up |
| Unlimited Sub | subscription_unlimited | Standard SaaS subscription | Monthly/yearly subscription, unlimited usage |
| Quota Sub | subscription_quota | SaaS with usage control | Subscribe for monthly quota + buy extra credits |
| Lifetime | lifetime | One-time purchase products | Pay once, use forever |
Switching Modes
Set in .env.local:
NEXT_PUBLIC_PRICING_MODEL=creditsAvailable values: credits, subscription_unlimited, subscription_quota, lifetime.
After changing, restart the project. The pricing page, checkout flow, and access control will all adapt automatically.
Mode 1: Credits
Dual credits system: purchased credits never expire, bonus credits expire per batch (default 30 days). Each service use deducts 1 credit, with consumption priority: bonus credits → purchased credits.

Best for: AI tools, image generation, API calls, and other pay-per-use scenarios.
Configure Credit Packages
Configure in PACKAGES in config/payment.ts:
export const PACKAGES = {
basic: {
credits: 10, // Number of credits
amount: 9.99, // USD price
amountCNY: 29, // CNY price (auto-used on domestic site)
name: 'Starter',
description: 'Perfect for casual writers',
features: ['10 AI writing credits', 'Blog post generation', '...'],
recommended: false
},
pro: {
credits: 50,
amount: 39.99,
amountCNY: 99,
name: 'Growth',
features: ['50 AI writing credits', '...'],
recommended: true // Mark as recommended
}
// max: { ... },
// ultra: { ... }, // 4th package (optional)
}Key points:
- Supports 2–4 credit packages, keys are fixed as
basic,pro,max,ultra— do not modify - You only need to change
name, prices,features, and other display content - Comment out the key for any package you don't need
- Domestic site will automatically use the
amountCNYprice
Mode 2: Unlimited Subscription
Users subscribe monthly or yearly with unlimited usage during the subscription period. Supports trial periods.

Best for: Standard SaaS products that don't need granular usage control.
Configure Subscription Plans
Configure in SUBSCRIPTION_PLANS in config/payment.ts:
export const SUBSCRIPTION_PLANS = {
basic: {
priceMonthly: 9.99, // Monthly price (USD)
priceYearly: 99.99, // Yearly price (USD)
priceMonthlyCNY: 29, // Monthly price (CNY)
priceYearlyCNY: 299, // Yearly price (CNY)
name: 'Basic',
features: ['50 articles / month', '...'],
recommended: false
},
pro: {
priceMonthly: 29.99,
priceYearly: 299.99,
name: 'Pro',
features: ['Unlimited articles', '...'],
recommended: true
}
// max: { ... },
// ultra: { ... }, // 4th plan (optional)
}Configure Trial Period
export const SUBSCRIPTION_UNLIMITED_CONFIG = {
trialDays: 7, // Trial days
trialPlan: 'pro' as SubscriptionPlan // Plan that supports trial
}Each user can only trial once — the system tracks this automatically. By default, only the pro plan supports trial — this is industry standard: let users try the premium tier for free, and after experiencing the better features, they're more likely to convert.
Mode 3: Quota Subscription
Triple credits system: subscription quota resets monthly, bonus credits expire per batch (default 30 days), purchased credits never expire. When quota runs out, users can buy extra credit packs to continue. Consumption priority: subscription quota → bonus credits → purchased credits.

Best for: SaaS products that need usage control with flexibility, like Claude Pro's model.
Configuration
Quota Subscription uses both SUBSCRIPTION_PLANS and PACKAGES:
- The
quotafield inSUBSCRIPTION_PLANSdefines the monthly quota PACKAGESdefines the extra credit packs available for purchase
// In SUBSCRIPTION_PLANS
pro: {
priceMonthly: 29.99,
priceYearly: 299.99,
name: 'Pro',
quota: 500, // Monthly subscribers get 500 uses/month
quotaYearly: 750, // Yearly subscribers get 750 uses/month (yearly perk)
// ...
}Mode 4: Lifetime
Users pay once and own it forever with unlimited usage.

Best for: UI component libraries, templates, toolkits, and other one-time delivery products.
Configure Lifetime Plans
Configure in LIFETIME_PLANS in config/payment.ts:
export const LIFETIME_PLANS = {
standard: {
price: 279, // USD price
priceCNY: 1699, // CNY price
originalPrice: 349, // Original price (for strikethrough display)
originalPriceCNY: 1999,
name: 'Lifetime',
features: ['200+ components', 'Lifetime updates', '...'],
recommended: false
},
exclusive: {
price: 399.99,
name: 'Exclusive',
features: ['Everything in Lifetime', 'Priority support', '...'],
recommended: true
}
}Key points:
- Supports 1–3 lifetime plans, keys are fixed as
standard,exclusive,ultimate— do not modify originalPriceis used to display a strikethrough price, creating a sense of discount- Comment out any plan you don't need
Mode Detection Utility Functions
config/payment.ts exports a set of utility functions for mode detection in your code:
import {
isCreditsMode, // Is current mode credits
isSubscriptionUnlimitedMode, // Is current mode unlimited subscription
isSubscriptionQuotaMode, // Is current mode quota subscription
isLifetimeMode, // Is current mode lifetime
hasCredits, // Does current mode use credits (credits or subscription_quota)
isSubscriptionMode // Is current mode a subscription type (unlimited or quota)
} from '@/config/payment'