fix(payments): Исправлена ошибка с дублированием скидки для всех платёжных систем
This commit is contained in:
@@ -10,7 +10,6 @@ from bot.middlewares.i18n import JsonI18n
|
||||
from bot.services.freekassa_service import FreeKassaService
|
||||
from config.settings import Settings
|
||||
from db.dal import payment_dal
|
||||
from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment
|
||||
|
||||
router = Router(name="user_subscription_payments_freekassa_router")
|
||||
|
||||
@@ -70,22 +69,19 @@ async def pay_fk_callback_handler(
|
||||
)
|
||||
currency_code = getattr(freekassa_service, "default_currency", None) or settings.DEFAULT_CURRENCY_SYMBOL or "RUB"
|
||||
|
||||
# Apply active discount if exists
|
||||
final_price_rub, discount_amount, promo_code_id = await apply_discount_to_payment(
|
||||
session, user_id, price_rub, promo_code_service
|
||||
)
|
||||
|
||||
# Price is already discounted at payments_subscription.py stage
|
||||
# Service will handle discount metadata if needed
|
||||
payment_record_payload = {
|
||||
"user_id": user_id,
|
||||
"amount": final_price_rub,
|
||||
"original_amount": price_rub if discount_amount else None,
|
||||
"discount_applied": discount_amount,
|
||||
"amount": price_rub,
|
||||
"original_amount": None,
|
||||
"discount_applied": None,
|
||||
"currency": currency_code,
|
||||
"status": "pending_freekassa",
|
||||
"description": payment_description,
|
||||
"subscription_duration_months": int(months),
|
||||
"provider": "freekassa",
|
||||
"promo_code_id": promo_code_id,
|
||||
"promo_code_id": None,
|
||||
}
|
||||
|
||||
try:
|
||||
@@ -111,13 +107,15 @@ async def pay_fk_callback_handler(
|
||||
payment_db_id=payment_record.payment_id,
|
||||
user_id=payment_record.user_id,
|
||||
months=months,
|
||||
amount=final_price_rub,
|
||||
amount=price_rub,
|
||||
currency=freekassa_service.default_currency,
|
||||
payment_method_id=freekassa_service.payment_method_id,
|
||||
ip_address=freekassa_service.server_ip,
|
||||
extra_params={
|
||||
"us_method": freekassa_service.payment_method_id,
|
||||
},
|
||||
promo_code_service=promo_code_service,
|
||||
session=session,
|
||||
)
|
||||
|
||||
if success:
|
||||
|
||||
Reference in New Issue
Block a user