From a146a6a3e9703e8301437864c2a7525263ce2ca6 Mon Sep 17 00:00:00 2001 From: Noloquideus Date: Wed, 22 Apr 2026 12:15:23 +0300 Subject: [PATCH] feat: add itpay creds --- .../abstractions/repositories/__init__.py | 18 ++++++++++++++++++ src/infrastructure/config/settings.py | 9 +++++++++ src/presentation/routing/order.py | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/application/abstractions/repositories/__init__.py b/src/application/abstractions/repositories/__init__.py index e69de29..5322e20 100644 --- a/src/application/abstractions/repositories/__init__.py +++ b/src/application/abstractions/repositories/__init__.py @@ -0,0 +1,18 @@ +from __future__ import annotations + +from typing import Protocol,runtime_checkable + +from src.application.domain.entities import SessionEntity,UserEntity + + +@runtime_checkable +class IUserRepository(Protocol): + ... + + +@runtime_checkable +class ISessionRepository(Protocol): + ... + + +__all__=['IUserRepository','ISessionRepository','UserEntity','SessionEntity'] diff --git a/src/infrastructure/config/settings.py b/src/infrastructure/config/settings.py index 7ee4f5a..eb31a11 100644 --- a/src/infrastructure/config/settings.py +++ b/src/infrastructure/config/settings.py @@ -84,6 +84,8 @@ class Settings(BaseSettings): RABBIT_CONNECT_TIMEOUT: int = 5 RABBIT_EMAIL_CODE_QUEUE: str = "email.verification_code" + ITPAY_AUTHORIZATION: str + LOG_LEVEL: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO" LOG_FORMAT: Literal["JSON", "TEXT"] = "TEXT" @@ -149,6 +151,7 @@ class Settings(BaseSettings): database = read_secret('database') csrf = read_secret_optional('csrf') rabbitmq = read_secret_optional('rabbitmq') + itpay = read_secret_optional('itpay') db_ci = {str(k).lower(): v for k, v in database.items()} @@ -197,6 +200,12 @@ class Settings(BaseSettings): rb_set('password','RABBIT_PASSWORD') rb_set('vhost','RABBIT_VHOST') + if itpay: + itpay_ci = {str(k).lower(): v for k, v in itpay.items()} + secret = itpay_ci.get('secret') + if secret is not None and str(secret).strip(): + data['ITPAY_AUTHORIZATION'] = f'Token {str(secret).strip()}' + return data @property diff --git a/src/presentation/routing/order.py b/src/presentation/routing/order.py index 71a4354..56dde64 100644 --- a/src/presentation/routing/order.py +++ b/src/presentation/routing/order.py @@ -11,12 +11,12 @@ from src.application.domain.exceptions import ApplicationException from src.presentation.decorators import csrf_protect, require_access_token from src.presentation.dependencies.logger import get_logger from src.presentation.schemas.order import CreateOrder +from src.infrastructure.config import settings order_router = APIRouter(prefix='/order', tags=['orders']) ITPAY_API_BASE = 'https://api.gw.itpay.ru' -ITPAY_AUTHORIZATION = 'Token REPLACE_WITH_JWT_FROM_ITPAY_DASHBOARD' HARDCODED_USDT_TO_RUB = Decimal('100') HARDCODED_GAS_RUB = Decimal('15') HARDCODED_OUR_COMMISSION_RUB = Decimal('25') @@ -52,7 +52,7 @@ async def create_order( } url = f'{ITPAY_API_BASE}/v1/payments' headers = { - 'Authorization': ITPAY_AUTHORIZATION, + 'Authorization': settings.ITPAY_AUTHORIZATION, 'Content-Type': 'application/json', 'Accept': 'application/json', }