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,38 +1,38 @@
import { getPlanFromId } from "@data/PREMIUM";
import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA";
import StripeService from '~/server/services/StripeService';
// import StripeService from '~/server/services/StripeService';
export default defineEventHandler(async event => {
const data = await getRequestDataOld(event, { requireSchema: false, allowGuests: false, allowLitlyx: false });
if (!data) return;
// const data = await getRequestDataOld(event, { requireSchema: false, allowGuests: false, allowLitlyx: false });
// if (!data) return;
const { project, pid } = data;
// const { project, pid } = data;
const body = await readBody(event);
// const body = await readBody(event);
const { planId } = body;
// const { planId } = body;
const PLAN = getPlanFromId(planId);
// const PLAN = getPlanFromId(planId);
if (!PLAN) {
console.error('PLAN', planId, 'NOT EXIST');
return setResponseStatus(event, 400, 'Plan not exist');
}
// if (!PLAN) {
// console.error('PLAN', planId, 'NOT EXIST');
// return setResponseStatus(event, 400, 'Plan not exist');
// }
const intent = await StripeService.createOnetimePayment(
StripeService.testMode ? PLAN.PRICE_TEST : PLAN.PRICE,
'https://dashboard.litlyx.com/payment_ok',
pid,
project.customer_id
)
// const intent = await StripeService.createOnetimePayment(
// StripeService.testMode ? PLAN.PRICE_TEST : PLAN.PRICE,
// 'https://dashboard.litlyx.com/payment_ok',
// pid,
// project.customer_id
// )
if (!intent) {
console.error('Cannot create Intent', { plan: PLAN });
return setResponseStatus(event, 400, 'Cannot create intent');
}
// if (!intent) {
// console.error('Cannot create Intent', { plan: PLAN });
// return setResponseStatus(event, 400, 'Cannot create intent');
// }
return intent.url;
// return intent.url;
});