Skip to content

Commit

Permalink
Merge pull request #375 from mollie/373-payment-resource-updates
Browse files Browse the repository at this point in the history
373 payment resource updates
  • Loading branch information
geertjanvdenbosch authored Feb 17, 2025
2 parents 1984f2f + 03f7ea7 commit 4c31b4b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
1 change: 0 additions & 1 deletion mollie/api/objects/client_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class ClientLink(ObjectBase):

def __init__(self, data, client):
warnings.warn(
"ClientLink is currently in open beta, and the final specification may still change.",
Expand Down
18 changes: 18 additions & 0 deletions mollie/api/objects/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ def subscription_id(self):
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
Expand Down
40 changes: 40 additions & 0 deletions tests/responses/payment_single_no_links.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"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": "[email protected]"
},
"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": {
Expand Down
39 changes: 39 additions & 0 deletions tests/test_payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"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": "[email protected]",
}

# properties from _links
assert payment.checkout_url == "https://www.mollie.com/payscreen/select-method/7UhSN1zuXS"
assert payment.changepaymentstate_url is None
Expand Down

0 comments on commit 4c31b4b

Please sign in to comment.