adyen-ruby-api-library 7.0.0 → 7.0.2
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/release.yml +18 -0
- data/.github/workflows/gh_release.yml +16 -0
- data/.github/workflows/release_request.yml +15 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/services.yml +28 -0
- data/.rubocop.yml +8 -0
- data/Gemfile +7 -7
- data/Makefile +14 -10
- data/README.md +13 -10
- data/Rakefile +3 -3
- data/adyen-ruby-api-library.gemspec +6 -3
- data/bin/console +2 -2
- data/lib/adyen/client.rb +96 -76
- data/lib/adyen/errors.rb +23 -18
- data/lib/adyen/hash_with_accessors.rb +12 -7
- data/lib/adyen/services/balanceControlService.rb +7 -14
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +22 -38
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +48 -79
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +6 -13
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +6 -13
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +12 -22
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +16 -29
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +26 -45
- data/lib/adyen/services/balancePlatform/platform_api.rb +12 -22
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +21 -37
- data/lib/adyen/services/balancePlatform.rb +38 -40
- data/lib/adyen/services/binLookup.rb +12 -22
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +11 -21
- data/lib/adyen/services/checkout/modifications_api.rb +31 -53
- data/lib/adyen/services/checkout/orders_api.rb +16 -29
- data/lib/adyen/services/checkout/payment_links_api.rb +16 -29
- data/lib/adyen/services/checkout/payments_api.rb +40 -53
- data/lib/adyen/services/checkout/recurring_api.rb +13 -23
- data/lib/adyen/services/checkout/utility_api.rb +11 -21
- data/lib/adyen/services/checkout.rb +32 -34
- data/lib/adyen/services/dataProtection.rb +7 -14
- data/lib/adyen/services/dispute.rb +6 -5
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +16 -29
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +26 -45
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +25 -29
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement.rb +32 -34
- data/lib/adyen/services/management/account_company_level_api.rb +18 -31
- data/lib/adyen/services/management/account_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/account_store_level_api.rb +43 -71
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +21 -37
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +21 -37
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +22 -38
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/api_key_company_level_api.rb +6 -13
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +6 -13
- data/lib/adyen/services/management/client_key_company_level_api.rb +6 -13
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +6 -13
- data/lib/adyen/services/management/my_api_credential_api.rb +26 -45
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +32 -54
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +26 -45
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +92 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +24 -40
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +6 -13
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +55 -89
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +55 -89
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +23 -39
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +23 -39
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +45 -73
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +21 -37
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +7 -14
- data/lib/adyen/services/management/users_company_level_api.rb +22 -38
- data/lib/adyen/services/management/users_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/webhooks_company_level_api.rb +37 -62
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +37 -62
- data/lib/adyen/services/management.rb +99 -96
- data/lib/adyen/services/marketpay.rb +42 -36
- data/lib/adyen/services/payment/general_api.rb +56 -0
- data/lib/adyen/services/payment/modifications_api.rb +83 -0
- data/lib/adyen/services/payment.rb +10 -158
- data/lib/adyen/services/payout/initialization_api.rb +16 -29
- data/lib/adyen/services/payout/instant_payouts_api.rb +6 -13
- data/lib/adyen/services/payout/reviewing_api.rb +11 -21
- data/lib/adyen/services/payout.rb +19 -21
- data/lib/adyen/services/posTerminalManagement.rb +27 -46
- data/lib/adyen/services/recurring.rb +32 -54
- data/lib/adyen/services/service.rb +5 -4
- data/lib/adyen/services/storedValue.rb +32 -54
- data/lib/adyen/services/transfers/capital_api.rb +38 -0
- data/lib/adyen/services/transfers/transactions_api.rb +12 -22
- data/lib/adyen/services/transfers/transfers_api.rb +6 -13
- data/lib/adyen/services/transfers.rb +20 -17
- data/lib/adyen/utils/hmac_validator.rb +9 -9
- data/lib/adyen/version.rb +3 -3
- data/lib/adyen-ruby-api-library.rb +21 -21
- data/spec/account_spec.rb +20 -20
- data/spec/balance_control_spec.rb +28 -29
- data/spec/balance_platform_spec.rb +108 -102
- data/spec/bin_lookup_spec.rb +50 -50
- data/spec/checkout_spec.rb +581 -515
- data/spec/client_spec.rb +118 -71
- data/spec/data_protection_spec.rb +4 -4
- data/spec/dispute_spec.rb +7 -7
- data/spec/errors_spec.rb +37 -17
- data/spec/fund_spec.rb +10 -10
- data/spec/hash_with_accessors_spec.rb +18 -8
- data/spec/hop_spec.rb +4 -4
- data/spec/lem_spec.rb +44 -49
- data/spec/management_spec.rb +46 -48
- data/spec/notification_spec.rb +9 -9
- data/spec/payments_spec.rb +31 -32
- data/spec/payouts_spec.rb +29 -32
- data/spec/pos_terminal_management_spec.rb +30 -32
- data/spec/recurring_spec.rb +8 -8
- data/spec/service_spec.rb +4 -0
- data/spec/spec_helper.rb +37 -35
- data/spec/stored_value_spec.rb +28 -27
- data/spec/transfers_spec.rb +48 -47
- data/spec/utils/hmac_validator_spec.rb +15 -14
- data/templates/api-single.mustache +13 -15
- data/templates/api-small.mustache +8 -15
- data/templates/api.mustache +7 -14
- metadata +27 -18
- data/.github/dependabot.yml +0 -8
- /data/spec/mocks/responses/Webhooks/{backslash_notification.json → backslash_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{colon_notification.json → colon_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{forwardslash_notification.json → forwardslash_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{mixed_notification.json → mixed_webhook.json} +0 -0
data/spec/checkout_spec.rb
CHANGED
@@ -1,637 +1,703 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe Adyen::Checkout, service: "checkout" do
|
4
|
+
RSpec.describe Adyen::Checkout, service: 'checkout' do
|
7
5
|
before(:all) do
|
8
6
|
@shared_values = {
|
9
7
|
client: create_client(:api_key),
|
10
|
-
service:
|
8
|
+
service: 'Checkout'
|
11
9
|
}
|
12
10
|
end
|
13
11
|
|
14
12
|
# must be created manually because every field in the response is an array
|
15
|
-
it
|
16
|
-
request_body = JSON.parse(json_from_file(
|
17
|
-
|
18
|
-
response_body = json_from_file(
|
19
|
-
|
20
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
it 'makes a payment_methods call' do
|
14
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payment_methods.json'))
|
15
|
+
|
16
|
+
response_body = json_from_file('mocks/responses/Checkout/payment_methods.json')
|
17
|
+
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'paymentMethods',
|
19
|
+
@shared_values[:client].checkout.version)
|
20
|
+
WebMock.stub_request(:post, url)
|
21
|
+
.with(
|
22
|
+
body: request_body,
|
23
|
+
headers: {
|
24
|
+
'x-api-key' => @shared_values[:client].api_key
|
25
|
+
}
|
26
|
+
)
|
27
|
+
.to_return(
|
28
|
+
body: response_body
|
29
|
+
)
|
31
30
|
|
32
31
|
result = @shared_values[:client].checkout.payments_api.payment_methods(request_body)
|
33
32
|
response_hash = result.response
|
34
33
|
|
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
|
34
|
+
expect(result.status)
|
35
|
+
.to eq(200)
|
36
|
+
expect(response_hash)
|
37
|
+
.to eq(JSON.parse(response_body))
|
38
|
+
expect(response_hash)
|
39
|
+
.to be_a Adyen::HashWithAccessors
|
40
|
+
expect(response_hash)
|
41
|
+
.to be_a_kind_of Hash
|
43
42
|
end
|
44
43
|
|
45
|
-
it
|
46
|
-
request_body = JSON.parse(json_from_file(
|
44
|
+
it 'makes a paymentMethods/balance call' do
|
45
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payment_methods_balance.json'))
|
47
46
|
|
48
|
-
response_body = json_from_file(
|
47
|
+
response_body = json_from_file('mocks/responses/Checkout/payment_methods_balance.json')
|
49
48
|
|
50
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
49
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'paymentMethods/balance',
|
50
|
+
@shared_values[:client].checkout.version)
|
51
|
+
WebMock.stub_request(:post, url)
|
52
|
+
.with(
|
53
|
+
body: request_body,
|
54
|
+
headers: {
|
55
|
+
'x-api-key' => @shared_values[:client].api_key
|
56
|
+
}
|
57
|
+
)
|
58
|
+
.to_return(
|
59
|
+
body: response_body
|
60
|
+
)
|
61
61
|
|
62
62
|
result = @shared_values[:client].checkout.orders_api.get_balance_of_gift_card(request_body)
|
63
63
|
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
64
64
|
response_hash = result.response
|
65
65
|
|
66
|
-
expect(result.status)
|
67
|
-
to eq(200)
|
68
|
-
expect(response_hash)
|
69
|
-
to eq(JSON.parse(response_body))
|
70
|
-
expect(response_hash)
|
71
|
-
to be_a Adyen::HashWithAccessors
|
72
|
-
expect(response_hash)
|
73
|
-
to be_a_kind_of Hash
|
74
|
-
expect(response_hash[
|
75
|
-
to eq(
|
66
|
+
expect(result.status)
|
67
|
+
.to eq(200)
|
68
|
+
expect(response_hash)
|
69
|
+
.to eq(JSON.parse(response_body))
|
70
|
+
expect(response_hash)
|
71
|
+
.to be_a Adyen::HashWithAccessors
|
72
|
+
expect(response_hash)
|
73
|
+
.to be_a_kind_of Hash
|
74
|
+
expect(response_hash['balance'])
|
75
|
+
.to eq('100')
|
76
76
|
end
|
77
77
|
|
78
78
|
# must be created manually due to payments/details format
|
79
|
-
it
|
80
|
-
request_body = JSON.parse(json_from_file(
|
81
|
-
|
82
|
-
response_body = json_from_file(
|
83
|
-
|
84
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
79
|
+
it 'makes a payments/details call' do
|
80
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payment-details.json'))
|
81
|
+
|
82
|
+
response_body = json_from_file('mocks/responses/Checkout/payment-details.json')
|
83
|
+
|
84
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/details',
|
85
|
+
@shared_values[:client].checkout.version)
|
86
|
+
WebMock.stub_request(:post, url)
|
87
|
+
.with(
|
88
|
+
body: request_body,
|
89
|
+
headers: {
|
90
|
+
'x-api-key' => @shared_values[:client].api_key
|
91
|
+
}
|
92
|
+
)
|
93
|
+
.to_return(
|
94
|
+
body: response_body
|
95
|
+
)
|
95
96
|
|
96
97
|
result = @shared_values[:client].checkout.payments_api.payments_details(request_body)
|
97
98
|
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
98
99
|
response_hash = result.response
|
99
100
|
|
100
|
-
expect(result.status)
|
101
|
-
to eq(200)
|
102
|
-
expect(response_hash)
|
103
|
-
to eq(JSON.parse(response_body))
|
104
|
-
expect(response_hash)
|
105
|
-
to be_a Adyen::HashWithAccessors
|
106
|
-
expect(response_hash)
|
107
|
-
to be_a_kind_of Hash
|
108
|
-
expect(response_hash[
|
109
|
-
to eq(
|
110
|
-
expect(response_hash.resultCode)
|
111
|
-
to eq(
|
101
|
+
expect(result.status)
|
102
|
+
.to eq(200)
|
103
|
+
expect(response_hash)
|
104
|
+
.to eq(JSON.parse(response_body))
|
105
|
+
expect(response_hash)
|
106
|
+
.to be_a Adyen::HashWithAccessors
|
107
|
+
expect(response_hash)
|
108
|
+
.to be_a_kind_of Hash
|
109
|
+
expect(response_hash['resultCode'])
|
110
|
+
.to eq('RedirectShopper')
|
111
|
+
expect(response_hash.resultCode)
|
112
|
+
.to eq('RedirectShopper')
|
112
113
|
end
|
113
114
|
|
114
115
|
# must be created manually due to payments/result format
|
115
|
-
it
|
116
|
-
request_body = JSON.parse(json_from_file(
|
117
|
-
|
118
|
-
response_body = json_from_file(
|
119
|
-
|
120
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
116
|
+
it 'makes a payments/result call' do
|
117
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payment-result.json'))
|
118
|
+
|
119
|
+
response_body = json_from_file('mocks/responses/Checkout/payment-result.json')
|
120
|
+
|
121
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/result',
|
122
|
+
@shared_values[:client].checkout.version)
|
123
|
+
WebMock.stub_request(:post, url)
|
124
|
+
.with(
|
125
|
+
body: request_body,
|
126
|
+
headers: {
|
127
|
+
'x-api-key' => @shared_values[:client].api_key
|
128
|
+
}
|
129
|
+
)
|
130
|
+
.to_return(
|
131
|
+
body: response_body
|
132
|
+
)
|
131
133
|
|
132
134
|
result = @shared_values[:client].checkout.classic_checkout_sdk_api.verify_payment_result(request_body)
|
133
135
|
response_hash = result.response
|
134
136
|
|
135
|
-
expect(result.status)
|
136
|
-
to eq(200)
|
137
|
-
expect(response_hash)
|
138
|
-
to eq(JSON.parse(response_body))
|
139
|
-
expect(response_hash)
|
140
|
-
to be_a Adyen::HashWithAccessors
|
141
|
-
expect(response_hash)
|
142
|
-
to be_a_kind_of Hash
|
143
|
-
expect(response_hash[
|
144
|
-
to eq(
|
145
|
-
expect(response_hash.resultCode)
|
146
|
-
to eq(
|
137
|
+
expect(result.status)
|
138
|
+
.to eq(200)
|
139
|
+
expect(response_hash)
|
140
|
+
.to eq(JSON.parse(response_body))
|
141
|
+
expect(response_hash)
|
142
|
+
.to be_a Adyen::HashWithAccessors
|
143
|
+
expect(response_hash)
|
144
|
+
.to be_a_kind_of Hash
|
145
|
+
expect(response_hash['resultCode'])
|
146
|
+
.to eq('Authorised')
|
147
|
+
expect(response_hash.resultCode)
|
148
|
+
.to eq('Authorised')
|
147
149
|
end
|
148
150
|
|
149
151
|
# must be created manually due to paymentsLinks format
|
150
|
-
it
|
151
|
-
request_body = JSON.parse(json_from_file(
|
152
|
-
|
153
|
-
response_body = json_from_file(
|
154
|
-
|
155
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
152
|
+
it 'makes a paymentLinks call' do
|
153
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payment_links.json'))
|
154
|
+
|
155
|
+
response_body = json_from_file('mocks/responses/Checkout/payment_links.json')
|
156
|
+
|
157
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'paymentLinks',
|
158
|
+
@shared_values[:client].checkout.version)
|
159
|
+
WebMock.stub_request(:post, url)
|
160
|
+
.with(
|
161
|
+
body: request_body,
|
162
|
+
headers: {
|
163
|
+
'x-api-key' => @shared_values[:client].api_key
|
164
|
+
}
|
165
|
+
)
|
166
|
+
.to_return(
|
167
|
+
body: response_body
|
168
|
+
)
|
166
169
|
|
167
170
|
result = @shared_values[:client].checkout.payment_links_api.payment_links(request_body)
|
168
171
|
response_hash = result.response
|
169
172
|
|
170
|
-
expect(result.status)
|
171
|
-
to eq(200)
|
172
|
-
expect(response_hash)
|
173
|
-
to eq(JSON.parse(response_body))
|
174
|
-
expect(response_hash)
|
175
|
-
to be_a Adyen::HashWithAccessors
|
176
|
-
expect(response_hash)
|
177
|
-
to be_a_kind_of Hash
|
173
|
+
expect(result.status)
|
174
|
+
.to eq(200)
|
175
|
+
expect(response_hash)
|
176
|
+
.to eq(JSON.parse(response_body))
|
177
|
+
expect(response_hash)
|
178
|
+
.to be_a Adyen::HashWithAccessors
|
179
|
+
expect(response_hash)
|
180
|
+
.to be_a_kind_of Hash
|
178
181
|
end
|
179
182
|
|
180
183
|
# must be created manually due to paymentsLinks/{linkId} format
|
181
|
-
it
|
182
|
-
response_body = json_from_file(
|
183
|
-
|
184
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
184
|
+
it 'makes a get paymentLinks/{linkId} call' do
|
185
|
+
response_body = json_from_file('mocks/responses/Checkout/get-payment-link.json')
|
186
|
+
|
187
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'paymentLinks/1',
|
188
|
+
@shared_values[:client].checkout.version)
|
189
|
+
WebMock.stub_request(:get, url)
|
190
|
+
.with(
|
191
|
+
headers: {
|
192
|
+
'x-api-key' => @shared_values[:client].api_key
|
193
|
+
}
|
194
|
+
)
|
195
|
+
.to_return(
|
196
|
+
body: response_body
|
197
|
+
)
|
198
|
+
|
199
|
+
result = @shared_values[:client].checkout.payment_links_api.get_payment_link('1')
|
196
200
|
response_hash = result.response
|
197
201
|
|
198
|
-
expect(result.status)
|
199
|
-
to eq(200)
|
200
|
-
expect(response_hash)
|
201
|
-
to eq(JSON.parse(response_body))
|
202
|
-
expect(response_hash)
|
203
|
-
to be_a Adyen::HashWithAccessors
|
204
|
-
expect(response_hash)
|
205
|
-
to be_a_kind_of Hash
|
206
|
-
expect(response_hash[
|
207
|
-
to eq(
|
208
|
-
expect(response_hash.id)
|
209
|
-
to eq(
|
202
|
+
expect(result.status)
|
203
|
+
.to eq(200)
|
204
|
+
expect(response_hash)
|
205
|
+
.to eq(JSON.parse(response_body))
|
206
|
+
expect(response_hash)
|
207
|
+
.to be_a Adyen::HashWithAccessors
|
208
|
+
expect(response_hash)
|
209
|
+
.to be_a_kind_of Hash
|
210
|
+
expect(response_hash['status'])
|
211
|
+
.to eq('active')
|
212
|
+
expect(response_hash.id)
|
213
|
+
.to eq('MockId')
|
210
214
|
end
|
211
215
|
|
212
216
|
# must be created manually due to paymentsLinks/{linkId} format
|
213
|
-
it
|
217
|
+
it 'makes a patch paymentLinks/{linkId} call' do
|
214
218
|
request_body = {
|
215
|
-
:
|
219
|
+
status: 'expired'
|
216
220
|
}
|
217
221
|
|
218
|
-
response_body = json_from_file(
|
219
|
-
|
220
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
222
|
+
response_body = json_from_file('mocks/responses/Checkout/update-payment-link.json')
|
223
|
+
|
224
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'paymentLinks/1',
|
225
|
+
@shared_values[:client].checkout.version)
|
226
|
+
WebMock.stub_request(:patch, url)
|
227
|
+
.with(
|
228
|
+
body: request_body,
|
229
|
+
headers: {
|
230
|
+
'x-api-key' => @shared_values[:client].api_key
|
231
|
+
}
|
232
|
+
)
|
233
|
+
.to_return(
|
234
|
+
body: response_body
|
235
|
+
)
|
236
|
+
|
237
|
+
result = @shared_values[:client].checkout.payment_links_api.update_payment_link(request_body, '1')
|
233
238
|
response_hash = result.response
|
234
239
|
|
235
|
-
expect(result.status)
|
236
|
-
to eq(200)
|
237
|
-
expect(response_hash)
|
238
|
-
to eq(JSON.parse(response_body))
|
239
|
-
expect(response_hash)
|
240
|
-
to be_a Adyen::HashWithAccessors
|
241
|
-
expect(response_hash)
|
242
|
-
to be_a_kind_of Hash
|
243
|
-
expect(response_hash[
|
244
|
-
to eq(
|
245
|
-
expect(response_hash.id)
|
246
|
-
to eq(
|
240
|
+
expect(result.status)
|
241
|
+
.to eq(200)
|
242
|
+
expect(response_hash)
|
243
|
+
.to eq(JSON.parse(response_body))
|
244
|
+
expect(response_hash)
|
245
|
+
.to be_a Adyen::HashWithAccessors
|
246
|
+
expect(response_hash)
|
247
|
+
.to be_a_kind_of Hash
|
248
|
+
expect(response_hash['status'])
|
249
|
+
.to eq('expired')
|
250
|
+
expect(response_hash.id)
|
251
|
+
.to eq('MockId')
|
247
252
|
end
|
248
253
|
|
249
|
-
it
|
250
|
-
request_body = JSON.parse(json_from_file(
|
254
|
+
it 'makes an orders call' do
|
255
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/orders.json'))
|
251
256
|
|
252
|
-
response_body = json_from_file(
|
257
|
+
response_body = json_from_file('mocks/responses/Checkout/orders.json')
|
253
258
|
|
254
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
259
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'orders',
|
260
|
+
@shared_values[:client].checkout.version)
|
261
|
+
WebMock.stub_request(:post, url)
|
262
|
+
.with(
|
263
|
+
body: request_body,
|
264
|
+
headers: {
|
265
|
+
'x-api-key' => @shared_values[:client].api_key
|
266
|
+
}
|
267
|
+
)
|
268
|
+
.to_return(
|
269
|
+
body: response_body
|
270
|
+
)
|
265
271
|
|
266
272
|
result = @shared_values[:client].checkout.orders_api.orders(request_body)
|
267
273
|
response_hash = result.response
|
268
274
|
|
269
|
-
expect(result.status)
|
270
|
-
to eq(200)
|
271
|
-
expect(response_hash)
|
272
|
-
to eq(JSON.parse(response_body))
|
273
|
-
expect(response_hash)
|
274
|
-
to be_a Adyen::HashWithAccessors
|
275
|
-
expect(response_hash)
|
276
|
-
to be_a_kind_of Hash
|
277
|
-
expect(response_hash[
|
278
|
-
to eq(100)
|
275
|
+
expect(result.status)
|
276
|
+
.to eq(200)
|
277
|
+
expect(response_hash)
|
278
|
+
.to eq(JSON.parse(response_body))
|
279
|
+
expect(response_hash)
|
280
|
+
.to be_a Adyen::HashWithAccessors
|
281
|
+
expect(response_hash)
|
282
|
+
.to be_a_kind_of Hash
|
283
|
+
expect(response_hash['remainingAmount']['value'])
|
284
|
+
.to eq(100)
|
279
285
|
end
|
280
286
|
|
281
|
-
it
|
282
|
-
request_body = JSON.parse(json_from_file(
|
287
|
+
it 'makes an orders/cancel call' do
|
288
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/orders_cancel.json'))
|
283
289
|
|
284
|
-
response_body = json_from_file(
|
290
|
+
response_body = json_from_file('mocks/responses/Checkout/orders_cancel.json')
|
285
291
|
|
286
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
292
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'orders/cancel',
|
293
|
+
@shared_values[:client].checkout.version)
|
294
|
+
WebMock.stub_request(:post, url)
|
295
|
+
.with(
|
296
|
+
body: request_body,
|
297
|
+
headers: {
|
298
|
+
'x-api-key' => @shared_values[:client].api_key
|
299
|
+
}
|
300
|
+
)
|
301
|
+
.to_return(
|
302
|
+
body: response_body
|
303
|
+
)
|
297
304
|
|
298
305
|
result = @shared_values[:client].checkout.orders_api.cancel_order(request_body)
|
299
306
|
response_hash = result.response
|
300
307
|
|
301
|
-
expect(result.status)
|
302
|
-
to eq(200)
|
303
|
-
expect(response_hash)
|
304
|
-
to eq(JSON.parse(response_body))
|
305
|
-
expect(response_hash)
|
306
|
-
to be_a Adyen::HashWithAccessors
|
307
|
-
expect(response_hash)
|
308
|
-
to be_a_kind_of Hash
|
309
|
-
expect(response_hash[
|
310
|
-
to eq(
|
308
|
+
expect(result.status)
|
309
|
+
.to eq(200)
|
310
|
+
expect(response_hash)
|
311
|
+
.to eq(JSON.parse(response_body))
|
312
|
+
expect(response_hash)
|
313
|
+
.to be_a Adyen::HashWithAccessors
|
314
|
+
expect(response_hash)
|
315
|
+
.to be_a_kind_of Hash
|
316
|
+
expect(response_hash['resultCode'])
|
317
|
+
.to eq('cancelled')
|
311
318
|
end
|
312
319
|
|
313
|
-
it
|
314
|
-
request_body = JSON.parse(json_from_file(
|
320
|
+
it 'makes an applePay/sessions call' do
|
321
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/apple_pay_sessions.json'))
|
315
322
|
|
316
|
-
response_body = json_from_file(
|
323
|
+
response_body = json_from_file('mocks/responses/Checkout/apple_pay_sessions.json')
|
317
324
|
|
318
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
325
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'applePay/sessions',
|
326
|
+
@shared_values[:client].checkout.version)
|
327
|
+
WebMock.stub_request(:post, url)
|
328
|
+
.with(
|
329
|
+
body: request_body,
|
330
|
+
headers: {
|
331
|
+
'x-api-key' => @shared_values[:client].api_key
|
332
|
+
}
|
333
|
+
)
|
334
|
+
.to_return(
|
335
|
+
body: response_body
|
336
|
+
)
|
329
337
|
|
330
338
|
result = @shared_values[:client].checkout.utility_api.get_apple_pay_session(request_body)
|
331
339
|
response_hash = result.response
|
332
340
|
|
333
|
-
expect(result.status)
|
334
|
-
to eq(200)
|
335
|
-
expect(response_hash)
|
336
|
-
to eq(JSON.parse(response_body))
|
337
|
-
expect(response_hash)
|
338
|
-
to be_a Adyen::HashWithAccessors
|
339
|
-
expect(response_hash)
|
340
|
-
to be_a_kind_of Hash
|
341
|
-
expect(response_hash[
|
342
|
-
to eq(
|
341
|
+
expect(result.status)
|
342
|
+
.to eq(200)
|
343
|
+
expect(response_hash)
|
344
|
+
.to eq(JSON.parse(response_body))
|
345
|
+
expect(response_hash)
|
346
|
+
.to be_a Adyen::HashWithAccessors
|
347
|
+
expect(response_hash)
|
348
|
+
.to be_a_kind_of Hash
|
349
|
+
expect(response_hash['data'])
|
350
|
+
.to eq('LARGE_BLOB_HERE')
|
343
351
|
end
|
344
352
|
|
345
|
-
it
|
346
|
-
request_body = JSON.parse(json_from_file(
|
353
|
+
it 'makes a sessions call' do
|
354
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/sessions.json'))
|
347
355
|
|
348
|
-
response_body = json_from_file(
|
356
|
+
response_body = json_from_file('mocks/responses/Checkout/sessions-success.json')
|
349
357
|
|
350
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
358
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'sessions',
|
359
|
+
@shared_values[:client].checkout.version)
|
360
|
+
WebMock.stub_request(:post, url)
|
361
|
+
.with(
|
362
|
+
body: request_body,
|
363
|
+
headers: {
|
364
|
+
'x-api-key' => @shared_values[:client].api_key
|
365
|
+
}
|
366
|
+
)
|
367
|
+
.to_return(body: response_body, status: 201)
|
359
368
|
|
360
369
|
result = @shared_values[:client].checkout.payments_api.sessions(request_body)
|
361
370
|
response_hash = result.response
|
362
371
|
|
363
|
-
expect(result.status)
|
364
|
-
to eq(201)
|
365
|
-
expect(response_hash)
|
366
|
-
to eq(JSON.parse(response_body))
|
367
|
-
expect(response_hash)
|
368
|
-
to be_a Adyen::HashWithAccessors
|
369
|
-
expect(response_hash)
|
370
|
-
to be_a_kind_of Hash
|
372
|
+
expect(result.status)
|
373
|
+
.to eq(201)
|
374
|
+
expect(response_hash)
|
375
|
+
.to eq(JSON.parse(response_body))
|
376
|
+
expect(response_hash)
|
377
|
+
.to be_a Adyen::HashWithAccessors
|
378
|
+
expect(response_hash)
|
379
|
+
.to be_a_kind_of Hash
|
371
380
|
end
|
372
381
|
|
373
|
-
it
|
374
|
-
request_body = JSON.parse(json_from_file(
|
375
|
-
|
376
|
-
response_body = json_from_file(
|
377
|
-
|
378
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
382
|
+
it 'makes a capture call' do
|
383
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/capture.json'))
|
384
|
+
|
385
|
+
response_body = json_from_file('mocks/responses/Checkout/capture.json')
|
386
|
+
|
387
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/12345/captures',
|
388
|
+
@shared_values[:client].checkout.version)
|
389
|
+
WebMock.stub_request(:post, url)
|
390
|
+
.with(
|
391
|
+
body: request_body,
|
392
|
+
headers: {
|
393
|
+
'x-api-key' => @shared_values[:client].api_key
|
394
|
+
}
|
395
|
+
)
|
396
|
+
.to_return(body: response_body, status: 201)
|
397
|
+
|
398
|
+
result = @shared_values[:client].checkout.modifications_api.capture_authorised_payment(request_body, '12345')
|
389
399
|
response_hash = result.response
|
390
|
-
|
391
|
-
expect(result.status)
|
392
|
-
to eq(201)
|
393
|
-
expect(response_hash)
|
394
|
-
to eq(JSON.parse(response_body))
|
395
|
-
expect(response_hash)
|
396
|
-
to be_a Adyen::HashWithAccessors
|
397
|
-
expect(response_hash)
|
398
|
-
to be_a_kind_of Hash
|
399
|
-
expect(response_hash.reference)
|
400
|
-
to eq(
|
401
|
-
expect(response_hash.pspReference)
|
402
|
-
to eq(
|
400
|
+
|
401
|
+
expect(result.status)
|
402
|
+
.to eq(201)
|
403
|
+
expect(response_hash)
|
404
|
+
.to eq(JSON.parse(response_body))
|
405
|
+
expect(response_hash)
|
406
|
+
.to be_a Adyen::HashWithAccessors
|
407
|
+
expect(response_hash)
|
408
|
+
.to be_a_kind_of Hash
|
409
|
+
expect(response_hash.reference)
|
410
|
+
.to eq('123456789')
|
411
|
+
expect(response_hash.pspReference)
|
412
|
+
.to eq('12345')
|
403
413
|
end
|
404
414
|
|
405
|
-
it
|
406
|
-
request_body = JSON.parse(json_from_file(
|
407
|
-
|
408
|
-
response_body = json_from_file(
|
409
|
-
|
410
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
415
|
+
it 'makes a psp specific cancel call' do
|
416
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/psp_cancel.json'))
|
417
|
+
|
418
|
+
response_body = json_from_file('mocks/responses/Checkout/psp_cancel.json')
|
419
|
+
|
420
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/12345/cancels',
|
421
|
+
@shared_values[:client].checkout.version)
|
422
|
+
WebMock.stub_request(:post, url)
|
423
|
+
.with(
|
424
|
+
body: request_body,
|
425
|
+
headers: {
|
426
|
+
'x-api-key' => @shared_values[:client].api_key
|
427
|
+
}
|
428
|
+
)
|
429
|
+
.to_return(body: response_body, status: 201)
|
430
|
+
|
431
|
+
result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment_by_psp_reference(
|
432
|
+
request_body, '12345'
|
433
|
+
)
|
421
434
|
response_hash = result.response
|
422
|
-
|
423
|
-
expect(result.status)
|
424
|
-
to eq(201)
|
425
|
-
expect(response_hash)
|
426
|
-
to eq(JSON.parse(response_body))
|
427
|
-
expect(response_hash)
|
428
|
-
to be_a Adyen::HashWithAccessors
|
429
|
-
expect(response_hash)
|
430
|
-
to be_a_kind_of Hash
|
431
|
-
expect(response_hash.reference)
|
432
|
-
to eq(
|
433
|
-
expect(response_hash.pspReference)
|
434
|
-
to eq(
|
435
|
+
|
436
|
+
expect(result.status)
|
437
|
+
.to eq(201)
|
438
|
+
expect(response_hash)
|
439
|
+
.to eq(JSON.parse(response_body))
|
440
|
+
expect(response_hash)
|
441
|
+
.to be_a Adyen::HashWithAccessors
|
442
|
+
expect(response_hash)
|
443
|
+
.to be_a_kind_of Hash
|
444
|
+
expect(response_hash.reference)
|
445
|
+
.to eq('123456789')
|
446
|
+
expect(response_hash.pspReference)
|
447
|
+
.to eq('12345')
|
435
448
|
end
|
436
449
|
|
437
|
-
it
|
438
|
-
request_body = JSON.parse(json_from_file(
|
439
|
-
|
440
|
-
response_body = json_from_file(
|
441
|
-
|
442
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
450
|
+
it 'makes a psp specific refunds call' do
|
451
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/refund.json'))
|
452
|
+
|
453
|
+
response_body = json_from_file('mocks/responses/Checkout/refund.json')
|
454
|
+
|
455
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/12345/refunds',
|
456
|
+
@shared_values[:client].checkout.version)
|
457
|
+
WebMock.stub_request(:post, url)
|
458
|
+
.with(
|
459
|
+
body: request_body,
|
460
|
+
headers: {
|
461
|
+
'x-api-key' => @shared_values[:client].api_key
|
462
|
+
}
|
463
|
+
)
|
464
|
+
.to_return(body: response_body, status: 201)
|
465
|
+
|
466
|
+
result = @shared_values[:client].checkout.modifications_api.refund_captured_payment(request_body, '12345')
|
453
467
|
response_hash = result.response
|
454
|
-
|
455
|
-
expect(result.status)
|
456
|
-
to eq(201)
|
457
|
-
expect(response_hash)
|
458
|
-
to eq(JSON.parse(response_body))
|
459
|
-
expect(response_hash)
|
460
|
-
to be_a Adyen::HashWithAccessors
|
461
|
-
expect(response_hash)
|
462
|
-
to be_a_kind_of Hash
|
463
|
-
expect(response_hash.reference)
|
464
|
-
to eq(
|
465
|
-
expect(response_hash.pspReference)
|
466
|
-
to eq(
|
468
|
+
|
469
|
+
expect(result.status)
|
470
|
+
.to eq(201)
|
471
|
+
expect(response_hash)
|
472
|
+
.to eq(JSON.parse(response_body))
|
473
|
+
expect(response_hash)
|
474
|
+
.to be_a Adyen::HashWithAccessors
|
475
|
+
expect(response_hash)
|
476
|
+
.to be_a_kind_of Hash
|
477
|
+
expect(response_hash.reference)
|
478
|
+
.to eq('123456789')
|
479
|
+
expect(response_hash.pspReference)
|
480
|
+
.to eq('12345')
|
467
481
|
end
|
468
482
|
|
469
|
-
it
|
470
|
-
request_body = JSON.parse(json_from_file(
|
471
|
-
|
472
|
-
response_body = json_from_file(
|
473
|
-
|
474
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
483
|
+
it 'makes a psp specific reversals call' do
|
484
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/psp_cancel.json'))
|
485
|
+
|
486
|
+
response_body = json_from_file('mocks/responses/Checkout/psp_cancel.json')
|
487
|
+
|
488
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/12345/reversals',
|
489
|
+
@shared_values[:client].checkout.version)
|
490
|
+
WebMock.stub_request(:post, url)
|
491
|
+
.with(
|
492
|
+
body: request_body,
|
493
|
+
headers: {
|
494
|
+
'x-api-key' => @shared_values[:client].api_key
|
495
|
+
}
|
496
|
+
)
|
497
|
+
.to_return(body: response_body, status: 201)
|
498
|
+
|
499
|
+
result = @shared_values[:client].checkout.modifications_api.refund_or_cancel_payment(request_body, '12345')
|
485
500
|
response_hash = result.response
|
486
|
-
|
487
|
-
expect(result.status)
|
488
|
-
to eq(201)
|
489
|
-
expect(response_hash)
|
490
|
-
to eq(JSON.parse(response_body))
|
491
|
-
expect(response_hash)
|
492
|
-
to be_a Adyen::HashWithAccessors
|
493
|
-
expect(response_hash)
|
494
|
-
to be_a_kind_of Hash
|
495
|
-
expect(response_hash.reference)
|
496
|
-
to eq(
|
497
|
-
expect(response_hash.pspReference)
|
498
|
-
to eq(
|
501
|
+
|
502
|
+
expect(result.status)
|
503
|
+
.to eq(201)
|
504
|
+
expect(response_hash)
|
505
|
+
.to eq(JSON.parse(response_body))
|
506
|
+
expect(response_hash)
|
507
|
+
.to be_a Adyen::HashWithAccessors
|
508
|
+
expect(response_hash)
|
509
|
+
.to be_a_kind_of Hash
|
510
|
+
expect(response_hash.reference)
|
511
|
+
.to eq('123456789')
|
512
|
+
expect(response_hash.pspReference)
|
513
|
+
.to eq('12345')
|
499
514
|
end
|
500
515
|
|
501
|
-
it
|
502
|
-
request_body = JSON.parse(json_from_file(
|
503
|
-
|
504
|
-
response_body = json_from_file(
|
505
|
-
|
506
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
516
|
+
it 'makes a psp specific amountUpdates call' do
|
517
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/amount_updates.json'))
|
518
|
+
|
519
|
+
response_body = json_from_file('mocks/responses/Checkout/amount_updates.json')
|
520
|
+
|
521
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'payments/12345/amountUpdates',
|
522
|
+
@shared_values[:client].checkout.version)
|
523
|
+
WebMock.stub_request(:post, url)
|
524
|
+
.with(
|
525
|
+
body: request_body,
|
526
|
+
headers: {
|
527
|
+
'x-api-key' => @shared_values[:client].api_key
|
528
|
+
}
|
529
|
+
)
|
530
|
+
.to_return(body: response_body, status: 201)
|
531
|
+
|
532
|
+
result = @shared_values[:client].checkout.modifications_api.update_authorised_amount(request_body, '12345')
|
517
533
|
response_hash = result.response
|
518
|
-
|
519
|
-
expect(result.status)
|
520
|
-
to eq(201)
|
521
|
-
expect(response_hash)
|
522
|
-
to eq(JSON.parse(response_body))
|
523
|
-
expect(response_hash)
|
524
|
-
to be_a Adyen::HashWithAccessors
|
525
|
-
expect(response_hash)
|
526
|
-
to be_a_kind_of Hash
|
527
|
-
expect(response_hash.reference)
|
528
|
-
to eq(
|
529
|
-
expect(response_hash.pspReference)
|
530
|
-
to eq(
|
534
|
+
|
535
|
+
expect(result.status)
|
536
|
+
.to eq(201)
|
537
|
+
expect(response_hash)
|
538
|
+
.to eq(JSON.parse(response_body))
|
539
|
+
expect(response_hash)
|
540
|
+
.to be_a Adyen::HashWithAccessors
|
541
|
+
expect(response_hash)
|
542
|
+
.to be_a_kind_of Hash
|
543
|
+
expect(response_hash.reference)
|
544
|
+
.to eq('123456789')
|
545
|
+
expect(response_hash.pspReference)
|
546
|
+
.to eq('12345')
|
531
547
|
end
|
532
548
|
|
533
|
-
it
|
534
|
-
request_body = JSON.parse(json_from_file(
|
535
|
-
|
536
|
-
response_body = json_from_file(
|
537
|
-
|
538
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
549
|
+
it 'makes a generic cancel call' do
|
550
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Checkout/generic_cancel.json'))
|
551
|
+
|
552
|
+
response_body = json_from_file('mocks/responses/Checkout/generic_cancel.json')
|
553
|
+
|
554
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'cancels',
|
555
|
+
@shared_values[:client].checkout.version)
|
556
|
+
WebMock.stub_request(:post, url)
|
557
|
+
.with(
|
558
|
+
body: request_body,
|
559
|
+
headers: {
|
560
|
+
'x-api-key' => @shared_values[:client].api_key
|
561
|
+
}
|
562
|
+
)
|
563
|
+
.to_return(body: response_body, status: 201)
|
564
|
+
|
548
565
|
result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment(request_body)
|
549
566
|
response_hash = result.response
|
550
|
-
|
551
|
-
expect(result.status)
|
552
|
-
to eq(201)
|
553
|
-
expect(response_hash)
|
554
|
-
to eq(JSON.parse(response_body))
|
555
|
-
expect(response_hash)
|
556
|
-
to be_a Adyen::HashWithAccessors
|
557
|
-
expect(response_hash)
|
558
|
-
to be_a_kind_of Hash
|
559
|
-
expect(response_hash.reference)
|
560
|
-
to eq(
|
561
|
-
expect(response_hash.pspReference)
|
562
|
-
to eq(
|
567
|
+
|
568
|
+
expect(result.status)
|
569
|
+
.to eq(201)
|
570
|
+
expect(response_hash)
|
571
|
+
.to eq(JSON.parse(response_body))
|
572
|
+
expect(response_hash)
|
573
|
+
.to be_a Adyen::HashWithAccessors
|
574
|
+
expect(response_hash)
|
575
|
+
.to be_a_kind_of Hash
|
576
|
+
expect(response_hash.reference)
|
577
|
+
.to eq('123456789')
|
578
|
+
expect(response_hash.pspReference)
|
579
|
+
.to eq('12345')
|
563
580
|
end
|
564
581
|
|
565
|
-
it
|
566
|
-
response_body = json_from_file(
|
567
|
-
|
568
|
-
url = @shared_values[:client].service_url(
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
582
|
+
it 'makes a get storedPaymentMethods call' do
|
583
|
+
response_body = json_from_file('mocks/responses/Checkout/stored_payment_methods.json')
|
584
|
+
|
585
|
+
url = @shared_values[:client].service_url(
|
586
|
+
@shared_values[:service],
|
587
|
+
'storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234',
|
588
|
+
@shared_values[:client].checkout.version
|
589
|
+
)
|
590
|
+
WebMock.stub_request(:get, url)
|
591
|
+
.with(
|
592
|
+
headers: {
|
593
|
+
'x-api-key' => @shared_values[:client].api_key
|
594
|
+
}
|
595
|
+
)
|
596
|
+
.to_return(
|
597
|
+
body: response_body
|
598
|
+
)
|
599
|
+
|
600
|
+
result = @shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(
|
601
|
+
query_params: {
|
602
|
+
'merchantAccount' => 'TestMerchantAccount',
|
603
|
+
'shopperReference' => 'test-1234'
|
604
|
+
}
|
605
|
+
)
|
580
606
|
response_hash = result.response
|
581
607
|
|
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[
|
591
|
-
to eq(
|
608
|
+
expect(result.status)
|
609
|
+
.to eq(200)
|
610
|
+
expect(response_hash)
|
611
|
+
.to eq(JSON.parse(response_body))
|
612
|
+
expect(response_hash)
|
613
|
+
.to be_a Adyen::HashWithAccessors
|
614
|
+
expect(response_hash)
|
615
|
+
.to be_a_kind_of Hash
|
616
|
+
expect(response_hash['shopperReference'])
|
617
|
+
.to eq('test-1234')
|
592
618
|
end
|
593
619
|
|
594
|
-
it
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
620
|
+
it 'makes a delete storedPaymentMethods call' do
|
621
|
+
url = @shared_values[:client].service_url(
|
622
|
+
@shared_values[:service],
|
623
|
+
'storedPaymentMethods/RL8FW7WZM6KXWD82?merchantAccount=TestMerchantAccount&shopperReference=test-1234',
|
624
|
+
@shared_values[:client].checkout.version
|
625
|
+
)
|
626
|
+
WebMock.stub_request(:delete, url)
|
627
|
+
.with(
|
628
|
+
headers: {
|
629
|
+
'x-api-key' => @shared_values[:client].api_key
|
630
|
+
}
|
631
|
+
)
|
632
|
+
.to_return(
|
633
|
+
body: '{}'
|
634
|
+
)
|
635
|
+
|
636
|
+
result = @shared_values[:client].checkout.recurring_api.delete_token_for_stored_payment_details(
|
637
|
+
'RL8FW7WZM6KXWD82',
|
638
|
+
query_params: {
|
639
|
+
'merchantAccount' => 'TestMerchantAccount',
|
640
|
+
'shopperReference' => 'test-1234'
|
641
|
+
}
|
642
|
+
)
|
643
|
+
result.response
|
644
|
+
|
645
|
+
expect(result.status)
|
646
|
+
.to eq(200)
|
612
647
|
end
|
613
648
|
|
614
|
-
it
|
615
|
-
response_body = json_from_file(
|
616
|
-
|
617
|
-
url = @shared_values[:client].service_url(
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
649
|
+
it 'tests sending the application headers' do
|
650
|
+
response_body = json_from_file('mocks/responses/Checkout/stored_payment_methods.json')
|
651
|
+
|
652
|
+
url = @shared_values[:client].service_url(
|
653
|
+
@shared_values[:service],
|
654
|
+
'storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234',
|
655
|
+
@shared_values[:client].checkout.version
|
656
|
+
)
|
657
|
+
WebMock.stub_request(:get, url)
|
658
|
+
.with(
|
659
|
+
headers: {
|
660
|
+
'x-api-key' => @shared_values[:client].api_key
|
661
|
+
}
|
662
|
+
)
|
663
|
+
.to_return(
|
664
|
+
body: response_body
|
665
|
+
)
|
666
|
+
|
667
|
+
@shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(query_params:
|
668
|
+
{
|
669
|
+
'merchantAccount' => 'TestMerchantAccount',
|
670
|
+
'shopperReference' => 'test-1234'
|
671
|
+
})
|
629
672
|
expect(
|
630
|
-
|
631
|
-
|
673
|
+
a_request(:get, 'http://localhost:3001/v70/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234')
|
674
|
+
.with(headers: {
|
675
|
+
'Accept' => '*/*',
|
676
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
677
|
+
'Adyen-Library-Name' => 'adyen-ruby-api-library',
|
678
|
+
'Adyen-Library-Version' => Adyen::VERSION,
|
679
|
+
'Content-Type' => 'application/json',
|
680
|
+
'User-Agent' => 'adyen-ruby-api-library/' + Adyen::VERSION,
|
681
|
+
'X-Api-Key' => 'api_key'
|
682
|
+
})
|
632
683
|
).to have_been_made.once
|
633
684
|
end
|
634
685
|
|
686
|
+
# must be created manually because every field in the response is an array
|
687
|
+
it 'makes a LIVE paymentMethods call' do
|
688
|
+
JSON.parse(json_from_file('mocks/requests/Checkout/payment_methods.json'))
|
689
|
+
|
690
|
+
json_from_file('mocks/responses/Checkout/payment_methods.json')
|
691
|
+
|
692
|
+
adyen = Adyen::Client.new
|
693
|
+
adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
|
694
|
+
adyen.env = :live
|
695
|
+
adyen.live_url_prefix = 'prefix'
|
696
|
+
url = adyen.service_url('Checkout', 'paymentMethods', @shared_values[:client].checkout.version)
|
697
|
+
|
698
|
+
expect(url)
|
699
|
+
.to eq('https://prefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods')
|
700
|
+
end
|
635
701
|
end
|
636
702
|
|
637
703
|
# rubocop:enable Metrics/BlockLength
|