gocardless_pro 2.30.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -7
- data/.travis.yml +0 -2
- data/lib/gocardless_pro/client.rb +1 -1
- data/lib/gocardless_pro/resources/billing_request.rb +4 -0
- data/lib/gocardless_pro/resources/billing_request_flow.rb +6 -0
- data/lib/gocardless_pro/resources/customer_bank_account.rb +7 -0
- data/lib/gocardless_pro/resources/event.rb +4 -2
- data/lib/gocardless_pro/resources/institution.rb +2 -0
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +6 -0
- data/lib/gocardless_pro/services/billing_requests_service.rb +46 -0
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +4 -5
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/resources/billing_request_flow_spec.rb +18 -0
- data/spec/resources/billing_request_spec.rb +72 -0
- data/spec/resources/institution_spec.rb +5 -0
- data/spec/services/billing_request_flows_service_spec.rb +18 -0
- data/spec/services/billing_requests_service_spec.rb +83 -0
- data/spec/services/institutions_service_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f717c8978ddc773f1e969653eeac91e91829c453b1ecf68da04ec9a9aa6a705b
|
4
|
+
data.tar.gz: 55c2a686cf9f74b43c3f85b808fecb589a704881fc3eee218c845413682129ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7e7459e76bbd33f58290cfd0822dcf796d4f2de2f4b7041984a8f4ac496ec7f43d0f16bd6f174169e0eaa77422d89f653b5c1e6cd1ae35d539a5a5f3294d61b
|
7
|
+
data.tar.gz: 5fb0db3f9079ba61f759651abf993119445a247a0ee78fd04b09f207b04b7cda7f09ab95ac43e0caa741ce6608edf81a95380c761cf1f73f22b83fd162d64087
|
data/.circleci/config.yml
CHANGED
@@ -25,7 +25,7 @@ jobs:
|
|
25
25
|
printf -- "---\n:rubygems_api_key: $RUBYGEM_PUBLISH_API_KEY\n" > $HOME/.gem/credentials
|
26
26
|
gem build *.gemspec
|
27
27
|
gem push *.gem
|
28
|
-
|
28
|
+
|
29
29
|
workflows:
|
30
30
|
version: 2
|
31
31
|
tests:
|
@@ -34,18 +34,14 @@ workflows:
|
|
34
34
|
matrix:
|
35
35
|
parameters:
|
36
36
|
faraday-version: ["0.9.2", "1.0"]
|
37
|
-
ruby-version: ["2.
|
37
|
+
ruby-version: ["2.3", "2.4", "2.5", "2.6", "2.7", "3.0"]
|
38
38
|
exclude:
|
39
|
-
- faraday-version: "1.0"
|
40
|
-
ruby-version: "2.1"
|
41
|
-
- faraday-version: "1.0"
|
42
|
-
ruby-version: "2.2"
|
43
39
|
- faraday-version: "0.9.2"
|
44
40
|
ruby-version: "3.0"
|
45
41
|
- publish:
|
46
42
|
filters:
|
47
43
|
branches:
|
48
44
|
only:
|
49
|
-
- master
|
45
|
+
- master
|
50
46
|
requires:
|
51
47
|
- test
|
data/.travis.yml
CHANGED
@@ -198,7 +198,7 @@ module GoCardlessPro
|
|
198
198
|
'User-Agent' => user_agent.to_s,
|
199
199
|
'Content-Type' => 'application/json',
|
200
200
|
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
|
201
|
-
'GoCardless-Client-Version' => '2.
|
201
|
+
'GoCardless-Client-Version' => '2.32.0',
|
202
202
|
},
|
203
203
|
}
|
204
204
|
end
|
@@ -23,7 +23,10 @@ module GoCardlessPro
|
|
23
23
|
attr_reader :expires_at
|
24
24
|
attr_reader :id
|
25
25
|
attr_reader :lock_bank_account
|
26
|
+
attr_reader :lock_currency
|
26
27
|
attr_reader :lock_customer_details
|
28
|
+
attr_reader :prefilled_bank_account
|
29
|
+
attr_reader :prefilled_customer
|
27
30
|
attr_reader :redirect_uri
|
28
31
|
attr_reader :session_token
|
29
32
|
attr_reader :show_redirect_buttons
|
@@ -41,7 +44,10 @@ module GoCardlessPro
|
|
41
44
|
@id = object['id']
|
42
45
|
@links = object['links']
|
43
46
|
@lock_bank_account = object['lock_bank_account']
|
47
|
+
@lock_currency = object['lock_currency']
|
44
48
|
@lock_customer_details = object['lock_customer_details']
|
49
|
+
@prefilled_bank_account = object['prefilled_bank_account']
|
50
|
+
@prefilled_customer = object['prefilled_customer']
|
45
51
|
@redirect_uri = object['redirect_uri']
|
46
52
|
@session_token = object['session_token']
|
47
53
|
@show_redirect_buttons = object['show_redirect_buttons']
|
@@ -22,6 +22,13 @@ module GoCardlessPro
|
|
22
22
|
# account. You may wish to handle this by updating the existing record
|
23
23
|
# instead, the ID of which will be provided as
|
24
24
|
# `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
|
25
32
|
class CustomerBankAccount
|
26
33
|
attr_reader :account_holder_name
|
27
34
|
attr_reader :account_number_ending
|
@@ -14,8 +14,10 @@ module GoCardlessPro
|
|
14
14
|
|
15
15
|
# Events are stored for all webhooks. An event refers to a resource which
|
16
16
|
# has been updated, for example a payment which has been collected, or a
|
17
|
-
# mandate which has been transferred.
|
18
|
-
#
|
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.
|
19
21
|
class Event
|
20
22
|
attr_reader :action
|
21
23
|
attr_reader :created_at
|
@@ -19,6 +19,7 @@ module GoCardlessPro
|
|
19
19
|
# Not all institutions support both Payment Initiation (PIS) and Account
|
20
20
|
# Information (AIS) services.
|
21
21
|
class Institution
|
22
|
+
attr_reader :bank_redirect
|
22
23
|
attr_reader :country_code
|
23
24
|
attr_reader :icon_url
|
24
25
|
attr_reader :id
|
@@ -30,6 +31,7 @@ module GoCardlessPro
|
|
30
31
|
def initialize(object, response = nil)
|
31
32
|
@object = object
|
32
33
|
|
34
|
+
@bank_redirect = object['bank_redirect']
|
33
35
|
@country_code = object['country_code']
|
34
36
|
@icon_url = object['icon_url']
|
35
37
|
@id = object['id']
|
@@ -23,6 +23,12 @@ module GoCardlessPro
|
|
23
23
|
# Bank account details may be supplied using [local
|
24
24
|
# details](#appendix-local-bank-details) or an IBAN.
|
25
25
|
#
|
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
|
+
#
|
26
32
|
# _Note:_ Usage of this endpoint is monitored. If your organisation relies on
|
27
33
|
# GoCardless for
|
28
34
|
# modulus or reachability checking but not for payment collection, please get in
|
@@ -144,6 +144,12 @@ module GoCardlessPro
|
|
144
144
|
# The endpoint takes the same payload as Customer Bank Accounts, but check
|
145
145
|
# the bank account is valid for the billing request scheme before creating
|
146
146
|
# 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.
|
147
153
|
# Example URL: /billing_requests/:identity/actions/collect_bank_account
|
148
154
|
#
|
149
155
|
# @param identity # Unique identifier, beginning with "BRQ".
|
@@ -218,6 +224,46 @@ module GoCardlessPro
|
|
218
224
|
Resources::BillingRequest.new(unenvelope_body(response.body), response)
|
219
225
|
end
|
220
226
|
|
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
|
+
|
221
267
|
# This is needed when you have a mandate request. As a scheme compliance rule we
|
222
268
|
# are required to
|
223
269
|
# allow the payer to crosscheck the details entered by them and confirm it.
|
@@ -119,11 +119,10 @@ module GoCardlessPro
|
|
119
119
|
# refund must start in `pending_submission`.</li>
|
120
120
|
# <li>`payout_bounced`: Transitions a payout to `bounced`. It must start
|
121
121
|
# in the `paid` state.</li>
|
122
|
-
# <li>`billing_request_fulfilled`: Authorises the billing request,
|
123
|
-
# it
|
124
|
-
#
|
125
|
-
#
|
126
|
-
# supported.</li>
|
122
|
+
# <li>`billing_request_fulfilled`: Authorises the billing request, and
|
123
|
+
# then fulfils it. The billing request must be in the `pending` state,
|
124
|
+
# with all actions completed except for `bank_authorisation`. Only billing
|
125
|
+
# requests with a `payment_request` are supported.</li>
|
127
126
|
# <li>`billing_request_fulfilled_and_payment_failed`: Authorises the
|
128
127
|
# billing request, fulfils it, and moves the associated payment to
|
129
128
|
# `failed`. The billing request must be in the `pending` state, with all
|
@@ -23,7 +23,10 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
23
23
|
'id' => 'id-input',
|
24
24
|
'links' => 'links-input',
|
25
25
|
'lock_bank_account' => 'lock_bank_account-input',
|
26
|
+
'lock_currency' => 'lock_currency-input',
|
26
27
|
'lock_customer_details' => 'lock_customer_details-input',
|
28
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
29
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
27
30
|
'redirect_uri' => 'redirect_uri-input',
|
28
31
|
'session_token' => 'session_token-input',
|
29
32
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -44,7 +47,10 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
44
47
|
'id' => 'id-input',
|
45
48
|
'links' => 'links-input',
|
46
49
|
'lock_bank_account' => 'lock_bank_account-input',
|
50
|
+
'lock_currency' => 'lock_currency-input',
|
47
51
|
'lock_customer_details' => 'lock_customer_details-input',
|
52
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
53
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
48
54
|
'redirect_uri' => 'redirect_uri-input',
|
49
55
|
'session_token' => 'session_token-input',
|
50
56
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -65,7 +71,10 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
65
71
|
'id' => 'id-input',
|
66
72
|
'links' => 'links-input',
|
67
73
|
'lock_bank_account' => 'lock_bank_account-input',
|
74
|
+
'lock_currency' => 'lock_currency-input',
|
68
75
|
'lock_customer_details' => 'lock_customer_details-input',
|
76
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
77
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
69
78
|
'redirect_uri' => 'redirect_uri-input',
|
70
79
|
'session_token' => 'session_token-input',
|
71
80
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -119,7 +128,10 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
119
128
|
'id' => 'id-input',
|
120
129
|
'links' => 'links-input',
|
121
130
|
'lock_bank_account' => 'lock_bank_account-input',
|
131
|
+
'lock_currency' => 'lock_currency-input',
|
122
132
|
'lock_customer_details' => 'lock_customer_details-input',
|
133
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
134
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
123
135
|
'redirect_uri' => 'redirect_uri-input',
|
124
136
|
'session_token' => 'session_token-input',
|
125
137
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -176,7 +188,10 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
176
188
|
'id' => 'id-input',
|
177
189
|
'links' => 'links-input',
|
178
190
|
'lock_bank_account' => 'lock_bank_account-input',
|
191
|
+
'lock_currency' => 'lock_currency-input',
|
179
192
|
'lock_customer_details' => 'lock_customer_details-input',
|
193
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
194
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
180
195
|
'redirect_uri' => 'redirect_uri-input',
|
181
196
|
'session_token' => 'session_token-input',
|
182
197
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -219,7 +234,10 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
219
234
|
'id' => 'id-input',
|
220
235
|
'links' => 'links-input',
|
221
236
|
'lock_bank_account' => 'lock_bank_account-input',
|
237
|
+
'lock_currency' => 'lock_currency-input',
|
222
238
|
'lock_customer_details' => 'lock_customer_details-input',
|
239
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
240
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
223
241
|
'redirect_uri' => 'redirect_uri-input',
|
224
242
|
'session_token' => 'session_token-input',
|
225
243
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -600,6 +600,78 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
600
600
|
end
|
601
601
|
end
|
602
602
|
|
603
|
+
describe '#choose_currency' do
|
604
|
+
subject(:post_response) { client.billing_requests.choose_currency(resource_id) }
|
605
|
+
|
606
|
+
let(:resource_id) { 'ABC123' }
|
607
|
+
|
608
|
+
let!(:stub) do
|
609
|
+
# /billing_requests/%v/actions/choose_currency
|
610
|
+
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
|
611
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
612
|
+
|
613
|
+
body: {
|
614
|
+
'billing_requests' => {
|
615
|
+
|
616
|
+
'actions' => 'actions-input',
|
617
|
+
'created_at' => 'created_at-input',
|
618
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
619
|
+
'id' => 'id-input',
|
620
|
+
'links' => 'links-input',
|
621
|
+
'mandate_request' => 'mandate_request-input',
|
622
|
+
'metadata' => 'metadata-input',
|
623
|
+
'payment_request' => 'payment_request-input',
|
624
|
+
'resources' => 'resources-input',
|
625
|
+
'status' => 'status-input',
|
626
|
+
},
|
627
|
+
}.to_json,
|
628
|
+
|
629
|
+
headers: response_headers
|
630
|
+
)
|
631
|
+
end
|
632
|
+
|
633
|
+
it 'wraps the response and calls the right endpoint' do
|
634
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
|
635
|
+
|
636
|
+
expect(stub).to have_been_requested
|
637
|
+
end
|
638
|
+
|
639
|
+
context 'when the request needs a body and custom header' do
|
640
|
+
let(:body) { { foo: 'bar' } }
|
641
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
642
|
+
subject(:post_response) { client.billing_requests.choose_currency(resource_id, body, headers) }
|
643
|
+
|
644
|
+
let(:resource_id) { 'ABC123' }
|
645
|
+
|
646
|
+
let!(:stub) do
|
647
|
+
# /billing_requests/%v/actions/choose_currency
|
648
|
+
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
|
649
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
650
|
+
with(
|
651
|
+
body: { foo: 'bar' },
|
652
|
+
headers: { 'Foo' => 'Bar' }
|
653
|
+
).to_return(
|
654
|
+
body: {
|
655
|
+
'billing_requests' => {
|
656
|
+
|
657
|
+
'actions' => 'actions-input',
|
658
|
+
'created_at' => 'created_at-input',
|
659
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
660
|
+
'id' => 'id-input',
|
661
|
+
'links' => 'links-input',
|
662
|
+
'mandate_request' => 'mandate_request-input',
|
663
|
+
'metadata' => 'metadata-input',
|
664
|
+
'payment_request' => 'payment_request-input',
|
665
|
+
'resources' => 'resources-input',
|
666
|
+
'status' => 'status-input',
|
667
|
+
},
|
668
|
+
}.to_json,
|
669
|
+
headers: response_headers
|
670
|
+
)
|
671
|
+
end
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
603
675
|
describe '#confirm_payer_details' do
|
604
676
|
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id) }
|
605
677
|
|
@@ -18,6 +18,7 @@ describe GoCardlessPro::Resources::Institution do
|
|
18
18
|
body: {
|
19
19
|
'institutions' => [{
|
20
20
|
|
21
|
+
'bank_redirect' => 'bank_redirect-input',
|
21
22
|
'country_code' => 'country_code-input',
|
22
23
|
'icon_url' => 'icon_url-input',
|
23
24
|
'id' => 'id-input',
|
@@ -38,6 +39,8 @@ describe GoCardlessPro::Resources::Institution do
|
|
38
39
|
it 'wraps each item in the resource class' do
|
39
40
|
expect(get_list_response.records.map(&:class).uniq.first).to eq(GoCardlessPro::Resources::Institution)
|
40
41
|
|
42
|
+
expect(get_list_response.records.first.bank_redirect).to eq('bank_redirect-input')
|
43
|
+
|
41
44
|
expect(get_list_response.records.first.country_code).to eq('country_code-input')
|
42
45
|
|
43
46
|
expect(get_list_response.records.first.icon_url).to eq('icon_url-input')
|
@@ -64,6 +67,7 @@ describe GoCardlessPro::Resources::Institution do
|
|
64
67
|
body: {
|
65
68
|
'institutions' => [{
|
66
69
|
|
70
|
+
'bank_redirect' => 'bank_redirect-input',
|
67
71
|
'country_code' => 'country_code-input',
|
68
72
|
'icon_url' => 'icon_url-input',
|
69
73
|
'id' => 'id-input',
|
@@ -84,6 +88,7 @@ describe GoCardlessPro::Resources::Institution do
|
|
84
88
|
body: {
|
85
89
|
'institutions' => [{
|
86
90
|
|
91
|
+
'bank_redirect' => 'bank_redirect-input',
|
87
92
|
'country_code' => 'country_code-input',
|
88
93
|
'icon_url' => 'icon_url-input',
|
89
94
|
'id' => 'id-input',
|
@@ -23,7 +23,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
23
23
|
'id' => 'id-input',
|
24
24
|
'links' => 'links-input',
|
25
25
|
'lock_bank_account' => 'lock_bank_account-input',
|
26
|
+
'lock_currency' => 'lock_currency-input',
|
26
27
|
'lock_customer_details' => 'lock_customer_details-input',
|
28
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
29
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
27
30
|
'redirect_uri' => 'redirect_uri-input',
|
28
31
|
'session_token' => 'session_token-input',
|
29
32
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -44,7 +47,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
44
47
|
'id' => 'id-input',
|
45
48
|
'links' => 'links-input',
|
46
49
|
'lock_bank_account' => 'lock_bank_account-input',
|
50
|
+
'lock_currency' => 'lock_currency-input',
|
47
51
|
'lock_customer_details' => 'lock_customer_details-input',
|
52
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
53
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
48
54
|
'redirect_uri' => 'redirect_uri-input',
|
49
55
|
'session_token' => 'session_token-input',
|
50
56
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -65,7 +71,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
65
71
|
'id' => 'id-input',
|
66
72
|
'links' => 'links-input',
|
67
73
|
'lock_bank_account' => 'lock_bank_account-input',
|
74
|
+
'lock_currency' => 'lock_currency-input',
|
68
75
|
'lock_customer_details' => 'lock_customer_details-input',
|
76
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
77
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
69
78
|
'redirect_uri' => 'redirect_uri-input',
|
70
79
|
'session_token' => 'session_token-input',
|
71
80
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -142,7 +151,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
142
151
|
'id' => 'id-input',
|
143
152
|
'links' => 'links-input',
|
144
153
|
'lock_bank_account' => 'lock_bank_account-input',
|
154
|
+
'lock_currency' => 'lock_currency-input',
|
145
155
|
'lock_customer_details' => 'lock_customer_details-input',
|
156
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
157
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
146
158
|
'redirect_uri' => 'redirect_uri-input',
|
147
159
|
'session_token' => 'session_token-input',
|
148
160
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -199,7 +211,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
199
211
|
'id' => 'id-input',
|
200
212
|
'links' => 'links-input',
|
201
213
|
'lock_bank_account' => 'lock_bank_account-input',
|
214
|
+
'lock_currency' => 'lock_currency-input',
|
202
215
|
'lock_customer_details' => 'lock_customer_details-input',
|
216
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
217
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
203
218
|
'redirect_uri' => 'redirect_uri-input',
|
204
219
|
'session_token' => 'session_token-input',
|
205
220
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -253,7 +268,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
253
268
|
'id' => 'id-input',
|
254
269
|
'links' => 'links-input',
|
255
270
|
'lock_bank_account' => 'lock_bank_account-input',
|
271
|
+
'lock_currency' => 'lock_currency-input',
|
256
272
|
'lock_customer_details' => 'lock_customer_details-input',
|
273
|
+
'prefilled_bank_account' => 'prefilled_bank_account-input',
|
274
|
+
'prefilled_customer' => 'prefilled_customer-input',
|
257
275
|
'redirect_uri' => 'redirect_uri-input',
|
258
276
|
'session_token' => 'session_token-input',
|
259
277
|
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
@@ -871,6 +871,89 @@ describe GoCardlessPro::Services::BillingRequestsService do
|
|
871
871
|
end
|
872
872
|
end
|
873
873
|
|
874
|
+
describe '#choose_currency' do
|
875
|
+
subject(:post_response) { client.billing_requests.choose_currency(resource_id) }
|
876
|
+
|
877
|
+
let(:resource_id) { 'ABC123' }
|
878
|
+
|
879
|
+
let!(:stub) do
|
880
|
+
# /billing_requests/%v/actions/choose_currency
|
881
|
+
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
|
882
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
883
|
+
|
884
|
+
body: {
|
885
|
+
'billing_requests' => {
|
886
|
+
|
887
|
+
'actions' => 'actions-input',
|
888
|
+
'created_at' => 'created_at-input',
|
889
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
890
|
+
'id' => 'id-input',
|
891
|
+
'links' => 'links-input',
|
892
|
+
'mandate_request' => 'mandate_request-input',
|
893
|
+
'metadata' => 'metadata-input',
|
894
|
+
'payment_request' => 'payment_request-input',
|
895
|
+
'resources' => 'resources-input',
|
896
|
+
'status' => 'status-input',
|
897
|
+
},
|
898
|
+
}.to_json,
|
899
|
+
|
900
|
+
headers: response_headers
|
901
|
+
)
|
902
|
+
end
|
903
|
+
|
904
|
+
it 'wraps the response and calls the right endpoint' do
|
905
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
|
906
|
+
|
907
|
+
expect(stub).to have_been_requested
|
908
|
+
end
|
909
|
+
|
910
|
+
describe 'retry behaviour' do
|
911
|
+
it "doesn't retry errors" do
|
912
|
+
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
|
913
|
+
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
914
|
+
to_timeout
|
915
|
+
|
916
|
+
expect { post_response }.to raise_error(Faraday::ConnectionFailed)
|
917
|
+
expect(stub).to have_been_requested
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
context 'when the request needs a body and custom header' do
|
922
|
+
let(:body) { { foo: 'bar' } }
|
923
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
924
|
+
subject(:post_response) { client.billing_requests.choose_currency(resource_id, body, headers) }
|
925
|
+
|
926
|
+
let(:resource_id) { 'ABC123' }
|
927
|
+
|
928
|
+
let!(:stub) do
|
929
|
+
# /billing_requests/%v/actions/choose_currency
|
930
|
+
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
|
931
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
932
|
+
with(
|
933
|
+
body: { foo: 'bar' },
|
934
|
+
headers: { 'Foo' => 'Bar' }
|
935
|
+
).to_return(
|
936
|
+
body: {
|
937
|
+
'billing_requests' => {
|
938
|
+
|
939
|
+
'actions' => 'actions-input',
|
940
|
+
'created_at' => 'created_at-input',
|
941
|
+
'fallback_enabled' => 'fallback_enabled-input',
|
942
|
+
'id' => 'id-input',
|
943
|
+
'links' => 'links-input',
|
944
|
+
'mandate_request' => 'mandate_request-input',
|
945
|
+
'metadata' => 'metadata-input',
|
946
|
+
'payment_request' => 'payment_request-input',
|
947
|
+
'resources' => 'resources-input',
|
948
|
+
'status' => 'status-input',
|
949
|
+
},
|
950
|
+
}.to_json,
|
951
|
+
headers: response_headers
|
952
|
+
)
|
953
|
+
end
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
874
957
|
describe '#confirm_payer_details' do
|
875
958
|
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id) }
|
876
959
|
|
@@ -17,6 +17,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
17
17
|
{
|
18
18
|
'institutions' => [{
|
19
19
|
|
20
|
+
'bank_redirect' => 'bank_redirect-input',
|
20
21
|
'country_code' => 'country_code-input',
|
21
22
|
'icon_url' => 'icon_url-input',
|
22
23
|
'id' => 'id-input',
|
@@ -42,6 +43,8 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
42
43
|
it 'wraps each item in the resource class' do
|
43
44
|
expect(get_list_response.records.map(&:class).uniq.first).to eq(GoCardlessPro::Resources::Institution)
|
44
45
|
|
46
|
+
expect(get_list_response.records.first.bank_redirect).to eq('bank_redirect-input')
|
47
|
+
|
45
48
|
expect(get_list_response.records.first.country_code).to eq('country_code-input')
|
46
49
|
|
47
50
|
expect(get_list_response.records.first.icon_url).to eq('icon_url-input')
|
@@ -91,6 +94,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
91
94
|
body: {
|
92
95
|
'institutions' => [{
|
93
96
|
|
97
|
+
'bank_redirect' => 'bank_redirect-input',
|
94
98
|
'country_code' => 'country_code-input',
|
95
99
|
'icon_url' => 'icon_url-input',
|
96
100
|
'id' => 'id-input',
|
@@ -111,6 +115,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
111
115
|
body: {
|
112
116
|
'institutions' => [{
|
113
117
|
|
118
|
+
'bank_redirect' => 'bank_redirect-input',
|
114
119
|
'country_code' => 'country_code-input',
|
115
120
|
'icon_url' => 'icon_url-input',
|
116
121
|
'id' => 'id-input',
|
@@ -140,6 +145,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
140
145
|
body: {
|
141
146
|
'institutions' => [{
|
142
147
|
|
148
|
+
'bank_redirect' => 'bank_redirect-input',
|
143
149
|
'country_code' => 'country_code-input',
|
144
150
|
'icon_url' => 'icon_url-input',
|
145
151
|
'id' => 'id-input',
|
@@ -160,6 +166,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
160
166
|
body: {
|
161
167
|
'institutions' => [{
|
162
168
|
|
169
|
+
'bank_redirect' => 'bank_redirect-input',
|
163
170
|
'country_code' => 'country_code-input',
|
164
171
|
'icon_url' => 'icon_url-input',
|
165
172
|
'id' => 'id-input',
|
@@ -185,6 +192,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
185
192
|
body: {
|
186
193
|
'institutions' => [{
|
187
194
|
|
195
|
+
'bank_redirect' => 'bank_redirect-input',
|
188
196
|
'country_code' => 'country_code-input',
|
189
197
|
'icon_url' => 'icon_url-input',
|
190
198
|
'id' => 'id-input',
|
@@ -208,6 +216,7 @@ describe GoCardlessPro::Services::InstitutionsService do
|
|
208
216
|
body: {
|
209
217
|
'institutions' => [{
|
210
218
|
|
219
|
+
'bank_redirect' => 'bank_redirect-input',
|
211
220
|
'country_code' => 'country_code-input',
|
212
221
|
'icon_url' => 'icon_url-input',
|
213
222
|
'id' => 'id-input',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocardless_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|