SRM is a command-line interface tool designed to simplify the management of Stripe resources, particularly for handling products, prices, and checkout sessions.
- Deploy product and price configurations to Stripe
- Pull existing configurations from Stripe
- Create subscription and one-time payment checkout sessions
- TypeScript support for configuration files
- Environment variable management
npm install -g srmCreate a srm.config.ts file in your project root:
import{PreSRMConfig}from"srm";import{taxCodes}from"srm";exportconstconfig={features: {basicAnalytics: 'Basic Analytics',aiReporting: 'AI Reporting',},products: {hobby: {name: 'Hobby Plan',id: 'hobby',taxCode: taxCodes.SOFTWARE_AS_A_SERVICE,prices: {monthly: {amount: 1000,interval: 'month',type: 'recurring',},lifetime: {amount: 20000,interval: 'one_time',type: 'one_time',},},features: ['basicAnalytics'],},// ... other products},}satisfiesPreSRMConfig;Deploy configuration to Stripe:
srm deploy [--config <path>] [--env <path>]Pull configuration from Stripe:
srm pull [--config <path>] [--env <path>]
Options:
--config <path>: Specify a custom path for the configuration file (default:srm.config.ts)--env <path>: Specify a custom path for the .env file (default:.env)
Create a .env file in your project root:
STRIPE_SECRET_KEY=your_stripe_secret_key_here
You can also use SRM programmatically in your TypeScript/JavaScript projects:
import{createSRM}from'srm';importStripefrom'stripe';import{config}from'./srm.config';conststripe=newStripe(process.env.STRIPE_SECRET_KEYasstring,{apiVersion: "2024-06-20",});constsrm=createSRM(config,{ stripe });// Create a subscription checkout URLconstsubscriptionUrl=awaitsrm.products.enterprise.prices.annual.createSubscriptionCheckoutUrl({userId: "user123",successUrl: "http://example.com/success",cancelUrl: "http://example.com/cancel",});// Create a one-time payment checkout URLconstoneTimeUrl=awaitsrm.products.hobby.prices.lifetime.createOneTimePaymentCheckoutUrl({userId: "user456",successUrl: "http://example.com/success",cancelUrl: "http://example.com/cancel",});To run the CLI tool locally during development:
npm run srm -- <command> [options]MIT