From 2a6c826f50acd1d5b0557dd600a5968e1030c799 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Fri, 5 Jun 2026 17:26:43 +0800 Subject: [PATCH] fix: restrict telegram pricing to private group --- frontend/components/account/AccountCenter.tsx | 23 ++++++++- .../__tests__/paymentReferralPricing.test.ts | 24 ++++++++-- frontend/components/account/account-copy.ts | 1 + .../components/account/telegram-pricing.ts | 19 ++++++++ frontend/components/account/types.ts | 1 + .../components/account/useAccountPayment.ts | 15 +++--- frontend/components/account/useBilling.ts | 10 ++-- src/auth/telegram_group_pricing.py | 11 ++++- src/payments/contract_checkout.py | 2 +- tests/test_telegram_group_pricing.py | 47 +++++++++++++++++-- 10 files changed, 129 insertions(+), 24 deletions(-) create mode 100644 frontend/components/account/telegram-pricing.ts diff --git a/frontend/components/account/AccountCenter.tsx b/frontend/components/account/AccountCenter.tsx index 5d8339e7..8eecb7cd 100644 --- a/frontend/components/account/AccountCenter.tsx +++ b/frontend/components/account/AccountCenter.tsx @@ -62,6 +62,10 @@ import { import { createAccountCopy } from "./account-copy"; import { resetWalletConnectProvider } from "./wallet"; import { useAccountPayment } from "./useAccountPayment"; +import { + isTelegramPrivateGroupPriceEligible, + telegramPrivateGroupAmountUsdc, +} from "./telegram-pricing"; // --- Main Component --- @@ -432,6 +436,12 @@ export function AccountCenter() { { plan_code: "pro_monthly", plan_id: 101, amount_usdc: "29.9", duration_days: 30 }, { plan_code: "pro_quarterly", plan_id: 102, amount_usdc: "79.9", duration_days: 90 }, ]; + const privateTelegramGroupPriceActive = isTelegramPrivateGroupPriceEligible( + backend?.telegram_pricing, + ); + const privateTelegramGroupAmount = telegramPrivateGroupAmountUsdc( + backend?.telegram_pricing, + ); const referral = backend?.referral; const referralCode = String(referral?.code || "").trim(); const appliedReferralCode = String(referral?.applied_code || "").trim(); @@ -1094,6 +1104,13 @@ export function AccountCenter() { const code = String(plan.plan_code || ""); const active = code === selectedPlanCode; const isQuarterly = code === "pro_quarterly"; + const isPrivateGroupMonthly = Boolean( + code === "pro_monthly" && + privateTelegramGroupPriceActive && + privateTelegramGroupAmount && + Number(plan.amount_usdc) === + Number(privateTelegramGroupAmount), + ); return (