From cbcd9ca1bc8c718543e09c5167449160c9f0654b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D0=B8=D1=81=20=D0=AE=D1=81=D1=83=D0=BF=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B5=D0=B2?= Date: Sat, 20 Jun 2026 00:26:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=BD=D0=BE=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20tbank?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy.yml | 4 +--- app/controllers/v1/delivery.py | 24 ++++++++++++++++++++++++ app/services/aggregator.py | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index d4038eb..bafbfde 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -73,8 +73,6 @@ jobs: run: | set -euo pipefail - apt update && apt install -y gettext-base - # Экспортируем все секреты как env-переменные while IFS= read -r -d '' entry; do key="${entry%%=*}" @@ -103,7 +101,7 @@ jobs: exit 1 fi done - envsubst < "$src" > "$dst" + perl -pe 's/\$\{(\w+)\}/exists $ENV{$1} ? $ENV{$1} : ""/ge' "$src" > "$dst" } render config.template.yaml config.rendered.yaml diff --git a/app/controllers/v1/delivery.py b/app/controllers/v1/delivery.py index 3745819..7482408 100644 --- a/app/controllers/v1/delivery.py +++ b/app/controllers/v1/delivery.py @@ -241,9 +241,23 @@ async def handle_tbank_payment_notification( notification: TBankPaymentNotification, service: AggregatorService = Depends(get_aggregator_service), ) -> 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: response_body = await service.handle_tbank_payment_notification(notification) except InvalidTBankPaymentNotificationError as exc: + logger.warning( + "tbank_notification_rejected", + order_id=notification.OrderId, + reason="invalid_token", + ) raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, detail={ @@ -252,6 +266,11 @@ async def handle_tbank_payment_notification( }, ) from exc except TBankPaymentNotificationProcessingError as exc: + logger.error( + "tbank_notification_processing_failed", + order_id=notification.OrderId, + exc_info=True, + ) raise HTTPException( status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail={ @@ -260,6 +279,11 @@ async def handle_tbank_payment_notification( }, ) from exc except AggregatorServiceError as exc: + logger.error( + "tbank_notification_processing_failed", + order_id=notification.OrderId, + exc_info=True, + ) raise HTTPException( status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail={ diff --git a/app/services/aggregator.py b/app/services/aggregator.py index 96c260a..3892b85 100644 --- a/app/services/aggregator.py +++ b/app/services/aggregator.py @@ -425,6 +425,10 @@ class AggregatorService: try: self._payment_adapter.verify_payment_notification(notification) except TBankPaymentNotificationTokenError as exc: + logger.warning( + "tbank_notification_token_invalid", + order_id=notification.OrderId, + ) raise InvalidTBankPaymentNotificationError( "TBank payment notification token is invalid." ) from exc @@ -438,6 +442,12 @@ class AggregatorService: success=notification.Success, 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) if action is TBankPaymentNotificationAction.ACKNOWLEDGE_ONLY: @@ -445,6 +455,11 @@ class AggregatorService: provider = self._resolve_order_provider(order) if self._has_existing_registration(order, provider): + logger.info( + "tbank_notification_registration_skipped_duplicate", + order_id=notification.OrderId, + provider=provider, + ) return "OK" registration_result = await self._register_provider_order( @@ -455,6 +470,11 @@ class AggregatorService: provider=provider, result=registration_result, ) + logger.info( + "tbank_notification_order_registered", + order_id=notification.OrderId, + provider=provider, + ) await self._send_payment_confirmation_email( order, order_uuid=notification.OrderId )