Welcome to Nebutra Sailor Docs 🎉
ChangelogIntroductionLicensing
Help Center (External) ↗

Manage Plans

Create Stripe products, configure plan limits in code, and add new billing tiers to Nebutra.

Plan tiers (FREE/PRO/ENTERPRISE) are a subscription concept and still map to Stripe products today (legacy, per ADR 2026-09-26). This is separate from one-time card checkout, which runs on Creem — see Creem integration.

Prerequisites

  • Stripe account with API access
  • Environment variables configured (see Payments Overview)
  • Stripe CLI installed: npm install -g stripe

Step 1: Create products in Stripe

Each billing tier maps to a Stripe product with one or more prices. Run the Stripe CLI to create them, or use the Dashboard UI.

# Create the PRO product
stripe products create \
  --name="Nebutra PRO" \
  --description="100,000 API calls/month, 10 members, email support"

# Create a monthly recurring price for PRO ($29/month)
stripe prices create \
  --product=prod_REPLACE_WITH_PRO_ID \
  --unit-amount=4900 \
  --currency=usd \
  --recurring[interval]=month \
  --nickname="PRO Monthly"

# Create the ENTERPRISE product (custom pricing — set price manually)
stripe products create \
  --name="Nebutra ENTERPRISE" \
  --description="Unlimited, SSO, SLA, custom contract"
  1. Go to Stripe Dashboard → Products → Add product.
  2. Set the name, description, and pricing for each tier.
  3. Copy the Price ID (price_...) for each tier into your .env file.

Step 2: Set price ID environment variables

After creating prices in Stripe, record their IDs — one per interval, matching packages/commerce/billing/src/catalog/checkout-plan.ts:

STRIPE_PRICE_ID_PRO_MONTHLY=price_xxxxxxxxxxxxxxxxxxxx
STRIPE_PRICE_ID_PRO_YEARLY=price_xxxxxxxxxxxxxxxxxxxx
STRIPE_PRICE_ID_ENTERPRISE_MONTHLY=price_xxxxxxxxxxxxxxxxxxxx
STRIPE_PRICE_ID_ENTERPRISE_YEARLY=price_xxxxxxxxxxxxxxxxxxxx

# Optional trial override per plan
STRIPE_TRIAL_DAYS_PRO=14
STRIPE_TRIAL_DAYS_ENTERPRISE=0

resolveCheckoutOffer reads the price id for a { plan, interval } selection straight from these env vars — there is no hardcoded price table to edit for the checkout price itself.

Step 3: Configure plan limits and features

Plan quotas and feature gates are not a static file — they are PlanConfigService (packages/commerce/billing/src/config/plan-config.ts), a database-driven, Redis-cached config keyed by plan: "FREE" | "PRO" | "ENTERPRISE", with a version field for grandfathering existing customers when you change limits. Each PlanConfig row holds features (Record<string, FeatureValue>) and limits (Record<string, LimitConfig> — limit: -1 means unlimited).

What is code is the entitlement catalog each plan draws from — packages/commerce/billing/src/entitlements/service.ts:

export const FEATURES = {
  // feature keys checked by requireFeature() — e.g. "ai.chat", "ai.embeddings", "api.access"
} as const;

export const PLAN_FEATURES: Record<Plan, FeatureKey[]> = {
  FREE: [/* … */],
  PRO: [/* … */],
  ENTERPRISE: [/* … */],
};

Step 4: Check a feature entitlement

Use isPlanFeature or checkEntitlement from @nebutra/billing anywhere in backend code:

import { isPlanFeature, checkEntitlement } from "@nebutra/billing";

const allowed = isPlanFeature("PRO", "ai.chat");
// → true/false, from the static PLAN_FEATURES table

const result = await checkEntitlement(organizationId, "ai.chat");
// → also accounts for per-organization grants/overrides, not just the plan default

The API gateway enforces this at the edge with the requireFeature middleware (backends/gateway/src/middlewares/entitlements.ts):

app.post("/api/v1/ai/generate", requireFeature("ai.images", 1), handler);

Adding a new plan tier

Use the Stripe CLI or Dashboard to create a new product and price. Copy the Price ID.

STRIPE_PRICE_ID_TEAMS_MONTHLY=price_xxxxxxxxxxxxxxxxxxxx

CHECKOUT_PLANS in catalog/checkout-plan.ts is currently ["pro", "enterprise"] — a new tier also needs an entry there so checkout can resolve its price id.

Insert or update the PlanConfig row (via the database, not a source file) with the new plan's limits and features.

export const PLAN_FEATURES: Record<Plan, FeatureKey[]> = {
  // …
  TEAMS: ["ai.chat", "ai.embeddings", "api.access"],
};

Updating plan limits

Plan limits live in the database (PlanConfigService), cached in Redis — not in a source file — so changing a limit does not require a deploy. PlanConfig.version supports grandfathering: a customer's active planVersion override keeps them on the limits they signed up for until you migrate them.

Subscription state itself (which plan a tenant is on) updates as soon as the Stripe webhook is received and processed — see Webhooks. There is no polling delay.

Related

Payments Overview

Architecture, environment variables, and Stripe Dashboard setup.

Paywall

Gate features and API routes by plan tier.

How is this guide?

Edit on GitHub

Last updated on

On this page

Prerequisites
Step 1: Create products in Stripe
Step 2: Set price ID environment variables
Step 3: Configure plan limits and features
Step 4: Check a feature entitlement
Adding a new plan tier
Updating plan limits
Related