adyen-ruby-api-library 11.1.0 → 11.3.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 +4 -4
- data/.github/workflows/label_new_issues.yml +1 -1
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/ruby.yml +11 -3
- data/.github/workflows/rubygems_release.yml +2 -2
- data/.github/workflows/stale.yml +1 -1
- data/AGENTS.md +73 -0
- data/README.md +3 -0
- data/VERSION +1 -1
- data/lib/adyen/client.rb +18 -8
- data/lib/adyen/services/balanceControl/balance_control_api.rb +1 -3
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +14 -18
- data/lib/adyen/services/balancePlatform/authorized_card_users_api.rb +4 -12
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +10 -30
- data/lib/adyen/services/balancePlatform/balances_api.rb +5 -15
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +1 -3
- data/lib/adyen/services/balancePlatform/card_orders_api.rb +2 -6
- data/lib/adyen/services/balancePlatform/direct_debit_mandates_api.rb +48 -0
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +1 -3
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +2 -6
- data/lib/adyen/services/balancePlatform/manage_card_pin_api.rb +3 -9
- data/lib/adyen/services/balancePlatform/manage_sca_devices_api.rb +6 -18
- data/lib/adyen/services/balancePlatform/network_tokens_api.rb +2 -6
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +3 -9
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +9 -27
- data/lib/adyen/services/balancePlatform/platform_api.rb +3 -9
- data/lib/adyen/services/balancePlatform/sca_association_management_api.rb +40 -0
- data/lib/adyen/services/balancePlatform/sca_device_management_api.rb +40 -0
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +4 -12
- data/lib/adyen/services/balancePlatform/transfer_limits_balance_account_level_api.rb +6 -18
- data/lib/adyen/services/balancePlatform/transfer_limits_balance_platform_level_api.rb +4 -12
- data/lib/adyen/services/balancePlatform/transfer_routes_api.rb +1 -3
- data/lib/adyen/services/balancePlatform.rb +15 -0
- data/lib/adyen/services/binLookup/bin_lookup_api.rb +2 -6
- data/lib/adyen/services/capital/dynamic_offers_api.rb +40 -0
- data/lib/adyen/services/capital/grant_accounts_api.rb +24 -0
- data/lib/adyen/services/capital/grant_offers_api.rb +32 -0
- data/lib/adyen/services/capital/grants_api.rb +64 -0
- data/lib/adyen/services/capital.rb +39 -0
- data/lib/adyen/services/checkout/donations_api.rb +2 -6
- data/lib/adyen/services/checkout/modifications_api.rb +6 -18
- data/lib/adyen/services/checkout/orders_api.rb +3 -9
- data/lib/adyen/services/checkout/payment_links_api.rb +3 -9
- data/lib/adyen/services/checkout/payments_api.rb +6 -18
- data/lib/adyen/services/checkout/recurring_api.rb +11 -9
- data/lib/adyen/services/checkout/utility_api.rb +4 -12
- data/lib/adyen/services/dataProtection/data_protection_api.rb +1 -3
- data/lib/adyen/services/disputes/disputes_api.rb +5 -15
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +4 -12
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +4 -12
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +3 -9
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +7 -21
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +5 -15
- data/lib/adyen/services/legalEntityManagement/tax_e_delivery_consent_api.rb +2 -6
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +5 -15
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +4 -12
- data/lib/adyen/services/management/account_company_level_api.rb +3 -9
- data/lib/adyen/services/management/account_merchant_level_api.rb +4 -12
- data/lib/adyen/services/management/account_store_level_api.rb +8 -24
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +4 -12
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +4 -12
- data/lib/adyen/services/management/android_files_company_level_api.rb +6 -18
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +4 -12
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +4 -12
- data/lib/adyen/services/management/api_key_company_level_api.rb +1 -3
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +1 -3
- data/lib/adyen/services/management/client_key_company_level_api.rb +1 -3
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +1 -3
- data/lib/adyen/services/management/my_api_credential_api.rb +6 -18
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +6 -18
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +5 -15
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +9 -27
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +2 -6
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +1 -3
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +10 -30
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +10 -30
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +4 -12
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +4 -12
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +8 -24
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +4 -12
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +2 -6
- data/lib/adyen/services/management/users_company_level_api.rb +4 -12
- data/lib/adyen/services/management/users_merchant_level_api.rb +4 -12
- data/lib/adyen/services/management/webhooks_company_level_api.rb +7 -21
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +7 -21
- data/lib/adyen/services/payment/modifications_api.rb +8 -24
- data/lib/adyen/services/payment/payments_api.rb +5 -15
- data/lib/adyen/services/paymentsApp/payments_app_api.rb +5 -15
- data/lib/adyen/services/payout/initialization_api.rb +3 -9
- data/lib/adyen/services/payout/instant_payouts_api.rb +1 -3
- data/lib/adyen/services/payout/reviewing_api.rb +2 -6
- data/lib/adyen/services/posMobile/pos_mobile_api.rb +1 -3
- data/lib/adyen/services/recurring/recurring_api.rb +7 -19
- data/lib/adyen/services/recurring.rb +1 -1
- data/lib/adyen/services/service.rb +10 -2
- data/lib/adyen/services/sessionAuthentication/session_authentication_api.rb +1 -3
- data/lib/adyen/services/storedValue/stored_value_api.rb +6 -18
- data/lib/adyen/services/transfers/capital_api.rb +3 -9
- data/lib/adyen/services/transfers/transactions_api.rb +2 -6
- data/lib/adyen/services/transfers/transfers_api.rb +6 -18
- data/lib/adyen/utils/hmac_validator.rb +0 -1
- data/lib/adyen/version.rb +1 -1
- data/lib/adyen-ruby-api-library.rb +1 -0
- data/sdk-generation-log/balancecontrol.json +8 -0
- data/sdk-generation-log/balanceplatform.json +8 -0
- data/sdk-generation-log/binlookup.json +8 -0
- data/sdk-generation-log/capital.json +8 -0
- data/sdk-generation-log/checkout.json +8 -0
- data/sdk-generation-log/dataprotection.json +8 -0
- data/sdk-generation-log/disputes.json +8 -0
- data/sdk-generation-log/legalentitymanagement.json +8 -0
- data/sdk-generation-log/management.json +8 -0
- data/sdk-generation-log/payment.json +8 -0
- data/sdk-generation-log/paymentsapp.json +8 -0
- data/sdk-generation-log/payout.json +8 -0
- data/sdk-generation-log/posmobile.json +8 -0
- data/sdk-generation-log/recurring.json +8 -0
- data/sdk-generation-log/sessionauthentication.json +8 -0
- data/sdk-generation-log/storedvalue.json +8 -0
- data/sdk-generation-log/transfers.json +8 -0
- data/spec/balance_platform_spec.rb +111 -0
- data/spec/capital_spec.rb +268 -0
- data/spec/client_spec.rb +206 -68
- data/spec/mocks/requests/BalancePlatform/update_mandate.json +14 -0
- data/spec/mocks/responses/BalancePlatform/get_list_of_mandates.json +19 -0
- data/spec/mocks/responses/BalancePlatform/get_mandate_by_id.json +14 -0
- data/spec/mocks/responses/BalancePlatform/get_tax_form_summary.json +17 -0
- data/spec/mocks/responses/Capital/calculate-preliminary-offer-from-dynamic-offer.json +16 -0
- data/spec/mocks/responses/Capital/create-static-offer-from-dynamic-offer.json +9 -0
- data/spec/mocks/responses/Capital/get-all-dynamic-offers.json +18 -0
- data/spec/mocks/responses/Capital/get-grant-account-success.json +20 -0
- data/spec/mocks/responses/Capital/get-grant-disbursement-success.json +26 -0
- data/spec/mocks/responses/Capital/get-grant-disbursements-success.json +30 -0
- data/spec/mocks/responses/Capital/get-grant-offer-success.json +31 -0
- data/spec/mocks/responses/Capital/get-grant-success.json +22 -0
- data/spec/mocks/responses/Capital/grant-offers-success.json +19 -0
- data/spec/mocks/responses/Capital/grants-success.json +26 -0
- data/spec/mocks/responses/Capital/request-grant.json +31 -0
- data/spec/mocks/responses/Capital/update-grant-disbursement-success.json +26 -0
- data/spec/service_spec.rb +40 -0
- data/templates/api-small.mustache +1 -3
- data/templates/api.mustache +1 -3
- metadata +44 -1
data/spec/client_spec.rb
CHANGED
|
@@ -18,6 +18,28 @@ RSpec.describe Adyen do
|
|
|
18
18
|
.to eq(:test)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
it 'raises ArgumentError when initialized with an invalid env string' do
|
|
22
|
+
expect { Adyen::Client.new(env: 'live') }
|
|
23
|
+
.to raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'raises ArgumentError when initialized with an invalid env value' do
|
|
27
|
+
expect { Adyen::Client.new(env: :invalid) }
|
|
28
|
+
.to raise_error(ArgumentError)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'strips https:// from live_url_prefix when passed via constructor' do
|
|
32
|
+
client = Adyen::Client.new(env: :live, live_url_prefix: 'https://myprefix')
|
|
33
|
+
expect(client.service_url_base('Payment'))
|
|
34
|
+
.to eq('https://myprefix-pal-live.adyenpayments.com/pal/servlet/Payment')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'does not mutate the original live_url_prefix string' do
|
|
38
|
+
prefix = 'https://myprefix'
|
|
39
|
+
Adyen::Client.new(env: :live, live_url_prefix: prefix)
|
|
40
|
+
expect(prefix).to eq('https://myprefix')
|
|
41
|
+
end
|
|
42
|
+
|
|
21
43
|
it 'sets the version number' do
|
|
22
44
|
@shared_values[:client].checkout.version = @shared_values[:version]
|
|
23
45
|
expect(@shared_values[:client].checkout.version)
|
|
@@ -32,8 +54,8 @@ RSpec.describe Adyen do
|
|
|
32
54
|
.to raise_error(Adyen::AuthenticationError)
|
|
33
55
|
end
|
|
34
56
|
|
|
35
|
-
it
|
|
36
|
-
expect{ @shared_values[:client].checkout.payments_api.payment_methods(
|
|
57
|
+
it 'fails a checkout call without oauth token' do
|
|
58
|
+
expect { @shared_values[:client].checkout.payments_api.payment_methods('{}') }.
|
|
37
59
|
to raise_error(Adyen::AuthenticationError)
|
|
38
60
|
end
|
|
39
61
|
|
|
@@ -43,6 +65,40 @@ RSpec.describe Adyen do
|
|
|
43
65
|
@shared_values[:client].api_key = 'api_key'
|
|
44
66
|
end
|
|
45
67
|
|
|
68
|
+
describe 'service name resolution' do
|
|
69
|
+
let(:client) { Adyen::Client.new(env: :mock, mock_service_url_base: 'https://mock.test') }
|
|
70
|
+
|
|
71
|
+
it 'is Checkout service when using checkout.payments_api' do
|
|
72
|
+
expect(client.checkout.payments_api.service)
|
|
73
|
+
.to eq('Checkout')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'is Checkout service when using checkout.recurring_api' do
|
|
77
|
+
expect(client.checkout.recurring_api.service)
|
|
78
|
+
.to eq('Checkout')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'is Recurring service when using recurring.recurring_api' do
|
|
82
|
+
expect(client.recurring.recurring_api.service)
|
|
83
|
+
.to eq('Recurring')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'is Payment service when using payment.payments_api' do
|
|
87
|
+
expect(client.payment.payments_api.service)
|
|
88
|
+
.to eq('Payment')
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'is Payment service when using payment.modifications_api' do
|
|
92
|
+
expect(client.payment.modifications_api.service)
|
|
93
|
+
.to eq('Payment')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'is Payout service when using payout.instant_payouts_api' do
|
|
97
|
+
expect(client.payout.instant_payouts_api.service)
|
|
98
|
+
.to eq('Payout')
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
46
102
|
it 'uses the specified mock service URL' do
|
|
47
103
|
client = Adyen::Client.new(env: :mock, mock_service_url_base: 'https://mock.test')
|
|
48
104
|
expect(client.service_url_base('Account'))
|
|
@@ -115,11 +171,11 @@ RSpec.describe Adyen do
|
|
|
115
171
|
|
|
116
172
|
# test with Ruby 3.2+ only (where Faraday requestOptions timeout is supported)
|
|
117
173
|
it 'initiates a Faraday connection with the provided options' do
|
|
118
|
-
skip
|
|
174
|
+
skip 'Only runs on Ruby >= 3.2' unless RUBY_VERSION >= '3.2'
|
|
119
175
|
connection_options = Faraday::ConnectionOptions.new(
|
|
120
176
|
request: {
|
|
121
|
-
open_timeout: 5,
|
|
122
|
-
timeout: 10
|
|
177
|
+
open_timeout: 5,
|
|
178
|
+
timeout: 10
|
|
123
179
|
}
|
|
124
180
|
)
|
|
125
181
|
expect(Faraday::ConnectionOptions).not_to receive(:new)
|
|
@@ -142,63 +198,63 @@ RSpec.describe Adyen do
|
|
|
142
198
|
|
|
143
199
|
# test with Ruby 3.2+ only (where Faraday requestOptions timeout is supported)
|
|
144
200
|
it 'initiates a Faraday connection with the expected default timeouts' do
|
|
145
|
-
skip
|
|
201
|
+
skip 'Only runs on Ruby >= 3.2' unless RUBY_VERSION >= '3.2'
|
|
146
202
|
client = Adyen::Client.new(env: :test)
|
|
147
203
|
expect(client.connection_options[:request][:open_timeout]).to eq(30)
|
|
148
204
|
expect(client.connection_options[:request][:timeout]).to eq(60)
|
|
149
205
|
end
|
|
150
206
|
|
|
151
|
-
it
|
|
152
|
-
client = Adyen::Client.new(api_key:
|
|
153
|
-
expect(client.service_url(
|
|
154
|
-
|
|
207
|
+
it 'checks the creation of checkout url' do
|
|
208
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
209
|
+
expect(client.service_url('Checkout', 'paymentMethods', '71')).
|
|
210
|
+
to eq('https://checkout-test.adyen.com/v71/paymentMethods')
|
|
155
211
|
end
|
|
156
212
|
|
|
157
|
-
it
|
|
158
|
-
client = Adyen::Client.new(api_key:
|
|
159
|
-
expect(client.service_url(
|
|
160
|
-
|
|
213
|
+
it 'checks the creation of checkout url' do
|
|
214
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :live, live_url_prefix: 'YourLiveUrlPrefix')
|
|
215
|
+
expect(client.service_url('Checkout', 'paymentMethods', '71')).
|
|
216
|
+
to eq('https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/checkout/v71/paymentMethods')
|
|
161
217
|
end
|
|
162
|
-
it
|
|
163
|
-
client = Adyen::Client.new(api_key:
|
|
164
|
-
expect(client.service_url(
|
|
165
|
-
|
|
218
|
+
it 'checks the creation of lem url' do
|
|
219
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :live)
|
|
220
|
+
expect(client.service_url('LegalEntityManagement', 'businessLines', '3')).
|
|
221
|
+
to eq('https://kyc-live.adyen.com/lem/v3/businessLines')
|
|
166
222
|
end
|
|
167
223
|
|
|
168
|
-
it
|
|
169
|
-
client = Adyen::Client.new(api_key:
|
|
170
|
-
expect(client.service_url(
|
|
171
|
-
|
|
224
|
+
it 'checks the creation of balancePlatform url' do
|
|
225
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :live)
|
|
226
|
+
expect(client.service_url('BalancePlatform', 'legalEntities', '1')).
|
|
227
|
+
to eq('https://balanceplatform-api-live.adyen.com/bcl/v1/legalEntities')
|
|
172
228
|
end
|
|
173
229
|
|
|
174
|
-
it
|
|
175
|
-
client = Adyen::Client.new(api_key:
|
|
176
|
-
expect(client.service_url(
|
|
177
|
-
|
|
230
|
+
it 'checks the creation of balancePlatform url' do
|
|
231
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
232
|
+
expect(client.service_url('BalancePlatform', 'legalEntities', '1')).
|
|
233
|
+
to eq('https://balanceplatform-api-test.adyen.com/bcl/v1/legalEntities')
|
|
178
234
|
end
|
|
179
235
|
|
|
180
|
-
it
|
|
181
|
-
client = Adyen::Client.new(api_key:
|
|
182
|
-
expect(client.service_url(
|
|
183
|
-
|
|
236
|
+
it 'checks the creation of transfers url' do
|
|
237
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
238
|
+
expect(client.service_url('Transfers', 'transactions', '1')).
|
|
239
|
+
to eq('https://balanceplatform-api-test.adyen.com/btl/v1/transactions')
|
|
184
240
|
end
|
|
185
241
|
|
|
186
|
-
it
|
|
187
|
-
client = Adyen::Client.new(api_key:
|
|
188
|
-
expect(client.service_url(
|
|
189
|
-
|
|
242
|
+
it 'checks the creation of management url' do
|
|
243
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
244
|
+
expect(client.service_url('Management', 'companies', '1')).
|
|
245
|
+
to eq('https://management-test.adyen.com/v1/companies')
|
|
190
246
|
end
|
|
191
247
|
|
|
192
|
-
it
|
|
193
|
-
client = Adyen::Client.new(api_key:
|
|
194
|
-
expect(client.service_url(
|
|
195
|
-
|
|
248
|
+
it 'checks the creation of binLookup url' do
|
|
249
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
250
|
+
expect(client.service_url('BinLookup', 'getCostEstimate', '54')).
|
|
251
|
+
to eq('https://pal-test.adyen.com/pal/servlet/BinLookup/v54/getCostEstimate')
|
|
196
252
|
end
|
|
197
253
|
|
|
198
|
-
it
|
|
199
|
-
client = Adyen::Client.new(api_key:
|
|
200
|
-
expect(client.service_url(
|
|
201
|
-
|
|
254
|
+
it 'check the creation of storedValue url' do
|
|
255
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
256
|
+
expect(client.service_url('StoredValue', 'issue', '46')).
|
|
257
|
+
to eq('https://pal-test.adyen.com/pal/servlet/StoredValue/v46/issue')
|
|
202
258
|
end
|
|
203
259
|
|
|
204
260
|
it 'checks the creation of checkout url' do
|
|
@@ -206,6 +262,7 @@ RSpec.describe Adyen do
|
|
|
206
262
|
expect(client.service_url('Checkout', 'paymentMethods', '70'))
|
|
207
263
|
.to eq('https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods')
|
|
208
264
|
end
|
|
265
|
+
|
|
209
266
|
it 'checks the creation of lem url' do
|
|
210
267
|
client = Adyen::Client.new(api_key: 'api_key', env: :live)
|
|
211
268
|
expect(client.service_url('LegalEntityManagement', 'businessLines', '3'))
|
|
@@ -276,19 +333,18 @@ RSpec.describe Adyen do
|
|
|
276
333
|
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
277
334
|
expect(client.service_url('TerminalCloudAPI', 'connectedTerminals', nil))
|
|
278
335
|
.to eq('https://terminal-api-test.adyen.com/connectedTerminals')
|
|
279
|
-
|
|
280
336
|
end
|
|
281
|
-
|
|
337
|
+
|
|
282
338
|
it 'checks the initialization of the terminal region' do
|
|
283
339
|
client = Adyen::Client.new(api_key: 'api_key', env: :test, terminal_region: 'eu')
|
|
284
340
|
expect(client.service_url('TerminalCloudAPI', 'connectedTerminals', nil))
|
|
285
|
-
|
|
341
|
+
.to eq('https://terminal-api-test-eu.adyen.com/connectedTerminals')
|
|
286
342
|
end
|
|
287
343
|
|
|
288
344
|
it 'checks the initialization of the terminal region set to nil per default' do
|
|
289
345
|
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
290
346
|
expect(client.service_url('TerminalCloudAPI', 'connectedTerminals', nil))
|
|
291
|
-
|
|
347
|
+
.to eq('https://terminal-api-test.adyen.com/connectedTerminals')
|
|
292
348
|
end
|
|
293
349
|
|
|
294
350
|
it 'checks the creation of PosMobile sessions url' do
|
|
@@ -301,13 +357,13 @@ RSpec.describe Adyen do
|
|
|
301
357
|
client = Adyen::Client.new(env: :test)
|
|
302
358
|
expect(client.service_url_base('Disputes'))
|
|
303
359
|
.to eq('https://ca-test.adyen.com/ca/services/DisputeService')
|
|
304
|
-
end
|
|
360
|
+
end
|
|
305
361
|
|
|
306
362
|
it 'checks the creation of DataProtection url' do
|
|
307
363
|
client = Adyen::Client.new(env: :test)
|
|
308
364
|
expect(client.service_url_base('DataProtection'))
|
|
309
365
|
.to eq('https://ca-test.adyen.com/ca/services/DataProtectionService')
|
|
310
|
-
end
|
|
366
|
+
end
|
|
311
367
|
|
|
312
368
|
it 'checks the creation of SessionAuthentication url for the test env' do
|
|
313
369
|
client = Adyen::Client.new(env: :test)
|
|
@@ -321,14 +377,21 @@ RSpec.describe Adyen do
|
|
|
321
377
|
.to eq('https://authe-live.adyen.com/authe/api')
|
|
322
378
|
end
|
|
323
379
|
|
|
380
|
+
it 'checks the creation of Recurring API url for the test env' do
|
|
381
|
+
client = Adyen::Client.new(env: :test)
|
|
382
|
+
expect(client.service_url_base('Recurring'))
|
|
383
|
+
.to eq('https://pal-test.adyen.com/pal/servlet/Recurring')
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
|
|
324
387
|
it 'raises FormatError on 400 response and checks content' do
|
|
325
388
|
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
326
389
|
mock_faraday_connection = double(Faraday::Connection)
|
|
327
390
|
error_body = {
|
|
328
391
|
status: 400,
|
|
329
|
-
errorCode:
|
|
330
|
-
message:
|
|
331
|
-
errorType:
|
|
392
|
+
errorCode: '702',
|
|
393
|
+
message: 'Structure of CreateCheckoutSessionRequest contains the following unknown fields: [paymentMethod]',
|
|
394
|
+
errorType: 'validation'
|
|
332
395
|
}
|
|
333
396
|
mock_response = Faraday::Response.new(status: 400, body: error_body)
|
|
334
397
|
|
|
@@ -349,12 +412,12 @@ RSpec.describe Adyen do
|
|
|
349
412
|
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
350
413
|
mock_faraday_connection = double(Faraday::Connection)
|
|
351
414
|
error_body = {
|
|
352
|
-
type:
|
|
353
|
-
title:
|
|
415
|
+
type: 'https://docs.adyen.com/errors/validation',
|
|
416
|
+
title: 'The request is missing required fields or contains invalid data.',
|
|
354
417
|
status: 422,
|
|
355
|
-
detail:
|
|
356
|
-
invalidFields: [{
|
|
357
|
-
errorCode:
|
|
418
|
+
detail: 'It is mandatory to specify a legalEntityId when creating a new account holder.',
|
|
419
|
+
invalidFields: [{ 'name' => 'legalEntityId', 'message' => 'legalEntityId is not provided' }],
|
|
420
|
+
errorCode: '30_011'
|
|
358
421
|
}
|
|
359
422
|
mock_response = Faraday::Response.new(status: 422, body: error_body)
|
|
360
423
|
|
|
@@ -377,11 +440,11 @@ RSpec.describe Adyen do
|
|
|
377
440
|
mock_faraday_connection = double(Faraday::Connection)
|
|
378
441
|
error_body = {
|
|
379
442
|
status: 422,
|
|
380
|
-
errorCode:
|
|
381
|
-
message:
|
|
382
|
-
errorType:
|
|
383
|
-
pspReference:
|
|
384
|
-
}
|
|
443
|
+
errorCode: '14_030',
|
|
444
|
+
message: 'Return URL is missing.',
|
|
445
|
+
errorType: 'validation',
|
|
446
|
+
pspReference: '8816118280275544'
|
|
447
|
+
}
|
|
385
448
|
mock_response = Faraday::Response.new(status: 422, body: error_body)
|
|
386
449
|
|
|
387
450
|
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
|
@@ -402,9 +465,9 @@ RSpec.describe Adyen do
|
|
|
402
465
|
mock_faraday_connection = double(Faraday::Connection)
|
|
403
466
|
error_body = {
|
|
404
467
|
status: 500,
|
|
405
|
-
errorCode:
|
|
406
|
-
message:
|
|
407
|
-
errorType:
|
|
468
|
+
errorCode: '999',
|
|
469
|
+
message: 'Unexpected error.',
|
|
470
|
+
errorType: 'server error'
|
|
408
471
|
}
|
|
409
472
|
mock_response = Faraday::Response.new(status: 500, body: error_body)
|
|
410
473
|
|
|
@@ -423,7 +486,7 @@ RSpec.describe Adyen do
|
|
|
423
486
|
it 'raises NotFoundError on 404 response and checks content' do
|
|
424
487
|
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
425
488
|
mock_faraday_connection = double(Faraday::Connection)
|
|
426
|
-
error_body =
|
|
489
|
+
error_body = '701 Version 71 is not supported, latest version: 68'
|
|
427
490
|
mock_response = Faraday::Response.new(status: 404, body: error_body)
|
|
428
491
|
|
|
429
492
|
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
|
@@ -438,10 +501,10 @@ RSpec.describe Adyen do
|
|
|
438
501
|
end
|
|
439
502
|
end
|
|
440
503
|
|
|
441
|
-
|
|
504
|
+
it 'raises NotFoundError on 404 response with an invalid JSON body' do
|
|
442
505
|
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
443
506
|
mock_faraday_connection = double(Faraday::Connection)
|
|
444
|
-
error_body =
|
|
507
|
+
error_body = 'this is an error message'
|
|
445
508
|
mock_response = Faraday::Response.new(status: 404, body: error_body)
|
|
446
509
|
|
|
447
510
|
allow(Faraday).to receive(:new).and_return(mock_faraday_connection)
|
|
@@ -455,5 +518,80 @@ RSpec.describe Adyen do
|
|
|
455
518
|
expect(error.msg).to eq('Not found error')
|
|
456
519
|
end
|
|
457
520
|
end
|
|
458
|
-
|
|
521
|
+
|
|
522
|
+
it 'ensures User-Agent is present in request headers' do
|
|
523
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
|
|
524
|
+
mock_response = Faraday::Response.new(status: 200, body: '{}')
|
|
525
|
+
|
|
526
|
+
mock_conn = instance_double(Faraday::Connection)
|
|
527
|
+
expect(Faraday).to receive(:new).and_yield(mock_conn).and_return(mock_conn)
|
|
528
|
+
allow(mock_conn).to receive(:adapter)
|
|
529
|
+
connection_headers = {}
|
|
530
|
+
allow(mock_conn).to receive(:headers).and_return(connection_headers)
|
|
531
|
+
|
|
532
|
+
expect(mock_conn).to receive(:post) do |&block|
|
|
533
|
+
mock_req = double('Faraday::Request')
|
|
534
|
+
allow(mock_req).to receive(:body=)
|
|
535
|
+
block.call(mock_req) if block_given?
|
|
536
|
+
mock_response
|
|
537
|
+
end.and_return(mock_response)
|
|
538
|
+
|
|
539
|
+
client.checkout.payments_api.payments({})
|
|
540
|
+
|
|
541
|
+
expect(connection_headers['User-Agent']).to_not be_nil
|
|
542
|
+
expect(connection_headers['User-Agent']).to_not be_empty
|
|
543
|
+
expect(connection_headers['User-Agent']).to eq("#{Adyen::NAME}/#{Adyen::VERSION}")
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
it 'ensures User-Agent includes application_name when provided' do
|
|
547
|
+
client = Adyen::Client.new(api_key: 'api_key', env: :test, application_name: 'MyTestApp')
|
|
548
|
+
mock_response = Faraday::Response.new(status: 200, body: '{}')
|
|
549
|
+
|
|
550
|
+
mock_conn = instance_double(Faraday::Connection)
|
|
551
|
+
expect(Faraday).to receive(:new).and_yield(mock_conn).and_return(mock_conn)
|
|
552
|
+
allow(mock_conn).to receive(:adapter)
|
|
553
|
+
connection_headers = {}
|
|
554
|
+
allow(mock_conn).to receive(:headers).and_return(connection_headers)
|
|
555
|
+
|
|
556
|
+
expect(mock_conn).to receive(:post) do |&block|
|
|
557
|
+
mock_req = double('Faraday::Request')
|
|
558
|
+
allow(mock_req).to receive(:body=)
|
|
559
|
+
block.call(mock_req) if block_given?
|
|
560
|
+
mock_response
|
|
561
|
+
end.and_return(mock_response)
|
|
562
|
+
|
|
563
|
+
client.checkout.payments_api.payments({})
|
|
564
|
+
|
|
565
|
+
expect(connection_headers['User-Agent']).to_not be_nil
|
|
566
|
+
expect(connection_headers['User-Agent']).to_not be_empty
|
|
567
|
+
expect(connection_headers['User-Agent']).to eq("MyTestApp #{Adyen::NAME}/#{Adyen::VERSION}")
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
it 'ensures User-Agent includes application_name when set after initialization' do
|
|
571
|
+
client = Adyen::Client.new
|
|
572
|
+
client.api_key = 'api_key'
|
|
573
|
+
client.env = :test
|
|
574
|
+
client.application_name = 'MyTestAppAfterInit' # Set after initialization
|
|
575
|
+
|
|
576
|
+
mock_response = Faraday::Response.new(status: 200, body: '{}')
|
|
577
|
+
|
|
578
|
+
mock_conn = instance_double(Faraday::Connection)
|
|
579
|
+
expect(Faraday).to receive(:new).and_yield(mock_conn).and_return(mock_conn)
|
|
580
|
+
allow(mock_conn).to receive(:adapter)
|
|
581
|
+
connection_headers = {}
|
|
582
|
+
allow(mock_conn).to receive(:headers).and_return(connection_headers)
|
|
583
|
+
|
|
584
|
+
expect(mock_conn).to receive(:post) do |&block|
|
|
585
|
+
mock_req = double('Faraday::Request')
|
|
586
|
+
allow(mock_req).to receive(:body=)
|
|
587
|
+
block.call(mock_req) if block_given?
|
|
588
|
+
mock_response
|
|
589
|
+
end.and_return(mock_response)
|
|
590
|
+
|
|
591
|
+
client.checkout.payments_api.payments({})
|
|
592
|
+
|
|
593
|
+
expect(connection_headers['User-Agent']).to_not be_nil
|
|
594
|
+
expect(connection_headers['User-Agent']).to_not be_empty
|
|
595
|
+
expect(connection_headers['User-Agent']).to eq("MyTestAppAfterInit #{Adyen::NAME}/#{Adyen::VERSION}")
|
|
596
|
+
end
|
|
459
597
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "MNDT7QXPLKT9R333640TX334709E",
|
|
3
|
+
"type": "bacs",
|
|
4
|
+
"balanceAccountId": "BA43EKD334339T6N8X655DW77",
|
|
5
|
+
"paymentInstrumentId": "PI43EKK334339T6N8X65688CS",
|
|
6
|
+
"status": "approved",
|
|
7
|
+
"counterparty": {
|
|
8
|
+
"accountHolder": {
|
|
9
|
+
"fullName": "Example Merchant Ltd"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"createdAt": "2026-02-23T13:04:15.683Z",
|
|
13
|
+
"updatedAt": "2026-02-23T13:04:15.683Z"
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mandates": [
|
|
3
|
+
{
|
|
4
|
+
"id": "MNDT7QXPLKT9R333640TX334709E",
|
|
5
|
+
"type": "bacs",
|
|
6
|
+
"balanceAccountId": "BA43EKD334339T6N8X655DW77",
|
|
7
|
+
"paymentInstrumentId": "PI43EKK334339T6N8X65688CS",
|
|
8
|
+
"status": "approved",
|
|
9
|
+
"counterparty": {
|
|
10
|
+
"accountHolder": {
|
|
11
|
+
"fullName": "Example Merchant Ltd"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"createdAt": "2026-02-23T13:04:15.683Z",
|
|
15
|
+
"updatedAt": "2026-02-23T13:04:15.683Z"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"itemsTotal": 1
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "MNDT7QXPLKT9R333640TX334709E",
|
|
3
|
+
"type": "bacs",
|
|
4
|
+
"balanceAccountId": "BA43EKD334339T6N8X655DW77",
|
|
5
|
+
"paymentInstrumentId": "PI43EKK334339T6N8X65688CS",
|
|
6
|
+
"status": "approved",
|
|
7
|
+
"counterparty": {
|
|
8
|
+
"accountHolder": {
|
|
9
|
+
"fullName": "Example Merchant Ltd"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"createdAt": "2026-02-23T13:04:15.683Z",
|
|
13
|
+
"updatedAt": "2026-02-23T13:04:15.683Z"
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dynamicOffers": [
|
|
3
|
+
{
|
|
4
|
+
"id": "DO00000000000000000000001",
|
|
5
|
+
"accountHolderId": "AH00000000000000000000001",
|
|
6
|
+
"financing": {
|
|
7
|
+
"minimum": {
|
|
8
|
+
"currency": "EUR",
|
|
9
|
+
"value": 5000
|
|
10
|
+
},
|
|
11
|
+
"maximum": {
|
|
12
|
+
"currency": "EUR",
|
|
13
|
+
"value": 25000
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "CG00000000000000000000001",
|
|
3
|
+
"fundingBalanceAccountId": "BA00000000000000000000001",
|
|
4
|
+
"limits": [
|
|
5
|
+
{
|
|
6
|
+
"amount": {
|
|
7
|
+
"currency": "EUR",
|
|
8
|
+
"value": 100000
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"balances": [
|
|
13
|
+
{
|
|
14
|
+
"currency": "EUR",
|
|
15
|
+
"principal": 10000,
|
|
16
|
+
"fee": 1000,
|
|
17
|
+
"total": 11000
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "DI00000000000000000000001",
|
|
3
|
+
"grantId": "GR00000000000000000000001",
|
|
4
|
+
"accountHolderId": "AH00000000000000000000001",
|
|
5
|
+
"balanceAccountId": "BA00000000000000000000001",
|
|
6
|
+
"amount": {
|
|
7
|
+
"currency": "EUR",
|
|
8
|
+
"value": 10000
|
|
9
|
+
},
|
|
10
|
+
"fee": {
|
|
11
|
+
"amount": {
|
|
12
|
+
"currency": "EUR",
|
|
13
|
+
"value": 1000
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"balances": {
|
|
17
|
+
"currency": "EUR",
|
|
18
|
+
"principal": 10000,
|
|
19
|
+
"fee": 1000,
|
|
20
|
+
"total": 11000
|
|
21
|
+
},
|
|
22
|
+
"repayment": {
|
|
23
|
+
"basisPoints": 1000,
|
|
24
|
+
"updateDescription": "string"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"disbursements": [
|
|
3
|
+
{
|
|
4
|
+
"id": "DI00000000000000000000001",
|
|
5
|
+
"grantId": "GR00000000000000000000001",
|
|
6
|
+
"accountHolderId": "AH00000000000000000000001",
|
|
7
|
+
"balanceAccountId": "BA00000000000000000000001",
|
|
8
|
+
"amount": {
|
|
9
|
+
"currency": "EUR",
|
|
10
|
+
"value": 10000
|
|
11
|
+
},
|
|
12
|
+
"fee": {
|
|
13
|
+
"amount": {
|
|
14
|
+
"currency": "EUR",
|
|
15
|
+
"value": 1000
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"balances": {
|
|
19
|
+
"currency": "EUR",
|
|
20
|
+
"principal": 10000,
|
|
21
|
+
"fee": 1000,
|
|
22
|
+
"total": 11000
|
|
23
|
+
},
|
|
24
|
+
"repayment": {
|
|
25
|
+
"basisPoints": 1000,
|
|
26
|
+
"updateDescription": "string"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "GO00000000000000000000001",
|
|
3
|
+
"accountHolderId": "AH00000000000000000000001",
|
|
4
|
+
"contractType": "cashAdvance",
|
|
5
|
+
"amount": {
|
|
6
|
+
"currency": "EUR",
|
|
7
|
+
"value": 10000
|
|
8
|
+
},
|
|
9
|
+
"fee": {
|
|
10
|
+
"amount": {
|
|
11
|
+
"currency": "EUR",
|
|
12
|
+
"value": 1000
|
|
13
|
+
},
|
|
14
|
+
"aprBasisPoints": 1200
|
|
15
|
+
},
|
|
16
|
+
"repayment": {
|
|
17
|
+
"basisPoints": 1000,
|
|
18
|
+
"term": {
|
|
19
|
+
"estimatedDays": 180,
|
|
20
|
+
"maximumDays": 365
|
|
21
|
+
},
|
|
22
|
+
"threshold": {
|
|
23
|
+
"amount": {
|
|
24
|
+
"currency": "EUR",
|
|
25
|
+
"value": 1000
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"startsAt": "2024-01-01T00:00:00Z",
|
|
30
|
+
"expiresAt": "2024-01-31T23:59:59Z"
|
|
31
|
+
}
|