Skip to content

Commit db61ab3

Browse files
authored
Merge pull request #98 from gocardless/template-changes
v2.32.0
2 parents a61617d + 5eb0456 commit db61ab3

18 files changed

+289
-18
lines changed

.circleci/config.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
printf -- "---\n:rubygems_api_key: $RUBYGEM_PUBLISH_API_KEY\n" > $HOME/.gem/credentials
2626
gem build *.gemspec
2727
gem push *.gem
28-
28+
2929
workflows:
3030
version: 2
3131
tests:
@@ -34,18 +34,14 @@ workflows:
3434
matrix:
3535
parameters:
3636
faraday-version: ["0.9.2", "1.0"]
37-
ruby-version: ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "3.0"]
37+
ruby-version: ["2.3", "2.4", "2.5", "2.6", "2.7", "3.0"]
3838
exclude:
39-
- faraday-version: "1.0"
40-
ruby-version: "2.1"
41-
- faraday-version: "1.0"
42-
ruby-version: "2.2"
4339
- faraday-version: "0.9.2"
4440
ruby-version: "3.0"
4541
- publish:
4642
filters:
4743
branches:
4844
only:
49-
- master
45+
- master
5046
requires:
5147
- test

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ language: ruby
22

33
rvm:
44
- 2.3.0
5-
- 2.2
6-
- 2.1
75
- 2.0.0
86

97
sudo: false

lib/gocardless_pro/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def default_options
198198
'User-Agent' => user_agent.to_s,
199199
'Content-Type' => 'application/json',
200200
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
201-
'GoCardless-Client-Version' => '2.30.0',
201+
'GoCardless-Client-Version' => '2.32.0',
202202
},
203203
}
204204
end

lib/gocardless_pro/resources/billing_request.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def mandate_request_mandate
9797
@links['mandate_request_mandate']
9898
end
9999

100+
def organisation
101+
@links['organisation']
102+
end
103+
100104
def payment_request
101105
@links['payment_request']
102106
end

lib/gocardless_pro/resources/billing_request_flow.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ class BillingRequestFlow
2323
attr_reader :expires_at
2424
attr_reader :id
2525
attr_reader :lock_bank_account
26+
attr_reader :lock_currency
2627
attr_reader :lock_customer_details
28+
attr_reader :prefilled_bank_account
29+
attr_reader :prefilled_customer
2730
attr_reader :redirect_uri
2831
attr_reader :session_token
2932
attr_reader :show_redirect_buttons
@@ -41,7 +44,10 @@ def initialize(object, response = nil)
4144
@id = object['id']
4245
@links = object['links']
4346
@lock_bank_account = object['lock_bank_account']
47+
@lock_currency = object['lock_currency']
4448
@lock_customer_details = object['lock_customer_details']
49+
@prefilled_bank_account = object['prefilled_bank_account']
50+
@prefilled_customer = object['prefilled_customer']
4551
@redirect_uri = object['redirect_uri']
4652
@session_token = object['session_token']
4753
@show_redirect_buttons = object['show_redirect_buttons']

lib/gocardless_pro/resources/customer_bank_account.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ module Resources
2222
# account. You may wish to handle this by updating the existing record
2323
# instead, the ID of which will be provided as
2424
# `links[customer_bank_account]` in the error response.
25+
#
26+
# _Note:_ To ensure the customer's bank accounts are valid, verify them
27+
# first
28+
# using
29+
#
30+
# [bank_details_lookups](#bank-details-lookups-perform-a-bank-details-lookup),
31+
# before proceeding with creating the accounts
2532
class CustomerBankAccount
2633
attr_reader :account_holder_name
2734
attr_reader :account_number_ending

lib/gocardless_pro/resources/event.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ module Resources
1414

1515
# Events are stored for all webhooks. An event refers to a resource which
1616
# has been updated, for example a payment which has been collected, or a
17-
# mandate which has been transferred. See [here](#event-actions) for a
18-
# complete list of event types.
17+
# mandate which has been transferred. Event creation is an asynchronous
18+
# process, so it can take some time between an action occurring and its
19+
# corresponding event getting included in API responses. See
20+
# [here](#event-actions) for a complete list of event types.
1921
class Event
2022
attr_reader :action
2123
attr_reader :created_at

lib/gocardless_pro/resources/institution.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Resources
1919
# Not all institutions support both Payment Initiation (PIS) and Account
2020
# Information (AIS) services.
2121
class Institution
22+
attr_reader :bank_redirect
2223
attr_reader :country_code
2324
attr_reader :icon_url
2425
attr_reader :id
@@ -30,6 +31,7 @@ class Institution
3031
def initialize(object, response = nil)
3132
@object = object
3233

34+
@bank_redirect = object['bank_redirect']
3335
@country_code = object['country_code']
3436
@icon_url = object['icon_url']
3537
@id = object['id']

lib/gocardless_pro/services/bank_details_lookups_service.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class BankDetailsLookupsService < BaseService
2323
# Bank account details may be supplied using [local
2424
# details](#appendix-local-bank-details) or an IBAN.
2525
#
26+
# _ACH scheme_ For compliance reasons, an extra validation step is done using
27+
# a third-party provider to make sure the customer's bank account can accept
28+
# Direct Debit. If a bank account is discovered to be closed or invalid, the
29+
# customer is requested to adjust the account number/routing number and
30+
# succeed in this check to continue with the flow.
31+
#
2632
# _Note:_ Usage of this endpoint is monitored. If your organisation relies on
2733
# GoCardless for
2834
# modulus or reachability checking but not for payment collection, please get in

lib/gocardless_pro/services/billing_requests_service.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ def collect_customer_details(identity, options = {})
144144
# The endpoint takes the same payload as Customer Bank Accounts, but check
145145
# the bank account is valid for the billing request scheme before creating
146146
# and attaching it.
147+
#
148+
# _ACH scheme_ For compliance reasons, an extra validation step is done using
149+
# a third-party provider to make sure the customer's bank account can accept
150+
# Direct Debit. If a bank account is discovered to be closed or invalid, the
151+
# customer is requested to adjust the account number/routing number and
152+
# succeed in this check to continue with the flow.
147153
# Example URL: /billing_requests/:identity/actions/collect_bank_account
148154
#
149155
# @param identity # Unique identifier, beginning with "BRQ".
@@ -218,6 +224,46 @@ def fulfil(identity, options = {})
218224
Resources::BillingRequest.new(unenvelope_body(response.body), response)
219225
end
220226

227+
# This will allow for the updating of the currency and subsequently the scheme
228+
# if needed for a billing request
229+
# this will only be available for mandate only flows, it will not support
230+
# payments requests or plans
231+
# Example URL: /billing_requests/:identity/actions/choose_currency
232+
#
233+
# @param identity # Unique identifier, beginning with "BRQ".
234+
# @param options [Hash] parameters as a hash, under a params key.
235+
def choose_currency(identity, options = {})
236+
path = sub_url('/billing_requests/:identity/actions/choose_currency', 'identity' => identity)
237+
238+
params = options.delete(:params) || {}
239+
options[:params] = {}
240+
options[:params]['data'] = params
241+
242+
options[:retry_failures] = false
243+
244+
begin
245+
response = make_request(:post, path, options)
246+
247+
# Response doesn't raise any errors until #body is called
248+
response.tap(&:body)
249+
rescue InvalidStateError => e
250+
if e.idempotent_creation_conflict?
251+
case @api_service.on_idempotency_conflict
252+
when :raise
253+
raise IdempotencyConflict, e.error
254+
when :fetch
255+
return get(e.conflicting_resource_id)
256+
end
257+
end
258+
259+
raise e
260+
end
261+
262+
return if response.body.nil?
263+
264+
Resources::BillingRequest.new(unenvelope_body(response.body), response)
265+
end
266+
221267
# This is needed when you have a mandate request. As a scheme compliance rule we
222268
# are required to
223269
# allow the payer to crosscheck the details entered by them and confirm it.

0 commit comments

Comments
 (0)