fix payments

This commit is contained in:
Emily
2024-06-12 15:43:23 +02:00
parent b7c3ef19ba
commit 6a7143c8d4
8 changed files with 173 additions and 89 deletions

View File

@@ -1,9 +1,8 @@
import { CustomPremiumPriceModel } from "../schema/CustomPremiumPriceSchema";
export type PREMIUM_TAG = typeof PREMIUM_TAGS[number];
export const PREMIUM_TAGS = [
'FREE', 'PLAN_1', 'PLAN_2', 'CUSTOM_1'
] as const;
export const PREMIUM_TAGS = ['FREE', 'PLAN_1', 'PLAN_2', 'CUSTOM_1'] as const;
export type PREMIUM_DATA = {
@@ -34,7 +33,7 @@ export const PREMIUM_PLAN: Record<PREMIUM_TAG, PREMIUM_DATA> = {
COUNT_LIMIT: 500_000,
AI_MESSAGE_LIMIT: 5_000,
PRICE: 'price_1POKCKB2lPUiVs9Vol8XOmhW',
PRICE_TEST: ''
PRICE_TEST: 'price_1POK34B2lPUiVs9VIROb0IIV'
},
CUSTOM_1: {
ID: 1001,
@@ -45,6 +44,18 @@ export const PREMIUM_PLAN: Record<PREMIUM_TAG, PREMIUM_DATA> = {
}
}
CustomPremiumPriceModel.find({}).then(custom_prices => {
for (const custom_price of custom_prices) {
PREMIUM_PLAN[custom_price.tag] = {
ID: custom_price.price_id,
COUNT_LIMIT: custom_price.count_limit,
AI_MESSAGE_LIMIT: custom_price.ai_message_limit,
PRICE: custom_price.price,
PRICE_TEST: custom_price.price_test || ''
}
}
});
export function getPlanFromTag(tag: PREMIUM_TAG) {
return PREMIUM_PLAN[tag];