add: 4x pro plan

This commit is contained in:
2026-03-22 05:33:39 +04:00
parent 014976027b
commit 1049677f19
7 changed files with 86 additions and 34 deletions
+3 -2
View File
@@ -219,10 +219,11 @@ async function applyPlan(payment: any) {
const [acc] = await sql`SELECT plan, plan_expires_at FROM accounts WHERE id = ${payment.account_id}`;
const now = new Date();
const expiry = acc.plan_expires_at ? new Date(acc.plan_expires_at) : null;
const base = (acc.plan === "pro" && expiry && expiry > now) ? expiry : now;
const samePlan = acc.plan === payment.plan && expiry && expiry > now;
const base = samePlan ? expiry : now;
const newExpiry = new Date(base);
newExpiry.setMonth(newExpiry.getMonth() + payment.months);
await sql`UPDATE accounts SET plan = 'pro', plan_expires_at = ${newExpiry.toISOString()} WHERE id = ${payment.account_id}`;
await sql`UPDATE accounts SET plan = ${payment.plan}, plan_expires_at = ${newExpiry.toISOString()} WHERE id = ${payment.account_id}`;
}
console.log(`Payment ${payment.id} activated: ${payment.plan} for account ${payment.account_id}`);
}
+4
View File
@@ -3,6 +3,10 @@ export const PLANS = {
label: "Pro",
monthlyUsd: 12,
},
pro4x: {
label: "Pro 4x",
monthlyUsd: 48,
},
lifetime: {
label: "Lifetime",
priceUsd: 140,
+2 -1
View File
@@ -72,7 +72,8 @@ export const routes = new Elysia()
if (!available.includes(coin)) { set.status = 400; return { error: `${coin} is temporarily unavailable` }; }
// Calculate amount
const amountUsd = plan === "lifetime" ? PLANS.lifetime.priceUsd : PLANS.pro.monthlyUsd * (months ?? 1);
const planPricing = plan === "lifetime" ? null : (plan === "pro4x" ? PLANS.pro4x : PLANS.pro);
const amountUsd = plan === "lifetime" ? PLANS.lifetime.priceUsd : planPricing!.monthlyUsd * (months ?? 1);
const rates = await getExchangeRates();
const rate = rates[coin];
if (!rate) { set.status = 500; return { error: "Could not fetch exchange rate" }; }