Refactor payment methods management to utilize a paginated list view

- Updated the payment methods management handler to directly build and display a paginated list of user payment methods, enhancing user experience.
- Removed legacy support for single card checks and deprecated keyboard functions in favor of the new list view.
- Improved localization handling for payment method titles and added fallback options for missing data.
This commit is contained in:
machka-pasla
2025-09-04 17:32:27 +03:00
parent 50cea15c92
commit a510ab1021
2 changed files with 16 additions and 14 deletions
+2 -6
View File
@@ -235,10 +235,6 @@ def get_payment_methods_manage_keyboard(lang: str, i18n_instance, has_card: bool
"""Deprecated in favor of get_payment_methods_list_keyboard. Kept for backward compatibility."""
_ = lambda key, **kwargs: i18n_instance.gettext(lang, key, **kwargs)
builder = InlineKeyboardBuilder()
# Route to the new list view
builder.row(
InlineKeyboardButton(text=_(key="payment_methods_title"), callback_data="pm:list:0")
)
builder.row(
InlineKeyboardButton(text=_(key="payment_method_bind_button"), callback_data="pm:bind")
)
@@ -305,7 +301,7 @@ def get_payment_method_details_keyboard(pm_id: str, lang: str, i18n_instance) ->
InlineKeyboardButton(text=_(key="payment_method_delete_button"), callback_data=f"pm:delete_confirm:{pm_id}")
)
builder.row(
InlineKeyboardButton(text=_(key="payment_methods_title"), callback_data="pm:list:0")
InlineKeyboardButton(text=_(key="back_to_main_menu_button"), callback_data="pm:list:0")
)
return builder.as_markup()
@@ -322,5 +318,5 @@ def get_bind_url_keyboard(bind_url: str, lang: str, i18n_instance) -> InlineKeyb
def get_back_to_payment_methods_keyboard(lang: str, i18n_instance) -> InlineKeyboardMarkup:
_ = lambda key, **kwargs: i18n_instance.gettext(lang, key, **kwargs)
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text=_(key="payment_methods_title"), callback_data="pm:list:0"))
builder.row(InlineKeyboardButton(text=_(key="back_to_main_menu_button"), callback_data="pm:list:0"))
return builder.as_markup()