Skip to content
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
36 changes: 36 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ Bank account details
# Get encrypted bank details
client.bank_account_details.get('BA123', params={...})

Bank account holder verifications
''''''''''''''''''''''''''''''''''''''''''

.. code:: python

# Create a bank account holder verification.
client.bank_account_holder_verifications.create(params={...})

# Get a bank account holder verification.
client.bank_account_holder_verifications.get('BAHV123', params={...})

Bank authorisations
''''''''''''''''''''''''''''''''''''''''''

Expand Down Expand Up @@ -356,6 +367,14 @@ Exports
# Iterate through all exports
client.exports.all(params={...})

Funds availabilities
''''''''''''''''''''''''''''''''''''''''''

.. code:: python

# Funds availability
client.funds_availabilities.check('MD123', params={...})

Instalment schedules
''''''''''''''''''''''''''''''''''''''''''

Expand Down Expand Up @@ -509,6 +528,9 @@ Outbound payments
# Update an outbound payment
client.outbound_payments.update('OUT123', params={...})

# Outbound payment statistics
client.outbound_payments.stats(params={...})

Payer authorisations
''''''''''''''''''''''''''''''''''''''''''

Expand Down Expand Up @@ -563,6 +585,20 @@ Payments
# Retry a payment
client.payments.retry('PM123', params={...})

Payment accounts
''''''''''''''''''''''''''''''''''''''''''

.. code:: python

# Get a single payment account details
client.payment_accounts.get('BA123', params={...})

# List payment accounts
client.payment_accounts.list(params={...})

# Iterate through all payment_accounts
client.payment_accounts.all(params={...})

Payment account transactions
''''''''''''''''''''''''''''''''''''''''''

Expand Down
13 changes: 11 additions & 2 deletions gocardless_pro/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,17 @@ def _handle_errors(self, response):
if response.status_code < 400:
return

error = response.json()['error']
exception_class = errors.ApiError.exception_for(response.status_code, error['type'], error.get('errors'))
error = response_body.get('error', response_body)

if isinstance(error, str):
error = {
'code': response.status_code,
'message': error,
}
exception_class = errors.ApiError
else:
exception_class = errors.ApiError.exception_for(response.status_code, error['type'], error.get('errors'))

raise exception_class(error)

def _url_for(self, path):
Expand Down
14 changes: 13 additions & 1 deletion gocardless_pro/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Client(object):
use the resource methods to access the API.

Args:
access_token (str): Find or generate this in your GoCardless Pro dashboard
access_token (str): Find or generate this in your GoCardless dashboard
(https://manage.gocardless.com/organisation/access-tokens).
environment (str): Either 'sandbox' or 'live'.
base_url (str): Manually set a base URL. Most people should use
Expand Down Expand Up @@ -45,6 +45,10 @@ def balances(self):
def bank_account_details(self):
return services.BankAccountDetailsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def bank_account_holder_verifications(self):
return services.BankAccountHolderVerificationsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def bank_authorisations(self):
return services.BankAuthorisationsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
Expand Down Expand Up @@ -105,6 +109,10 @@ def events(self):
def exports(self):
return services.ExportsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def funds_availabilities(self):
return services.FundsAvailabilitiesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def instalment_schedules(self):
return services.InstalmentSchedulesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
Expand Down Expand Up @@ -153,6 +161,10 @@ def payer_themes(self):
def payments(self):
return services.PaymentsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

@property
def payment_accounts(self):
return services.PaymentAccountsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

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

from .bank_account_detail import BankAccountDetail

from .bank_account_holder_verification import BankAccountHolderVerification

from .bank_authorisation import BankAuthorisation

from .bank_details_lookup import BankDetailsLookup
Expand Down Expand Up @@ -37,6 +39,8 @@

from .export import Export

from .funds_availability import FundsAvailability

from .instalment_schedule import InstalmentSchedule

from .institution import Institution
Expand All @@ -61,6 +65,8 @@

from .payment import Payment

from .payment_account import PaymentAccount

from .payment_account_transaction import PaymentAccountTransaction

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

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

Example:
bank_account_holder_verification = client.bank_account_holder_verifications.get()
bank_account_holder_verification.id
"""

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

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


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


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


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


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













14 changes: 14 additions & 0 deletions gocardless_pro/resources/billing_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ def metadata(self):
return self.attributes.get('metadata')


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


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


@property
def payment_request(self):
return self.PaymentRequest(self.attributes.get('payment_request'))
Expand Down Expand Up @@ -275,6 +285,10 @@ def verify(self):







class PaymentRequest(object):
"""Wrapper for the response's 'payment_request' attribute."""

Expand Down
8 changes: 8 additions & 0 deletions gocardless_pro/resources/billing_request_with_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ def mandate_request(self):
def metadata(self):
return self.attributes.get('metadata')

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

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

@property
def payment_request(self):
return self.attributes.get('payment_request')
Expand Down
4 changes: 4 additions & 0 deletions gocardless_pro/resources/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def new_mandate(self):
def organisation(self):
return self.attributes.get('organisation')

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

@property
def parent_event(self):
return self.attributes.get('parent_event')
Expand Down
26 changes: 26 additions & 0 deletions gocardless_pro/resources/funds_availability.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 FundsAvailability(object):
"""A thin wrapper around a funds_availability, providing easy access to its
attributes.

Example:
funds_availability = client.funds_availabilities.get()
funds_availability.id
"""

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

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





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

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

Example:
payment_account = client.payment_accounts.get()
payment_account.id
"""

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

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


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


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


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


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


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


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
















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

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

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



3 changes: 3 additions & 0 deletions gocardless_pro/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from .balances_service import BalancesService
from .bank_account_details_service import BankAccountDetailsService
from .bank_account_holder_verifications_service import BankAccountHolderVerificationsService
from .bank_authorisations_service import BankAuthorisationsService
from .bank_details_lookups_service import BankDetailsLookupsService
from .billing_requests_service import BillingRequestsService
Expand All @@ -20,6 +21,7 @@
from .customer_notifications_service import CustomerNotificationsService
from .events_service import EventsService
from .exports_service import ExportsService
from .funds_availabilities_service import FundsAvailabilitiesService
from .instalment_schedules_service import InstalmentSchedulesService
from .institutions_service import InstitutionsService
from .logos_service import LogosService
Expand All @@ -32,6 +34,7 @@
from .payer_authorisations_service import PayerAuthorisationsService
from .payer_themes_service import PayerThemesService
from .payments_service import PaymentsService
from .payment_accounts_service import PaymentAccountsService
from .payment_account_transactions_service import PaymentAccountTransactionsService
from .payouts_service import PayoutsService
from .payout_items_service import PayoutItemsService
Expand Down
Loading