From 0dc54a26b9fc574ac1417b9bd86af6c832bea1a5 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 21 Oct 2026 14:27:23 +0200 Subject: [PATCH] fix: use one-star subscription probe --- VERSION | 2 +- bot.py | 12 ++++++------ tests/test_payments.py | 10 +++------- user_store.py | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index 55812f1..89226b1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0+68 +0.1.0+69 diff --git a/bot.py b/bot.py index e4e6bfc..ba9d0ca 100644 --- a/bot.py +++ b/bot.py @@ -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: diff --git a/tests/test_payments.py b/tests/test_payments.py index 673651a..5376c8d 100644 --- a/tests/test_payments.py +++ b/tests/test_payments.py @@ -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) diff --git a/user_store.py b/user_store.py index 3753e7f..6270347 100644 --- a/user_store.py +++ b/user_store.py @@ -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,