adyen-ruby-api-library 6.2.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/workflows/codeql.yml +41 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/rubygems_release.yml +1 -1
- data/.gitignore +3 -0
- data/Makefile +72 -0
- data/README.md +20 -18
- data/lib/adyen/client.rb +82 -42
- data/lib/adyen/errors.rb +2 -2
- data/lib/adyen/services/balanceControlService.rb +28 -0
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +63 -0
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +123 -0
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +51 -0
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +75 -0
- data/lib/adyen/services/balancePlatform/platform_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +63 -0
- data/lib/adyen/services/balancePlatform.rb +61 -0
- data/lib/adyen/services/binLookup.rb +40 -0
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +39 -0
- data/lib/adyen/services/checkout/modifications_api.rb +87 -0
- data/lib/adyen/services/checkout/orders_api.rb +51 -0
- data/lib/adyen/services/checkout/payment_links_api.rb +51 -0
- data/lib/adyen/services/checkout/payments_api.rb +87 -0
- data/lib/adyen/services/checkout/recurring_api.rb +39 -0
- data/lib/adyen/services/checkout/utility_api.rb +39 -0
- data/lib/adyen/services/checkout.rb +39 -180
- data/lib/adyen/services/dataProtection.rb +28 -0
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +75 -0
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement.rb +51 -0
- data/lib/adyen/services/management/account_company_level_api.rb +51 -0
- data/lib/adyen/services/management/account_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/account_store_level_api.rb +111 -0
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +63 -0
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/my_api_credential_api.rb +75 -0
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +87 -0
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +75 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +111 -0
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +63 -0
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/users_company_level_api.rb +63 -0
- data/lib/adyen/services/management/users_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/webhooks_company_level_api.rb +99 -0
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +99 -0
- data/lib/adyen/services/management.rb +151 -0
- data/lib/adyen/services/payment.rb +172 -0
- data/lib/adyen/services/payout/initialization_api.rb +51 -0
- data/lib/adyen/services/payout/instant_payouts_api.rb +27 -0
- data/lib/adyen/services/payout/reviewing_api.rb +39 -0
- data/lib/adyen/services/payout.rb +31 -0
- data/lib/adyen/services/posTerminalManagement.rb +76 -0
- data/lib/adyen/services/recurring.rb +81 -13
- data/lib/adyen/services/service.rb +6 -1
- data/lib/adyen/services/storedValue.rb +88 -0
- data/lib/adyen/services/transfers/transactions_api.rb +39 -0
- data/lib/adyen/services/transfers/transfers_api.rb +27 -0
- data/lib/adyen/services/transfers.rb +26 -0
- data/lib/adyen/utils/hmac_validator.rb +2 -3
- data/lib/adyen/version.rb +2 -2
- data/lib/adyen-ruby-api-library.rb +11 -5
- data/spec/account_spec.rb +1 -1
- data/spec/balance_control_spec.rb +44 -0
- data/spec/balance_platform_spec.rb +123 -0
- data/spec/bin_lookup_spec.rb +68 -10
- data/spec/checkout_spec.rb +85 -62
- data/spec/client_spec.rb +89 -10
- data/spec/errors_spec.rb +1 -1
- data/spec/fund_spec.rb +1 -1
- data/spec/hop_spec.rb +1 -1
- data/spec/lem_spec.rb +68 -0
- data/spec/management_spec.rb +68 -0
- data/spec/mocks/requests/BalanceControl/balance_transfer.json +10 -0
- data/spec/mocks/requests/BalancePlatform/create_account_holder.json +5 -0
- data/spec/mocks/requests/BalancePlatform/update_account_holder.json +10 -0
- data/spec/mocks/requests/LegalEntityManagement/create_business_line.json +15 -0
- data/spec/mocks/requests/Management/create_store.json +15 -0
- data/spec/mocks/requests/Recurring/create_permit.json +6 -0
- data/spec/mocks/requests/StoredValue/issue_giftcard.json +12 -0
- data/spec/mocks/requests/Transfers/get_transactions.json +82 -0
- data/spec/mocks/requests/Transfers/make_transfer.json +32 -0
- data/spec/mocks/responses/BalanceControl/balance_transfer.json +14 -0
- data/spec/mocks/responses/BalancePlatform/create_account_holder.json +41 -0
- data/spec/mocks/responses/BalancePlatform/get_balance_account.json +15 -0
- data/spec/mocks/responses/BalancePlatform/update_account_holder.json +16 -0
- data/spec/mocks/responses/Checkout/stored_payment_methods.json +1 -0
- data/spec/mocks/responses/LegalEntityManagement/create_business_line.json +17 -0
- data/spec/mocks/responses/Management/create_store.json +23 -0
- data/spec/mocks/responses/Management/get_companies.json +42 -0
- data/spec/mocks/responses/Recurring/create_permit.json +4 -0
- data/spec/mocks/responses/StoredValue/issue_giftcard.json +13 -0
- data/spec/mocks/responses/Transfers/get_transactions.json +82 -0
- data/spec/mocks/responses/Transfers/make_transfer.json +36 -0
- data/spec/mocks/responses/Webhooks/backslash_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/colon_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/forwardslash_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/mixed_notification.json +41 -0
- data/spec/notification_spec.rb +1 -1
- data/spec/payments_spec.rb +41 -23
- data/spec/payouts_spec.rb +43 -16
- data/spec/pos_terminal_management_spec.rb +46 -0
- data/spec/recurring_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/stored_value_spec.rb +43 -0
- data/spec/transfers_spec.rb +63 -0
- data/spec/utils/hmac_validator_spec.rb +20 -6
- data/templates/api-single.mustache +29 -0
- data/templates/api-small.mustache +37 -0
- data/templates/api.mustache +36 -0
- data/templates/config.yaml +10 -0
- metadata +107 -11
- data/lib/adyen/services/bin_lookup.rb +0 -18
- data/lib/adyen/services/data_protection.rb +0 -17
- data/lib/adyen/services/payments.rb +0 -34
- data/lib/adyen/services/payouts.rb +0 -22
- data/lib/adyen/services/postfmapi.rb +0 -19
- data/spec/mocks/requests/Recurring/store_token.json +0 -15
- data/spec/mocks/responses/Recurring/store_token.json +0 -7
- data/spec/postfmapi_spec.rb +0 -16
data/spec/bin_lookup_spec.rb
CHANGED
@@ -1,15 +1,73 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "json"
|
2
3
|
|
3
|
-
|
4
|
-
# client instance to be used in dynamically generated tests
|
5
|
-
client = create_client(:basic)
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
RSpec.describe Adyen::BinLookup, service: "BinLookup" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "BinLookup",
|
11
|
+
}
|
12
|
+
end
|
13
13
|
|
14
|
-
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a get_cost_estimate POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BinLookup/get_cost_estimate.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/BinLookup/get_cost_estimate.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "getCostEstimate", @shared_values[:client].bin_lookup.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].bin_lookup.get_cost_estimate(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
it "makes a get3ds_availability POST call" do
|
45
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BinLookup/get_3ds_availability.json"))
|
46
|
+
|
47
|
+
response_body = json_from_file("mocks/responses/BinLookup/get_3ds_availability.json")
|
48
|
+
|
49
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "get3dsAvailability", @shared_values[:client].bin_lookup.version)
|
50
|
+
WebMock.stub_request(:post, url).
|
51
|
+
with(
|
52
|
+
body: request_body,
|
53
|
+
headers: {
|
54
|
+
"x-api-key" => @shared_values[:client].api_key
|
55
|
+
}
|
56
|
+
).
|
57
|
+
to_return(
|
58
|
+
body: response_body
|
59
|
+
)
|
60
|
+
|
61
|
+
result = @shared_values[:client].bin_lookup.get3ds_availability(request_body)
|
62
|
+
response_hash = result.response
|
63
|
+
|
64
|
+
expect(result.status).
|
65
|
+
to eq(200)
|
66
|
+
expect(response_hash).
|
67
|
+
to eq(JSON.parse(response_body))
|
68
|
+
expect(response_hash).
|
69
|
+
to be_a Adyen::HashWithAccessors
|
70
|
+
expect(response_hash).
|
71
|
+
to be_a_kind_of Hash
|
72
|
+
end
|
15
73
|
end
|
data/spec/checkout_spec.rb
CHANGED
@@ -29,7 +29,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
29
29
|
body: response_body
|
30
30
|
)
|
31
31
|
|
32
|
-
result = @shared_values[:client].checkout.payment_methods(request_body)
|
32
|
+
result = @shared_values[:client].checkout.payments_api.payment_methods(request_body)
|
33
33
|
response_hash = result.response
|
34
34
|
|
35
35
|
expect(result.status).
|
@@ -44,13 +44,6 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
44
44
|
|
45
45
|
it "makes a paymentMethods/balance call" do
|
46
46
|
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods_balance.json"))
|
47
|
-
request_body[:applicationInfo] = {}
|
48
|
-
request_body[:applicationInfo][:adyenPaymentSource] = {
|
49
|
-
:name => "adyen-test",
|
50
|
-
:version => "1.0.0",
|
51
|
-
}
|
52
|
-
|
53
|
-
@shared_values[:client].add_application_info(request_body)
|
54
47
|
|
55
48
|
response_body = json_from_file("mocks/responses/Checkout/payment_methods_balance.json")
|
56
49
|
|
@@ -66,16 +59,10 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
66
59
|
body: response_body
|
67
60
|
)
|
68
61
|
|
69
|
-
result = @shared_values[:client].checkout.
|
62
|
+
result = @shared_values[:client].checkout.orders_api.get_balance_of_gift_card(request_body)
|
70
63
|
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
71
64
|
response_hash = result.response
|
72
65
|
|
73
|
-
expect(request_body[:applicationInfo][:adyenLibrary][:name]).
|
74
|
-
to eq(Adyen::NAME)
|
75
|
-
expect(request_body[:applicationInfo][:adyenLibrary][:version]).
|
76
|
-
to eq(Adyen::VERSION)
|
77
|
-
expect(request_body[:applicationInfo][:adyenPaymentSource][:name]).
|
78
|
-
to eq("adyen-test")
|
79
66
|
expect(result.status).
|
80
67
|
to eq(200)
|
81
68
|
expect(response_hash).
|
@@ -91,13 +78,6 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
91
78
|
# must be created manually due to payments/details format
|
92
79
|
it "makes a payments/details call" do
|
93
80
|
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment-details.json"))
|
94
|
-
request_body[:applicationInfo] = {}
|
95
|
-
request_body[:applicationInfo][:adyenPaymentSource] = {
|
96
|
-
:name => "adyen-test",
|
97
|
-
:version => "1.0.0",
|
98
|
-
}
|
99
|
-
|
100
|
-
@shared_values[:client].add_application_info(request_body)
|
101
81
|
|
102
82
|
response_body = json_from_file("mocks/responses/Checkout/payment-details.json")
|
103
83
|
|
@@ -113,16 +93,10 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
113
93
|
body: response_body
|
114
94
|
)
|
115
95
|
|
116
|
-
result = @shared_values[:client].checkout.
|
96
|
+
result = @shared_values[:client].checkout.payments_api.payments_details(request_body)
|
117
97
|
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
118
98
|
response_hash = result.response
|
119
99
|
|
120
|
-
expect(request_body[:applicationInfo][:adyenLibrary][:name]).
|
121
|
-
to eq(Adyen::NAME)
|
122
|
-
expect(request_body[:applicationInfo][:adyenLibrary][:version]).
|
123
|
-
to eq(Adyen::VERSION)
|
124
|
-
expect(request_body[:applicationInfo][:adyenPaymentSource][:name]).
|
125
|
-
to eq("adyen-test")
|
126
100
|
expect(result.status).
|
127
101
|
to eq(200)
|
128
102
|
expect(response_hash).
|
@@ -140,7 +114,6 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
140
114
|
# must be created manually due to payments/result format
|
141
115
|
it "makes a payments/result call" do
|
142
116
|
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment-result.json"))
|
143
|
-
@shared_values[:client].add_application_info(request_body)
|
144
117
|
|
145
118
|
response_body = json_from_file("mocks/responses/Checkout/payment-result.json")
|
146
119
|
|
@@ -156,7 +129,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
156
129
|
body: response_body
|
157
130
|
)
|
158
131
|
|
159
|
-
result = @shared_values[:client].checkout.
|
132
|
+
result = @shared_values[:client].checkout.classic_checkout_sdk_api.verify_payment_result(request_body)
|
160
133
|
response_hash = result.response
|
161
134
|
|
162
135
|
expect(result.status).
|
@@ -176,13 +149,6 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
176
149
|
# must be created manually due to paymentsLinks format
|
177
150
|
it "makes a paymentLinks call" do
|
178
151
|
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_links.json"))
|
179
|
-
request_body[:applicationInfo] = {}
|
180
|
-
request_body[:applicationInfo][:adyenPaymentSource] = {
|
181
|
-
:name => "adyen-test",
|
182
|
-
:version => "1.0.0",
|
183
|
-
}
|
184
|
-
|
185
|
-
@shared_values[:client].add_application_info(request_body)
|
186
152
|
|
187
153
|
response_body = json_from_file("mocks/responses/Checkout/payment_links.json")
|
188
154
|
|
@@ -198,7 +164,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
198
164
|
body: response_body
|
199
165
|
)
|
200
166
|
|
201
|
-
result = @shared_values[:client].checkout.payment_links(request_body)
|
167
|
+
result = @shared_values[:client].checkout.payment_links_api.payment_links(request_body)
|
202
168
|
response_hash = result.response
|
203
169
|
|
204
170
|
expect(result.status).
|
@@ -226,7 +192,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
226
192
|
body: response_body
|
227
193
|
)
|
228
194
|
|
229
|
-
result = @shared_values[:client].checkout.
|
195
|
+
result = @shared_values[:client].checkout.payment_links_api.get_payment_link("1")
|
230
196
|
response_hash = result.response
|
231
197
|
|
232
198
|
expect(result.status).
|
@@ -249,7 +215,6 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
249
215
|
:status => "expired",
|
250
216
|
}
|
251
217
|
|
252
|
-
@shared_values[:client].add_application_info(request_body)
|
253
218
|
response_body = json_from_file("mocks/responses/Checkout/update-payment-link.json")
|
254
219
|
|
255
220
|
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
|
@@ -264,7 +229,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
264
229
|
body: response_body
|
265
230
|
)
|
266
231
|
|
267
|
-
result = @shared_values[:client].checkout.
|
232
|
+
result = @shared_values[:client].checkout.payment_links_api.update_payment_link(request_body, "1")
|
268
233
|
response_hash = result.response
|
269
234
|
|
270
235
|
expect(result.status).
|
@@ -298,7 +263,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
298
263
|
body: response_body
|
299
264
|
)
|
300
265
|
|
301
|
-
result = @shared_values[:client].checkout.orders(request_body)
|
266
|
+
result = @shared_values[:client].checkout.orders_api.orders(request_body)
|
302
267
|
response_hash = result.response
|
303
268
|
|
304
269
|
expect(result.status).
|
@@ -330,7 +295,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
330
295
|
body: response_body
|
331
296
|
)
|
332
297
|
|
333
|
-
result = @shared_values[:client].checkout.
|
298
|
+
result = @shared_values[:client].checkout.orders_api.cancel_order(request_body)
|
334
299
|
response_hash = result.response
|
335
300
|
|
336
301
|
expect(result.status).
|
@@ -362,7 +327,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
362
327
|
body: response_body
|
363
328
|
)
|
364
329
|
|
365
|
-
result = @shared_values[:client].checkout.
|
330
|
+
result = @shared_values[:client].checkout.utility_api.get_apple_pay_session(request_body)
|
366
331
|
response_hash = result.response
|
367
332
|
|
368
333
|
expect(result.status).
|
@@ -392,7 +357,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
392
357
|
)
|
393
358
|
.to_return(body: response_body, status: 201)
|
394
359
|
|
395
|
-
result = @shared_values[:client].checkout.sessions(request_body)
|
360
|
+
result = @shared_values[:client].checkout.payments_api.sessions(request_body)
|
396
361
|
response_hash = result.response
|
397
362
|
|
398
363
|
expect(result.status).
|
@@ -420,7 +385,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
420
385
|
)
|
421
386
|
.to_return(body: response_body, status: 201)
|
422
387
|
|
423
|
-
result = @shared_values[:client].checkout.
|
388
|
+
result = @shared_values[:client].checkout.modifications_api.capture_authorised_payment(request_body, "12345")
|
424
389
|
response_hash = result.response
|
425
390
|
|
426
391
|
expect(result.status).
|
@@ -452,7 +417,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
452
417
|
)
|
453
418
|
.to_return(body: response_body, status: 201)
|
454
419
|
|
455
|
-
result = @shared_values[:client].checkout.
|
420
|
+
result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment_by_psp_reference(request_body, "12345")
|
456
421
|
response_hash = result.response
|
457
422
|
|
458
423
|
expect(result.status).
|
@@ -484,7 +449,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
484
449
|
)
|
485
450
|
.to_return(body: response_body, status: 201)
|
486
451
|
|
487
|
-
result = @shared_values[:client].checkout.
|
452
|
+
result = @shared_values[:client].checkout.modifications_api.refund_captured_payment(request_body, "12345")
|
488
453
|
response_hash = result.response
|
489
454
|
|
490
455
|
expect(result.status).
|
@@ -516,7 +481,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
516
481
|
)
|
517
482
|
.to_return(body: response_body, status: 201)
|
518
483
|
|
519
|
-
result = @shared_values[:client].checkout.
|
484
|
+
result = @shared_values[:client].checkout.modifications_api.refund_or_cancel_payment(request_body, "12345")
|
520
485
|
response_hash = result.response
|
521
486
|
|
522
487
|
expect(result.status).
|
@@ -548,7 +513,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
548
513
|
)
|
549
514
|
.to_return(body: response_body, status: 201)
|
550
515
|
|
551
|
-
result = @shared_values[:client].checkout.
|
516
|
+
result = @shared_values[:client].checkout.modifications_api.update_authorised_amount(request_body, "12345")
|
552
517
|
response_hash = result.response
|
553
518
|
|
554
519
|
expect(result.status).
|
@@ -580,7 +545,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
580
545
|
)
|
581
546
|
.to_return(body: response_body, status: 201)
|
582
547
|
|
583
|
-
result = @shared_values[:client].checkout.
|
548
|
+
result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment(request_body)
|
584
549
|
response_hash = result.response
|
585
550
|
|
586
551
|
expect(result.status).
|
@@ -597,18 +562,76 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
597
562
|
to eq("12345")
|
598
563
|
end
|
599
564
|
|
600
|
-
|
601
|
-
|
565
|
+
it "makes a get storedPaymentMethods call" do
|
566
|
+
response_body = json_from_file("mocks/responses/Checkout/stored_payment_methods.json")
|
567
|
+
|
568
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234", @shared_values[:client].checkout.version)
|
569
|
+
WebMock.stub_request(:get, url).
|
570
|
+
with(
|
571
|
+
headers: {
|
572
|
+
"x-api-key" => @shared_values[:client].api_key
|
573
|
+
}
|
574
|
+
).
|
575
|
+
to_return(
|
576
|
+
body: response_body
|
577
|
+
)
|
578
|
+
|
579
|
+
result = @shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(queryParams:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
|
580
|
+
response_hash = result.response
|
581
|
+
|
582
|
+
expect(result.status).
|
583
|
+
to eq(200)
|
584
|
+
expect(response_hash).
|
585
|
+
to eq(JSON.parse(response_body))
|
586
|
+
expect(response_hash).
|
587
|
+
to be_a Adyen::HashWithAccessors
|
588
|
+
expect(response_hash).
|
589
|
+
to be_a_kind_of Hash
|
590
|
+
expect(response_hash["shopperReference"]).
|
591
|
+
to eq("test-1234")
|
592
|
+
end
|
602
593
|
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
594
|
+
it "makes a delete storedPaymentMethods call" do
|
595
|
+
|
596
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods/RL8FW7WZM6KXWD82?merchantAccount=TestMerchantAccount&shopperReference=test-1234", @shared_values[:client].checkout.version)
|
597
|
+
WebMock.stub_request(:delete, url).
|
598
|
+
with(
|
599
|
+
headers: {
|
600
|
+
"x-api-key" => @shared_values[:client].api_key
|
601
|
+
}
|
602
|
+
).
|
603
|
+
to_return(
|
604
|
+
body: "{}"
|
605
|
+
)
|
606
|
+
|
607
|
+
result = @shared_values[:client].checkout.recurring_api.delete_token_for_stored_payment_details("RL8FW7WZM6KXWD82", queryParams:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
|
608
|
+
response_hash = result.response
|
609
|
+
|
610
|
+
expect(result.status).
|
611
|
+
to eq(200)
|
612
|
+
end
|
613
|
+
|
614
|
+
it "tests sending the application headers" do
|
615
|
+
response_body = json_from_file("mocks/responses/Checkout/stored_payment_methods.json")
|
616
|
+
|
617
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234", @shared_values[:client].checkout.version)
|
618
|
+
WebMock.stub_request(:get, url).
|
619
|
+
with(
|
620
|
+
headers: {
|
621
|
+
"x-api-key" => @shared_values[:client].api_key
|
622
|
+
}
|
623
|
+
).
|
624
|
+
to_return(
|
625
|
+
body: response_body
|
626
|
+
)
|
627
|
+
|
628
|
+
result = @shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(queryParams:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
|
629
|
+
expect(
|
630
|
+
a_request(:get, "http://localhost:3001/v70/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234")
|
631
|
+
.with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Adyen-Library-Name'=>'adyen-ruby-api-library', 'Adyen-Library-Version'=>'7.0.0', 'Content-Type'=>'application/json', 'User-Agent'=>'adyen-ruby-api-library/7.0.0', 'X-Api-Key'=>'api_key'})
|
632
|
+
).to have_been_made.once
|
633
|
+
end
|
610
634
|
|
611
|
-
generate_tests(client, "Checkout", test_sets, client.checkout)
|
612
635
|
end
|
613
636
|
|
614
637
|
# rubocop:enable Metrics/BlockLength
|
data/spec/client_spec.rb
CHANGED
@@ -25,15 +25,15 @@ 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].
|
28
|
+
expect{ @shared_values[:client].payment.authorise("{}") }.
|
29
29
|
to raise_error(Adyen::AuthenticationError)
|
30
30
|
@shared_values[:client].ws_user = @shared_values[:ws_user]
|
31
|
-
expect{ @shared_values[:client].
|
31
|
+
expect{ @shared_values[:client].payment.authorise("{}") }.
|
32
32
|
to raise_error(Adyen::AuthenticationError)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "fails a checkout call without api key" do
|
36
|
-
expect{ @shared_values[:client].checkout.payment_methods("{}") }.
|
36
|
+
expect{ @shared_values[:client].checkout.payments_api.payment_methods("{}") }.
|
37
37
|
to raise_error(Adyen::AuthenticationError)
|
38
38
|
@shared_values[:client].api_key = "api_key"
|
39
39
|
end
|
@@ -60,28 +60,41 @@ RSpec.describe Adyen do
|
|
60
60
|
client = Adyen::Client.new(env: :test)
|
61
61
|
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
62
62
|
expect(client.service_url_base("Account")).
|
63
|
-
to eq("https://cal-test.adyen.com/cal/services")
|
63
|
+
to eq("https://cal-test.adyen.com/cal/services/Account")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "generates the correct service URL base for CAL LIVE" do
|
67
67
|
client = Adyen::Client.new(env: :live)
|
68
68
|
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
69
69
|
expect(client.service_url_base("Account")).
|
70
|
-
to eq("https://cal-live.adyen.com/cal/services")
|
70
|
+
to eq("https://cal-live.adyen.com/cal/services/Account")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "generates the correct service URL base for PAL TEST" do
|
74
74
|
client = Adyen::Client.new(env: :test)
|
75
75
|
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
76
76
|
expect(client.service_url_base("Payment")).
|
77
|
-
to eq("https://pal-test.adyen.com/pal/servlet")
|
77
|
+
to eq("https://pal-test.adyen.com/pal/servlet/Payment")
|
78
78
|
end
|
79
79
|
|
80
80
|
it "generates the correct service URL base for PAL LIVE" do
|
81
81
|
client = Adyen::Client.new(env: :live)
|
82
82
|
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
83
83
|
expect(client.service_url_base("Payment")).
|
84
|
-
to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet")
|
84
|
+
to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet/Payment")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "generates the correct service URL PAL authorise TEST" do
|
88
|
+
client = Adyen::Client.new(env: :test)
|
89
|
+
expect(client.service_url("Payment", "authorise", "68")).
|
90
|
+
to eq("https://pal-test.adyen.com/pal/servlet/Payment/v68/authorise")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "generates the correct service URL base for PAL LIVE" do
|
94
|
+
client = Adyen::Client.new(env: :live)
|
95
|
+
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
96
|
+
expect(client.service_url("Payment", "authorise", "68")).
|
97
|
+
to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet/Payment/v68/authorise")
|
85
98
|
end
|
86
99
|
|
87
100
|
it "generates a new set of ConnectionOptions when none are provided" do
|
@@ -106,8 +119,74 @@ RSpec.describe Adyen do
|
|
106
119
|
mock_response = Faraday::Response.new(status: 200)
|
107
120
|
|
108
121
|
expect(Adyen::AdyenResult).to receive(:new)
|
109
|
-
expect(Faraday).to receive(:new).with("http://localhost:3001/
|
122
|
+
expect(Faraday).to receive(:new).with("http://localhost:3001/v70/payments/details", connection_options).and_return(mock_faraday_connection)
|
110
123
|
expect(mock_faraday_connection).to receive(:post).and_return(mock_response)
|
111
|
-
client.checkout.
|
112
|
-
end
|
124
|
+
client.checkout.payments_api.payments_details(request_body)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "checks the creation of checkout url" do
|
128
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
129
|
+
expect(client.service_url("Checkout", "paymentMethods", "70")).
|
130
|
+
to eq("https://checkout-test.adyen.com/v70/paymentMethods")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "checks the creation of checkout url" do
|
134
|
+
client = Adyen::Client.new(api_key: "api_key", env: :live, live_url_prefix: "YourLiveUrlPrefix")
|
135
|
+
expect(client.service_url("Checkout", "paymentMethods", "70")).
|
136
|
+
to eq("https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/v70/paymentMethods")
|
137
|
+
end
|
138
|
+
it "checks the creation of lem url" do
|
139
|
+
client = Adyen::Client.new(api_key: "api_key", env: :live)
|
140
|
+
expect(client.service_url("LegalEntityManagement", "businessLines", "3")).
|
141
|
+
to eq("https://kyc-live.adyen.com/lem/v3/businessLines")
|
142
|
+
end
|
143
|
+
|
144
|
+
it "checks the creation of balancePlatform url" do
|
145
|
+
client = Adyen::Client.new(api_key: "api_key", env: :live)
|
146
|
+
expect(client.service_url("BalancePlatform", "legalEntities", "1")).
|
147
|
+
to eq("https://balanceplatform-api-live.adyen.com/bcl/v1/legalEntities")
|
148
|
+
end
|
149
|
+
|
150
|
+
it "checks the creation of balancePlatform url" do
|
151
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
152
|
+
expect(client.service_url("BalancePlatform", "legalEntities", "1")).
|
153
|
+
to eq("https://balanceplatform-api-test.adyen.com/bcl/v1/legalEntities")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "checks the creation of transfers url" do
|
157
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
158
|
+
expect(client.service_url("Transfers", "transactions", "1")).
|
159
|
+
to eq("https://balanceplatform-api-test.adyen.com/btl/v1/transactions")
|
160
|
+
end
|
161
|
+
|
162
|
+
it "checks the creation of management url" do
|
163
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
164
|
+
expect(client.service_url("Management", "companies", "1")).
|
165
|
+
to eq("https://management-test.adyen.com/v1/companies")
|
166
|
+
end
|
167
|
+
|
168
|
+
it "checks the creation of binLookup url" do
|
169
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
170
|
+
expect(client.service_url("BinLookup", "getCostEstimate", "54")).
|
171
|
+
to eq("https://pal-test.adyen.com/pal/servlet/BinLookup/v54/getCostEstimate")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "check the creation of storedValue url" do
|
175
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
176
|
+
expect(client.service_url("StoredValue", "issue", "46")).
|
177
|
+
to eq("https://pal-test.adyen.com/pal/servlet/StoredValue/v46/issue")
|
178
|
+
end
|
179
|
+
|
180
|
+
it "check the creation of payout url" do
|
181
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
182
|
+
expect(client.service_url("Payout", "declineThirdParty", "68")).
|
183
|
+
to eq("https://pal-test.adyen.com/pal/servlet/Payout/v68/declineThirdParty")
|
184
|
+
end
|
185
|
+
|
186
|
+
it "checks the creation of PosTerminalManagement url" do
|
187
|
+
client = Adyen::Client.new(api_key: "api_key", env: :test)
|
188
|
+
expect(client.service_url("PosTerminalManagement", "assignTerminals", "1")).
|
189
|
+
to eq("https://postfmapi-test.adyen.com/postfmapi/terminal/v1/assignTerminals")
|
190
|
+
end
|
191
|
+
|
113
192
|
end
|
data/spec/errors_spec.rb
CHANGED
@@ -33,7 +33,7 @@ RSpec.describe Adyen::AdyenError do
|
|
33
33
|
expect(Adyen::AdyenError.new(@shared_values[:request], nil, nil, 'code').to_s).to eq("Adyen::AdyenError code:code, request:#{@shared_values[:request]}")
|
34
34
|
end
|
35
35
|
it 'uses the proper error class name' do
|
36
|
-
expect(Adyen::PermissionError.new('message', @shared_values[:request]).to_s).to eq("Adyen::PermissionError code:403, msg:message, request:#{@shared_values[:request]}")
|
36
|
+
expect(Adyen::PermissionError.new('message', @shared_values[:request], 'response').to_s).to eq("Adyen::PermissionError code:403, msg:message, request:#{@shared_values[:request]}, response:response")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
describe '#masking' do
|
data/spec/fund_spec.rb
CHANGED
data/spec/hop_spec.rb
CHANGED
data/spec/lem_spec.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::LegalEntityManagement, service: "LegalEntityManagement" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "LegalEntityManagement",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a business_lines POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/LegalEntityManagement/create_business_line.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/LegalEntityManagement/create_business_line.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "businessLines", @shared_values[:client].legal_entity_management.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].legal_entity_management.business_lines_api.create_business_line(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
|
45
|
+
it "makes a documents DELETE call" do
|
46
|
+
|
47
|
+
|
48
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "documents/123", @shared_values[:client].legal_entity_management.version)
|
49
|
+
WebMock.stub_request(:delete, url).
|
50
|
+
with(
|
51
|
+
headers: {
|
52
|
+
"x-api-key" => @shared_values[:client].api_key
|
53
|
+
}
|
54
|
+
).
|
55
|
+
to_return(
|
56
|
+
body: "{}"
|
57
|
+
)
|
58
|
+
|
59
|
+
result = @shared_values[:client].legal_entity_management.documents_api.delete_document('123')
|
60
|
+
response_hash = result.response
|
61
|
+
|
62
|
+
expect(result.status).
|
63
|
+
to eq(200)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
|