feat: add get payments and orders

This commit is contained in:
2026-05-17 15:55:51 +03:00
parent 50bfaa9264
commit e41e89277f
7 changed files with 107 additions and 5 deletions

View File

@@ -29,6 +29,11 @@ class IPaymentRepository(ABC):
raise NotImplementedError
@abstractmethod
async def get_by_id_for_user(self,*,payment_id:str,user_id:str) -> PaymentEntity | None:
raise NotImplementedError
@abstractmethod
async def list_by_user_id(self,*,user_id:str,limit:int,offset:int) -> list[PaymentEntity]:
raise NotImplementedError

View File

@@ -1,4 +1,4 @@
from src.application.commands.create_order_command import CreateOrderCommand
from src.application.commands.create_payment_command import CreatePaymentCommand
from src.application.commands.create_crypto_transfer_completed_command import CreateCryptoTransferCompletedCommand
from src.application.commands.payment_read_commands import GetOrderCommand,GetOrderStatusCommand,GetPaymentConfigCommand,GetPaymentQuoteCommand,GetPaymentQuoteFromRubCommand,ListOrdersCommand,ListPaymentsCommand,OrderPaymentResult
from src.application.commands.payment_read_commands import GetOrderCommand,GetOrderStatusCommand,GetPaymentCommand,GetPaymentConfigCommand,GetPaymentQuoteCommand,GetPaymentQuoteFromRubCommand,ListOrdersCommand,ListPaymentsCommand,OrderPaymentResult

View File

@@ -91,6 +91,24 @@ class ListPaymentsCommand:
return payments
class GetPaymentCommand:
def __init__(self, *, unit_of_work: IUnitOfWork, logger: ILogger):
self._unit_of_work = unit_of_work
self._logger = logger
@transactional
async def __call__(self, *, payment_id: str, user_id: str) -> PaymentEntity:
payment = await self._unit_of_work.payment_repository.get_by_id_for_user(
payment_id=payment_id,
user_id=user_id,
)
if payment is None:
raise NotFoundException(message='Payment not found')
self._logger.info({'event':'payment_detail_requested','payment_id':payment_id,'user_id':user_id})
return payment
class GetOrderCommand:
def __init__(self, *, unit_of_work: IUnitOfWork, logger: ILogger):
self._unit_of_work = unit_of_work