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 #102

Merged
merged 7 commits into from
Dec 3, 2024
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<!-- @format -->
# 2.1.0

- Added `mandate_request[consent_type]` parameter to Billing Request creation.
- Added `constraints[payment_method]` parameter to Billing Request creation.
- Added `subscription_request` parameter to Billing Request creation.
- Added `instalment_schedule_request` parameter to Billing Request creation.

# 1.53.0

- Added `/exports` APIs and added `exports` as a new event type available for Embed merchants
2 changes: 1 addition & 1 deletion gocardless_pro/__init__.py
Original file line number Diff line number Diff line change
@@ -2,5 +2,5 @@

from .client import Client

__version__ = '2.0.0'
__version__ = '2.1.0'

4 changes: 2 additions & 2 deletions gocardless_pro/api_client.py
Original file line number Diff line number Diff line change
@@ -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': '2.0.0',
'GoCardless-Client-Version': '2.1.0',
'User-Agent': self._user_agent(),
'GoCardless-Version': '2015-07-06',
}
@@ -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/2.0.0',
'gocardless-pro-python/2.1.0',
'python/{0}'.format(python_version),
'{0}/{1}'.format(platform.python_implementation(), vm_version),
'{0}/{1}'.format(platform.system(), platform.release()),
77 changes: 77 additions & 0 deletions gocardless_pro/resources/billing_request.py
Original file line number Diff line number Diff line change
@@ -31,11 +31,21 @@ def fallback_enabled(self):
return self.attributes.get('fallback_enabled')


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


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


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


@property
def links(self):
return self.Links(self.attributes.get('links'))
@@ -86,6 +96,53 @@ def subscription_request(self):





class InstalmentScheduleRequest(object):
"""Wrapper for the response's 'instalment_schedule_request' attribute."""

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

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

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

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

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

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

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

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

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

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




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

@@ -112,6 +169,14 @@ def customer_bank_account(self):
def customer_billing_detail(self):
return self.attributes.get('customer_billing_detail')

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

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

@property
def mandate_request(self):
return self.attributes.get('mandate_request')
@@ -140,6 +205,10 @@ def payment_request_payment(self):
def subscription_request(self):
return self.attributes.get('subscription_request')

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




@@ -298,6 +367,10 @@ def interval(self):
def interval_unit(self):
return self.attributes.get('interval_unit')

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

@property
def metadata(self):
return self.attributes.get('metadata')
@@ -314,6 +387,10 @@ def name(self):
def payment_reference(self):
return self.attributes.get('payment_reference')

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

@property
def start_date(self):
return self.attributes.get('start_date')
7 changes: 7 additions & 0 deletions gocardless_pro/resources/billing_request_flow.py
Original file line number Diff line number Diff line change
@@ -106,6 +106,11 @@ def show_success_redirect_button(self):
return self.attributes.get('show_success_redirect_button')


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





@@ -224,3 +229,5 @@ def swedish_identity_number(self):





4 changes: 3 additions & 1 deletion gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@ class BillingRequestsService(base_service.BaseService):
def create(self,params=None, headers=None):
"""Create a Billing Request.


<p class="notice"><strong>Important</strong>: All properties associated
with `subscription_request` and `instalment_schedule_request` are only
supported for ACH and PAD schemes.</p>

Args:
params (dict, optional): Request body.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

setup(
name = 'gocardless_pro',
version = '2.0.0',
version = '2.1.0',
packages = find_packages(exclude=['tests']),
install_requires = ['requests>=2.6', 'six'],
author = 'GoCardless',
4 changes: 2 additions & 2 deletions tests/fixtures/bank_authorisations.json
Original file line number Diff line number Diff line change
@@ -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-09-24T11:55:55.926Z","expires_at":"2024-09-24T11:55:55.926Z","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-12-03T12:55:13.866Z","expires_at":"2024-12-03T12:55:13.866Z","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-09-24T11:55:55.926Z","expires_at":"2024-09-24T11:55:55.926Z","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-12-03T12:55:13.866Z","expires_at":"2024-12-03T12:55:13.866Z","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
@@ -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":false,"created_at":"2024-09-24T11:55:55.929Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-09-24T11:55:55.929Z","id":"BRF123","language":"en","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":"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":false,"created_at":"2024-12-03T12:55:13.871Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-12-03T12:55:13.871Z","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":false,"show_success_redirect_button":false,"skip_success_screen":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":false,"created_at":"2024-09-24T11:55:55.929Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-09-24T11:55:55.929Z","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}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2024-12-03T12:55:13.871Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-12-03T12:55:13.871Z","id":"BRF123","language":"en","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":"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":true,"skip_success_screen":false}}
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/billing_request_templates.json
Original file line number Diff line number Diff line change
@@ -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":"100.00","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":"100.00","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 2887","before":"example before 9430"},"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":"100.00","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":"100.00","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 5740","before":"example before 8475"},"limit":50}}
},
"get": {
"method": "GET",
Loading