adyen-ruby-api-library 10.4.0 → 11.0.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/.github/CODEOWNERS +1 -1
- data/.github/workflows/codeql.yml +1 -1
- data/.github/workflows/release.yml +3 -2
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/rubygems_release.yml +1 -1
- data/README.md +4 -10
- data/VERSION +1 -1
- data/lib/adyen/client.rb +49 -14
- data/lib/adyen/errors.rb +8 -6
- data/lib/adyen/services/{balanceControlService.rb → balanceControl/balance_control_api.rb} +5 -4
- data/lib/adyen/services/balanceControl.rb +24 -0
- data/lib/adyen/services/balancePlatform/authorized_card_users_api.rb +2 -2
- data/lib/adyen/services/balancePlatform/balances_api.rb +2 -2
- data/lib/adyen/services/balancePlatform/transfer_limits_balance_account_level_api.rb +76 -0
- data/lib/adyen/services/balancePlatform/transfer_limits_balance_platform_level_api.rb +56 -0
- data/lib/adyen/services/balancePlatform.rb +10 -0
- data/lib/adyen/services/binLookup/bin_lookup_api.rb +36 -0
- data/lib/adyen/services/binLookup.rb +8 -21
- data/lib/adyen/services/checkout/donations_api.rb +1 -1
- data/lib/adyen/services/checkout/utility_api.rb +10 -0
- data/lib/adyen/services/dataProtection/data_protection_api.rb +26 -0
- data/lib/adyen/services/dataProtection.rb +8 -11
- data/lib/adyen/services/disputes/disputes_api.rb +66 -0
- data/lib/adyen/services/disputes.rb +8 -51
- data/lib/adyen/services/legalEntityManagement.rb +1 -1
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +7 -7
- data/lib/adyen/services/openBanking/account_verification_api.rb +36 -0
- data/lib/adyen/services/openBanking.rb +24 -0
- data/lib/adyen/services/payment/modifications_api.rb +98 -0
- data/lib/adyen/services/payment/payments_api.rb +66 -0
- data/lib/adyen/services/payment.rb +11 -131
- data/lib/adyen/services/paymentsApp/payments_app_api.rb +66 -0
- data/lib/adyen/services/paymentsApp.rb +8 -51
- data/lib/adyen/services/posMobile/pos_mobile_api.rb +26 -0
- data/lib/adyen/services/posMobile.rb +8 -11
- data/lib/adyen/services/recurring/recurring_api.rb +80 -0
- data/lib/adyen/services/recurring.rb +8 -61
- data/lib/adyen/services/sessionAuthentication/session_authentication_api.rb +1 -1
- data/lib/adyen/services/storedValue/stored_value_api.rb +76 -0
- data/lib/adyen/services/storedValue.rb +8 -61
- data/lib/adyen/version.rb +1 -1
- data/lib/adyen-ruby-api-library.rb +4 -1
- data/spec/balance_control_spec.rb +7 -5
- data/spec/balance_platform_spec.rb +344 -63
- data/spec/bin_lookup_spec.rb +4 -3
- data/spec/client_spec.rb +101 -2
- data/spec/data_protection_spec.rb +1 -1
- data/spec/disputes_spec.rb +2 -1
- data/spec/mocks/requests/BalancePlatform/create_transfer_limit.json +14 -0
- data/spec/mocks/requests/BalancePlatform/create_webhook_setting.json +16 -0
- data/spec/mocks/requests/OpenBanking/create_account_verification_routes.json +6 -0
- data/spec/mocks/requests/SessionAuthentication/create_authentication_session.json +16 -0
- data/spec/mocks/responses/BalancePlatform/create_transfer_limit.json +16 -0
- data/spec/mocks/responses/BalancePlatform/create_webhook_setting.json +17 -0
- data/spec/mocks/responses/BalancePlatform/get_all_authorised_card_users.json +6 -0
- data/spec/mocks/responses/BalancePlatform/get_all_webhook_settings.json +38 -0
- data/spec/mocks/responses/BalancePlatform/get_specific_transfer_limit.json +17 -0
- data/spec/mocks/responses/BalancePlatform/get_transfer_limits.json +38 -0
- data/spec/mocks/responses/OpenBanking/create_account_verification_routes.json +11 -0
- data/spec/mocks/responses/OpenBanking/get_account_verification_report.json +30 -0
- data/spec/mocks/responses/SessionAuthentication/create_authentication_session.json +4 -0
- data/spec/open_banking_spec.rb +68 -0
- data/spec/payments_spec.rb +1 -1
- data/spec/recurring_spec.rb +1 -1
- data/spec/session_authentication_spec.rb +40 -0
- data/spec/stored_value_spec.rb +1 -1
- data/templates/api.mustache +1 -1
- metadata +31 -2
@@ -10,54 +10,46 @@ RSpec.describe Adyen::BalancePlatform, service: 'balancePlatform' do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# must be created manually because every field in the response is an array
|
13
|
-
it 'makes
|
13
|
+
it 'makes an account_holder POST call' do
|
14
14
|
request_body = JSON.parse(json_from_file('mocks/requests/BalancePlatform/create_account_holder.json'))
|
15
|
-
|
16
15
|
response_body = json_from_file('mocks/responses/BalancePlatform/create_account_holder.json')
|
17
16
|
|
18
|
-
url = @shared_values[:client].service_url(
|
19
|
-
|
17
|
+
url = @shared_values[:client].service_url(
|
18
|
+
@shared_values[:service],
|
19
|
+
'accountHolders',
|
20
|
+
@shared_values[:client].balance_platform.version
|
21
|
+
)
|
20
22
|
WebMock.stub_request(:post, url)
|
21
23
|
.with(
|
22
24
|
body: request_body,
|
23
|
-
headers: {
|
24
|
-
'x-api-key' => @shared_values[:client].api_key
|
25
|
-
}
|
26
|
-
)
|
27
|
-
.to_return(
|
28
|
-
body: response_body
|
25
|
+
headers: { 'x-api-key' => @shared_values[:client].api_key }
|
29
26
|
)
|
27
|
+
.to_return(body: response_body)
|
30
28
|
|
31
29
|
result = @shared_values[:client].balance_platform.account_holders_api.create_account_holder(request_body)
|
32
30
|
response_hash = result.response
|
33
31
|
|
34
|
-
expect(result.status)
|
35
|
-
|
36
|
-
expect(response_hash)
|
37
|
-
|
38
|
-
expect(response_hash)
|
39
|
-
.to be_a Adyen::HashWithAccessors
|
40
|
-
expect(response_hash)
|
41
|
-
.to be_a_kind_of Hash
|
32
|
+
expect(result.status).to eq(200)
|
33
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
34
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
35
|
+
expect(response_hash).to be_a_kind_of Hash
|
42
36
|
end
|
43
37
|
|
44
|
-
it 'makes
|
38
|
+
it 'makes an account_holder PATCH call' do
|
45
39
|
request_body = JSON.parse(json_from_file('mocks/requests/BalancePlatform/update_account_holder.json'))
|
46
|
-
|
47
40
|
response_body = json_from_file('mocks/responses/BalancePlatform/update_account_holder.json')
|
48
41
|
|
49
|
-
url = @shared_values[:client].service_url(
|
50
|
-
|
42
|
+
url = @shared_values[:client].service_url(
|
43
|
+
@shared_values[:service],
|
44
|
+
'accountHolders/AH3227C223222C5GKR23686TF',
|
45
|
+
@shared_values[:client].balance_platform.version
|
46
|
+
)
|
51
47
|
WebMock.stub_request(:patch, url)
|
52
48
|
.with(
|
53
49
|
body: request_body,
|
54
|
-
headers: {
|
55
|
-
'x-api-key' => @shared_values[:client].api_key
|
56
|
-
}
|
57
|
-
)
|
58
|
-
.to_return(
|
59
|
-
body: response_body
|
50
|
+
headers: { 'x-api-key' => @shared_values[:client].api_key }
|
60
51
|
)
|
52
|
+
.to_return(body: response_body)
|
61
53
|
|
62
54
|
result = @shared_values[:client].balance_platform.account_holders_api.update_account_holder(
|
63
55
|
request_body,
|
@@ -65,43 +57,32 @@ RSpec.describe Adyen::BalancePlatform, service: 'balancePlatform' do
|
|
65
57
|
)
|
66
58
|
response_hash = result.response
|
67
59
|
|
68
|
-
expect(result.status)
|
69
|
-
|
70
|
-
expect(response_hash)
|
71
|
-
|
72
|
-
expect(response_hash)
|
73
|
-
.to be_a Adyen::HashWithAccessors
|
74
|
-
expect(response_hash)
|
75
|
-
.to be_a_kind_of Hash
|
60
|
+
expect(result.status).to eq(200)
|
61
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
62
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
63
|
+
expect(response_hash).to be_a_kind_of Hash
|
76
64
|
end
|
77
65
|
|
78
66
|
it 'makes a balance_account GET call' do
|
79
67
|
response_body = json_from_file('mocks/responses/BalancePlatform/get_balance_account.json')
|
80
68
|
|
81
|
-
url = @shared_values[:client].service_url(
|
82
|
-
|
69
|
+
url = @shared_values[:client].service_url(
|
70
|
+
@shared_values[:service],
|
71
|
+
'balanceAccounts/BA3227C223222B5BLP6JQC3FD',
|
72
|
+
@shared_values[:client].balance_platform.version
|
73
|
+
)
|
83
74
|
WebMock.stub_request(:get, url)
|
84
|
-
.with(
|
85
|
-
|
86
|
-
'x-api-key' => @shared_values[:client].api_key
|
87
|
-
}
|
88
|
-
)
|
89
|
-
.to_return(
|
90
|
-
body: response_body
|
91
|
-
)
|
75
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
76
|
+
.to_return(body: response_body)
|
92
77
|
|
93
78
|
result = @shared_values[:client].balance_platform.balance_accounts_api
|
94
79
|
.get_balance_account('BA3227C223222B5BLP6JQC3FD')
|
95
80
|
response_hash = result.response
|
96
81
|
|
97
|
-
expect(result.status)
|
98
|
-
|
99
|
-
expect(response_hash)
|
100
|
-
|
101
|
-
expect(response_hash)
|
102
|
-
.to be_a Adyen::HashWithAccessors
|
103
|
-
expect(response_hash)
|
104
|
-
.to be_a_kind_of Hash
|
82
|
+
expect(result.status).to eq(200)
|
83
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
84
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
85
|
+
expect(response_hash).to be_a_kind_of Hash
|
105
86
|
end
|
106
87
|
|
107
88
|
it 'makes a balance_account/sweeps DELETE call' do
|
@@ -111,19 +92,319 @@ RSpec.describe Adyen::BalancePlatform, service: 'balancePlatform' do
|
|
111
92
|
@shared_values[:client].balance_platform.version
|
112
93
|
)
|
113
94
|
WebMock.stub_request(:delete, url)
|
95
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
96
|
+
.to_return(body: '{}')
|
97
|
+
|
98
|
+
result = @shared_values[:client].balance_platform.balance_accounts_api.delete_sweep('balanceAccountID', 'sweepID')
|
99
|
+
result.response
|
100
|
+
|
101
|
+
expect(result.status).to eq(200)
|
102
|
+
end
|
103
|
+
|
104
|
+
## balancePlatform level transferLimits
|
105
|
+
it 'makes a create_transfer_limit POST call' do
|
106
|
+
request_body = JSON.parse(json_from_file('mocks/requests/BalancePlatform/create_transfer_limit.json'))
|
107
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/create_transfer_limit.json')
|
108
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
109
|
+
|
110
|
+
url = @shared_values[:client].service_url(
|
111
|
+
@shared_values[:service],
|
112
|
+
"balancePlatforms/#{balance_platform_id}/transferLimits",
|
113
|
+
@shared_values[:client].balance_platform.version
|
114
|
+
)
|
115
|
+
WebMock.stub_request(:post, url)
|
114
116
|
.with(
|
115
|
-
|
116
|
-
|
117
|
-
}
|
117
|
+
body: request_body,
|
118
|
+
headers: { 'x-api-key' => @shared_values[:client].api_key }
|
118
119
|
)
|
119
|
-
.to_return(
|
120
|
-
|
120
|
+
.to_return(body: response_body)
|
121
|
+
|
122
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_platform_level_api
|
123
|
+
.create_transfer_limit(request_body, balance_platform_id)
|
124
|
+
response_hash = result.response
|
125
|
+
|
126
|
+
expect(result.status).to eq(200)
|
127
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
128
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
129
|
+
expect(response_hash).to be_a_kind_of Hash
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'makes a get_transfer_limits GET call' do
|
133
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/get_transfer_limits.json')
|
134
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
135
|
+
|
136
|
+
url = @shared_values[:client].service_url(
|
137
|
+
@shared_values[:service],
|
138
|
+
"balancePlatforms/#{balance_platform_id}/transferLimits",
|
139
|
+
@shared_values[:client].balance_platform.version
|
140
|
+
)
|
141
|
+
WebMock.stub_request(:get, url)
|
142
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
143
|
+
.to_return(body: response_body)
|
144
|
+
|
145
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_platform_level_api
|
146
|
+
.get_transfer_limits(balance_platform_id)
|
147
|
+
response_hash = result.response
|
148
|
+
|
149
|
+
expect(result.status).to eq(200)
|
150
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
151
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
152
|
+
expect(response_hash).to be_a_kind_of Hash
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'makes a get_specific_transfer_limit GET call' do
|
156
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/get_specific_transfer_limit.json')
|
157
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
158
|
+
transfer_limit_id = 'YOUR_TRANSFER_LIMIT_ID'
|
159
|
+
|
160
|
+
url = @shared_values[:client].service_url(
|
161
|
+
@shared_values[:service],
|
162
|
+
"balancePlatforms/#{balance_platform_id}/transferLimits/#{transfer_limit_id}",
|
163
|
+
@shared_values[:client].balance_platform.version
|
164
|
+
)
|
165
|
+
WebMock.stub_request(:get, url)
|
166
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
167
|
+
.to_return(body: response_body)
|
168
|
+
|
169
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_platform_level_api
|
170
|
+
.get_specific_transfer_limit(balance_platform_id, transfer_limit_id)
|
171
|
+
response_hash = result.response
|
172
|
+
|
173
|
+
expect(result.status).to eq(200)
|
174
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
175
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
176
|
+
expect(response_hash).to be_a_kind_of Hash
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'makes a delete_pending_transfer_limit DELETE call' do
|
180
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
181
|
+
transfer_limit_id = 'YOUR_TRANSFER_LIMIT_ID'
|
182
|
+
|
183
|
+
url = @shared_values[:client].service_url(
|
184
|
+
@shared_values[:service],
|
185
|
+
"balancePlatforms/#{balance_platform_id}/transferLimits/#{transfer_limit_id}",
|
186
|
+
@shared_values[:client].balance_platform.version
|
187
|
+
)
|
188
|
+
WebMock.stub_request(:delete, url)
|
189
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
190
|
+
.to_return(status: 204, body: '')
|
191
|
+
|
192
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_platform_level_api
|
193
|
+
.delete_pending_transfer_limit(balance_platform_id, transfer_limit_id)
|
194
|
+
|
195
|
+
expect(result.status).to eq(204)
|
196
|
+
end
|
197
|
+
|
198
|
+
## balanceAccount level transferLimits
|
199
|
+
it 'makes a create_transfer_limit POST call' do
|
200
|
+
request_body = JSON.parse(json_from_file('mocks/requests/BalancePlatform/create_transfer_limit.json'))
|
201
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/create_transfer_limit.json')
|
202
|
+
balance_account_id = 'YOUR_BALANCE_ACCOUNT_ID'
|
203
|
+
|
204
|
+
url = @shared_values[:client].service_url(
|
205
|
+
@shared_values[:service],
|
206
|
+
"balanceAccounts/#{balance_account_id}/transferLimits",
|
207
|
+
@shared_values[:client].balance_platform.version
|
208
|
+
)
|
209
|
+
WebMock.stub_request(:post, url)
|
210
|
+
.with(
|
211
|
+
body: request_body,
|
212
|
+
headers: { 'x-api-key' => @shared_values[:client].api_key }
|
121
213
|
)
|
214
|
+
.to_return(body: response_body)
|
122
215
|
|
123
|
-
result = @shared_values[:client].balance_platform.
|
124
|
-
|
216
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_account_level_api
|
217
|
+
.create_transfer_limit(request_body, balance_account_id)
|
218
|
+
response_hash = result.response
|
219
|
+
|
220
|
+
expect(result.status).to eq(200)
|
221
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
222
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
223
|
+
expect(response_hash).to be_a_kind_of Hash
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'makes a get_transfer_limits GET call' do
|
227
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/get_transfer_limits.json')
|
228
|
+
balance_account_id = 'YOUR_BALANCE_ACCOUNT_ID'
|
229
|
+
|
230
|
+
url = @shared_values[:client].service_url(
|
231
|
+
@shared_values[:service],
|
232
|
+
"balanceAccounts/#{balance_account_id}/transferLimits",
|
233
|
+
@shared_values[:client].balance_platform.version
|
234
|
+
)
|
235
|
+
WebMock.stub_request(:get, url)
|
236
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
237
|
+
.to_return(body: response_body)
|
238
|
+
|
239
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_account_level_api
|
240
|
+
.get_transfer_limits(balance_account_id)
|
241
|
+
response_hash = result.response
|
242
|
+
|
243
|
+
expect(result.status).to eq(200)
|
244
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
245
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
246
|
+
expect(response_hash).to be_a_kind_of Hash
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'makes a get_specific_transfer_limit GET call' do
|
250
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/get_specific_transfer_limit.json')
|
251
|
+
balance_account_id = 'YOUR_BALANCE_ACCOUNT_ID'
|
252
|
+
transfer_limit_id = 'YOUR_TRANSFER_LIMIT_ID'
|
253
|
+
|
254
|
+
url = @shared_values[:client].service_url(
|
255
|
+
@shared_values[:service],
|
256
|
+
"balanceAccounts/#{balance_account_id}/transferLimits/#{transfer_limit_id}",
|
257
|
+
@shared_values[:client].balance_platform.version
|
258
|
+
)
|
259
|
+
WebMock.stub_request(:get, url)
|
260
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
261
|
+
.to_return(body: response_body)
|
262
|
+
|
263
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_account_level_api
|
264
|
+
.get_specific_transfer_limit(balance_account_id, transfer_limit_id)
|
265
|
+
response_hash = result.response
|
266
|
+
|
267
|
+
expect(result.status).to eq(200)
|
268
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
269
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
270
|
+
expect(response_hash).to be_a_kind_of Hash
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'makes a delete_pending_transfer_limit DELETE call' do
|
274
|
+
balance_account_id = 'YOUR_BALANCE_ACCOUNT_ID'
|
275
|
+
transfer_limit_id = 'YOUR_TRANSFER_LIMIT_ID'
|
276
|
+
|
277
|
+
url = @shared_values[:client].service_url(
|
278
|
+
@shared_values[:service],
|
279
|
+
"balanceAccounts/#{balance_account_id}/transferLimits/#{transfer_limit_id}",
|
280
|
+
@shared_values[:client].balance_platform.version
|
281
|
+
)
|
282
|
+
WebMock.stub_request(:delete, url)
|
283
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
284
|
+
.to_return(status: 204, body: '')
|
285
|
+
|
286
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_account_level_api
|
287
|
+
.delete_pending_transfer_limit(balance_account_id, transfer_limit_id)
|
288
|
+
|
289
|
+
expect(result.status).to eq(204)
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'makes an approve_pending_transfer_limits POST call' do
|
293
|
+
request_body = ['TRLI00000000000000000000000001', 'TRLI00000000000000000000000002']
|
294
|
+
balance_account_id = 'YOUR_BALANCE_ACCOUNT_ID'
|
295
|
+
|
296
|
+
url = @shared_values[:client].service_url(
|
297
|
+
@shared_values[:service],
|
298
|
+
"balanceAccounts/#{balance_account_id}/transferLimits/approve",
|
299
|
+
@shared_values[:client].balance_platform.version
|
300
|
+
)
|
301
|
+
WebMock.stub_request(:post, url)
|
302
|
+
.with(
|
303
|
+
body: request_body,
|
304
|
+
headers: { 'x-api-key' => @shared_values[:client].api_key }
|
305
|
+
)
|
306
|
+
.to_return(status: 204, body: '')
|
307
|
+
|
308
|
+
result = @shared_values[:client].balance_platform.transfer_limits_balance_account_level_api
|
309
|
+
.approve_pending_transfer_limits(request_body, balance_account_id)
|
310
|
+
|
311
|
+
expect(result.status).to eq(204)
|
312
|
+
end
|
313
|
+
|
314
|
+
## webhook settings
|
315
|
+
it 'makes a create_webhook_setting POST call' do
|
316
|
+
request_body = JSON.parse(json_from_file('mocks/requests/BalancePlatform/create_webhook_setting.json'))
|
317
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/create_webhook_setting.json')
|
318
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
319
|
+
webhook_id = 'YOUR_WEBHOOK_ID'
|
320
|
+
|
321
|
+
url = @shared_values[:client].service_url(
|
322
|
+
@shared_values[:service],
|
323
|
+
"balancePlatforms/#{balance_platform_id}/webhooks/#{webhook_id}/settings",
|
324
|
+
@shared_values[:client].balance_platform.version
|
325
|
+
)
|
326
|
+
WebMock.stub_request(:post, url)
|
327
|
+
.with(
|
328
|
+
body: request_body,
|
329
|
+
headers: { 'x-api-key' => @shared_values[:client].api_key }
|
330
|
+
)
|
331
|
+
.to_return(body: response_body)
|
332
|
+
|
333
|
+
result = @shared_values[:client].balance_platform.balances_api
|
334
|
+
.create_webhook_setting(request_body, balance_platform_id, webhook_id)
|
335
|
+
response_hash = result.response
|
336
|
+
|
337
|
+
expect(result.status).to eq(200)
|
338
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
339
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
340
|
+
expect(response_hash).to be_a_kind_of Hash
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'makes a delete_webhook_setting DELETE call' do
|
344
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
345
|
+
webhook_id = 'YOUR_WEBHOOK_ID'
|
346
|
+
setting_id = 'BWHS000000000000001'
|
347
|
+
|
348
|
+
url = @shared_values[:client].service_url(
|
349
|
+
@shared_values[:service],
|
350
|
+
"balancePlatforms/#{balance_platform_id}/webhooks/#{webhook_id}/settings/#{setting_id}",
|
351
|
+
@shared_values[:client].balance_platform.version
|
352
|
+
)
|
353
|
+
WebMock.stub_request(:delete, url)
|
354
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
355
|
+
.to_return(status: 204, body: '')
|
356
|
+
|
357
|
+
result = @shared_values[:client].balance_platform.balances_api
|
358
|
+
.delete_webhook_setting(balance_platform_id, webhook_id, setting_id)
|
359
|
+
|
360
|
+
expect(result.status).to eq(204)
|
361
|
+
end
|
362
|
+
|
363
|
+
it 'makes a get_all_webhook_settings GET call' do
|
364
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/get_all_webhook_settings.json')
|
365
|
+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
|
366
|
+
webhook_id = 'YOUR_WEBHOOK_ID'
|
367
|
+
|
368
|
+
url = @shared_values[:client].service_url(
|
369
|
+
@shared_values[:service],
|
370
|
+
"balancePlatforms/#{balance_platform_id}/webhooks/#{webhook_id}/settings",
|
371
|
+
@shared_values[:client].balance_platform.version
|
372
|
+
)
|
373
|
+
WebMock.stub_request(:get, url)
|
374
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
375
|
+
.to_return(body: response_body)
|
376
|
+
|
377
|
+
result = @shared_values[:client].balance_platform.balances_api
|
378
|
+
.get_all_webhook_settings(balance_platform_id, webhook_id)
|
379
|
+
response_hash = result.response
|
380
|
+
|
381
|
+
expect(result.status).to eq(200)
|
382
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
383
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
384
|
+
expect(response_hash).to be_a_kind_of Hash
|
385
|
+
end
|
386
|
+
|
387
|
+
## authorisedCardUsers
|
388
|
+
it 'makes a get_all_authorised_card_users GET call' do
|
389
|
+
response_body = json_from_file('mocks/responses/BalancePlatform/get_all_authorised_card_users.json')
|
390
|
+
payment_instrument_id = 'PI01234567890'
|
391
|
+
|
392
|
+
url = @shared_values[:client].service_url(
|
393
|
+
@shared_values[:service],
|
394
|
+
"paymentInstruments/#{payment_instrument_id}/authorisedCardUsers",
|
395
|
+
@shared_values[:client].balance_platform.version
|
396
|
+
)
|
397
|
+
WebMock.stub_request(:get, url)
|
398
|
+
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
|
399
|
+
.to_return(body: response_body)
|
400
|
+
|
401
|
+
result = @shared_values[:client].balance_platform.authorized_card_users_api
|
402
|
+
.get_all_authorised_card_users(payment_instrument_id)
|
403
|
+
response_hash = result.response
|
125
404
|
|
126
|
-
expect(result.status)
|
127
|
-
|
405
|
+
expect(result.status).to eq(200)
|
406
|
+
expect(response_hash).to eq(JSON.parse(response_body))
|
407
|
+
expect(response_hash).to be_a Adyen::HashWithAccessors
|
408
|
+
expect(response_hash).to be_a_kind_of Hash
|
128
409
|
end
|
129
410
|
end
|
data/spec/bin_lookup_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
-
RSpec.describe Adyen::BinLookup, service: '
|
4
|
+
RSpec.describe Adyen::BinLookup, service: 'binLookup' do
|
5
5
|
before(:all) do
|
6
6
|
@shared_values = {
|
7
7
|
client: create_client(:api_key),
|
@@ -28,7 +28,7 @@ RSpec.describe Adyen::BinLookup, service: 'BinLookup' do
|
|
28
28
|
body: response_body
|
29
29
|
)
|
30
30
|
|
31
|
-
result = @shared_values[:client].bin_lookup.get_cost_estimate(request_body)
|
31
|
+
result = @shared_values[:client].bin_lookup.bin_lookup_api.get_cost_estimate(request_body)
|
32
32
|
response_hash = result.response
|
33
33
|
|
34
34
|
expect(result.status)
|
@@ -58,7 +58,8 @@ RSpec.describe Adyen::BinLookup, service: 'BinLookup' do
|
|
58
58
|
body: response_body
|
59
59
|
)
|
60
60
|
|
61
|
-
result = @shared_values[:client].bin_lookup.get3ds_availability(request_body)
|
61
|
+
result = @shared_values[:client].bin_lookup.bin_lookup_api.get3ds_availability(request_body)
|
62
|
+
|
62
63
|
response_hash = result.response
|
63
64
|
|
64
65
|
expect(result.status)
|
data/spec/client_spec.rb
CHANGED
@@ -25,10 +25,10 @@ RSpec.describe Adyen do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'fails payments call without WS user and password' do
|
28
|
-
expect { @shared_values[:client].payment.authorise('{}') }
|
28
|
+
expect { @shared_values[:client].payment.payments_api.authorise('{}') }
|
29
29
|
.to raise_error(Adyen::AuthenticationError)
|
30
30
|
@shared_values[:client].ws_user = @shared_values[:ws_user]
|
31
|
-
expect { @shared_values[:client].payment.authorise('{}') }
|
31
|
+
expect { @shared_values[:client].payment.payments_api.authorise('{}') }
|
32
32
|
.to raise_error(Adyen::AuthenticationError)
|
33
33
|
end
|
34
34
|
|
@@ -302,4 +302,103 @@ RSpec.describe Adyen do
|
|
302
302
|
expect(client.service_url_base('Disputes'))
|
303
303
|
.to eq('https://ca-test.adyen.com/ca/services/DisputesService')
|
304
304
|
end
|
305
|
+
|
306
|
+
it 'raises FormatError on 400 response and checks content' do
|
307
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
308
|
+
mock_faraday_connection = double(Faraday::Connection)
|
309
|
+
error_body = {
|
310
|
+
status: 400,
|
311
|
+
errorCode: "702",
|
312
|
+
message: "Structure of CreateCheckoutSessionRequest contains the following unknown fields: [paymentMethod]",
|
313
|
+
errorType: "validation"
|
314
|
+
}
|
315
|
+
mock_response = Faraday::Response.new(status: 400, body: error_body)
|
316
|
+
|
317
|
+
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
318
|
+
allow(mock_faraday_connection).to receive_message_chain(:headers, :[]=)
|
319
|
+
allow(mock_faraday_connection).to receive(:post).and_return(mock_response)
|
320
|
+
|
321
|
+
expect {
|
322
|
+
client.checkout.payments_api.payments({})
|
323
|
+
}.to raise_error(Adyen::FormatError) do |error|
|
324
|
+
expect(error.code).to eq(400)
|
325
|
+
expect(error.msg).to eq('Structure of CreateCheckoutSessionRequest contains the following unknown fields: [paymentMethod] ErrorCode: 702')
|
326
|
+
expect(error.response[:errorCode]).to eq('702')
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'raises ValidationError on 422 response with RestServiceError (based on RFC 7807)' do
|
331
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
332
|
+
mock_faraday_connection = double(Faraday::Connection)
|
333
|
+
error_body = {
|
334
|
+
type: "https://docs.adyen.com/errors/validation",
|
335
|
+
title: "The request is missing required fields or contains invalid data.",
|
336
|
+
status: 422,
|
337
|
+
detail: "It is mandatory to specify a legalEntityId when creating a new account holder.",
|
338
|
+
invalidFields: [{ "name" => "legalEntityId", "message" => "legalEntityId is not provided" }],
|
339
|
+
errorCode: "30_011"
|
340
|
+
}
|
341
|
+
mock_response = Faraday::Response.new(status: 422, body: error_body)
|
342
|
+
|
343
|
+
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
344
|
+
allow(mock_faraday_connection).to receive_message_chain(:headers, :[]=)
|
345
|
+
allow(mock_faraday_connection).to receive(:post).and_return(mock_response)
|
346
|
+
|
347
|
+
expect {
|
348
|
+
client.checkout.payments_api.payments({})
|
349
|
+
}.to raise_error(Adyen::ValidationError) do |error|
|
350
|
+
expect(error.code).to eq(422)
|
351
|
+
expect(error.msg).to eq('It is mandatory to specify a legalEntityId when creating a new account holder. ErrorCode: 30_011')
|
352
|
+
expect(error.response[:errorCode]).to eq('30_011')
|
353
|
+
expect(error.response[:invalidFields]).to have_attributes(size: 1)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
it 'raises ValidationError on 422 response with ServiceError (legacy)' do
|
358
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
359
|
+
mock_faraday_connection = double(Faraday::Connection)
|
360
|
+
error_body = {
|
361
|
+
status: 422,
|
362
|
+
errorCode: "14_030",
|
363
|
+
message: "Return URL is missing.",
|
364
|
+
errorType: "validation",
|
365
|
+
pspReference: "8816118280275544"
|
366
|
+
}
|
367
|
+
mock_response = Faraday::Response.new(status: 422, body: error_body)
|
368
|
+
|
369
|
+
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
370
|
+
allow(mock_faraday_connection).to receive_message_chain(:headers, :[]=)
|
371
|
+
allow(mock_faraday_connection).to receive(:post).and_return(mock_response)
|
372
|
+
|
373
|
+
expect {
|
374
|
+
client.checkout.payments_api.payments({})
|
375
|
+
}.to raise_error(Adyen::ValidationError) do |error|
|
376
|
+
expect(error.code).to eq(422)
|
377
|
+
expect(error.msg).to eq('Return URL is missing. ErrorCode: 14_030')
|
378
|
+
expect(error.response[:errorCode]).to eq('14_030')
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
it 'raises ServerError on 500 response and checks content' do
|
383
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
384
|
+
mock_faraday_connection = double(Faraday::Connection)
|
385
|
+
error_body = {
|
386
|
+
status: 500,
|
387
|
+
errorCode: "999",
|
388
|
+
message: "Unexpected error.",
|
389
|
+
errorType: "server error"
|
390
|
+
}
|
391
|
+
mock_response = Faraday::Response.new(status: 500, body: error_body)
|
392
|
+
|
393
|
+
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
394
|
+
allow(mock_faraday_connection).to receive_message_chain(:headers, :[]=)
|
395
|
+
allow(mock_faraday_connection).to receive(:post).and_return(mock_response)
|
396
|
+
|
397
|
+
expect {
|
398
|
+
client.checkout.payments_api.payments({})
|
399
|
+
}.to raise_error(Adyen::ServerError) do |error|
|
400
|
+
expect(error.code).to eq(500)
|
401
|
+
expect(error.msg).to eq('Unexpected error. ErrorCode: 999')
|
402
|
+
end
|
403
|
+
end
|
305
404
|
end
|
@@ -10,5 +10,5 @@ RSpec.describe Adyen::DataProtection, service: 'Data Protection Service' do
|
|
10
10
|
%w[request_subject_erasure result SUCCESS]
|
11
11
|
]
|
12
12
|
|
13
|
-
generate_tests(client, 'DataProtectionService', test_sets, client.data_protection)
|
13
|
+
generate_tests(client, 'DataProtectionService', test_sets, client.data_protection.data_protection_api)
|
14
14
|
end
|
data/spec/disputes_spec.rb
CHANGED
@@ -28,7 +28,8 @@ RSpec.describe Adyen::Disputes, service: 'disputes service' do
|
|
28
28
|
body: response_body
|
29
29
|
)
|
30
30
|
|
31
|
-
result = @shared_values[:client].disputes.retrieve_applicable_defense_reasons(request_body)
|
31
|
+
result = @shared_values[:client].disputes.disputes_api.retrieve_applicable_defense_reasons(request_body)
|
32
|
+
|
32
33
|
response_hash = result.response
|
33
34
|
|
34
35
|
expect(result.status)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"amount": {
|
3
|
+
"currency": "EUR",
|
4
|
+
"value": 10000
|
5
|
+
},
|
6
|
+
"reference": "Your reference for the transfer limit",
|
7
|
+
"scaInformation": {
|
8
|
+
"scaOnApproval": true
|
9
|
+
},
|
10
|
+
"scope": "perTransaction",
|
11
|
+
"startsAt": "2025-08-15T06:36:20+01:00",
|
12
|
+
"endsAt": "2026-08-14T00:00:00+01:00",
|
13
|
+
"transferType": "all"
|
14
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"type": "balance",
|
3
|
+
"target": {
|
4
|
+
"type": "balanceAccount",
|
5
|
+
"id": "BA00000000000000000LIABLE"
|
6
|
+
},
|
7
|
+
"currency": "USD",
|
8
|
+
"status": "active",
|
9
|
+
"conditions": [
|
10
|
+
{
|
11
|
+
"balanceType": "available",
|
12
|
+
"conditionType": "lessThan",
|
13
|
+
"value": 500000
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|