fix: handle YooKassa NotFoundError gracefully in get_payment_info

Catch NotFoundError (404) separately from generic exceptions.
Old/expired payments return 404 from YooKassa API — this is expected
and should be logged as WARNING without traceback, not ERROR.
This commit is contained in:
Fringg
2026-02-17 18:46:32 +03:00
parent 10e231e52e
commit df5b1a072d

View File

@@ -5,6 +5,7 @@ from typing import Any
import structlog
from yookassa import Configuration, Payment as YooKassaPayment
from yookassa.domain.common.confirmation_type import ConfirmationType
from yookassa.domain.exceptions.not_found_error import NotFoundError as YooKassaNotFoundError
from yookassa.domain.request.payment_request_builder import PaymentRequestBuilder
from app.config import settings
@@ -412,6 +413,12 @@ class YooKassaService:
}
logger.warning('Платеж не найден в YooKassa ID', payment_id_in_yookassa=payment_id_in_yookassa)
return None
except YooKassaNotFoundError:
logger.warning(
'Платеж не найден в YooKassa (404)',
payment_id_in_yookassa=payment_id_in_yookassa,
)
return None
except Exception as e:
logger.error(
'Ошибка получения информации о платеже YooKassa',