feat: Implement Stripe integration for subscription management, including new services, controllers, Prisma models, and webhook handling.
This commit is contained in:
@@ -1533,6 +1533,45 @@ async function main() {
|
||||
|
||||
console.log('');
|
||||
|
||||
// =============================================
|
||||
// Seed Subscription Plans
|
||||
// =============================================
|
||||
console.log('💳 Seeding Subscription Plans...');
|
||||
|
||||
const subscriptionPlans = [
|
||||
{
|
||||
name: 'Professional Annual',
|
||||
description: 'Full access to all agent features',
|
||||
stripePriceId: process.env.STRIPE_PRICE_ID,
|
||||
amount: 49900,
|
||||
currency: 'usd',
|
||||
interval: 'year',
|
||||
features: JSON.stringify([
|
||||
'Agent Co-Marketing',
|
||||
'Priority 24/7 Support',
|
||||
'Whitelabel Client Portals',
|
||||
'Advanced CRM Tools & Analytics',
|
||||
]),
|
||||
isActive: true,
|
||||
sortOrder: 1,
|
||||
},
|
||||
];
|
||||
|
||||
for (const plan of subscriptionPlans) {
|
||||
const existingPlan = await prisma.subscriptionPlan.findUnique({
|
||||
where: { stripePriceId: plan.stripePriceId },
|
||||
});
|
||||
|
||||
if (existingPlan) {
|
||||
console.log(` ⚠️ Plan "${plan.name}" already exists`);
|
||||
} else {
|
||||
await prisma.subscriptionPlan.create({ data: plan });
|
||||
console.log(` ✅ Created plan: ${plan.name} ($${(plan.amount / 100).toFixed(2)}/${plan.interval})`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
// =============================================
|
||||
// Summary
|
||||
// =============================================
|
||||
@@ -1544,6 +1583,7 @@ async function main() {
|
||||
const systemSectionCount = await prisma.profileSection.count({ where: { isSystem: true } });
|
||||
const agentTypeSectionCount = await prisma.agentTypeSection.count();
|
||||
const cmsContentCount = await prisma.cmsContent.count();
|
||||
const planCount = await prisma.subscriptionPlan.count();
|
||||
|
||||
console.log('📊 Database Summary:');
|
||||
console.log(` Total Users: ${userCount}`);
|
||||
@@ -1553,6 +1593,7 @@ async function main() {
|
||||
console.log(` Profile Fields: ${fieldCount}`);
|
||||
console.log(` Section Assignments: ${agentTypeSectionCount}`);
|
||||
console.log(` CMS Content: ${cmsContentCount}`);
|
||||
console.log(` Plans: ${planCount}`);
|
||||
console.log('\n🌱 Seeding completed!\n');
|
||||
|
||||
await prisma.$disconnect();
|
||||
|
||||
Reference in New Issue
Block a user