fix: restrict telegram pricing to private group

This commit is contained in:
2569718930@qq.com
2026-06-05 17:26:43 +08:00
parent 09979f3bb5
commit 2a6c826f50
10 changed files with 129 additions and 24 deletions
@@ -22,20 +22,17 @@ import { usePaymentState } from "./usePaymentState";
import { useWalletBind } from "./useWalletBind";
import { usePaymentFlow } from "./usePaymentFlow";
import { useBilling } from "./useBilling";
// ============================================================
function telegramMemberAmountUsdc(pricing?: TelegramPricing | null) {
if (!pricing?.is_group_member) return "";
const amount = String(pricing.amount_usdc || "").trim();
const numeric = Number(amount);
return Number.isFinite(numeric) && numeric > 0 ? amount : "";
}
import {
isTelegramPrivateGroupPriceEligible,
telegramPrivateGroupAmountUsdc,
} from "./telegram-pricing";
function applyTelegramGroupPricingToPlanList(
plans: PaymentPlan[],
pricing?: TelegramPricing | null,
): PaymentPlan[] {
const telegramAmountUsdc = telegramMemberAmountUsdc(pricing);
if (!isTelegramPrivateGroupPriceEligible(pricing)) return plans;
const telegramAmountUsdc = telegramPrivateGroupAmountUsdc(pricing);
if (!telegramAmountUsdc) return plans;
return plans.map((plan) =>
String(plan.plan_code || "").toLowerCase() === "pro_monthly"