Repository: mollie/mollie-api-python

Issue:
Update Payment resource
The Payment resource can contain multiple properties that are missing right now:

- restrictPaymentMethodsToCountry
- shippingAddress
- billingAddress
- lines



Discussion:

Patch:
diff --git a/mollie/api/objects/client_link.py b/mollie/api/objects/client_link.py
index dc2a298..7be2e74 100644
--- a/mollie/api/objects/client_link.py
+++ b/mollie/api/objects/client_link.py
@@ -5,7 +5,6 @@ from .base import ObjectBase
 
 
 class ClientLink(ObjectBase):
-
     def __init__(self, data, client):
         warnings.warn(
             "ClientLink is currently in open beta, and the final specification may still change.",
diff --git a/mollie/api/objects/payment.py b/mollie/api/objects/payment.py
index ed361d5..4db49bc 100644
--- a/mollie/api/objects/payment.py
+++ b/mollie/api/objects/payment.py
@@ -161,6 +161,24 @@ class Payment(ObjectBase):
     def cancel_url(self):
         return self._get_property("cancelUrl")
 
+    @property
+    def lines(self):
+        # We do not use the OrderLine object here, because lines on a Payment
+        # are not a resource, but simply a property that exists on the Payment.
+        return self._get_property("lines")
+
+    @property
+    def restrict_payment_methods_to_country(self):
+        return self._get_property("restrictPaymentMethodsToCountry")
+
+    @property
+    def shipping_address(self):
+        return self._get_property("shippingAddress")
+
+    @property
+    def billing_address(self):
+        return self._get_property("billingAddress")
+
     # documented _links
 
     @property


Test patch:
diff --git a/tests/responses/payment_single_no_links.json b/tests/responses/payment_single_no_links.json
index c53d20a..43b78c2 100644
--- a/tests/responses/payment_single_no_links.json
+++ b/tests/responses/payment_single_no_links.json
@@ -10,6 +10,46 @@
     "value": "10.00",
     "currency": "EUR"
   },
+    "restrictPaymentMethodsToCountry": "NL",
+  "billingAddress": {
+    "streetAndNumber": "Keizersgracht 313",
+    "city": "Amsterdam",
+    "region": "Noord-Holland",
+    "postalCode": "1234AB",
+    "country": "NL",
+    "title": "Dhr.",
+    "givenName": "Piet",
+    "familyName": "Mondriaan",
+    "email": "piet@mondriaan.com",
+    "phone": "+31309202070"
+  },
+  "shippingAddress": {
+    "streetAndNumber": "Keizersgracht 313",
+    "streetAdditional": "4th floor",
+    "city": "Haarlem",
+    "region": "Noord-Holland",
+    "postalCode": "5678AB",
+    "country": "NL",
+    "title": "Mr.",
+    "givenName": "Chuck",
+    "familyName": "Norris",
+    "email": "norris@chucknorrisfacts.net"
+  },
+  "lines": [
+    {
+      "type": "physical",
+      "description": "Product 1",
+      "quantity": 1,
+      "unitPrice": {
+        "value": "2.00",
+        "currency": "EUR"
+      },
+      "totalAmount": {
+        "value": "2.00",
+        "currency": "EUR"
+      }
+    }
+  ],
   "description": "Order #12345",
   "method": "ideal",
   "metadata": {
diff --git a/tests/test_payments.py b/tests/test_payments.py
index 9a26276..0ce06ff 100644
--- a/tests/test_payments.py
+++ b/tests/test_payments.py
@@ -110,6 +110,45 @@ def test_get_single_payment(client, response):
     assert payment.capture_mode == "automatic"
     assert payment.capture_before == "2023-01-20T09:13:37+00+00"
     assert payment.capture_delay == "20 hours"
+    assert payment.restrict_payment_methods_to_country == "NL"
+    # lines property
+    assert payment.lines == [
+        {
+            "type": "physical",
+            "description": "Product 1",
+            "quantity": 1,
+            "unitPrice": {"value": "2.00", "currency": "EUR"},
+            "totalAmount": {"value": "2.00", "currency": "EUR"},
+        }
+    ]
+    # billing_address property
+    assert payment.billing_address == {
+        "streetAndNumber": "Keizersgracht 313",
+        "city": "Amsterdam",
+        "region": "Noord-Holland",
+        "postalCode": "1234AB",
+        "country": "NL",
+        "title": "Dhr.",
+        "givenName": "Piet",
+        "familyName": "Mondriaan",
+        "email": "piet@mondriaan.com",
+        "phone": "+31309202070",
+    }
+
+    # shipping_address property
+    assert payment.shipping_address == {
+        "streetAndNumber": "Keizersgracht 313",
+        "streetAdditional": "4th floor",
+        "city": "Haarlem",
+        "region": "Noord-Holland",
+        "postalCode": "5678AB",
+        "country": "NL",
+        "title": "Mr.",
+        "givenName": "Chuck",
+        "familyName": "Norris",
+        "email": "norris@chucknorrisfacts.net",
+    }
+
     # properties from _links
     assert payment.checkout_url == "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS"
     assert payment.changepaymentstate_url is None