Skip to content

Commit

Permalink
Merge pull request #59 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Release v1.28.0
  • Loading branch information
szastupov authored Apr 22, 2022
2 parents 0ff8001 + 96df2bf commit afcfaaf
Show file tree
Hide file tree
Showing 39 changed files with 310 additions and 117 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<!-- @format -->
# 1.28.0

- Added support for billing request fallbacks

# 1.27.0

- Release Block API
Expand Down
27 changes: 15 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,43 @@ Billing requests
# Iterate through all billing_requests
client.billing_requests.all(params={...})
# Create a billing_request
# Create a Billing Request
client.billing_requests.create(params={...})
# Get a single billing request
# Get a single Billing Request
client.billing_requests.get('BRQ123', params={...})
# Collect customer details for the billing request
# Collect customer details for a Billing Request
client.billing_requests.collect_customer_details('BRQ123', params={...})
# Collect bank account details for the billing request
# Collect bank account details for a Billing Request
client.billing_requests.collect_bank_account('BRQ123', params={...})
# Fulfil a billing request
# Fulfil a Billing Request
client.billing_requests.fulfil('BRQ123', params={...})
# Confirm the customer and bank_account details
# Confirm the customer and bank account details
client.billing_requests.confirm_payer_details('BRQ123', params={...})
# Cancel a billing request
# Cancel a Billing Request
client.billing_requests.cancel('BRQ123', params={...})
# Notify the customer of a billing request
# Notify the customer of a Billing Request
client.billing_requests.notify('BRQ123', params={...})
# Trigger fallback for a Billing Request
client.billing_requests.fallback('BRQ123', params={...})
Billing request flows
''''''''''''''''''''''''''''''''''''''''''

.. code:: python
# Create a billing request flow
# Create a Billing Request Flow
client.billing_request_flows.create(params={...})
# Initialise a billing request flow
client.billing_request_flows.initialise('BRQ123', params={...})
# Initialise a Billing Request Flow
client.billing_request_flows.initialise('BRF123', params={...})
Billing request templates
''''''''''''''''''''''''''''''''''''''''''
Expand Down Expand Up @@ -329,7 +332,7 @@ Institutions

.. code:: python
# List institutions
# List Institutions
client.institutions.list(params={...})
# Iterate through all institutions
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.27.0'
__version__ = '1.28.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.27.0',
'GoCardless-Client-Version': '1.28.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.27.0',
'gocardless-pro-python/1.28.0',
'python/{0}'.format(python_version),
'{0}/{1}'.format(platform.python_implementation(), vm_version),
'{0}/{1}'.format(platform.system(), platform.release()),
Expand Down
15 changes: 15 additions & 0 deletions gocardless_pro/resources/billing_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def created_at(self):
return self.attributes.get('created_at')


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


@property
def id(self):
return self.attributes.get('id')
Expand Down Expand Up @@ -69,6 +74,8 @@ def status(self):





class Links(object):
"""Wrapper for the response's 'links' attribute."""

Expand Down Expand Up @@ -128,6 +135,10 @@ def currency(self):
def links(self):
return self.attributes.get('links')

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

@property
def scheme(self):
return self.attributes.get('scheme')
Expand Down Expand Up @@ -167,6 +178,10 @@ def description(self):
def links(self):
return self.attributes.get('links')

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

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


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





Expand Down Expand Up @@ -105,3 +110,5 @@ def billing_request(self):





4 changes: 4 additions & 0 deletions gocardless_pro/resources/redirect_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class Links(object):
def __init__(self, attributes):
self.attributes = attributes

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

@property
def creditor(self):
return self.attributes.get('creditor')
Expand Down
6 changes: 3 additions & 3 deletions gocardless_pro/services/billing_request_flows_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BillingRequestFlowsService(base_service.BaseService):


def create(self,params=None, headers=None):
"""Create a billing request flow.
"""Create a Billing Request Flow.
Creates a new billing request flow.
Expand All @@ -39,14 +39,14 @@ def create(self,params=None, headers=None):


def initialise(self,identity,params=None, headers=None):
"""Initialise a billing request flow.
"""Initialise a Billing Request Flow.
Returns the flow having generated a fresh session token which can be
used to power
integrations that manipulate the flow.
Args:
identity (string): Unique identifier, beginning with "BRQ".
identity (string): Unique identifier, beginning with "BRF".
params (dict, optional): Request body.
Returns:
Expand Down
45 changes: 35 additions & 10 deletions gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def list(self,params=None, headers=None):
"""List Billing Requests.
Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your
billing_requests.
billing requests.
Args:
params (dict, optional): Query string parameters.
Expand All @@ -44,7 +44,7 @@ def all(self, params=None):


def create(self,params=None, headers=None):
"""Create a billing_request.
"""Create a Billing Request.
Expand Down Expand Up @@ -72,7 +72,7 @@ def create(self,params=None, headers=None):


def get(self,identity,params=None, headers=None):
"""Get a single billing request.
"""Get a single Billing Request.
Fetches a billing request
Expand All @@ -95,7 +95,7 @@ def get(self,identity,params=None, headers=None):


def collect_customer_details(self,identity,params=None, headers=None):
"""Collect customer details for the billing request.
"""Collect customer details for a Billing Request.
If the billing request has a pending
<code>collect_customer_details</code>
Expand Down Expand Up @@ -129,7 +129,7 @@ def collect_customer_details(self,identity,params=None, headers=None):


def collect_bank_account(self,identity,params=None, headers=None):
"""Collect bank account details for the billing request.
"""Collect bank account details for a Billing Request.
If the billing request has a pending
<code>collect_bank_account</code> action, this endpoint can be
Expand Down Expand Up @@ -161,7 +161,7 @@ def collect_bank_account(self,identity,params=None, headers=None):


def fulfil(self,identity,params=None, headers=None):
"""Fulfil a billing request.
"""Fulfil a Billing Request.
If a billing request is ready to be fulfilled, call this endpoint to
cause
Expand All @@ -187,9 +187,9 @@ def fulfil(self,identity,params=None, headers=None):


def confirm_payer_details(self,identity,params=None, headers=None):
"""Confirm the customer and bank_account details.
"""Confirm the customer and bank account details.
This is needed when you have mandate_request. As a scheme compliance
This is needed when you have a mandate request. As a scheme compliance
rule we are required to
allow the payer to crosscheck the details entered by them and confirm
it.
Expand All @@ -214,7 +214,7 @@ def confirm_payer_details(self,identity,params=None, headers=None):


def cancel(self,identity,params=None, headers=None):
"""Cancel a billing request.
"""Cancel a Billing Request.
Immediately cancels a billing request, causing all billing request
flows
Expand All @@ -240,7 +240,7 @@ def cancel(self,identity,params=None, headers=None):


def notify(self,identity,params=None, headers=None):
"""Notify the customer of a billing request.
"""Notify the customer of a Billing Request.
Notifies the customer linked to the billing request, asking them to
authorise it.
Expand All @@ -264,3 +264,28 @@ def notify(self,identity,params=None, headers=None):
retry_failures=False)
return self._resource_for(response)


def fallback(self,identity,params=None, headers=None):
"""Trigger fallback for a Billing Request.
Triggers a fallback from the open-banking flow to direct debit. Note,
the billing request must have fallback enabled.
Args:
identity (string): Unique identifier, beginning with "BRQ".
params (dict, optional): Request body.
Returns:
BillingRequest
"""
path = self._sub_url_params('/billing_requests/:identity/actions/fallback', {

'identity': identity,
})

if params is not None:
params = {'data': params}
response = self._perform_request('POST', path, params, headers,
retry_failures=False)
return self._resource_for(response)

4 changes: 2 additions & 2 deletions gocardless_pro/services/institutions_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class InstitutionsService(base_service.BaseService):


def list(self,params=None, headers=None):
"""List institutions.
"""List Institutions.
Returns a list of all supported institutions.
Returns a list of supported institutions.
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.27.0',
version = '1.28.0',
packages = find_packages(exclude=['tests']),
install_requires = ['requests>=2.6', 'six'],
author = 'GoCardless',
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":"2021-12-30T15:25:21.182Z","expires_at":"2021-12-30T15:25:21.182Z","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-04-22T13:38:19.720Z","expires_at":"2022-04-22T13:38:19.720Z","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":"2021-12-30T15:25:21.182Z","expires_at":"2021-12-30T15:25:21.182Z","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-04-22T13:38:19.720Z","expires_at":"2022-04-22T13:38:19.720Z","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"}}
}
}
6 changes: 3 additions & 3 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":"2021-12-30T15:25:21.185Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2021-12-30T15:25:21.185Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_customer_details":true,"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123"}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2022-04-22T13:38:19.722Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-04-22T13:38:19.722Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_customer_details":true,"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": ["BRQ123"],
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2021-12-30T15:25:21.185Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2021-12-30T15:25:21.185Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_customer_details":true,"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123"}}
"url_params": ["BRF123"],
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-04-22T13:38:19.722Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-04-22T13:38:19.722Z","id":"BRF123","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_customer_details":true,"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":false}}
}
}
Loading

0 comments on commit afcfaaf

Please sign in to comment.