логи для нотификации tbank
Deploy / deploy (push) Successful in 56s

This commit is contained in:
Раис Юсупалиев
2026-06-20 00:26:48 +03:00
parent 65c07f1da3
commit cbcd9ca1bc
3 changed files with 45 additions and 3 deletions
+1 -3
View File
@@ -73,8 +73,6 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
apt update && apt install -y gettext-base
# Экспортируем все секреты как env-переменные # Экспортируем все секреты как env-переменные
while IFS= read -r -d '' entry; do while IFS= read -r -d '' entry; do
key="${entry%%=*}" key="${entry%%=*}"
@@ -103,7 +101,7 @@ jobs:
exit 1 exit 1
fi fi
done done
envsubst < "$src" > "$dst" perl -pe 's/\$\{(\w+)\}/exists $ENV{$1} ? $ENV{$1} : ""/ge' "$src" > "$dst"
} }
render config.template.yaml config.rendered.yaml render config.template.yaml config.rendered.yaml
+24
View File
@@ -241,9 +241,23 @@ async def handle_tbank_payment_notification(
notification: TBankPaymentNotification, notification: TBankPaymentNotification,
service: AggregatorService = Depends(get_aggregator_service), service: AggregatorService = Depends(get_aggregator_service),
) -> PlainTextResponse: ) -> PlainTextResponse:
logger.info(
"tbank_notification_received",
order_id=notification.OrderId,
status=notification.Status,
success=notification.Success,
payment_id=notification.PaymentId,
error_code=notification.ErrorCode,
amount=notification.Amount,
)
try: try:
response_body = await service.handle_tbank_payment_notification(notification) response_body = await service.handle_tbank_payment_notification(notification)
except InvalidTBankPaymentNotificationError as exc: except InvalidTBankPaymentNotificationError as exc:
logger.warning(
"tbank_notification_rejected",
order_id=notification.OrderId,
reason="invalid_token",
)
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
@@ -252,6 +266,11 @@ async def handle_tbank_payment_notification(
}, },
) from exc ) from exc
except TBankPaymentNotificationProcessingError as exc: except TBankPaymentNotificationProcessingError as exc:
logger.error(
"tbank_notification_processing_failed",
order_id=notification.OrderId,
exc_info=True,
)
raise HTTPException( raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE, status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail={ detail={
@@ -260,6 +279,11 @@ async def handle_tbank_payment_notification(
}, },
) from exc ) from exc
except AggregatorServiceError as exc: except AggregatorServiceError as exc:
logger.error(
"tbank_notification_processing_failed",
order_id=notification.OrderId,
exc_info=True,
)
raise HTTPException( raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE, status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail={ detail={
+20
View File
@@ -425,6 +425,10 @@ class AggregatorService:
try: try:
self._payment_adapter.verify_payment_notification(notification) self._payment_adapter.verify_payment_notification(notification)
except TBankPaymentNotificationTokenError as exc: except TBankPaymentNotificationTokenError as exc:
logger.warning(
"tbank_notification_token_invalid",
order_id=notification.OrderId,
)
raise InvalidTBankPaymentNotificationError( raise InvalidTBankPaymentNotificationError(
"TBank payment notification token is invalid." "TBank payment notification token is invalid."
) from exc ) from exc
@@ -438,6 +442,12 @@ class AggregatorService:
success=notification.Success, success=notification.Success,
error_code=notification.ErrorCode, error_code=notification.ErrorCode,
) )
logger.info(
"tbank_notification_action_resolved",
order_id=notification.OrderId,
status=notification.Status,
action=action.name,
)
order = await self._load_order_and_mark_payment_status(notification) order = await self._load_order_and_mark_payment_status(notification)
if action is TBankPaymentNotificationAction.ACKNOWLEDGE_ONLY: if action is TBankPaymentNotificationAction.ACKNOWLEDGE_ONLY:
@@ -445,6 +455,11 @@ class AggregatorService:
provider = self._resolve_order_provider(order) provider = self._resolve_order_provider(order)
if self._has_existing_registration(order, provider): if self._has_existing_registration(order, provider):
logger.info(
"tbank_notification_registration_skipped_duplicate",
order_id=notification.OrderId,
provider=provider,
)
return "OK" return "OK"
registration_result = await self._register_provider_order( registration_result = await self._register_provider_order(
@@ -455,6 +470,11 @@ class AggregatorService:
provider=provider, provider=provider,
result=registration_result, result=registration_result,
) )
logger.info(
"tbank_notification_order_registered",
order_id=notification.OrderId,
provider=provider,
)
await self._send_payment_confirmation_email( await self._send_payment_confirmation_email(
order, order_uuid=notification.OrderId order, order_uuid=notification.OrderId
) )