diff --git a/src/bitpay/models/invoice/invoice.py b/src/bitpay/models/invoice/invoice.py index 318b3b1..ebaf00a 100644 --- a/src/bitpay/models/invoice/invoice.py +++ b/src/bitpay/models/invoice/invoice.py @@ -2,10 +2,11 @@ Invoice """ -from typing import List, Union +from typing import List, Union, Dict from pydantic import Field from .buyer import Buyer from .buyer_provided_info import BuyerProvidedInfo +from .invoice_refund_address import InvoiceRefundAddress from .miner_fees import MinerFees from .refund_info import RefundInfo from .shopper import Shopper @@ -47,7 +48,7 @@ class Invoice(BitPayModel): payment_codes: Union[dict, None] = None acceptance_window: Union[int, None] = None buyer: Union[Buyer, None] = None - refund_addresses: Union[List[str], None] = None + refund_addresses: Union[List[Dict[str, InvoiceRefundAddress]], None] = None close_url: Union[str, None] = Field(alias="closeURL", default=None) auto_redirect: Union[bool, None] = False json_paypro_required: bool = False diff --git a/src/bitpay/models/invoice/invoice_refund_address.py b/src/bitpay/models/invoice/invoice_refund_address.py new file mode 100644 index 0000000..63f1ed7 --- /dev/null +++ b/src/bitpay/models/invoice/invoice_refund_address.py @@ -0,0 +1,20 @@ +""" +InvoiceRefundAddress +""" + +from datetime import datetime +from typing import Union +from pydantic import field_serializer + +from bitpay.models.bitpay_model import BitPayModel + + +class InvoiceRefundAddress(BitPayModel): + date: Union[datetime, None] = None + email: Union[str, None] = None + tag: Union[int, None] = None + type: Union[str, None] = None + + @field_serializer("date") + def serialize_datetime(self, dt: datetime) -> str: + return super().serialize_datetime_to_iso8601(dt) diff --git a/tests/unit/json/create_invoice_response.json b/tests/unit/json/create_invoice_response.json index 98e7678..191c07d 100644 --- a/tests/unit/json/create_invoice_response.json +++ b/tests/unit/json/create_invoice_response.json @@ -31,7 +31,15 @@ "notify": true }, "autoRedirect": true, - "refundAddresses": [], + "refundAddresses": [ + { + "n2MDYgEhxCAnuoVd1JpPmvxZShE6rQA6zv": { + "type": "buyerSupplied", + "date": "2024-01-08T23:50:56.556Z", + "email": "email@email.com" + } + } + ], "refundAddressRequestPending": false, "buyerProvidedEmail": "m.warzybok@sumoheavy.com", "buyerProvidedInfo": {