feat: add itpay creds

This commit is contained in:
2026-04-22 12:15:23 +03:00
parent 2627354673
commit a146a6a3e9
3 changed files with 29 additions and 2 deletions

View File

@@ -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']

View File

@@ -84,6 +84,8 @@ class Settings(BaseSettings):
RABBIT_CONNECT_TIMEOUT: int = 5 RABBIT_CONNECT_TIMEOUT: int = 5
RABBIT_EMAIL_CODE_QUEUE: str = "email.verification_code" RABBIT_EMAIL_CODE_QUEUE: str = "email.verification_code"
ITPAY_AUTHORIZATION: str
LOG_LEVEL: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO" LOG_LEVEL: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO"
LOG_FORMAT: Literal["JSON", "TEXT"] = "TEXT" LOG_FORMAT: Literal["JSON", "TEXT"] = "TEXT"
@@ -149,6 +151,7 @@ class Settings(BaseSettings):
database = read_secret('database') database = read_secret('database')
csrf = read_secret_optional('csrf') csrf = read_secret_optional('csrf')
rabbitmq = read_secret_optional('rabbitmq') rabbitmq = read_secret_optional('rabbitmq')
itpay = read_secret_optional('itpay')
db_ci = {str(k).lower(): v for k, v in database.items()} 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('password','RABBIT_PASSWORD')
rb_set('vhost','RABBIT_VHOST') 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 return data
@property @property

View File

@@ -11,12 +11,12 @@ from src.application.domain.exceptions import ApplicationException
from src.presentation.decorators import csrf_protect, require_access_token from src.presentation.decorators import csrf_protect, require_access_token
from src.presentation.dependencies.logger import get_logger from src.presentation.dependencies.logger import get_logger
from src.presentation.schemas.order import CreateOrder from src.presentation.schemas.order import CreateOrder
from src.infrastructure.config import settings
order_router = APIRouter(prefix='/order', tags=['orders']) order_router = APIRouter(prefix='/order', tags=['orders'])
ITPAY_API_BASE = 'https://api.gw.itpay.ru' ITPAY_API_BASE = 'https://api.gw.itpay.ru'
ITPAY_AUTHORIZATION = 'Token REPLACE_WITH_JWT_FROM_ITPAY_DASHBOARD'
HARDCODED_USDT_TO_RUB = Decimal('100') HARDCODED_USDT_TO_RUB = Decimal('100')
HARDCODED_GAS_RUB = Decimal('15') HARDCODED_GAS_RUB = Decimal('15')
HARDCODED_OUR_COMMISSION_RUB = Decimal('25') HARDCODED_OUR_COMMISSION_RUB = Decimal('25')
@@ -52,7 +52,7 @@ async def create_order(
} }
url = f'{ITPAY_API_BASE}/v1/payments' url = f'{ITPAY_API_BASE}/v1/payments'
headers = { headers = {
'Authorization': ITPAY_AUTHORIZATION, 'Authorization': settings.ITPAY_AUTHORIZATION,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
} }