Skip to content

Commit

Permalink
Merge pull request #66 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Bump to v1.33.0
  • Loading branch information
opsz2 authored Nov 30, 2022
2 parents 317d7b7 + c97f205 commit 1613fda
Show file tree
Hide file tree
Showing 50 changed files with 345 additions and 80 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<!-- @format -->
# 1.33.0

- Added `mandate_request[description]` and `mandate_request[constraints]` parameters to Billing Request creation
- Added `consent_parameters` to mandate

# 1.32.0

- Added support for `prefilled_customer` and `prefilled_bank_account` in Billing Request Flow
Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ Mandate pdfs
# Create a mandate PDF
client.mandate_pdfs.create(params={...})
Mandate request constraints
''''''''''''''''''''''''''''''''''''''''''

.. code:: python
Payer authorisations
''''''''''''''''''''''''''''''''''''''''''

Expand Down
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__ = '1.32.0'
__version__ = '1.33.0'

4 changes: 2 additions & 2 deletions gocardless_pro/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,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': '1.32.0',
'GoCardless-Client-Version': '1.33.0',
'User-Agent': self._user_agent(),
'GoCardless-Version': '2015-07-06',
}
Expand All @@ -150,7 +150,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/1.32.0',
'gocardless-pro-python/1.33.0',
'python/{0}'.format(python_version),
'{0}/{1}'.format(platform.python_implementation(), vm_version),
'{0}/{1}'.format(platform.system(), platform.release()),
Expand Down
4 changes: 4 additions & 0 deletions gocardless_pro/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ def mandate_import_entries(self):
def mandate_pdfs(self):
return services.MandatePdfsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def mandate_request_constraints(self):
return services.MandateRequestConstraintsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def payer_authorisations(self):
return services.PayerAuthorisationsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
Expand Down
2 changes: 2 additions & 0 deletions gocardless_pro/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

from .mandate_pdf import MandatePdf

from .mandate_request_constraints import MandateRequestConstraints

from .payer_authorisation import PayerAuthorisation

from .payment import Payment
Expand Down
8 changes: 8 additions & 0 deletions gocardless_pro/resources/billing_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,18 @@ class MandateRequest(object):
def __init__(self, attributes):
self.attributes = attributes

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

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

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

@property
def links(self):
return self.attributes.get('links')
Expand Down
7 changes: 7 additions & 0 deletions gocardless_pro/resources/billing_request_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def mandate_request_currency(self):
return self.attributes.get('mandate_request_currency')


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


@property
def mandate_request_metadata(self):
return self.attributes.get('mandate_request_metadata')
Expand Down Expand Up @@ -126,6 +131,8 @@ def updated_at(self):








7 changes: 7 additions & 0 deletions gocardless_pro/resources/creditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def __init__(self, attributes, api_response):
self.attributes = attributes
self.api_response = api_response

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


@property
def address_line1(self):
return self.attributes.get('address_line1')
Expand Down Expand Up @@ -130,6 +135,8 @@ def verification_status(self):








Expand Down
30 changes: 30 additions & 0 deletions gocardless_pro/resources/mandate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def __init__(self, attributes, api_response):
self.attributes = attributes
self.api_response = api_response

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


@property
def created_at(self):
return self.attributes.get('created_at')
Expand Down Expand Up @@ -63,6 +68,31 @@ def status(self):



class ConsentParameters(object):
"""Wrapper for the response's 'consent_parameters' attribute."""

def __init__(self, attributes):
self.attributes = attributes

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

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

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

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







Expand Down
47 changes: 47 additions & 0 deletions gocardless_pro/resources/mandate_request_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

class MandateRequestConstraints(object):
"""A thin wrapper around a mandate_request_constraints, providing easy access to its
attributes.
Example:
mandate_request_constraints = client.mandate_request_constraints.get()
mandate_request_constraints.id
"""

def __init__(self, attributes, api_response):
self.attributes = attributes
self.api_response = api_response

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


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


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


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











1 change: 1 addition & 0 deletions gocardless_pro/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .mandate_imports_service import MandateImportsService
from .mandate_import_entries_service import MandateImportEntriesService
from .mandate_pdfs_service import MandatePdfsService
from .mandate_request_constraints_service import MandateRequestConstraintsService
from .payer_authorisations_service import PayerAuthorisationsService
from .payments_service import PaymentsService
from .payouts_service import PayoutsService
Expand Down
9 changes: 6 additions & 3 deletions gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@ def choose_currency(self,identity,params=None, headers=None):
"""Change currency for a Billing Request.
This will allow for the updating of the currency and subsequently the
scheme if needed for a billing request
this will only be available for mandate only flows, it will not support
payments requests or plans
scheme if
needed for a Billing Request. This will only be available for mandate
only flows
which do not have the lock_currency flag set to true on the Billing
Request Flow. It
will also not support any request which has a payments request.
Args:
identity (string): Unique identifier, beginning with "BRQ".
Expand Down
18 changes: 18 additions & 0 deletions gocardless_pro/services/mandate_request_constraints_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

from . import base_service
from .. import resources
from ..paginator import Paginator
from .. import errors

class MandateRequestConstraintsService(base_service.BaseService):
"""Service class that provides access to the mandate_request_constraints
endpoints of the GoCardless Pro API.
"""

RESOURCE_CLASS = resources.MandateRequestConstraints
RESOURCE_NAME = 'mandate_request_constraints'

6 changes: 6 additions & 0 deletions gocardless_pro/services/payout_items_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def list(self,params=None, headers=None):
Returns a [cursor-paginated](#api-usage-cursor-pagination) list of
items in the payout.
<div class="notice notice--warning u-block">
<strong>Note</strong>: From 1 March 2023 onwards, we will only serve
requests for payout items created in the last 6 months. Requests for
older payouts will return an HTTP status <code>410 Gone</code>.
</div>
Args:
params (dict, optional): Query string parameters.
Expand Down
1 change: 1 addition & 0 deletions gocardless_pro/services/scenario_simulators_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def run(self,identity,params=None, headers=None):
<li>`mandate_expired`: Transitions a mandate through to `expired`, having been submitted to the banks, set up successfully and then expired because no collection attempts were made against it for longer than the scheme's dormancy period (13 months for Bacs, 3 years for SEPA, 15 months for ACH, Betalingsservice, and BECS). It must start in the `pending_submission` state. Not compatible with Autogiro, BECS NZ, and PAD mandates, which do not expire.</li>
<li>`mandate_transferred`: Transitions a mandate through to `transferred`, having been submitted to the banks, set up successfully and then moved to a new bank account due to the customer using the UK's Current Account Switching Service (CASS). It must start in the `pending_submission` state. Only compatible with Bacs mandates.</li>
<li>`mandate_transferred_with_resubmission`: Transitions a mandate through `transferred` and resubmits it to the banks, can be caused be the UK's Current Account Switching Service (CASS) or when a customer contacts GoCardless to change their bank details. It must start in the `pending_submission` state. Only compatible with Bacs, SEPA and Autogiro mandates.</li>
<li>`mandate_suspended_by_payer`: Transitions a mandate to `suspended_by_payer`, as if payer has suspended the mandate after it has been setup successfully. It must start in the `activated` state. Only compatible with PAY_TO mandates.</li>
<li>`refund_paid`: Transitions a refund to `paid`. It must start in either the `pending_submission` or `submitted` state.</li>
<li>`refund_settled`: Transitions a refund to `paid`, if it's not already, then generates a payout that includes the refund, thereby settling the funds. It must start in one of `pending_submission`, `submitted` or `paid` states.</li>
<li>`refund_bounced`: Transitions a refund to `bounced`. It must start in either the `pending_submission`, `submitted`, or `paid` state.</li>
Expand Down
4 changes: 3 additions & 1 deletion gocardless_pro/services/subscriptions_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def list(self,params=None, headers=None):
"""List subscriptions.
Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your
subscriptions.
subscriptions. Please note if the subscriptions are related to
customers who have been removed, they will not be shown in the
response.
Args:
params (dict, optional): Query string parameters.
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 = '1.32.0',
version = '1.33.0',
packages = find_packages(exclude=['tests']),
install_requires = ['requests>=2.6', 'six'],
author = 'GoCardless',
Expand Down
3 changes: 3 additions & 0 deletions tests/client_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def test_mandate_import_entries_returns_service():
def test_mandate_pdfs_returns_service():
assert_is_instance(client.mandate_pdfs, services.MandatePdfsService)

def test_mandate_request_constraints_returns_service():
assert_is_instance(client.mandate_request_constraints, services.MandateRequestConstraintsService)

def test_payer_authorisations_returns_service():
assert_is_instance(client.payer_authorisations, services.PayerAuthorisationsService)

Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/bank_authorisations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method": "GET",
"path_template": "/bank_authorisations/:identity",
"url_params": ["BAU123"],
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2022-07-22T14:11:31.377Z","expires_at":"2022-07-22T14:11:31.377Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2022-11-30T15:26:36.924Z","expires_at":"2022-11-30T15:26:36.924Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
},
"create": {
"method": "POST",
"path_template": "/bank_authorisations",
"url_params": [],
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2022-07-22T14:11:31.377Z","expires_at":"2022-07-22T14:11:31.377Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2022-11-30T15:26:36.924Z","expires_at":"2022-11-30T15:26:36.924Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/billing_request_flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method": "POST",
"path_template": "/billing_request_flows",
"url_params": [],
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-07-22T14:11:31.381Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-07-22T14:11:31.381Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":false,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","language":"en","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-11-30T15:26:36.928Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-11-30T15:26:36.928Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":true,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","language":"en","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":false}}
},
"initialise": {
"method": "POST",
"path_template": "/billing_request_flows/:identity/actions/initialise",
"url_params": ["BRF123"],
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2022-07-22T14:11:31.381Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-07-22T14:11:31.381Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":true,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","language":"en","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-11-30T15:26:36.928Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-11-30T15:26:36.928Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":false,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","language":"en","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true}}
}
}
Loading

0 comments on commit 1613fda

Please sign in to comment.