fix dashboard + payments

This commit is contained in:
Emily
2025-04-13 18:15:43 +02:00
parent 1d5dad44fa
commit 946f9d4d32
22 changed files with 272 additions and 521 deletions

View File

@@ -1,6 +1,6 @@
import { getPlanFromId, PREMIUM_PLAN } from "@data/PREMIUM";
import { canTryAppsumoCode, checkAppsumoCode, useAppsumoCode, useTryAppsumoCode } from "~/server/services/AppsumoService";
import StripeService from '~/server/services/StripeService';
function getPlanToActivate(current_plan_id: number) {
if (current_plan_id === PREMIUM_PLAN.FREE.ID) {
@@ -38,13 +38,13 @@ export default defineEventHandler(async event => {
const valid = await checkAppsumoCode(code);
if (!valid) return setResponseStatus(event, 400, 'Code not valid');
const currentPlan = getPlanFromId(project.premium_type);
if (!currentPlan) return setResponseStatus(event, 400, 'Current plan not found');
const planToActivate = getPlanToActivate(currentPlan.ID);
if (!planToActivate) return setResponseStatus(event, 400, 'Cannot use code on current plan');
// const currentPlan = getPlanFromId(project.premium_type);
// if (!currentPlan) return setResponseStatus(event, 400, 'Current plan not found');
// const planToActivate = getPlanToActivate(currentPlan.ID);
// if (!planToActivate) return setResponseStatus(event, 400, 'Cannot use code on current plan');
await StripeService.createSubscription(project.customer_id, planToActivate.ID);
// await StripeService.createSubscription(project.customer_id, planToActivate.ID);
await useAppsumoCode(pid, code);
// await useAppsumoCode(pid, code);
});