Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gocardless_pro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

from .client import Client

__version__ = '3.4.1'
__version__ = '3.5.0'

4 changes: 2 additions & 2 deletions gocardless_pro/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _default_headers(self):
'Authorization': 'Bearer {0}'.format(self.access_token),
'Content-Type': 'application/json',
'GoCardless-Client-Library': 'gocardless-pro-python',
'GoCardless-Client-Version': '3.4.1',
'GoCardless-Client-Version': '3.5.0',
'User-Agent': self._user_agent(),
'GoCardless-Version': '2015-07-06',
}
Expand All @@ -181,7 +181,7 @@ def _user_agent(self):
python_version = '.'.join(platform.python_version_tuple()[0:2])
vm_version = '{}.{}.{}-{}{}'.format(*sys.version_info)
return ' '.join([
'gocardless-pro-python/3.4.1',
'gocardless-pro-python/3.5.0',
'python/{0}'.format(python_version),
'{0}/{1}'.format(platform.python_implementation(), vm_version),
'{0}/{1}'.format(platform.system(), platform.release()),
Expand Down
7 changes: 7 additions & 0 deletions gocardless_pro/resources/mandate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def links(self):
return self.Links(self.attributes.get('links'))


@property
def mandate_type(self):
return self.attributes.get('mandate_type')


@property
def metadata(self):
return self.attributes.get('metadata')
Expand Down Expand Up @@ -175,4 +180,6 @@ def new_mandate(self):






2 changes: 1 addition & 1 deletion gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def notify(self,identity,params=None, headers=None):
authorise it.
Currently, the customer can only be notified by email.

This endpoint is currently supported only for Instant Bank Pay Billing
This endpoint is currently supported only for Pay by Bank Billing
Requests.

Args:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name = 'gocardless_pro',
version = '3.4.1',
version = '3.5.0',
packages = find_packages(exclude=['tests']),
install_requires = ['requests>=2.6'],
python_requires = '>=3.6',
Expand Down
52 changes: 52 additions & 0 deletions tests/code_samples/billing_requests_code_samples_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,60 @@ def test_billing_requests_notify_code_sample():



@responses.activate
def test_billing_requests_fallback_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/billing_requests/:identity/actions/fallback'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'billing_requests': {} }
for _ in range(5):
responses.add(
'POST',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.billing_requests.fallback("BR123")
finally:
sys.stdout = old_stdout




@responses.activate
def test_billing_requests_choose_currency_code_sample():
# Convert :param placeholders to regex wildcards for flexible matching
stub_url = '/billing_requests/:identity/actions/choose_currency'
url_pattern = re.compile('https://api.gocardless.com' + re.sub(r':[\w]+', r'[^/]+', stub_url))
# Mock response - repeat multiple times to handle code samples with multiple API calls
response_body = { 'billing_requests': {} }
for _ in range(5):
responses.add(
'POST',
url_pattern,
json=response_body,
status=200
)

client = gocardless_pro.Client(access_token='SECRET_TOKEN', environment='live')

# Suppress stdout from code samples that use print
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
client.billing_requests.choose_currency("BR123", params={
"currency": "GBP"
})
finally:
sys.stdout = old_stdout



Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/events.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions tests/fixtures/mandates.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
"method": "POST",
"path_template": "/mandates",
"url_params": [],
"body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 101","max_amount_per_payment":101,"max_amount_per_period":101,"max_payments_per_period":101,"period":"week","start_date":"example start_date 101"},"consent_type":"example consent_type 101","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
"body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 101","max_amount_per_payment":101,"max_amount_per_period":101,"max_payments_per_period":101,"period":"week","start_date":"example start_date 101"},"consent_type":"example consent_type 101","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
},
"list": {
"method": "GET",
"path_template": "/mandates",
"url_params": [],
"body": {"mandates":[{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 102","max_amount_per_payment":102,"max_amount_per_period":102,"max_payments_per_period":102,"period":"month","start_date":"example start_date 102"},"consent_type":"example consent_type 102","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"},{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 103","max_amount_per_payment":103,"max_amount_per_period":103,"max_payments_per_period":103,"period":"year","start_date":"example start_date 103"},"consent_type":"example consent_type 103","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}}
"body": {"mandates":[{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 102","max_amount_per_payment":102,"max_amount_per_period":102,"max_payments_per_period":102,"period":"month","start_date":"example start_date 102"},"consent_type":"example consent_type 102","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"},{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 103","max_amount_per_payment":103,"max_amount_per_period":103,"max_payments_per_period":103,"period":"year","start_date":"example start_date 103"},"consent_type":"example consent_type 103","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}}
},
"get": {
"method": "GET",
"path_template": "/mandates/:identity",
"url_params": ["MD123"],
"body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 104","max_amount_per_payment":104,"max_amount_per_period":104,"max_payments_per_period":104,"period":"flexible","start_date":"example start_date 104"},"consent_type":"example consent_type 104","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
"body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 104","max_amount_per_payment":104,"max_amount_per_period":104,"max_payments_per_period":104,"period":"flexible","start_date":"example start_date 104"},"consent_type":"example consent_type 104","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
},
"update": {
"method": "PUT",
"path_template": "/mandates/:identity",
"url_params": ["MD123"],
"body": {"mandates":{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 105","max_amount_per_payment":105,"max_amount_per_period":105,"max_payments_per_period":105,"period":"day","start_date":"example start_date 105"},"consent_type":"example consent_type 105","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
"body": {"mandates":{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 105","max_amount_per_payment":105,"max_amount_per_period":105,"max_payments_per_period":105,"period":"day","start_date":"example start_date 105"},"consent_type":"example consent_type 105","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
},
"cancel": {
"method": "POST",
"path_template": "/mandates/:identity/actions/cancel",
"url_params": ["MD123"],
"body": {"mandates":{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 106","max_amount_per_payment":106,"max_amount_per_period":106,"max_payments_per_period":106,"period":"week","start_date":"example start_date 106"},"consent_type":"example consent_type 106","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
"body": {"mandates":{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 106","max_amount_per_payment":106,"max_amount_per_period":106,"max_payments_per_period":106,"period":"week","start_date":"example start_date 106"},"consent_type":"example consent_type 106","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
},
"reinstate": {
"method": "POST",
"path_template": "/mandates/:identity/actions/reinstate",
"url_params": ["MD123"],
"body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 107","max_amount_per_payment":107,"max_amount_per_period":107,"max_payments_per_period":107,"period":"month","start_date":"example start_date 107"},"consent_type":"example consent_type 107","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
"body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 107","max_amount_per_payment":107,"max_amount_per_period":107,"max_payments_per_period":107,"period":"month","start_date":"example start_date 107"},"consent_type":"example consent_type 107","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"mandate_type":"bank_debit","metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}}
}
}
6 changes: 6 additions & 0 deletions tests/integration/mandates_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_mandates_create():
assert response.created_at == body.get('created_at')
assert response.funds_settlement == body.get('funds_settlement')
assert response.id == body.get('id')
assert response.mandate_type == body.get('mandate_type')
assert response.metadata == body.get('metadata')
assert response.next_possible_charge_date == body.get('next_possible_charge_date')
assert response.next_possible_standard_ach_charge_date == body.get('next_possible_standard_ach_charge_date')
Expand Down Expand Up @@ -108,6 +109,7 @@ def test_mandates_list():
assert [r.created_at for r in response.records] == [b.get('created_at') for b in body]
assert [r.funds_settlement for r in response.records] == [b.get('funds_settlement') for b in body]
assert [r.id for r in response.records] == [b.get('id') for b in body]
assert [r.mandate_type for r in response.records] == [b.get('mandate_type') for b in body]
assert [r.metadata for r in response.records] == [b.get('metadata') for b in body]
assert [r.next_possible_charge_date for r in response.records] == [b.get('next_possible_charge_date') for b in body]
assert [r.next_possible_standard_ach_charge_date for r in response.records] == [b.get('next_possible_standard_ach_charge_date') for b in body]
Expand Down Expand Up @@ -180,6 +182,7 @@ def test_mandates_get():
assert response.created_at == body.get('created_at')
assert response.funds_settlement == body.get('funds_settlement')
assert response.id == body.get('id')
assert response.mandate_type == body.get('mandate_type')
assert response.metadata == body.get('metadata')
assert response.next_possible_charge_date == body.get('next_possible_charge_date')
assert response.next_possible_standard_ach_charge_date == body.get('next_possible_standard_ach_charge_date')
Expand Down Expand Up @@ -235,6 +238,7 @@ def test_mandates_update():
assert response.created_at == body.get('created_at')
assert response.funds_settlement == body.get('funds_settlement')
assert response.id == body.get('id')
assert response.mandate_type == body.get('mandate_type')
assert response.metadata == body.get('metadata')
assert response.next_possible_charge_date == body.get('next_possible_charge_date')
assert response.next_possible_standard_ach_charge_date == body.get('next_possible_standard_ach_charge_date')
Expand Down Expand Up @@ -290,6 +294,7 @@ def test_mandates_cancel():
assert response.created_at == body.get('created_at')
assert response.funds_settlement == body.get('funds_settlement')
assert response.id == body.get('id')
assert response.mandate_type == body.get('mandate_type')
assert response.metadata == body.get('metadata')
assert response.next_possible_charge_date == body.get('next_possible_charge_date')
assert response.next_possible_standard_ach_charge_date == body.get('next_possible_standard_ach_charge_date')
Expand Down Expand Up @@ -340,6 +345,7 @@ def test_mandates_reinstate():
assert response.created_at == body.get('created_at')
assert response.funds_settlement == body.get('funds_settlement')
assert response.id == body.get('id')
assert response.mandate_type == body.get('mandate_type')
assert response.metadata == body.get('metadata')
assert response.next_possible_charge_date == body.get('next_possible_charge_date')
assert response.next_possible_standard_ach_charge_date == body.get('next_possible_standard_ach_charge_date')
Expand Down
Loading