mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
fix payments
This commit is contained in:
@@ -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];
|
||||
|
||||
21
shared/schema/CustomPremiumPriceSchema.ts
Normal file
21
shared/schema/CustomPremiumPriceSchema.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { model, Schema } from 'mongoose';
|
||||
|
||||
export type TCustomPremiumPrice = {
|
||||
tag: string,
|
||||
price_id: number,
|
||||
count_limit: number,
|
||||
ai_message_limit: number,
|
||||
price: string,
|
||||
price_test?: string
|
||||
}
|
||||
|
||||
const CustomPremiumPriceSchema = new Schema<TCustomPremiumPrice>({
|
||||
tag: { type: String, required: true },
|
||||
price_id: { type: Number, required: true },
|
||||
count_limit: { type: Number, required: true },
|
||||
ai_message_limit: { type: Number, required: true },
|
||||
price: { type: String, required: true },
|
||||
price_test: { type: String },
|
||||
})
|
||||
|
||||
export const CustomPremiumPriceModel = model<TCustomPremiumPrice>('custom_premium_prices', CustomPremiumPriceSchema);
|
||||
Reference in New Issue
Block a user