fix: use one-star subscription probe

This commit is contained in:
admin committed 2026-10-21 14:27:23 +02:00
1 parent a5389e9927
commit 0dc54a26b9
4 files changed
+11 -15

No files matched your search

+1 -1
View File
@@ -1 +1 @@
0.1.0+68
0.1.0+69
+6 -6
View File
@@ -493,23 +493,23 @@ async def subscribe_command(message: Message, state: FSMContext) -> None:
async def _send_zero_star_invoice(message: Message, user_id: int) -> None:
"""Sends a zero-Star invoice only as an API behavior probe; never grants access."""
"""Sends a one-Star test invoice; never grants access."""
try:
await message.bot.send_invoice(
chat_id=message.chat.id,
title="Тестовый счёт на 0 ⭐",
description="Проверка поддержки нулевой цены Telegram Stars",
title="Тестовый счёт на 1 ⭐",
description="Проверка поддержки минимального платежа Telegram Stars",
payload=f"sub:0:{datetime.datetime.now(datetime.timezone.utc):%Y%m%d%H%M%S}",
currency="XTR",
prices=[LabeledPrice(label="Тест", amount=0)],
prices=[LabeledPrice(label="Тест", amount=1)],
provider_token="",
message_thread_id=message.message_thread_id,
)
except Exception as exc:
logger.info("Zero-Star invoice rejected by Telegram (%s)", type(exc).__name__)
await message.answer("Telegram отклонил тестовый счёт на 0 ⭐.")
await message.answer("Telegram отклонил тестовый счёт на 1 ⭐.")
return
await message.answer("Telegram принял тестовый счёт на 0 ⭐. Доступ он не выдаёт.")
await message.answer("Telegram принял тестовый счёт на 1 ⭐. Доступ он не выдаёт.")
async def _send_subscription_invoice(message: Message, user_id: int, days: int = 30) -> None:
+3 -7
View File
@@ -230,17 +230,13 @@ class SubscribeCommandTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(markup.inline_keyboard[0][0].text, "🧪 Оплатил (dev, 10 дн.)")
self.assertEqual(markup.inline_keyboard[0][0].callback_data, "dev_paid:42:10")
async def test_zero_star_plan_is_present_and_does_not_grant_access(self):
async def test_zero_star_plan_is_present_and_probes_one_star_invoice(self):
from pathlib import Path
self.assertEqual(user_store.SUBSCRIPTION_PLANS[0], 0)
source = Path(bot.__file__).read_text(encoding="utf-8")
body = source.split("async def _send_zero_star_invoice")[1].split("\nasync def _send_subscription_invoice")[0]
self.assertIn("amount=0", body)
body = source.split("async def _send_zero_star_invoice")[1].split("\n\nasync def _send_subscription_invoice")[0]
self.assertIn("amount=1", body)
self.assertNotIn("activate_subscription", body)
self.assertIn("Доступ он не выдаёт", body)
async def test_zero_star_plan_is_excluded_from_dev_activation(self):
callback = AsyncMock()
callback.data = "dev_paid:42:0"
callback.from_user = SimpleNamespace(id=42)
+1 -1
View File
@@ -142,7 +142,7 @@ TRIAL_DAYS = 3
SUBSCRIPTION_MONTH_DAYS = 30 # Совместимость со старым dev-сценарием.
SUBSCRIPTION_PRICE_STARS = 450
SUBSCRIPTION_PLANS = {
0: 0,
0: 1,
1: 15,
10: 150,
30: 450,