56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
/**
|
|
* Script to list all Stripe prices
|
|
* Run with: node scripts/list-stripe-prices.js
|
|
*/
|
|
|
|
const Stripe = require('stripe');
|
|
|
|
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || 'sk_test_51R8p8R4atifoBlu1U9sMJh3rkQbO1G1xeguwFMQYMIMeaLNrTX7YFO5Ovu3P1VfbwcOoEmiy6I0UWi4DThNNzHG100YF75TnJr');
|
|
|
|
async function listPrices() {
|
|
console.log('Fetching Stripe prices...\n');
|
|
|
|
try {
|
|
const prices = await stripe.prices.list({ limit: 50, expand: ['data.product'] });
|
|
|
|
if (prices.data.length === 0) {
|
|
console.log('No prices found. You need to create prices in Stripe Dashboard.');
|
|
console.log('\nSteps:');
|
|
console.log('1. Go to https://dashboard.stripe.com/products');
|
|
console.log('2. Click on each product (Starter, Pro, Enterprise)');
|
|
console.log('3. Add a recurring price (monthly and yearly)');
|
|
console.log('4. Copy the Price IDs (format: price_xxxxx)');
|
|
return;
|
|
}
|
|
|
|
console.log('Available Prices:\n');
|
|
console.log('='.repeat(100));
|
|
|
|
for (const price of prices.data) {
|
|
const product = typeof price.product === 'object' ? price.product : { name: price.product };
|
|
const interval = price.recurring ? `${price.recurring.interval}ly` : 'one-time';
|
|
const amount = (price.unit_amount / 100).toFixed(2);
|
|
|
|
console.log(`Price ID: ${price.id}`);
|
|
console.log(`Product: ${product.name || product.id}`);
|
|
console.log(`Amount: ${amount} ${price.currency.toUpperCase()}`);
|
|
console.log(`Interval: ${interval}`);
|
|
console.log(`Active: ${price.active}`);
|
|
console.log('-'.repeat(100));
|
|
}
|
|
|
|
console.log('\n\nCopy the relevant Price IDs to your .env file:');
|
|
console.log('STRIPE_STARTER_MONTHLY_PRICE_ID=price_xxxxx');
|
|
console.log('STRIPE_STARTER_YEARLY_PRICE_ID=price_xxxxx');
|
|
console.log('STRIPE_PRO_MONTHLY_PRICE_ID=price_xxxxx');
|
|
console.log('STRIPE_PRO_YEARLY_PRICE_ID=price_xxxxx');
|
|
console.log('STRIPE_ENTERPRISE_MONTHLY_PRICE_ID=price_xxxxx');
|
|
console.log('STRIPE_ENTERPRISE_YEARLY_PRICE_ID=price_xxxxx');
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching prices:', error.message);
|
|
}
|
|
}
|
|
|
|
listPrices();
|