feat: update full path payment
This commit is contained in:
@@ -16,18 +16,18 @@ class PaymentRepository(IPaymentRepository):
|
||||
self._logger=logger
|
||||
|
||||
|
||||
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:
|
||||
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) -> bool:
|
||||
stmt=select(Payment).where(Payment.order_id==order_id)
|
||||
existing=await self._session.scalar(stmt)
|
||||
if existing is not None:
|
||||
return
|
||||
return False
|
||||
paid_at_dt=datetime.fromisoformat(paid_at.replace('Z','+00:00')) if paid_at else None
|
||||
expired_dt=datetime.fromisoformat(expired_date.replace('Z','+00:00')) if expired_date else None
|
||||
paid_amount_dec=Decimal(str(itpay_paid_amount)) if itpay_paid_amount is not None else None
|
||||
model=Payment(
|
||||
user_id=user_id,
|
||||
order_id=order_id,
|
||||
status=PaymentStatus.PENDING,
|
||||
status=PaymentStatus.MONEY_ACCEPTED,
|
||||
receipt_cloudekassir_id=None,
|
||||
receipt_cloudekassir_link=None,
|
||||
itpay_payment_id=itpay_payment_id,
|
||||
@@ -38,6 +38,17 @@ class PaymentRepository(IPaymentRepository):
|
||||
)
|
||||
self._session.add(model)
|
||||
await self._session.flush()
|
||||
return True
|
||||
|
||||
|
||||
async def update_crypto_transfer_completed(self,*,order_id:str,web3_transaction_hash:str|None) -> None:
|
||||
stmt=select(Payment).where(Payment.order_id==order_id)
|
||||
model=await self._session.scalar(stmt)
|
||||
if model is None:
|
||||
return
|
||||
model.status=PaymentStatus.USDT_DELIVERED
|
||||
model.web3_transaction_hash=web3_transaction_hash
|
||||
await self._session.flush()
|
||||
return
|
||||
|
||||
|
||||
@@ -46,6 +57,7 @@ class PaymentRepository(IPaymentRepository):
|
||||
model=await self._session.scalar(stmt)
|
||||
if model is None:
|
||||
return
|
||||
model.status=PaymentStatus.COMPLETED
|
||||
model.receipt_cloudekassir_id=receipt_cloudekassir_id
|
||||
model.receipt_cloudekassir_link=receipt_cloudekassir_link
|
||||
await self._session.flush()
|
||||
|
||||
Reference in New Issue
Block a user