Skip to content

Commit

Permalink
Merge pull request #95 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Template changes
  • Loading branch information
KarmanLeung authored May 30, 2024
2 parents 54839c7 + 0aee401 commit 89ffc32
Show file tree
Hide file tree
Showing 51 changed files with 396 additions and 81 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.52.0

- Added new endpoints `/branding/logos` and `/branding/payer_themes` available for Embed merchants

# 1.51.0

- Added `payer_requested_dual_signature` field for Billing Request Confirmation endpoint.
Expand Down
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ Institutions
# List institutions for Billing Request
client.institutions.list_for_billing_request('BRQ123', params={...})
Logos
''''''''''''''''''''''''''''''''''''''''''

.. code:: python
# Create a logo associated with a creditor
client.logos.create_for_creditor(params={...})
Mandates
''''''''''''''''''''''''''''''''''''''''''

Expand Down Expand Up @@ -454,6 +462,14 @@ Payer authorisations
# Confirm a Payer Authorisation
client.payer_authorisations.confirm('PA123', params={...})
Payer themes
''''''''''''''''''''''''''''''''''''''''''

.. code:: python
# Create a payer theme associated with a creditor
client.payer_themes.create_for_creditor(params={...})
Payments
''''''''''''''''''''''''''''''''''''''''''

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.51.0'
__version__ = '1.52.0'

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

@property
def logos(self):
return services.LogosService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def mandates(self):
return services.MandatesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
Expand All @@ -121,6 +125,10 @@ def negative_balance_limits(self):
def payer_authorisations(self):
return services.PayerAuthorisationsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def payer_themes(self):
return services.PayerThemesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

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

from .institution import Institution

from .logo import Logo

from .mandate import Mandate

from .mandate_import import MandateImport
Expand All @@ -45,6 +47,8 @@

from .payer_authorisation import PayerAuthorisation

from .payer_theme import PayerTheme

from .payment import Payment

from .payout import Payout
Expand Down
4 changes: 4 additions & 0 deletions gocardless_pro/resources/billing_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ def currency(self):
def description(self):
return self.attributes.get('description')

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

@property
def links(self):
return self.attributes.get('links')
Expand Down
26 changes: 26 additions & 0 deletions gocardless_pro/resources/logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
#

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

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

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





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

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

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

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





2 changes: 2 additions & 0 deletions gocardless_pro/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
from .events_service import EventsService
from .instalment_schedules_service import InstalmentSchedulesService
from .institutions_service import InstitutionsService
from .logos_service import LogosService
from .mandates_service import MandatesService
from .mandate_imports_service import MandateImportsService
from .mandate_import_entries_service import MandateImportEntriesService
from .mandate_pdfs_service import MandatePdfsService
from .negative_balance_limits_service import NegativeBalanceLimitsService
from .payer_authorisations_service import PayerAuthorisationsService
from .payer_themes_service import PayerThemesService
from .payments_service import PaymentsService
from .payouts_service import PayoutsService
from .payout_items_service import PayoutItemsService
Expand Down
6 changes: 6 additions & 0 deletions gocardless_pro/services/bank_details_lookups_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def create(self,params=None, headers=None):
and
reachability check are performed.
For UK-based bank accounts, where an account holder name is provided
(and an account number, a sort code or an iban
are already present), we verify that the account holder name and bank
account number match the details held by
the relevant bank.
If your request returns an [error](#api-usage-errors) or the
`available_debit_schemes`
attribute is an empty array, you will not be able to collect payments
Expand Down
6 changes: 6 additions & 0 deletions gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def collect_bank_account(self,identity,params=None, headers=None):
the
customer is requested to adjust the account number/routing number and
succeed in this check to continue with the flow.
_BACS scheme_ [Payer Name
Verification](https://hub.gocardless.com/s/article/Introduction-to-Payer-Name-Verification?language=en_GB)
is enabled by default for UK based bank accounts, meaning we verify the
account holder name and bank account
number match the details held by the relevant bank.
Args:
identity (string): Unique identifier, beginning with "BRQ".
Expand Down
40 changes: 40 additions & 0 deletions gocardless_pro/services/logos_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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 LogosService(base_service.BaseService):
"""Service class that provides access to the logos
endpoints of the GoCardless Pro API.
"""

RESOURCE_CLASS = resources.Logo
RESOURCE_NAME = 'logos'


def create_for_creditor(self,params=None, headers=None):
"""Create a logo associated with a creditor.
Creates a new logo associated with a creditor. If a creditor already
has a logo, this will update the existing logo linked to the creditor.
Args:
params (dict, optional): Request body.
Returns:
Logo
"""
path = '/branding/logos'

if params is not None:
params = {self._envelope_key(): params}

response = self._perform_request('POST', path, params, headers,
retry_failures=True)
return self._resource_for(response)

41 changes: 41 additions & 0 deletions gocardless_pro/services/payer_themes_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 PayerThemesService(base_service.BaseService):
"""Service class that provides access to the payer_themes
endpoints of the GoCardless Pro API.
"""

RESOURCE_CLASS = resources.PayerTheme
RESOURCE_NAME = 'payer_themes'


def create_for_creditor(self,params=None, headers=None):
"""Create a payer theme associated with a creditor.
Creates a new payer theme associated with a creditor. If a creditor
already has payer themes, this will update the existing payer theme
linked to the creditor.
Args:
params (dict, optional): Request body.
Returns:
PayerTheme
"""
path = '/branding/payer_themes'

if params is not None:
params = {self._envelope_key(): params}

response = self._perform_request('POST', path, params, headers,
retry_failures=True)
return self._resource_for(response)

1 change: 0 additions & 1 deletion gocardless_pro/services/subscriptions_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def pause(self,identity,params=None, headers=None):
- `pause_cycles_must_be_greater_than_or_equal_to` if the provided value
for `pause_cycles` cannot be satisfied.
Args:
identity (string): Unique identifier, beginning with "SB".
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.51.0',
version = '1.52.0',
packages = find_packages(exclude=['tests']),
install_requires = ['requests>=2.6', 'six'],
author = 'GoCardless',
Expand Down
6 changes: 6 additions & 0 deletions tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def test_instalment_schedules_returns_service():
def test_institutions_returns_service():
assert isinstance(client.institutions, services.InstitutionsService)

def test_logos_returns_service():
assert isinstance(client.logos, services.LogosService)

def test_mandates_returns_service():
assert isinstance(client.mandates, services.MandatesService)

Expand All @@ -80,6 +83,9 @@ def test_negative_balance_limits_returns_service():
def test_payer_authorisations_returns_service():
assert isinstance(client.payer_authorisations, services.PayerAuthorisationsService)

def test_payer_themes_returns_service():
assert isinstance(client.payer_themes, services.PayerThemesService)

def test_payments_returns_service():
assert isinstance(client.payments, services.PaymentsService)

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": "POST",
"path_template": "/bank_authorisations",
"url_params": [],
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-18T11:22:22.488Z","expires_at":"2024-01-18T11:22:22.488Z","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"}}
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-05-30T12:57:42.874Z","expires_at":"2024-05-30T12:57:42.874Z","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"}}
},
"get": {
"method": "GET",
"path_template": "/bank_authorisations/:identity",
"url_params": ["BAU123"],
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-18T11:22:22.488Z","expires_at":"2024-01-18T11:22:22.488Z","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"}}
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-05-30T12:57:42.874Z","expires_at":"2024-05-30T12:57:42.874Z","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"}}
}
}
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":"2024-01-18T11:22:22.494Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-01-18T11:22:22.494Z","id":"BRF123","language":"en","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":"user@example.com","family_name":"Osborne","given_name":"Frank","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,"show_success_redirect_button":false}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-05-30T12:57:42.880Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-05-30T12:57:42.880Z","id":"BRF123","language":"en","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":"user@example.com","family_name":"Osborne","given_name":"Frank","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,"show_success_redirect_button":true}}
},
"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":true,"created_at":"2024-01-18T11:22:22.494Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-01-18T11:22:22.494Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":false,"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":"user@example.com","family_name":"Osborne","given_name":"Frank","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,"show_success_redirect_button":false}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-05-30T12:57:42.880Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-05-30T12:57:42.880Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":true,"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":"user@example.com","family_name":"Osborne","given_name":"Frank","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,"show_success_redirect_button":false}}
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/billing_request_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"method": "GET",
"path_template": "/billing_request_templates",
"url_params": [],
"body": {"billing_request_templates":[{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"},{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 4467","before":"example before 2286"},"limit":50}}
"body": {"billing_request_templates":[{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"},{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 4983","before":"example before 8146"},"limit":50}}
},
"get": {
"method": "GET",
Expand Down
Loading

0 comments on commit 89ffc32

Please sign in to comment.