gocardless_pro 2.27.0 → 2.28.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 +20 -1
- data/lib/gocardless_pro.rb +6 -0
- data/lib/gocardless_pro/api_service.rb +4 -0
- data/lib/gocardless_pro/client.rb +6 -1
- data/lib/gocardless_pro/error/authentication_error.rb +4 -0
- data/lib/gocardless_pro/error/permission_error.rb +4 -0
- data/lib/gocardless_pro/error/rate_limit_error.rb +4 -0
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +12 -1
- data/lib/gocardless_pro/resources/bank_authorisation.rb +3 -5
- data/lib/gocardless_pro/resources/billing_request.rb +29 -7
- data/lib/gocardless_pro/resources/billing_request_flow.rb +10 -0
- data/lib/gocardless_pro/resources/billing_request_template.rb +68 -0
- data/lib/gocardless_pro/resources/payer_authorisation.rb +9 -0
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +0 -2
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +23 -0
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +131 -0
- data/lib/gocardless_pro/services/billing_requests_service.rb +49 -22
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +0 -4
- data/lib/gocardless_pro/services/creditors_service.rb +0 -2
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +0 -4
- data/lib/gocardless_pro/services/customers_service.rb +0 -2
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +0 -6
- data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -6
- data/lib/gocardless_pro/services/mandates_service.rb +0 -6
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +0 -6
- data/lib/gocardless_pro/services/payments_service.rb +0 -6
- data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -4
- data/lib/gocardless_pro/services/refunds_service.rb +0 -2
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +28 -6
- data/lib/gocardless_pro/services/subscriptions_service.rb +2 -10
- data/lib/gocardless_pro/services/webhooks_service.rb +0 -2
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/api_service_spec.rb +12 -1
- data/spec/middlewares/raise_gocardless_errors_spec.rb +30 -0
- data/spec/resources/bank_authorisation_spec.rb +7 -7
- data/spec/resources/billing_request_flow_spec.rb +90 -0
- data/spec/resources/billing_request_spec.rb +75 -29
- data/spec/resources/billing_request_template_spec.rb +502 -0
- data/spec/services/bank_authorisations_service_spec.rb +7 -20
- data/spec/services/billing_request_flows_service_spec.rb +101 -0
- data/spec/services/billing_request_templates_service_spec.rb +789 -0
- data/spec/services/billing_requests_service_spec.rb +87 -47
- data/spec/services/creditor_bank_accounts_service_spec.rb +0 -13
- data/spec/services/creditors_service_spec.rb +0 -13
- data/spec/services/customer_bank_accounts_service_spec.rb +0 -13
- data/spec/services/customers_service_spec.rb +0 -13
- data/spec/services/instalment_schedules_service_spec.rb +0 -26
- data/spec/services/mandate_imports_service_spec.rb +0 -13
- data/spec/services/mandates_service_spec.rb +0 -13
- data/spec/services/payer_authorisations_service_spec.rb +0 -13
- data/spec/services/payments_service_spec.rb +0 -13
- data/spec/services/redirect_flows_service_spec.rb +0 -13
- data/spec/services/refunds_service_spec.rb +0 -13
- data/spec/services/subscriptions_service_spec.rb +0 -13
- metadata +16 -7
data/spec/api_service_spec.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe GoCardlessPro::ApiService do
|
|
4
|
-
subject(:service)
|
|
4
|
+
subject(:service) do
|
|
5
|
+
described_class.new('https://api.example.com', 'secret_token', options)
|
|
6
|
+
end
|
|
5
7
|
|
|
8
|
+
let(:options) { {} }
|
|
6
9
|
let(:default_response) do
|
|
7
10
|
{
|
|
8
11
|
status: 200,
|
|
@@ -174,4 +177,12 @@ describe GoCardlessPro::ApiService do
|
|
|
174
177
|
expect(stub).to have_been_requested
|
|
175
178
|
end
|
|
176
179
|
end
|
|
180
|
+
|
|
181
|
+
describe 'when passing an invalid :on_idempotency_conflict' do
|
|
182
|
+
let(:options) { { on_idempotency_conflict: :junk } }
|
|
183
|
+
|
|
184
|
+
it 'raises an error' do
|
|
185
|
+
expect { service }.to raise_error(ArgumentError)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
177
188
|
end
|
|
@@ -74,6 +74,36 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
context 'for a Permission error' do
|
|
78
|
+
let(:status) { 403 }
|
|
79
|
+
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
|
|
80
|
+
|
|
81
|
+
it 'raises a GoCardlessError' do
|
|
82
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
|
83
|
+
to raise_error(GoCardlessPro::PermissionError)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'for a RateLimit error' do
|
|
88
|
+
let(:status) { 429 }
|
|
89
|
+
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
|
|
90
|
+
|
|
91
|
+
it 'raises a GoCardlessError' do
|
|
92
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
|
93
|
+
to raise_error(GoCardlessPro::RateLimitError)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'for a Authentication error' do
|
|
98
|
+
let(:status) { 401 }
|
|
99
|
+
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
|
|
100
|
+
|
|
101
|
+
it 'raises a GoCardlessError' do
|
|
102
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
|
103
|
+
to raise_error(GoCardlessPro::AuthenticationError)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
77
107
|
context 'for an invalid API usage error' do
|
|
78
108
|
let(:status) { 400 }
|
|
79
109
|
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
|
|
@@ -24,13 +24,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
24
24
|
'bank_authorisations' => {
|
|
25
25
|
|
|
26
26
|
'authorisation_type' => 'authorisation_type-input',
|
|
27
|
+
'authorised_at' => 'authorised_at-input',
|
|
27
28
|
'created_at' => 'created_at-input',
|
|
28
29
|
'expires_at' => 'expires_at-input',
|
|
29
30
|
'id' => 'id-input',
|
|
30
31
|
'last_visited_at' => 'last_visited_at-input',
|
|
31
32
|
'links' => 'links-input',
|
|
32
33
|
'redirect_uri' => 'redirect_uri-input',
|
|
33
|
-
'short_url' => 'short_url-input',
|
|
34
34
|
'url' => 'url-input',
|
|
35
35
|
},
|
|
36
36
|
}.to_json,
|
|
@@ -58,13 +58,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
58
58
|
'bank_authorisations' => {
|
|
59
59
|
|
|
60
60
|
'authorisation_type' => 'authorisation_type-input',
|
|
61
|
+
'authorised_at' => 'authorised_at-input',
|
|
61
62
|
'created_at' => 'created_at-input',
|
|
62
63
|
'expires_at' => 'expires_at-input',
|
|
63
64
|
'id' => 'id-input',
|
|
64
65
|
'last_visited_at' => 'last_visited_at-input',
|
|
65
66
|
'links' => 'links-input',
|
|
66
67
|
'redirect_uri' => 'redirect_uri-input',
|
|
67
|
-
'short_url' => 'short_url-input',
|
|
68
68
|
'url' => 'url-input',
|
|
69
69
|
},
|
|
70
70
|
}.to_json,
|
|
@@ -107,13 +107,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
107
107
|
{
|
|
108
108
|
|
|
109
109
|
'authorisation_type' => 'authorisation_type-input',
|
|
110
|
+
'authorised_at' => 'authorised_at-input',
|
|
110
111
|
'created_at' => 'created_at-input',
|
|
111
112
|
'expires_at' => 'expires_at-input',
|
|
112
113
|
'id' => 'id-input',
|
|
113
114
|
'last_visited_at' => 'last_visited_at-input',
|
|
114
115
|
'links' => 'links-input',
|
|
115
116
|
'redirect_uri' => 'redirect_uri-input',
|
|
116
|
-
'short_url' => 'short_url-input',
|
|
117
117
|
'url' => 'url-input',
|
|
118
118
|
}
|
|
119
119
|
end
|
|
@@ -125,13 +125,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
125
125
|
'bank_authorisations' => {
|
|
126
126
|
|
|
127
127
|
'authorisation_type' => 'authorisation_type-input',
|
|
128
|
+
'authorised_at' => 'authorised_at-input',
|
|
128
129
|
'created_at' => 'created_at-input',
|
|
129
130
|
'expires_at' => 'expires_at-input',
|
|
130
131
|
'id' => 'id-input',
|
|
131
132
|
'last_visited_at' => 'last_visited_at-input',
|
|
132
133
|
'links' => 'links-input',
|
|
133
134
|
'redirect_uri' => 'redirect_uri-input',
|
|
134
|
-
'short_url' => 'short_url-input',
|
|
135
135
|
'url' => 'url-input',
|
|
136
136
|
},
|
|
137
137
|
}
|
|
@@ -143,13 +143,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
143
143
|
{
|
|
144
144
|
|
|
145
145
|
'authorisation_type' => 'authorisation_type-input',
|
|
146
|
+
'authorised_at' => 'authorised_at-input',
|
|
146
147
|
'created_at' => 'created_at-input',
|
|
147
148
|
'expires_at' => 'expires_at-input',
|
|
148
149
|
'id' => 'id-input',
|
|
149
150
|
'last_visited_at' => 'last_visited_at-input',
|
|
150
151
|
'links' => 'links-input',
|
|
151
152
|
'redirect_uri' => 'redirect_uri-input',
|
|
152
|
-
'short_url' => 'short_url-input',
|
|
153
153
|
'url' => 'url-input',
|
|
154
154
|
},
|
|
155
155
|
|
|
@@ -194,13 +194,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
194
194
|
{
|
|
195
195
|
|
|
196
196
|
'authorisation_type' => 'authorisation_type-input',
|
|
197
|
+
'authorised_at' => 'authorised_at-input',
|
|
197
198
|
'created_at' => 'created_at-input',
|
|
198
199
|
'expires_at' => 'expires_at-input',
|
|
199
200
|
'id' => 'id-input',
|
|
200
201
|
'last_visited_at' => 'last_visited_at-input',
|
|
201
202
|
'links' => 'links-input',
|
|
202
203
|
'redirect_uri' => 'redirect_uri-input',
|
|
203
|
-
'short_url' => 'short_url-input',
|
|
204
204
|
'url' => 'url-input',
|
|
205
205
|
}
|
|
206
206
|
end
|
|
@@ -235,13 +235,13 @@ describe GoCardlessPro::Resources::BankAuthorisation do
|
|
|
235
235
|
'bank_authorisations' => {
|
|
236
236
|
|
|
237
237
|
'authorisation_type' => 'authorisation_type-input',
|
|
238
|
+
'authorised_at' => 'authorised_at-input',
|
|
238
239
|
'created_at' => 'created_at-input',
|
|
239
240
|
'expires_at' => 'expires_at-input',
|
|
240
241
|
'id' => 'id-input',
|
|
241
242
|
'last_visited_at' => 'last_visited_at-input',
|
|
242
243
|
'links' => 'links-input',
|
|
243
244
|
'redirect_uri' => 'redirect_uri-input',
|
|
244
|
-
'short_url' => 'short_url-input',
|
|
245
245
|
'url' => 'url-input',
|
|
246
246
|
},
|
|
247
247
|
}.to_json,
|
|
@@ -16,10 +16,15 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
|
16
16
|
{
|
|
17
17
|
|
|
18
18
|
'authorisation_url' => 'authorisation_url-input',
|
|
19
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
|
19
20
|
'created_at' => 'created_at-input',
|
|
20
21
|
'expires_at' => 'expires_at-input',
|
|
22
|
+
'id' => 'id-input',
|
|
21
23
|
'links' => 'links-input',
|
|
24
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
|
25
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
|
22
26
|
'redirect_uri' => 'redirect_uri-input',
|
|
27
|
+
'session_token' => 'session_token-input',
|
|
23
28
|
}
|
|
24
29
|
end
|
|
25
30
|
|
|
@@ -30,10 +35,15 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
|
30
35
|
'billing_request_flows' => {
|
|
31
36
|
|
|
32
37
|
'authorisation_url' => 'authorisation_url-input',
|
|
38
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
|
33
39
|
'created_at' => 'created_at-input',
|
|
34
40
|
'expires_at' => 'expires_at-input',
|
|
41
|
+
'id' => 'id-input',
|
|
35
42
|
'links' => 'links-input',
|
|
43
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
|
44
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
|
36
45
|
'redirect_uri' => 'redirect_uri-input',
|
|
46
|
+
'session_token' => 'session_token-input',
|
|
37
47
|
},
|
|
38
48
|
}
|
|
39
49
|
).
|
|
@@ -44,10 +54,15 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
|
44
54
|
{
|
|
45
55
|
|
|
46
56
|
'authorisation_url' => 'authorisation_url-input',
|
|
57
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
|
47
58
|
'created_at' => 'created_at-input',
|
|
48
59
|
'expires_at' => 'expires_at-input',
|
|
60
|
+
'id' => 'id-input',
|
|
49
61
|
'links' => 'links-input',
|
|
62
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
|
63
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
|
50
64
|
'redirect_uri' => 'redirect_uri-input',
|
|
65
|
+
'session_token' => 'session_token-input',
|
|
51
66
|
},
|
|
52
67
|
|
|
53
68
|
}.to_json,
|
|
@@ -91,10 +106,15 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
|
91
106
|
{
|
|
92
107
|
|
|
93
108
|
'authorisation_url' => 'authorisation_url-input',
|
|
109
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
|
94
110
|
'created_at' => 'created_at-input',
|
|
95
111
|
'expires_at' => 'expires_at-input',
|
|
112
|
+
'id' => 'id-input',
|
|
96
113
|
'links' => 'links-input',
|
|
114
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
|
115
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
|
97
116
|
'redirect_uri' => 'redirect_uri-input',
|
|
117
|
+
'session_token' => 'session_token-input',
|
|
98
118
|
}
|
|
99
119
|
end
|
|
100
120
|
|
|
@@ -126,4 +146,74 @@ describe GoCardlessPro::Resources::BillingRequestFlow do
|
|
|
126
146
|
end
|
|
127
147
|
end
|
|
128
148
|
end
|
|
149
|
+
|
|
150
|
+
describe '#initialise' do
|
|
151
|
+
subject(:post_response) { client.billing_request_flows.initialise(resource_id) }
|
|
152
|
+
|
|
153
|
+
let(:resource_id) { 'ABC123' }
|
|
154
|
+
|
|
155
|
+
let!(:stub) do
|
|
156
|
+
# /billing_request_flows/%v/actions/initialise
|
|
157
|
+
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
|
|
158
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
|
159
|
+
body: {
|
|
160
|
+
'billing_request_flows' => {
|
|
161
|
+
|
|
162
|
+
'authorisation_url' => 'authorisation_url-input',
|
|
163
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
|
164
|
+
'created_at' => 'created_at-input',
|
|
165
|
+
'expires_at' => 'expires_at-input',
|
|
166
|
+
'id' => 'id-input',
|
|
167
|
+
'links' => 'links-input',
|
|
168
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
|
169
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
|
170
|
+
'redirect_uri' => 'redirect_uri-input',
|
|
171
|
+
'session_token' => 'session_token-input',
|
|
172
|
+
},
|
|
173
|
+
}.to_json,
|
|
174
|
+
headers: response_headers
|
|
175
|
+
)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'wraps the response and calls the right endpoint' do
|
|
179
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequestFlow)
|
|
180
|
+
|
|
181
|
+
expect(stub).to have_been_requested
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
context 'when the request needs a body and custom header' do
|
|
185
|
+
let(:body) { { foo: 'bar' } }
|
|
186
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
|
187
|
+
subject(:post_response) { client.billing_request_flows.initialise(resource_id, body, headers) }
|
|
188
|
+
|
|
189
|
+
let(:resource_id) { 'ABC123' }
|
|
190
|
+
|
|
191
|
+
let!(:stub) do
|
|
192
|
+
# /billing_request_flows/%v/actions/initialise
|
|
193
|
+
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
|
|
194
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
|
195
|
+
with(
|
|
196
|
+
body: { foo: 'bar' },
|
|
197
|
+
headers: { 'Foo' => 'Bar' }
|
|
198
|
+
).to_return(
|
|
199
|
+
body: {
|
|
200
|
+
'billing_request_flows' => {
|
|
201
|
+
|
|
202
|
+
'authorisation_url' => 'authorisation_url-input',
|
|
203
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
|
204
|
+
'created_at' => 'created_at-input',
|
|
205
|
+
'expires_at' => 'expires_at-input',
|
|
206
|
+
'id' => 'id-input',
|
|
207
|
+
'links' => 'links-input',
|
|
208
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
|
209
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
|
210
|
+
'redirect_uri' => 'redirect_uri-input',
|
|
211
|
+
'session_token' => 'session_token-input',
|
|
212
|
+
},
|
|
213
|
+
}.to_json,
|
|
214
|
+
headers: response_headers
|
|
215
|
+
)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
129
219
|
end
|
|
@@ -19,7 +19,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
19
19
|
'billing_requests' => [{
|
|
20
20
|
|
|
21
21
|
'actions' => 'actions-input',
|
|
22
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
23
22
|
'created_at' => 'created_at-input',
|
|
24
23
|
'id' => 'id-input',
|
|
25
24
|
'links' => 'links-input',
|
|
@@ -45,8 +44,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
45
44
|
|
|
46
45
|
expect(get_list_response.records.first.actions).to eq('actions-input')
|
|
47
46
|
|
|
48
|
-
expect(get_list_response.records.first.auto_fulfil).to eq('auto_fulfil-input')
|
|
49
|
-
|
|
50
47
|
expect(get_list_response.records.first.created_at).to eq('created_at-input')
|
|
51
48
|
|
|
52
49
|
expect(get_list_response.records.first.id).to eq('id-input')
|
|
@@ -78,7 +75,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
78
75
|
'billing_requests' => [{
|
|
79
76
|
|
|
80
77
|
'actions' => 'actions-input',
|
|
81
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
82
78
|
'created_at' => 'created_at-input',
|
|
83
79
|
'id' => 'id-input',
|
|
84
80
|
'links' => 'links-input',
|
|
@@ -103,7 +99,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
103
99
|
'billing_requests' => [{
|
|
104
100
|
|
|
105
101
|
'actions' => 'actions-input',
|
|
106
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
107
102
|
'created_at' => 'created_at-input',
|
|
108
103
|
'id' => 'id-input',
|
|
109
104
|
'links' => 'links-input',
|
|
@@ -136,7 +131,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
136
131
|
{
|
|
137
132
|
|
|
138
133
|
'actions' => 'actions-input',
|
|
139
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
140
134
|
'created_at' => 'created_at-input',
|
|
141
135
|
'id' => 'id-input',
|
|
142
136
|
'links' => 'links-input',
|
|
@@ -155,7 +149,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
155
149
|
'billing_requests' => {
|
|
156
150
|
|
|
157
151
|
'actions' => 'actions-input',
|
|
158
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
159
152
|
'created_at' => 'created_at-input',
|
|
160
153
|
'id' => 'id-input',
|
|
161
154
|
'links' => 'links-input',
|
|
@@ -174,7 +167,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
174
167
|
{
|
|
175
168
|
|
|
176
169
|
'actions' => 'actions-input',
|
|
177
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
178
170
|
'created_at' => 'created_at-input',
|
|
179
171
|
'id' => 'id-input',
|
|
180
172
|
'links' => 'links-input',
|
|
@@ -226,7 +218,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
226
218
|
{
|
|
227
219
|
|
|
228
220
|
'actions' => 'actions-input',
|
|
229
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
230
221
|
'created_at' => 'created_at-input',
|
|
231
222
|
'id' => 'id-input',
|
|
232
223
|
'links' => 'links-input',
|
|
@@ -268,7 +259,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
268
259
|
'billing_requests' => {
|
|
269
260
|
|
|
270
261
|
'actions' => 'actions-input',
|
|
271
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
272
262
|
'created_at' => 'created_at-input',
|
|
273
263
|
'id' => 'id-input',
|
|
274
264
|
'links' => 'links-input',
|
|
@@ -306,7 +296,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
306
296
|
'billing_requests' => {
|
|
307
297
|
|
|
308
298
|
'actions' => 'actions-input',
|
|
309
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
310
299
|
'created_at' => 'created_at-input',
|
|
311
300
|
'id' => 'id-input',
|
|
312
301
|
'links' => 'links-input',
|
|
@@ -341,7 +330,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
341
330
|
'billing_requests' => {
|
|
342
331
|
|
|
343
332
|
'actions' => 'actions-input',
|
|
344
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
345
333
|
'created_at' => 'created_at-input',
|
|
346
334
|
'id' => 'id-input',
|
|
347
335
|
'links' => 'links-input',
|
|
@@ -397,7 +385,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
397
385
|
'billing_requests' => {
|
|
398
386
|
|
|
399
387
|
'actions' => 'actions-input',
|
|
400
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
401
388
|
'created_at' => 'created_at-input',
|
|
402
389
|
'id' => 'id-input',
|
|
403
390
|
'links' => 'links-input',
|
|
@@ -437,7 +424,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
437
424
|
'billing_requests' => {
|
|
438
425
|
|
|
439
426
|
'actions' => 'actions-input',
|
|
440
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
441
427
|
'created_at' => 'created_at-input',
|
|
442
428
|
'id' => 'id-input',
|
|
443
429
|
'links' => 'links-input',
|
|
@@ -454,20 +440,19 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
454
440
|
end
|
|
455
441
|
end
|
|
456
442
|
|
|
457
|
-
describe '#
|
|
458
|
-
subject(:post_response) { client.billing_requests.
|
|
443
|
+
describe '#collect_bank_account' do
|
|
444
|
+
subject(:post_response) { client.billing_requests.collect_bank_account(resource_id) }
|
|
459
445
|
|
|
460
446
|
let(:resource_id) { 'ABC123' }
|
|
461
447
|
|
|
462
448
|
let!(:stub) do
|
|
463
|
-
# /billing_requests/%v/actions/
|
|
464
|
-
stub_url = '/billing_requests/:identity/actions/
|
|
449
|
+
# /billing_requests/%v/actions/collect_bank_account
|
|
450
|
+
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
|
|
465
451
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
|
466
452
|
body: {
|
|
467
453
|
'billing_requests' => {
|
|
468
454
|
|
|
469
455
|
'actions' => 'actions-input',
|
|
470
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
471
456
|
'created_at' => 'created_at-input',
|
|
472
457
|
'id' => 'id-input',
|
|
473
458
|
'links' => 'links-input',
|
|
@@ -491,13 +476,13 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
491
476
|
context 'when the request needs a body and custom header' do
|
|
492
477
|
let(:body) { { foo: 'bar' } }
|
|
493
478
|
let(:headers) { { 'Foo' => 'Bar' } }
|
|
494
|
-
subject(:post_response) { client.billing_requests.
|
|
479
|
+
subject(:post_response) { client.billing_requests.collect_bank_account(resource_id, body, headers) }
|
|
495
480
|
|
|
496
481
|
let(:resource_id) { 'ABC123' }
|
|
497
482
|
|
|
498
483
|
let!(:stub) do
|
|
499
|
-
# /billing_requests/%v/actions/
|
|
500
|
-
stub_url = '/billing_requests/:identity/actions/
|
|
484
|
+
# /billing_requests/%v/actions/collect_bank_account
|
|
485
|
+
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
|
|
501
486
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
|
502
487
|
with(
|
|
503
488
|
body: { foo: 'bar' },
|
|
@@ -507,7 +492,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
507
492
|
'billing_requests' => {
|
|
508
493
|
|
|
509
494
|
'actions' => 'actions-input',
|
|
510
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
511
495
|
'created_at' => 'created_at-input',
|
|
512
496
|
'id' => 'id-input',
|
|
513
497
|
'links' => 'links-input',
|
|
@@ -537,7 +521,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
537
521
|
'billing_requests' => {
|
|
538
522
|
|
|
539
523
|
'actions' => 'actions-input',
|
|
540
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
541
524
|
'created_at' => 'created_at-input',
|
|
542
525
|
'id' => 'id-input',
|
|
543
526
|
'links' => 'links-input',
|
|
@@ -577,7 +560,74 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
577
560
|
'billing_requests' => {
|
|
578
561
|
|
|
579
562
|
'actions' => 'actions-input',
|
|
580
|
-
'
|
|
563
|
+
'created_at' => 'created_at-input',
|
|
564
|
+
'id' => 'id-input',
|
|
565
|
+
'links' => 'links-input',
|
|
566
|
+
'mandate_request' => 'mandate_request-input',
|
|
567
|
+
'metadata' => 'metadata-input',
|
|
568
|
+
'payment_request' => 'payment_request-input',
|
|
569
|
+
'resources' => 'resources-input',
|
|
570
|
+
'status' => 'status-input',
|
|
571
|
+
},
|
|
572
|
+
}.to_json,
|
|
573
|
+
headers: response_headers
|
|
574
|
+
)
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
end
|
|
578
|
+
|
|
579
|
+
describe '#confirm_payer_details' do
|
|
580
|
+
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id) }
|
|
581
|
+
|
|
582
|
+
let(:resource_id) { 'ABC123' }
|
|
583
|
+
|
|
584
|
+
let!(:stub) do
|
|
585
|
+
# /billing_requests/%v/actions/confirm_payer_details
|
|
586
|
+
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
|
|
587
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
|
588
|
+
body: {
|
|
589
|
+
'billing_requests' => {
|
|
590
|
+
|
|
591
|
+
'actions' => 'actions-input',
|
|
592
|
+
'created_at' => 'created_at-input',
|
|
593
|
+
'id' => 'id-input',
|
|
594
|
+
'links' => 'links-input',
|
|
595
|
+
'mandate_request' => 'mandate_request-input',
|
|
596
|
+
'metadata' => 'metadata-input',
|
|
597
|
+
'payment_request' => 'payment_request-input',
|
|
598
|
+
'resources' => 'resources-input',
|
|
599
|
+
'status' => 'status-input',
|
|
600
|
+
},
|
|
601
|
+
}.to_json,
|
|
602
|
+
headers: response_headers
|
|
603
|
+
)
|
|
604
|
+
end
|
|
605
|
+
|
|
606
|
+
it 'wraps the response and calls the right endpoint' do
|
|
607
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
|
|
608
|
+
|
|
609
|
+
expect(stub).to have_been_requested
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
context 'when the request needs a body and custom header' do
|
|
613
|
+
let(:body) { { foo: 'bar' } }
|
|
614
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
|
615
|
+
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id, body, headers) }
|
|
616
|
+
|
|
617
|
+
let(:resource_id) { 'ABC123' }
|
|
618
|
+
|
|
619
|
+
let!(:stub) do
|
|
620
|
+
# /billing_requests/%v/actions/confirm_payer_details
|
|
621
|
+
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
|
|
622
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
|
623
|
+
with(
|
|
624
|
+
body: { foo: 'bar' },
|
|
625
|
+
headers: { 'Foo' => 'Bar' }
|
|
626
|
+
).to_return(
|
|
627
|
+
body: {
|
|
628
|
+
'billing_requests' => {
|
|
629
|
+
|
|
630
|
+
'actions' => 'actions-input',
|
|
581
631
|
'created_at' => 'created_at-input',
|
|
582
632
|
'id' => 'id-input',
|
|
583
633
|
'links' => 'links-input',
|
|
@@ -607,7 +657,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
607
657
|
'billing_requests' => {
|
|
608
658
|
|
|
609
659
|
'actions' => 'actions-input',
|
|
610
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
611
660
|
'created_at' => 'created_at-input',
|
|
612
661
|
'id' => 'id-input',
|
|
613
662
|
'links' => 'links-input',
|
|
@@ -647,7 +696,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
647
696
|
'billing_requests' => {
|
|
648
697
|
|
|
649
698
|
'actions' => 'actions-input',
|
|
650
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
651
699
|
'created_at' => 'created_at-input',
|
|
652
700
|
'id' => 'id-input',
|
|
653
701
|
'links' => 'links-input',
|
|
@@ -677,7 +725,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
677
725
|
'billing_requests' => {
|
|
678
726
|
|
|
679
727
|
'actions' => 'actions-input',
|
|
680
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
681
728
|
'created_at' => 'created_at-input',
|
|
682
729
|
'id' => 'id-input',
|
|
683
730
|
'links' => 'links-input',
|
|
@@ -717,7 +764,6 @@ describe GoCardlessPro::Resources::BillingRequest do
|
|
|
717
764
|
'billing_requests' => {
|
|
718
765
|
|
|
719
766
|
'actions' => 'actions-input',
|
|
720
|
-
'auto_fulfil' => 'auto_fulfil-input',
|
|
721
767
|
'created_at' => 'created_at-input',
|
|
722
768
|
'id' => 'id-input',
|
|
723
769
|
'links' => 'links-input',
|