Skip to content

Commit 70b857f

Browse files
Changes generated by b32716e8dc0be2381602a8faf94f5586b2197c32
This commit was automatically created from gocardless/gocardless-pro-python-template@b32716e by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-python-template/actions/runs/20171862075
1 parent c6c450a commit 70b857f

File tree

12 files changed

+257
-15
lines changed

12 files changed

+257
-15
lines changed

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,17 @@ Payments
574574
# Retry a payment
575575
client.payments.retry('PM123', params={...})
576576
577+
Payment accounts
578+
''''''''''''''''''''''''''''''''''''''''''
579+
580+
.. code:: python
581+
582+
# List payment accounts
583+
client.payment_accounts.list(params={...})
584+
585+
# Iterate through all payment_accounts
586+
client.payment_accounts.all(params={...})
587+
577588
Payment account transactions
578589
''''''''''''''''''''''''''''''''''''''''''
579590

gocardless_pro/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def payer_themes(self):
157157
def payments(self):
158158
return services.PaymentsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
159159

160+
@property
161+
def payment_accounts(self):
162+
return services.PaymentAccountsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
163+
160164
@property
161165
def payment_account_transactions(self):
162166
return services.PaymentAccountTransactionsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

gocardless_pro/resources/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363

6464
from .payment import Payment
6565

66+
from .payment_account import PaymentAccount
67+
6668
from .payment_account_transaction import PaymentAccountTransaction
6769

6870
from .payout import Payout
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# WARNING: Do not edit by hand, this file was generated by Crank:
2+
#
3+
# https://github.com/gocardless/crank
4+
#
5+
6+
class PaymentAccount(object):
7+
"""A thin wrapper around a payment_account, providing easy access to its
8+
attributes.
9+
10+
Example:
11+
payment_account = client.payment_accounts.get()
12+
payment_account.id
13+
"""
14+
15+
def __init__(self, attributes, api_response):
16+
self.attributes = attributes
17+
self.api_response = api_response
18+
19+
@property
20+
def account_balance(self):
21+
return self.attributes.get('account_balance')
22+
23+
24+
@property
25+
def account_holder_name(self):
26+
return self.attributes.get('account_holder_name')
27+
28+
29+
@property
30+
def account_number_ending(self):
31+
return self.attributes.get('account_number_ending')
32+
33+
34+
@property
35+
def bank_name(self):
36+
return self.attributes.get('bank_name')
37+
38+
39+
@property
40+
def currency(self):
41+
return self.attributes.get('currency')
42+
43+
44+
@property
45+
def id(self):
46+
return self.attributes.get('id')
47+
48+
49+
@property
50+
def links(self):
51+
return self.Links(self.attributes.get('links'))
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
class Links(object):
69+
"""Wrapper for the response's 'links' attribute."""
70+
71+
def __init__(self, attributes):
72+
self.attributes = attributes
73+
74+
@property
75+
def creditor(self):
76+
return self.attributes.get('creditor')
77+
78+
79+

gocardless_pro/services/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from .payer_authorisations_service import PayerAuthorisationsService
3434
from .payer_themes_service import PayerThemesService
3535
from .payments_service import PaymentsService
36+
from .payment_accounts_service import PaymentAccountsService
3637
from .payment_account_transactions_service import PaymentAccountTransactionsService
3738
from .payouts_service import PayoutsService
3839
from .payout_items_service import PayoutItemsService
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# WARNING: Do not edit by hand, this file was generated by Crank:
2+
#
3+
# https://github.com/gocardless/crank
4+
#
5+
6+
from . import base_service
7+
from .. import resources
8+
from ..paginator import Paginator
9+
from .. import errors
10+
11+
class PaymentAccountsService(base_service.BaseService):
12+
"""Service class that provides access to the payment_accounts
13+
endpoints of the GoCardless Pro API.
14+
"""
15+
16+
RESOURCE_CLASS = resources.PaymentAccount
17+
RESOURCE_NAME = 'payment_accounts'
18+
19+
20+
def list(self,params=None, headers=None):
21+
"""List payment accounts.
22+
23+
Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your
24+
payment accounts.
25+
26+
Args:
27+
params (dict, optional): Query string parameters.
28+
29+
Returns:
30+
ListResponse of PaymentAccount instances
31+
"""
32+
path = '/payment_accounts'
33+
34+
35+
response = self._perform_request('GET', path, params, headers,
36+
retry_failures=True)
37+
return self._resource_for(response)
38+
39+
def all(self,params=None):
40+
if params is None:
41+
params = {}
42+
return Paginator(self, params, identity_params={
43+
})
44+
45+

tests/client_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def test_payer_themes_returns_service():
107107
def test_payments_returns_service():
108108
assert isinstance(client.payments, services.PaymentsService)
109109

110+
def test_payment_accounts_returns_service():
111+
assert isinstance(client.payment_accounts, services.PaymentAccountsService)
112+
110113
def test_payment_account_transactions_returns_service():
111114
assert isinstance(client.payment_account_transactions, services.PaymentAccountTransactionsService)
112115

tests/fixtures/billing_request_with_actions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"method": "POST",
66
"path_template": "/billing_requests/create_with_actions",
77
"url_params": [],
8-
"body": {"billing_request_with_actions":{"bank_authorisations":{"authorisation_type":"example authorisation_type 102","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-15T10:00:00.000Z","expires_at":"2024-01-15T10:00:00.000Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"},"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 101","authorisation_type":"example authorisation_type 101"},"collect_customer_details":{"default_country_code":"example default_country_code 101","incomplete_fields":{"customer":["example customer 101"],"customer_billing_detail":["example customer_billing_detail 101"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 101"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 101","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 102","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 101","constraints":{"end_date":"example end_date 101","max_amount_per_payment":101,"payment_method":"example payment_method 101","periodic_limits":[{"alignment":"creation_date","max_payments":101,"max_total_amount":101,"period":"week"}],"start_date":"example start_date 101"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 101"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 101"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"utility","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"[email protected]","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 102"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 101"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 101"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}}}
8+
"body": {"billing_request_with_actions":{"bank_authorisations":{"authorisation_type":"example authorisation_type 102","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-15T10:00:00.000Z","expires_at":"2024-01-15T10:00:00.000Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"},"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 101","authorisation_type":"example authorisation_type 101"},"collect_customer_details":{"default_country_code":"example default_country_code 101","incomplete_fields":{"customer":["example customer 102"],"customer_billing_detail":["example customer_billing_detail 102"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 101"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 101","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 101","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 101","constraints":{"end_date":"example end_date 101","max_amount_per_payment":101,"payment_method":"example payment_method 101","periodic_limits":[{"alignment":"creation_date","max_payments":101,"max_total_amount":101,"period":"week"}],"start_date":"example start_date 101"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 101"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 101"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"utility","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"[email protected]","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 101"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 101"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 101"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}}}
99
}
1010
}

0 commit comments

Comments
 (0)