
Prices as Code
Define your product pricing schemas with type-safe definitions and synchronize them with Stripe.
v3.3.0 Get Started View on GitHubPrices as Code is a TypeScript library that makes it easy to manage product pricing with Stripe and allows for extending to custom providers.
🎉 What's New in v3.3.0
- Pull Model: Generate configuration files from existing provider data
- Bidirectional Sync: Now supports both Push and Pull operations
- Onboarding Support: Easily onboard existing customers with the Pull mode
- Multiple Format Options: Configure in YAML, JSON, or TypeScript
Type-Safe
Use TypeScript and Zod schemas to define your pricing models with full type safety.
Multi-Provider
Support for Stripe with an extensible architecture allowing for custom providers.
Bidirectional
Push local config to providers or pull provider data into your codebase.
Idempotent
Run it multiple times, only changes what's needed. Perfect for CI/CD pipelines.
Metadata Support
Add custom metadata to your products and prices for enhanced flexibility.
Quick Installation
npm install prices-as-code
or
yarn add prices-as-code
Example Configuration
import { Config } from 'prices-as-code';
const config: Config = {
products: [
{
provider: 'stripe',
name: 'Basic Plan',
description: 'For individuals and small teams',
features: ['5 projects', '10GB storage', 'Email support']
},
{
provider: 'stripe',
name: 'Pro Plan',
description: 'For growing businesses',
features: ['Unlimited projects', '100GB storage', 'Priority support']
}
],
prices: [
{
provider: 'stripe',
name: 'Basic Monthly',
unitAmount: 999, // $9.99
currency: 'usd',
type: 'recurring',
recurring: {
interval: 'month'
},
productKey: 'basic_plan'
}
]
};
Why Prices as Code?
Managing pricing across multiple billing providers is complex and error-prone. Prices as Code provides a unified way to:
- Centralize Pricing Logic: Define pricing once, deploy everywhere
- Ensure Consistency: Maintain the same pricing information across systems
- Reduce Errors: Catch pricing mistakes before they happen with type safety
- Simplify Workflow: Integrate pricing management into your CI/CD pipeline
Explore the Documentation
Step-by-step guides to get you started with Prices as Code
View GuidesDetailed API documentation for developers
View APIInformation about supported billing providers
View ProvidersSupported Providers
Currently, Prices as Code supports this billing provider:
Looking for more providers? Check out Adding Custom Providers.
Prices as Code is currently in active development. APIs may change in future versions.
License
This project is licensed under the MIT License