fix: agent 4 to 6
This commit is contained in:
@@ -6,3 +6,8 @@ class IPaymentRepository(ABC):
|
||||
async def create_completed(self,*,user_id:str,order_id:str,itpay_payment_id:str,itpay_paid_amount:str|None,transaction_id:str|None,paid_at:str|None,expired_date:str|None) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@abstractmethod
|
||||
async def update_receipt(self,*,order_id:str,receipt_cloudekassir_id:str|None,receipt_cloudekassir_link:str|None) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class CreatePaymentCloudkassirCommand:
|
||||
if paid_total is not None and abs(total_amount - paid_total) > Decimal('0.02'):
|
||||
raise ApplicationException(status_code=400, message='Receipt total does not match paid amount')
|
||||
|
||||
await self._receipt.create_receipt(
|
||||
receipt_response = await self._receipt.create_receipt(
|
||||
order_id=order_id,
|
||||
user_id=user_id,
|
||||
email=email,
|
||||
@@ -102,3 +102,11 @@ class CreatePaymentCloudkassirCommand:
|
||||
service_fee=service_fee,
|
||||
request_id=str(ULID()),
|
||||
)
|
||||
receipt_model = receipt_response.get('Model')
|
||||
if not isinstance(receipt_model, dict):
|
||||
receipt_model = {}
|
||||
await self._unit_of_work.payment_repository.update_receipt(
|
||||
order_id=order_id,
|
||||
receipt_cloudekassir_id=str(receipt_model.get('Id') or '') or None,
|
||||
receipt_cloudekassir_link=str(receipt_model.get('ReceiptLocalUrl') or '') or None,
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ class PaymentEntity:
|
||||
order_id: str | None = None
|
||||
status: PaymentStatus | None = None
|
||||
|
||||
receipt_cloudekassir_id: str | None = None
|
||||
receipt_cloudekassir_link: str | None = None
|
||||
|
||||
itpay_payment_id: str | None = None
|
||||
|
||||
@@ -68,10 +68,10 @@ class ClaudeKassirClient(IReceipt):
|
||||
'amount': float(principal),
|
||||
'vat': 0,
|
||||
'method': 4,
|
||||
'object': 4,
|
||||
'object': 1,
|
||||
'measurement_unit': 'шт',
|
||||
'agent_info': {
|
||||
'type': 4,
|
||||
'type': 6,
|
||||
},
|
||||
'supplier_info': {
|
||||
'name': 'Принципал',
|
||||
@@ -86,7 +86,7 @@ class ClaudeKassirClient(IReceipt):
|
||||
'amount': float(fee),
|
||||
'vat': 0,
|
||||
'method': 4,
|
||||
'object': 1,
|
||||
'object': 4,
|
||||
'measurement_unit': 'шт',
|
||||
},
|
||||
],
|
||||
@@ -99,7 +99,7 @@ class ClaudeKassirClient(IReceipt):
|
||||
'email': email,
|
||||
'phone': phone,
|
||||
},
|
||||
'Email': email,
|
||||
'Email': 'company@elcsa.ru',
|
||||
'SuccessUrl': success_url or self._success_url,
|
||||
'FailUrl': fail_url or self._fail_url,
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ class Payment(Base, UlidPrimaryKeyMixin, AuditTimestampsMixin):
|
||||
default=PaymentStatus.PENDING,
|
||||
)
|
||||
|
||||
receipt_cloudekassir_link: Mapped[str] = mapped_column(nullable=True)
|
||||
receipt_cloudekassir_id: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
receipt_cloudekassir_link: Mapped[str | None] = mapped_column(nullable=True)
|
||||
|
||||
itpay_payment_id: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
itpay_paid_amount: Mapped[Decimal | None] = mapped_column(Numeric(38, 2), nullable=True)
|
||||
|
||||
@@ -28,6 +28,7 @@ class PaymentRepository(IPaymentRepository):
|
||||
user_id=user_id,
|
||||
order_id=order_id,
|
||||
status=PaymentStatus.PENDING,
|
||||
receipt_cloudekassir_id=None,
|
||||
receipt_cloudekassir_link=None,
|
||||
itpay_payment_id=itpay_payment_id,
|
||||
itpay_paid_amount=paid_amount_dec,
|
||||
@@ -39,3 +40,14 @@ class PaymentRepository(IPaymentRepository):
|
||||
await self._session.flush()
|
||||
return
|
||||
|
||||
|
||||
async def update_receipt(self,*,order_id:str,receipt_cloudekassir_id:str|None,receipt_cloudekassir_link:str|None) -> None:
|
||||
stmt=select(Payment).where(Payment.order_id==order_id)
|
||||
model=await self._session.scalar(stmt)
|
||||
if model is None:
|
||||
return
|
||||
model.receipt_cloudekassir_id=receipt_cloudekassir_id
|
||||
model.receipt_cloudekassir_link=receipt_cloudekassir_link
|
||||
await self._session.flush()
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user