fix: fix menus and modal views after payment providers refactor

This commit is contained in:
3252a8
2026-05-18 11:01:32 +03:00
parent 51c9c8b4f0
commit 960754c54e
13 changed files with 482 additions and 62 deletions
@@ -7,7 +7,10 @@ from typing import Optional
from aiogram import types
from sqlalchemy.ext.asyncio import AsyncSession
from bot.keyboards.inline.user_keyboards import get_payment_url_keyboard
from bot.keyboards.inline.user_keyboards import (
get_payment_url_keyboard,
payment_methods_back_callback,
)
from bot.middlewares.i18n import JsonI18n
from db.dal import payment_dal
from db.models import Payment
@@ -155,7 +158,9 @@ async def render_payment_link(
payment_url,
current_lang,
i18n,
back_callback=f"subscribe_period:{parts.human_value}",
back_callback=payment_methods_back_callback(
parts.human_value, parts.sale_mode, parts.price
),
back_text_key=back_text_key,
)
await edit_or_answer(
@@ -123,7 +123,9 @@ def sale_mode_is_hwid_devices(sale_mode: str) -> bool:
def sale_mode_tariff_key(sale_mode: str) -> Optional[str]:
return str(sale_mode or "").split("@", 1)[1] if "@" in str(sale_mode or "") else None
if "@" not in str(sale_mode or ""):
return None
return str(sale_mode).split("@", 1)[1].split("|", 1)[0] or None
def format_number_for_payload(value: Any) -> str:
+4 -1
View File
@@ -6,6 +6,7 @@ from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup, LabeledPri
from aiohttp import web
from sqlalchemy.ext.asyncio import AsyncSession
from bot.keyboards.inline.user_keyboards import payment_methods_back_callback
from bot.middlewares.i18n import JsonI18n
from bot.services.referral_service import ReferralService
from bot.services.subscription_service import SubscriptionService
@@ -210,7 +211,9 @@ async def pay_stars_callback_handler(
[
InlineKeyboardButton(
text=translator("back_to_payment_methods_button"),
callback_data=f"subscribe_period:{parts.human_value}",
callback_data=payment_methods_back_callback(
parts.human_value, parts.sale_mode, parts.price
),
)
]
]
+18 -3
View File
@@ -26,6 +26,7 @@ from bot.keyboards.inline.user_keyboards import (
get_payment_url_keyboard,
get_yk_autopay_choice_keyboard,
get_yk_saved_cards_keyboard,
payment_methods_back_callback,
)
from bot.middlewares.i18n import JsonI18n
from bot.services.lknpd_service import LknpdService
@@ -1132,7 +1133,9 @@ async def _initiate_yk_payment(
"description": payment_description,
"subscription_duration_months": int(months) if sale_base == "subscription" else None,
"sale_mode": sale_base,
"tariff_key": sale_mode.split("@", 1)[1] if "@" in sale_mode else None,
"tariff_key": sale_mode.split("@", 1)[1].split("|", 1)[0]
if "@" in sale_mode
else None,
"purchased_gb": float(months)
if sale_base in {"traffic", "traffic_package", "topup", "premium_topup"}
else None,
@@ -1458,6 +1461,9 @@ async def pay_yk_callback_handler(
i18n,
has_saved_cards=True,
sale_mode=sale_mode,
back_callback=payment_methods_back_callback(
_format_value(months), sale_mode, price_rub
),
),
)
except Exception as e_edit:
@@ -1472,6 +1478,9 @@ async def pay_yk_callback_handler(
i18n,
has_saved_cards=True,
sale_mode=sale_mode,
back_callback=payment_methods_back_callback(
_format_value(months), sale_mode, price_rub
),
),
)
except Exception:
@@ -1495,7 +1504,7 @@ async def pay_yk_callback_handler(
price_rub=price_rub,
currency_code_for_yk=currency_code_for_yk,
save_payment_method=autopay_enabled and autopay_require_binding,
back_callback=f"subscribe_period:{_format_value(months)}",
back_callback=payment_methods_back_callback(_format_value(months), sale_mode, price_rub),
sale_mode=sale_mode,
)
try:
@@ -1579,7 +1588,7 @@ async def pay_yk_new_card_handler(
price_rub=price_rub,
currency_code_for_yk=currency_code_for_yk,
save_payment_method=autopay_enabled and autopay_require_binding,
back_callback=f"subscribe_period:{_format_value(months)}",
back_callback=payment_methods_back_callback(_format_value(months), sale_mode, price_rub),
sale_mode=sale_mode,
)
try:
@@ -1671,6 +1680,9 @@ async def pay_yk_saved_list_handler(
i18n,
has_saved_cards=False,
sale_mode=sale_mode,
back_callback=payment_methods_back_callback(
_format_value(months), sale_mode, price_rub
),
),
)
except Exception as e_edit:
@@ -1685,6 +1697,9 @@ async def pay_yk_saved_list_handler(
i18n,
has_saved_cards=False,
sale_mode=sale_mode,
back_callback=payment_methods_back_callback(
_format_value(months), sale_mode, price_rub
),
),
)
except Exception: