- Fix saveWiFiPassword to use encrypted passwords map instead of decrypted - Fix getWiFiPassword to decrypt from encrypted storage - Fix test expectations for migration and encryption functions - Remove unused error variables to fix linting warnings - All 27 tests now passing with proper encryption/decryption flow The WiFi credentials cache feature was already implemented but had bugs where encrypted and decrypted password maps were being mixed. This commit ensures proper encryption is maintained throughout the storage lifecycle.
95 lines
2.7 KiB
JavaScript
95 lines
2.7 KiB
JavaScript
/**
|
|
* Setup Stripe Products and Prices
|
|
* Run once: node scripts/setup-stripe-products.js
|
|
*/
|
|
|
|
require('dotenv').config();
|
|
const Stripe = require('stripe');
|
|
|
|
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
|
|
|
async function setupStripeProducts() {
|
|
console.log('Setting up Stripe products and prices...\n');
|
|
|
|
try {
|
|
// 1. Create Starter Kit product
|
|
console.log('Creating Starter Kit product...');
|
|
const starterKit = await stripe.products.create({
|
|
name: 'WellNuo Starter Kit',
|
|
description: '2x Motion Sensors + 1x Door Sensor + 1x Hub - Everything you need to start monitoring',
|
|
metadata: {
|
|
type: 'hardware',
|
|
sku: 'KIT-STARTER-001'
|
|
}
|
|
});
|
|
console.log(`✓ Product created: ${starterKit.id}`);
|
|
|
|
// Create price for Starter Kit ($399 one-time)
|
|
const starterKitPrice = await stripe.prices.create({
|
|
product: starterKit.id,
|
|
unit_amount: 39900, // $399.00
|
|
currency: 'usd',
|
|
metadata: {
|
|
display_name: 'Starter Kit'
|
|
}
|
|
});
|
|
console.log(`✓ Price created: ${starterKitPrice.id} ($399.00)\n`);
|
|
|
|
// 2. Create Premium Subscription product
|
|
console.log('Creating Premium Subscription product...');
|
|
const premium = await stripe.products.create({
|
|
name: 'WellNuo Premium',
|
|
description: 'AI Julia assistant, 90-day activity history, invite up to 5 family members',
|
|
metadata: {
|
|
type: 'subscription',
|
|
tier: 'premium'
|
|
}
|
|
});
|
|
console.log(`✓ Product created: ${premium.id}`);
|
|
|
|
// Create price for Premium ($49/month)
|
|
const premiumPrice = await stripe.prices.create({
|
|
product: premium.id,
|
|
unit_amount: 4900, // $49.00
|
|
currency: 'usd',
|
|
recurring: {
|
|
interval: 'month'
|
|
},
|
|
metadata: {
|
|
display_name: 'Premium Monthly'
|
|
}
|
|
});
|
|
console.log(`✓ Price created: ${premiumPrice.id} ($49.00/month)\n`);
|
|
|
|
// Summary
|
|
console.log('='.repeat(50));
|
|
console.log('STRIPE SETUP COMPLETE');
|
|
console.log('='.repeat(50));
|
|
console.log('\nAdd these to your .env file:\n');
|
|
console.log(`STRIPE_PRICE_STARTER_KIT=${starterKitPrice.id}`);
|
|
console.log(`STRIPE_PRICE_PREMIUM=${premiumPrice.id}`);
|
|
console.log(`STRIPE_PRODUCT_STARTER_KIT=${starterKit.id}`);
|
|
console.log(`STRIPE_PRODUCT_PREMIUM=${premium.id}`);
|
|
console.log('\n');
|
|
|
|
return {
|
|
starterKit: {
|
|
productId: starterKit.id,
|
|
priceId: starterKitPrice.id
|
|
},
|
|
premium: {
|
|
productId: premium.id,
|
|
priceId: premiumPrice.id
|
|
}
|
|
};
|
|
|
|
} catch (error) {
|
|
console.error('Error setting up Stripe:', error.message);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
setupStripeProducts()
|
|
.then(() => process.exit(0))
|
|
.catch(() => process.exit(1));
|