From 72ceb7971d0574f8166fe84d69e56c2cdbe79b76 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 5 Apr 2025 16:42:52 +0200 Subject: [PATCH] update pricing data --- dashboard/server/api/project/delete.delete.ts | 3 --- dashboard/server/api/user/delete_account.delete.ts | 2 +- payments/src/controllers/WebhookController.ts | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dashboard/server/api/project/delete.delete.ts b/dashboard/server/api/project/delete.delete.ts index 5ee8bf5..c1b39b9 100644 --- a/dashboard/server/api/project/delete.delete.ts +++ b/dashboard/server/api/project/delete.delete.ts @@ -1,7 +1,6 @@ import { ProjectModel } from "@schema/project/ProjectSchema"; import { ProjectCountModel } from "@schema/project/ProjectsCounts"; import { SessionModel } from "@schema/metrics/SessionSchema"; -import { LimitNotifyModel } from "@schema/broker/LimitNotifySchema"; import { AiChatModel } from "@schema/ai/AiChatSchema"; export default defineEventHandler(async event => { @@ -18,14 +17,12 @@ export default defineEventHandler(async event => { const projectDeletation = ProjectModel.deleteOne({ _id: project_id }); const countDeletation = ProjectCountModel.deleteMany({ project_id }); const sessionsDeletation = SessionModel.deleteMany({ project_id }); - const notifiesDeletation = LimitNotifyModel.deleteMany({ project_id }); const aiChatsDeletation = AiChatModel.deleteMany({ project_id }); const results = await Promise.all([ projectDeletation, countDeletation, sessionsDeletation, - notifiesDeletation, aiChatsDeletation ]) diff --git a/dashboard/server/api/user/delete_account.delete.ts b/dashboard/server/api/user/delete_account.delete.ts index 3d84b6c..27ecbdc 100644 --- a/dashboard/server/api/user/delete_account.delete.ts +++ b/dashboard/server/api/user/delete_account.delete.ts @@ -34,6 +34,7 @@ export default defineEventHandler(async event => { const passwordDeletation = await PasswordModel.deleteMany({ user_id: userData.id }); const limitdeletation = await UserLimitModel.deleteMany({ user_id: userData.id }); + const notifiesDeletation = await LimitNotifyModel.deleteMany({ user_id: userData.id }); await StripeService.deleteCustomer(premium.customer_id); @@ -43,7 +44,6 @@ export default defineEventHandler(async event => { const userSettingsDeletation = await UserSettingsModel.deleteOne({ project_id }); const countDeletation = await ProjectCountModel.deleteMany({ project_id }); const sessionsDeletation = await SessionModel.deleteMany({ project_id }); - const notifiesDeletation = await LimitNotifyModel.deleteMany({ project_id }); const aiChatsDeletation = await AiChatModel.deleteMany({ project_id }); //Shields diff --git a/payments/src/controllers/WebhookController.ts b/payments/src/controllers/WebhookController.ts index f4776be..e6a7827 100644 --- a/payments/src/controllers/WebhookController.ts +++ b/payments/src/controllers/WebhookController.ts @@ -69,6 +69,9 @@ export async function onPaymentSuccess(event: Event.InvoicePaidEvent) { const databaseSubscription = premiumData.subscription_id; + const currentSubscriptionData = await StripeService.getSubscription(subscription_id); + if (!currentSubscriptionData || currentSubscriptionData.status !== 'active') return { error: 'subscription not active' } + if (databaseSubscription != subscription_id) { try { await StripeService.deleteSubscription(databaseSubscription);