mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
new selfhosted version
This commit is contained in:
18
dashboard/server/api/payments/cancel_plan.ts
Normal file
18
dashboard/server/api/payments/cancel_plan.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { PremiumModel } from "~/shared/schema/PremiumSchema";
|
||||
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
//TODO: SELFHOST
|
||||
|
||||
const ctx = await getRequestContext(event, 'flag:allowAnonRegistered');
|
||||
const { user_id } = ctx;
|
||||
|
||||
const tRpc = useTRPC();
|
||||
|
||||
const premiumData = await PremiumModel.findOne({ user_id });
|
||||
if (!premiumData) throw createError({ status: 400, message: 'Error getting premium data. Please contact support.' });
|
||||
|
||||
const result = await tRpc.payments.subscription.cancelPlan.mutate({ user_id, customer_id: premiumData.customer_id });
|
||||
return result;
|
||||
});
|
||||
Reference in New Issue
Block a user