Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template changes #91

Merged
merged 5 commits into from
Nov 28, 2023
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<!-- @format -->
# 1.49.0

- Expose the GET `/transferred_mandates` endpoint

# 1.48.0

- Added a new field `verification_status` to creditor_bank_accounts API's response
Expand Down
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@ Tax rates
# Get a single tax rate
client.tax_rates.get('GB_VAT_1', params={...})

Transferred mandates
''''''''''''''''''''''''''''''''''''''''''

.. code:: python

# Get updated customer bank details
client.transferred_mandates.transferred_mandates('MD123', params={...})

Verification details
''''''''''''''''''''''''''''''''''''''''''

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.48.0'
__version__ = '1.49.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.48.0',
'GoCardless-Client-Version': '1.49.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.48.0',
'gocardless-pro-python/1.49.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 @@ -157,6 +157,10 @@ def subscriptions(self):
def tax_rates(self):
return services.TaxRatesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def transferred_mandates(self):
return services.TransferredMandatesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def verification_details(self):
return services.VerificationDetailsService(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 @@ -63,6 +63,8 @@

from .tax_rate import TaxRate

from .transferred_mandate import TransferredMandate

from .verification_detail import VerificationDetail

from .webhook import Webhook
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 @@ -31,6 +31,11 @@ def created_at(self):
return self.attributes.get('created_at')


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


@property
def exit_uri(self):
return self.attributes.get('exit_uri')
Expand Down Expand Up @@ -117,6 +122,8 @@ def show_success_redirect_button(self):





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

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

class TransferredMandate(object):
"""A thin wrapper around a transferred_mandate, providing easy access to its
attributes.

Example:
transferred_mandate = client.transferred_mandates.get()
transferred_mandate.id
"""

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

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


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


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


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








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

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

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

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





1 change: 1 addition & 0 deletions gocardless_pro/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
from .scheme_identifiers_service import SchemeIdentifiersService
from .subscriptions_service import SubscriptionsService
from .tax_rates_service import TaxRatesService
from .transferred_mandates_service import TransferredMandatesService
from .verification_details_service import VerificationDetailsService
from .webhooks_service import WebhooksService
4 changes: 4 additions & 0 deletions gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def collect_bank_account(self,identity,params=None, headers=None):
creating
and attaching it.

If the scheme is PayTo and the pay_id is available, this can be
included in the payload along with the
country_code.

_ACH scheme_ For compliance reasons, an extra validation step is done
using
a third-party provider to make sure the customer's bank account can
Expand Down
41 changes: 41 additions & 0 deletions gocardless_pro/services/transferred_mandates_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 TransferredMandatesService(base_service.BaseService):
"""Service class that provides access to the transferred_mandates
endpoints of the GoCardless Pro API.
"""

RESOURCE_CLASS = resources.TransferredMandate
RESOURCE_NAME = 'transferred_mandates'


def transferred_mandates(self,identity,params=None, headers=None):
"""Get updated customer bank details.

Returns new customer bank details for a mandate that's been recently
transferred

Args:
identity (string): Unique identifier, beginning with "MD". Note that this prefix may not apply to mandates created before 2016.
params (dict, optional): Query string parameters.

Returns:
TransferredMandate
"""
path = self._sub_url_params('/transferred_mandates/:identity', {

'identity': identity,
})

response = self._perform_request('GET', path, params, headers,
retry_failures=False)
return self._resource_for(response)

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.48.0',
version = '1.49.0',
packages = find_packages(exclude=['tests']),
install_requires = ['requests>=2.6', 'six'],
author = 'GoCardless',
Expand Down
3 changes: 3 additions & 0 deletions tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def test_subscriptions_returns_service():
def test_tax_rates_returns_service():
assert isinstance(client.tax_rates, services.TaxRatesService)

def test_transferred_mandates_returns_service():
assert isinstance(client.transferred_mandates, services.TransferredMandatesService)

def test_verification_details_returns_service():
assert isinstance(client.verification_details, services.VerificationDetailsService)

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":"2023-10-26T12:34:26.338Z","expires_at":"2023-10-26T12:34:26.338Z","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":"2023-11-27T14:47:39.045Z","expires_at":"2023-11-27T14:47:39.045Z","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":"2023-10-26T12:34:26.338Z","expires_at":"2023-10-26T12:34:26.338Z","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":"2023-11-27T14:47:39.045Z","expires_at":"2023-11-27T14:47:39.045Z","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":"2023-10-26T12:34:26.342Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-10-26T12:34:26.342Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"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","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":false,"created_at":"2023-11-27T14:47:39.049Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-11-27T14:47:39.049Z","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":"[email protected]","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}}
},
"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":"2023-10-26T12:34:26.342Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-10-26T12:34:26.342Z","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":"[email protected]","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}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2023-11-27T14:47:39.049Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-11-27T14:47:39.049Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"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","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":true}}
}
}
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 5343","before":"example before 1053"},"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 9859","before":"example before 5166"},"limit":50}}
},
"get": {
"method": "GET",
Expand Down
Loading