diff --git a/backend/bot/keyboards/inline/user_keyboards.py b/backend/bot/keyboards/inline/user_keyboards.py index fa1ef76..a3eb142 100644 --- a/backend/bot/keyboards/inline/user_keyboards.py +++ b/backend/bot/keyboards/inline/user_keyboards.py @@ -462,7 +462,7 @@ def get_payment_method_keyboard( for method in settings.payment_methods_order: spec = get_provider_spec(method) - if not spec or not spec.button_text_key or not spec.is_enabled(settings): + if not spec or not spec.callback_prefix or not spec.is_enabled(settings): continue callback_data = spec.callback_data( value=value_str, @@ -473,7 +473,7 @@ def get_payment_method_keyboard( if not callback_data: continue builder.button( - text=provider_telegram_button_text(spec, settings, _, language=lang), + text=provider_telegram_button_text(spec, settings, language=lang), callback_data=callback_data, ) builder.button( diff --git a/backend/bot/payment_providers/base.py b/backend/bot/payment_providers/base.py index c787b8d..b273249 100644 --- a/backend/bot/payment_providers/base.py +++ b/backend/bot/payment_providers/base.py @@ -44,7 +44,6 @@ class PaymentProviderSpec: pending_status: str enabled: EnabledPredicate service_key: Optional[str] = None - button_text_key: Optional[str] = None callback_prefix: Optional[str] = None webapp_label: Optional[str] = None webapp_labels: Optional[Mapping[str, str]] = None diff --git a/backend/bot/payment_providers/cryptopay.py b/backend/bot/payment_providers/cryptopay.py index 779951a..abbe245 100644 --- a/backend/bot/payment_providers/cryptopay.py +++ b/backend/bot/payment_providers/cryptopay.py @@ -365,7 +365,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_cryptopay", enabled=lambda settings: settings.CRYPTOPAY_ENABLED, service_key="cryptopay_service", - button_text_key="pay_with_cryptopay_button", callback_prefix="pay_crypto", router=router, create_service=create_service, diff --git a/backend/bot/payment_providers/freekassa.py b/backend/bot/payment_providers/freekassa.py index 6ebfc09..1341b06 100644 --- a/backend/bot/payment_providers/freekassa.py +++ b/backend/bot/payment_providers/freekassa.py @@ -491,7 +491,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_freekassa", enabled=lambda settings: settings.FREEKASSA_ENABLED, service_key="freekassa_service", - button_text_key="pay_with_sbp_button", callback_prefix="pay_fk", router=router, create_service=create_service, diff --git a/backend/bot/payment_providers/heleket.py b/backend/bot/payment_providers/heleket.py index f3c16ce..6533d4b 100644 --- a/backend/bot/payment_providers/heleket.py +++ b/backend/bot/payment_providers/heleket.py @@ -471,7 +471,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_heleket", enabled=lambda settings: settings.HELEKET_ENABLED, service_key="heleket_service", - button_text_key="pay_with_heleket_button", callback_prefix="pay_heleket", router=router, create_service=create_service, diff --git a/backend/bot/payment_providers/platega.py b/backend/bot/payment_providers/platega.py index b3361f0..10d8a20 100644 --- a/backend/bot/payment_providers/platega.py +++ b/backend/bot/payment_providers/platega.py @@ -499,7 +499,6 @@ SBP_SPEC = PaymentProviderSpec( pending_status="pending_platega", enabled=lambda settings: settings.PLATEGA_ENABLED and settings.PLATEGA_SBP_ENABLED, service_key="platega_service", - button_text_key="pay_with_platega_sbp_button", callback_prefix="pay_platega_sbp", aliases=("platega",), router=router, @@ -521,7 +520,6 @@ CRYPTO_SPEC = PaymentProviderSpec( pending_status="pending_platega", enabled=lambda settings: settings.PLATEGA_ENABLED and settings.PLATEGA_CRYPTO_ENABLED, service_key="platega_service", - button_text_key="pay_with_platega_crypto_button", callback_prefix="pay_platega_crypto", create_webapp_payment=create_crypto_webapp_payment, ) diff --git a/backend/bot/payment_providers/registry.py b/backend/bot/payment_providers/registry.py index 201a4c6..28bfc0f 100644 --- a/backend/bot/payment_providers/registry.py +++ b/backend/bot/payment_providers/registry.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional +from typing import Any, Dict, Iterable, List, Mapping, Optional from . import cryptopay, freekassa, heleket, platega, severpay, stars, wata, yookassa from .base import PaymentProviderPresentation, PaymentProviderSpec, ServiceFactoryContext @@ -83,7 +83,6 @@ def resolve_provider_presentation( settings: Any = None, *, language: Optional[str] = None, - translate: Optional[Callable[[str], str]] = None, ) -> PaymentProviderPresentation: lang = _normalize_language(language, settings) webapp_label = ( @@ -111,14 +110,6 @@ def resolve_provider_presentation( ) telegram_emoji = telegram_emoji_override or spec.default_telegram_emoji - if ( - not telegram_label_override - and not spec.telegram_labels - and translate - and spec.button_text_key - ): - telegram_label = translate(spec.button_text_key) - return PaymentProviderPresentation( webapp_label=webapp_label, webapp_icon=webapp_icon, @@ -131,7 +122,6 @@ def resolve_provider_presentation( def provider_telegram_button_text( spec: PaymentProviderSpec, settings: Any, - translate: Callable[[str], str], *, language: Optional[str] = None, ) -> str: diff --git a/backend/bot/payment_providers/severpay.py b/backend/bot/payment_providers/severpay.py index 98233db..2a73e92 100644 --- a/backend/bot/payment_providers/severpay.py +++ b/backend/bot/payment_providers/severpay.py @@ -434,7 +434,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_severpay", enabled=lambda settings: settings.SEVERPAY_ENABLED, service_key="severpay_service", - button_text_key="pay_with_severpay_button", callback_prefix="pay_severpay", router=router, create_service=create_service, diff --git a/backend/bot/payment_providers/stars.py b/backend/bot/payment_providers/stars.py index 699e2a9..08e2d08 100644 --- a/backend/bot/payment_providers/stars.py +++ b/backend/bot/payment_providers/stars.py @@ -360,7 +360,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_stars", enabled=lambda settings: settings.STARS_ENABLED, service_key="stars_service", - button_text_key="pay_with_stars_button", callback_prefix="pay_stars", router=router, create_service=create_service, diff --git a/backend/bot/payment_providers/wata.py b/backend/bot/payment_providers/wata.py index dde4963..7dfaaa4 100644 --- a/backend/bot/payment_providers/wata.py +++ b/backend/bot/payment_providers/wata.py @@ -440,7 +440,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_wata", enabled=lambda settings: settings.WATA_ENABLED, service_key="wata_service", - button_text_key="pay_with_wata_button", callback_prefix="pay_wata", router=router, create_service=create_service, diff --git a/backend/bot/payment_providers/yookassa.py b/backend/bot/payment_providers/yookassa.py index 2a12b41..8a37a31 100644 --- a/backend/bot/payment_providers/yookassa.py +++ b/backend/bot/payment_providers/yookassa.py @@ -2514,7 +2514,6 @@ SPEC = PaymentProviderSpec( pending_status="pending_yookassa", enabled=lambda settings: settings.YOOKASSA_ENABLED, service_key="yookassa_service", - button_text_key="pay_with_yookassa_button", callback_prefix="pay_yk", router=router, create_service=create_service, diff --git a/locales/en.json b/locales/en.json index 6a4edea..c291db4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -41,7 +41,6 @@ "choose_payment_method": "Choose payment method:", "choose_payment_method_traffic": "Choose how to pay for the traffic package:", "pay_button": "💳 Pay", - "pay_with_yookassa_button": "💳 YooKassa", "yookassa_autopay_flow_prompt": "Auto-renew is enabled. Choose how you'd like to pay:", "yookassa_autopay_pay_saved_card_button": "💳 Pay with saved card", "yookassa_autopay_pay_new_card_button": "➕ Pay with new card", @@ -49,16 +48,7 @@ "yookassa_autopay_no_saved_cards": "No saved cards found. Pay with a new card or link one in Payment Methods.", "back_to_autopay_method_choice_button": "⬅️ Back", "yookassa_autopay_charge_initiated": "Charge request sent to the selected card. We'll notify you once the payment completes.", - "pay_with_sbp_button": "📱 SBP", - "pay_with_platega_button": "💳 Platega (SBP/Cards)", - "pay_with_platega_sbp_button": "🏦 Pay via SBP", - "pay_with_platega_crypto_button": "🪙 Pay with crypto", - "pay_with_severpay_button": "💳 SeverPay", - "pay_with_wata_button": "Wata", - "pay_with_heleket_button": "🪙 Heleket", "back_to_payment_methods_button": "⬅️ Back", - "pay_with_cryptopay_button": "💎 CryptoBot", - "pay_with_stars_button": "🌟 Telegram Stars", "connect_button": "🔗 Connect", "cancel_button": "❌ Cancel", "devices_button": "📱 My Devices ({current_devices}/{max_devices})", diff --git a/locales/ru.json b/locales/ru.json index 8243b67..5df8e5c 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -41,7 +41,6 @@ "choose_payment_method": "Выберите способ оплаты:", "choose_payment_method_traffic": "Выберите способ оплаты пакета трафика:", "pay_button": "💳 Оплатить", - "pay_with_yookassa_button": "💳 ЮKassa", "yookassa_autopay_flow_prompt": "Автопродление включено. Выберите, как оплатить подписку:", "yookassa_autopay_pay_saved_card_button": "💳 Оплата привязанной картой", "yookassa_autopay_pay_new_card_button": "➕ Оплата новой картой", @@ -49,16 +48,7 @@ "yookassa_autopay_no_saved_cards": "Сохранённых карт нет. Оплатите новой картой или привяжите карту в разделе «Способы оплаты».", "back_to_autopay_method_choice_button": "⬅️ Назад", "yookassa_autopay_charge_initiated": "Запрос на списание с выбранной карты отправлен. Сообщим, как только платёж завершится.", - "pay_with_sbp_button": "📱 СБП", - "pay_with_platega_button": "💳 Platega (СБП/карты)", - "pay_with_platega_sbp_button": "🏦 Оплата через СБП", - "pay_with_platega_crypto_button": "🪙 Оплата криптой", - "pay_with_severpay_button": "💳 SeverPay", - "pay_with_wata_button": "Wata", - "pay_with_heleket_button": "🪙 Heleket", "back_to_payment_methods_button": "⬅️ Назад", - "pay_with_cryptopay_button": "💎 CryptoBot", - "pay_with_stars_button": "🌟 Звезды Telegram", "connect_button": "🔗 Подключиться", "devices_button": "📱 Мои устройства ({current_devices}/{max_devices})", "my_devices_details": "📱 Список ваших устройств ({current_devices}/{max_devices})\n\n{devices}\n\nВы можете отключить устройство, выбрав его в списке ниже.\n
Примечание: Если вы отключили устройство, оно будет автоматически подключено заново при следующем использовании. Перед удалением убедитесь, что вы удалили подписку из приложения.", diff --git a/tests/test_payment_provider_registry.py b/tests/test_payment_provider_registry.py index dcb08b0..4d26889 100644 --- a/tests/test_payment_provider_registry.py +++ b/tests/test_payment_provider_registry.py @@ -75,7 +75,6 @@ def test_wata_is_registered_as_single_provider_module(): assert spec is not None assert spec.service_key == "wata_service" assert spec.pending_status == "pending_wata" - assert spec.button_text_key == "pay_with_wata_button" assert spec.callback_prefix == "pay_wata" assert spec.router is not None assert spec.create_service is not None @@ -175,15 +174,14 @@ def test_provider_telegram_button_text_uses_provider_defaults_until_customized() spec = get_provider_spec("wata") assert spec is not None - translate = lambda key: f"i18n:{key}" assert ( - provider_telegram_button_text(spec, SimpleNamespace(), translate, language="en") + provider_telegram_button_text(spec, SimpleNamespace(), language="en") == f"{spec.default_telegram_emoji} Wata" ) settings = SimpleNamespace(PAYMENT_WATA_TELEGRAM_LABEL_EN="Pay Wata") assert ( - provider_telegram_button_text(spec, settings, translate, language="en") + provider_telegram_button_text(spec, settings, language="en") == f"{spec.default_telegram_emoji} Pay Wata" )