Skip to content

Commit b297ba9

Browse files
Update Payment object, so it contains lines, billing and shipping address and restrict_payment_methods_to_country
1 parent 1984f2f commit b297ba9

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

mollie/api/objects/payment.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ def subscription_id(self):
161161
def cancel_url(self):
162162
return self._get_property("cancelUrl")
163163

164+
@property
165+
def lines(self):
166+
# We do not use the OrderLine object here, because lines on a Payment
167+
# are not a resource, but simply a property that exists on the Payment.
168+
return self._get_property("lines")
169+
170+
@property
171+
def restrict_payment_methods_to_country(self):
172+
return self._get_property("restrictPaymentMethodsToCountry")
173+
174+
@property
175+
def shipping_address(self):
176+
return self._get_property("shippingAddress")
177+
178+
@property
179+
def billing_address(self):
180+
return self._get_property("billingAddress")
181+
164182
# documented _links
165183

166184
@property

tests/responses/payment_single_no_links.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@
1010
"value": "10.00",
1111
"currency": "EUR"
1212
},
13+
"restrictPaymentMethodsToCountry": "NL",
14+
"billingAddress": {
15+
"streetAndNumber": "Keizersgracht 313",
16+
"city": "Amsterdam",
17+
"region": "Noord-Holland",
18+
"postalCode": "1234AB",
19+
"country": "NL",
20+
"title": "Dhr.",
21+
"givenName": "Piet",
22+
"familyName": "Mondriaan",
23+
"email": "[email protected]",
24+
"phone": "+31309202070"
25+
},
26+
"shippingAddress": {
27+
"streetAndNumber": "Keizersgracht 313",
28+
"streetAdditional": "4th floor",
29+
"city": "Haarlem",
30+
"region": "Noord-Holland",
31+
"postalCode": "5678AB",
32+
"country": "NL",
33+
"title": "Mr.",
34+
"givenName": "Chuck",
35+
"familyName": "Norris",
36+
"email": "[email protected]"
37+
},
38+
"lines": [
39+
{
40+
"type": "physical",
41+
"description": "Product 1",
42+
"quantity": 1,
43+
"unitPrice": {
44+
"value": "2.00",
45+
"currency": "EUR"
46+
},
47+
"totalAmount": {
48+
"value": "2.00",
49+
"currency": "EUR"
50+
}
51+
}
52+
],
1353
"description": "Order #12345",
1454
"method": "ideal",
1555
"metadata": {

tests/test_payments.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,45 @@ def test_get_single_payment(client, response):
110110
assert payment.capture_mode == "automatic"
111111
assert payment.capture_before == "2023-01-20T09:13:37+00+00"
112112
assert payment.capture_delay == "20 hours"
113+
assert payment.restrict_payment_methods_to_country == "NL"
114+
# lines property
115+
assert payment.lines == [
116+
{
117+
"type": "physical",
118+
"description": "Product 1",
119+
"quantity": 1,
120+
"unitPrice": {"value": "2.00", "currency": "EUR"},
121+
"totalAmount": {"value": "2.00", "currency": "EUR"},
122+
}
123+
]
124+
# billing_address property
125+
assert payment.billing_address == {
126+
"streetAndNumber": "Keizersgracht 313",
127+
"city": "Amsterdam",
128+
"region": "Noord-Holland",
129+
"postalCode": "1234AB",
130+
"country": "NL",
131+
"title": "Dhr.",
132+
"givenName": "Piet",
133+
"familyName": "Mondriaan",
134+
"email": "[email protected]",
135+
"phone": "+31309202070",
136+
}
137+
138+
# shipping_address property
139+
assert payment.shipping_address == {
140+
"streetAndNumber": "Keizersgracht 313",
141+
"streetAdditional": "4th floor",
142+
"city": "Haarlem",
143+
"region": "Noord-Holland",
144+
"postalCode": "5678AB",
145+
"country": "NL",
146+
"title": "Mr.",
147+
"givenName": "Chuck",
148+
"familyName": "Norris",
149+
"email": "[email protected]",
150+
}
151+
113152
# properties from _links
114153
assert payment.checkout_url == "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS"
115154
assert payment.changepaymentstate_url is None

0 commit comments

Comments
 (0)