@venturekit-pro/billing
v0.0.0-dev.20260507015944
Published
Invoicing, plans, usage tracking, and feature gating for VentureKit
Readme
@venturekit-pro/billing
Warning: This package is in active development and not production-ready. APIs may change without notice.
Billing and invoicing for VentureKit — plan definitions, feature limits, usage-to-invoice mapping, and auto-migration support.
Installation
npm install @venturekit-pro/billing@devOverview
@venturekit-pro/billing provides:
- Plan definitions —
definePlans()with feature limits and pricing tiers - Subscription management — create, upgrade, downgrade, cancel, pause, resume
- Invoice generation — from plan + usage, with tax calculation
- Usage tracking — record and meter feature usage
- Feature gating — plan-based and usage-based access control
- Auto-migrations — billing tables created automatically via
vk migrate
Note: This package handles invoicing and plan management. Payment processing is NOT included — integrate any payment provider separately.
Defining Plans
import { definePlans } from '@venturekit-pro/billing';
const plans = definePlans([
{
id: 'free',
name: 'Free',
features: {
projects: { limit: 3 },
storage: { limit: 1_000_000_000 }, // 1 GB
apiRequests: { limit: 10_000, period: 'month' },
support: false,
},
},
{
id: 'pro',
name: 'Pro',
features: {
projects: { limit: 50 },
storage: { limit: 100_000_000_000 }, // 100 GB
apiRequests: { limit: 1_000_000, period: 'month' },
support: true,
},
},
]);Feature Checking
import { getFeatureLimit, hasFeature } from '@venturekit-pro/billing';
const maxProjects = getFeatureLimit(plans, 'free', 'projects');
// → 3
const hasSupport = hasFeature(plans, 'free', 'support');
// → falseUsage-to-Invoice Mapping
import { mapUsageToLineItems } from '@venturekit-pro/billing';
const lineItems = mapUsageToLineItems(currentUsage, planFeatures);
// Returns structured line items for invoice generationAuto-Migrations
When @venturekit-pro/billing is added to a project, vk migrate automatically discovers and applies billing-related database tables:
import { getBillingMigrationsDir } from '@venturekit-pro/billing';
const migrationsDir = getBillingMigrationsDir();
// Returns path to SQL migration filesAPI Reference
See the API reference for full documentation.
License
Apache-2.0 — see LICENSE for details.
