From 5c71fc0de2d7b7dadfe857c823ec6684b11ca2e6 Mon Sep 17 00:00:00 2001 From: 3252a8 <3252a8@proton.me> Date: Mon, 25 May 2026 00:23:48 +0300 Subject: [PATCH] fix: hide links from payment success message --- .../bot/payment_providers/shared/success.py | 18 +----------------- backend/bot/payment_providers/yookassa.py | 12 +----------- locales/en.json | 8 ++++---- locales/ru.json | 8 ++++---- tests/test_yookassa_hwid_webhook.py | 2 +- 5 files changed, 11 insertions(+), 37 deletions(-) diff --git a/backend/bot/payment_providers/shared/success.py b/backend/bot/payment_providers/shared/success.py index 1ca7672..76060d8 100644 --- a/backend/bot/payment_providers/shared/success.py +++ b/backend/bot/payment_providers/shared/success.py @@ -11,10 +11,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from bot.keyboards.inline.user_keyboards import get_connect_and_main_keyboard from bot.services.notification_service import NotificationService from bot.utils.config_link import prepare_config_links -from bot.utils.install_links import ( - append_install_share_link_text, - ensure_user_install_guide_links, -) +from bot.utils.install_links import ensure_user_install_guide_links from bot.utils.text_sanitizer import sanitize_display_name, username_for_display from db.dal import payment_dal, user_dal from db.models import Payment, User @@ -75,7 +72,6 @@ class SuccessMessage: months: Any base_end_date: Optional[datetime] final_end_date: Optional[datetime] - config_link_text: str applied_referee_bonus_days: int = 0 applied_promo_bonus_days: int = 0 inviter_name: Optional[str] = None @@ -102,13 +98,11 @@ def build_success_message(payload: SuccessMessage) -> str: "payment_successful_traffic_full", traffic_gb=format_human_units(payload.months), end_date=end_text, - config_link=payload.config_link_text, ) if base in _HWID_DEVICE_MODES: return _( "payment_successful_hwid_devices_full", count=format_human_units(payload.months), - config_link=payload.config_link_text, ) if payload.applied_referee_bonus_days and payload.final_end_date: base_end_text = _fmt_date(payload.base_end_date or payload.final_end_date, end_text) @@ -119,7 +113,6 @@ def build_success_message(payload: SuccessMessage) -> str: bonus_days=payload.applied_referee_bonus_days, final_end_date=end_text, inviter_name=payload.inviter_name or _("friend_placeholder"), - config_link=payload.config_link_text, ) if payload.applied_promo_bonus_days and payload.final_end_date: return _( @@ -127,13 +120,11 @@ def build_success_message(payload: SuccessMessage) -> str: months=payload.months, bonus_days=payload.applied_promo_bonus_days, end_date=end_text, - config_link=payload.config_link_text, ) return _( "payment_successful_full", months=payload.months, end_date=end_text, - config_link=payload.config_link_text, ) @@ -314,7 +305,6 @@ async def finalize_successful_payment( config_link_display, connect_button_url = await prepare_config_links( req.settings, raw_config_link ) - config_link_text = config_link_display or translator("config_link_not_available") base_end_date = activation.get("end_date") if activation else None final_end_date = base_end_date @@ -338,7 +328,6 @@ async def finalize_successful_payment( ), base_end_date=base_end_date, final_end_date=final_end_date, - config_link_text=config_link_text, applied_referee_bonus_days=applied_referee_bonus_days, applied_promo_bonus_days=applied_promo_bonus_days, inviter_name=inviter_name, @@ -358,11 +347,6 @@ async def finalize_successful_payment( if install_share_url: try: await req.session.commit() - success_text = append_install_share_link_text( - success_text, - translator, - install_share_url, - ) except Exception: await req.session.rollback() logging.exception( diff --git a/backend/bot/payment_providers/yookassa.py b/backend/bot/payment_providers/yookassa.py index 390b2fb..dfff647 100644 --- a/backend/bot/payment_providers/yookassa.py +++ b/backend/bot/payment_providers/yookassa.py @@ -36,10 +36,7 @@ from bot.services.panel_api_service import PanelApiService from bot.services.referral_service import ReferralService from bot.services.subscription_service import SubscriptionService from bot.utils.config_link import prepare_config_links -from bot.utils.install_links import ( - append_install_share_link_text, - ensure_user_install_guide_links, -) +from bot.utils.install_links import ensure_user_install_guide_links from bot.utils.request_security import ip_in_allowlist, request_client_ip from config.settings import Settings from db.dal import payment_dal, user_billing_dal, user_dal @@ -784,7 +781,6 @@ async def process_successful_payment( config_link_display, connect_button_url = await prepare_config_links( settings, activation_details.get("subscription_url") if activation_details else None ) - config_link_text = config_link_display or _("config_link_not_available") # Auto-renew charges show a concise message and skip the connect keyboard, so # they bypass the shared success-message builder. if sale_mode_base == "subscription" and is_auto_renew and final_end_date_for_user: @@ -823,7 +819,6 @@ async def process_successful_payment( ), base_end_date=base_subscription_end_date, final_end_date=final_end_date_for_user, - config_link_text=config_link_text, applied_referee_bonus_days=applied_referee_bonus_days_from_referral or 0, applied_promo_bonus_days=applied_promo_bonus_days, inviter_name=inviter_name, @@ -836,11 +831,6 @@ async def process_successful_payment( if include_keyboard: install_links = await ensure_user_install_guide_links(session, settings, user_id) install_share_url = install_links.public_share_url - details_message = append_install_share_link_text( - details_message, - translator, - install_share_url, - ) await send_success_message_to_user( bot=bot, user_id=user_id, diff --git a/locales/en.json b/locales/en.json index aea4c2e..5c75a2c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -70,10 +70,10 @@ "payment_invoice_sent_message": "Telegram has sent the invoice above. Complete the payment or pick another method below.", "payment_invoice_sent_message_traffic": "Invoice for {traffic_gb} GB sent above. Complete the payment or pick another method below.", "payment_successful_error_details": "✅ Payment succeeded, but an error occurred displaying details. Your subscription is active. Contact support if anything is wrong.", - "payment_successful_full": "✅ Payment successful!\nYour {months}-month subscription is active until {end_date}.\n\nConnection key:\n{config_link}\n\nTo connect, open the link and follow the instructions 👇", - "payment_successful_traffic_full": "✅ Payment successful!\nYour {traffic_gb} GB package is active.\nValidity: {end_date}\n\nConnection key:\n{config_link}\n\nTo connect, open the link and follow the instructions 👇", - "payment_successful_hwid_devices_full": "✅ Payment successful!\nExtra HWID devices added: +{count}.\n\nConnection key:\n{config_link}\n\nTo connect, open the link and follow the instructions 👇", - "payment_successful_with_referral_bonus_full": "✅ Payment successful!\nYour {months}-month subscription (base end date: {base_end_date}) has been extended by {bonus_days} bonus days for referral from {inviter_name} and is now active until {final_end_date}.\n\nConnection key:\n{config_link}\n\nTo connect, open the link and follow the instructions 👇", + "payment_successful_full": "✅ Payment successful!\nYour {months}-month subscription is active until {end_date}.", + "payment_successful_traffic_full": "✅ Payment successful!\nYour {traffic_gb} GB package is active.\nValidity: {end_date}", + "payment_successful_hwid_devices_full": "✅ Payment successful!\nExtra HWID devices added: +{count}.", + "payment_successful_with_referral_bonus_full": "✅ Payment successful!\nYour {months}-month subscription (base end date: {base_end_date}) has been extended by {bonus_days} bonus days for referral from {inviter_name} and is now active until {final_end_date}.", "payment_failed": "❌ Payment failed or was cancelled. Please try again or contact support.", "config_link_not_available": "not available, contact support", "traffic_unlimited": "Unlimited", diff --git a/locales/ru.json b/locales/ru.json index ab36faa..78ea13c 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -70,10 +70,10 @@ "payment_invoice_sent_message": "Счёт Telegram Stars отправлен выше. Нажмите «Оплатить» или вернитесь к выбору способа ниже.", "payment_invoice_sent_message_traffic": "Счет на пакет {traffic_gb} ГБ отправлен выше. Нажмите «Оплатить» или вернитесь к выбору способа ниже.", "payment_successful_error_details": "✅ Оплата прошла успешно, но возникла ошибка при отображении деталей. Ваша подписка активна. Свяжитесь с поддержкой, если что-то не так.", - "payment_successful_full": "✅ Оплата прошла успешно!\nВаша подписка на {months} мес. активна до {end_date}.\n\nКлюч подключения:\n{config_link}\n\nЧтобы подключиться, перейдите по ссылке и следуйте инструкции 👇", - "payment_successful_traffic_full": "✅ Оплата прошла успешно!\nВаш пакет {traffic_gb} ГБ активирован.\nДата действия: {end_date}\n\nКлюч подключения:\n{config_link}\n\nЧтобы подключиться, перейдите по ссылке и следуйте инструкции 👇", - "payment_successful_hwid_devices_full": "✅ Оплата прошла успешно!\nДобавлено HWID устройств: +{count}.\n\nКлюч подключения:\n{config_link}\n\nЧтобы подключиться, перейдите по ссылке и следуйте инструкции 👇", - "payment_successful_with_referral_bonus_full": "✅ Оплата прошла успешно!\nВаша подписка на {months} мес. (базовая дата окончания: {base_end_date}) продлена на {bonus_days} бонусных дней за приглашение от {inviter_name} и теперь активна до {final_end_date}.\n\nКлюч подключения:\n{config_link}\n\nЧтобы подключиться, перейдите по ссылке и следуйте инструкции 👇", + "payment_successful_full": "✅ Оплата прошла успешно!\nВаша подписка на {months} мес. активна до {end_date}.", + "payment_successful_traffic_full": "✅ Оплата прошла успешно!\nВаш пакет {traffic_gb} ГБ активирован.\nДата действия: {end_date}", + "payment_successful_hwid_devices_full": "✅ Оплата прошла успешно!\nДобавлено HWID устройств: +{count}.", + "payment_successful_with_referral_bonus_full": "✅ Оплата прошла успешно!\nВаша подписка на {months} мес. (базовая дата окончания: {base_end_date}) продлена на {bonus_days} бонусных дней за приглашение от {inviter_name} и теперь активна до {final_end_date}.", "payment_failed": "❌ Оплата не удалась или была отменена. Пожалуйста, попробуйте еще раз или свяжитесь с поддержкой.", "config_link_not_available": "недоступна, обратитесь в поддержку", "traffic_unlimited": "Безлимитный", diff --git a/tests/test_yookassa_hwid_webhook.py b/tests/test_yookassa_hwid_webhook.py index 4609a62..435e147 100644 --- a/tests/test_yookassa_hwid_webhook.py +++ b/tests/test_yookassa_hwid_webhook.py @@ -8,7 +8,7 @@ from bot.payment_providers import yookassa class _I18n: def gettext(self, _lang, key, **kwargs): if key == "payment_successful_hwid_devices_full": - return f"HWID +{kwargs['count']} {kwargs['config_link']}" + return f"HWID +{kwargs['count']}" if key == "config_link_not_available": return "n/a" return key