88
99from pydantic import BaseConfig , Extra , Field
1010
11- from glQiwiApi .types .amount import HashablePlainAmount , PlainAmount
11+ from glQiwiApi .types .amount import Amount , HashableAmount
1212from glQiwiApi .types .base import HashableBase
1313from glQiwiApi .types .exceptions import WebhookSignatureUnverifiedError
1414
@@ -39,7 +39,7 @@ class BillError(HashableBase):
3939
4040
4141class Bill (HashableBase ):
42- amount : HashablePlainAmount
42+ value : HashableAmount
4343 status : BillStatus
4444 site_id : str = Field (..., alias = 'siteId' )
4545 id : str = Field (..., alias = 'billId' )
@@ -61,13 +61,13 @@ def invoice_uid(self) -> str:
6161class RefundedBill (HashableBase ):
6262 """object: RefundedBill"""
6363
64- amount : PlainAmount
64+ value : Amount
6565 datetime : datetime
6666 refund_id : str = Field (..., alias = 'refundId' )
6767 status : str
6868
6969 def __str__ (self ) -> str :
70- return f'№{ self .refund_id } { self .status } { self .amount } { self .datetime } '
70+ return f'№{ self .refund_id } { self .status } { self .value } { self .datetime } '
7171
7272
7373class BillWebhookPayload (Bill ):
@@ -79,13 +79,13 @@ class BillWebhook(HashableBase):
7979 bill : BillWebhookPayload = Field (..., alias = 'bill' )
8080
8181 def __repr__ (self ) -> str :
82- return f'#{ self .bill .id } { self .bill .amount } { self .bill .status } '
82+ return f'#{ self .bill .id } { self .bill .value } { self .bill .status } '
8383
8484 def verify_signature (self , sha256_signature : str , secret_p2p_key : str ) -> None :
8585 webhook_key = base64 .b64decode (bytes (secret_p2p_key , 'utf-8' ))
8686 bill = self .bill
8787
88- invoice_params = f'{ bill .amount .currency } |{ bill .amount .value } |{ bill .id } |{ bill .site_id } |{ bill .status .value } '
88+ invoice_params = f'{ bill .value .currency } |{ bill .value .value } |{ bill .id } |{ bill .site_id } |{ bill .status .value } '
8989 generated_signature = hmac .new (
9090 webhook_key , invoice_params .encode ('utf-8' ), hashlib .sha256
9191 ).hexdigest ()
0 commit comments