From 9ca2fe487c4ce4caf6350ce52d87bc5ffe04dfe0 Mon Sep 17 00:00:00 2001 From: VAQYBIN Date: Wed, 21 Jan 2026 01:13:26 +0500 Subject: [PATCH] =?UTF-8?q?fix(promo):=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=B7=D0=B0=D1=86=D1=8B=D0=BA=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E=20=D0=B8=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D1=80=D1=82=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D0=BE?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D1=82=20=D0=B7=D0=B2=D1=91=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8=20=D0=B8=20=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/services/crypto_pay_service.py | 12 ++++++++---- bot/services/stars_service.py | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bot/services/crypto_pay_service.py b/bot/services/crypto_pay_service.py index babca27..daa9118 100644 --- a/bot/services/crypto_pay_service.py +++ b/bot/services/crypto_pay_service.py @@ -18,7 +18,6 @@ from bot.services.notification_service import NotificationService from db.dal import payment_dal, user_dal from bot.utils.text_sanitizer import sanitize_display_name, username_for_display from bot.utils.config_link import prepare_config_links -from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment class CryptoPayService: @@ -73,9 +72,14 @@ class CryptoPayService: return None # Apply active discount if exists - final_amount, discount_amount, promo_code_id = await apply_discount_to_payment( - session, user_id, amount, promo_code_service - ) + if promo_code_service: + # Import here to avoid circular import + from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment + final_amount, discount_amount, promo_code_id = await apply_discount_to_payment( + session, user_id, amount, promo_code_service + ) + else: + final_amount, discount_amount, promo_code_id = amount, None, None # Create pending payment in DB and commit to persist try: diff --git a/bot/services/stars_service.py b/bot/services/stars_service.py index c6d0dad..4bd2252 100644 --- a/bot/services/stars_service.py +++ b/bot/services/stars_service.py @@ -15,7 +15,6 @@ from .notification_service import NotificationService from bot.keyboards.inline.user_keyboards import get_connect_and_main_keyboard from bot.utils.text_sanitizer import sanitize_display_name, username_for_display from bot.utils.config_link import prepare_config_links -from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment class StarsService: @@ -37,6 +36,9 @@ class StarsService: promo_code_id = None if promo_code_service: + # Import here to avoid circular import + from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment + # Apply discount and round up using ceiling final_price_float, discount_float, promo_code_id = await apply_discount_to_payment( session, user_id, float(stars_price), promo_code_service