adyen-ruby-api-library 7.0.0 → 7.0.2

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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/release.yml +18 -0
  4. data/.github/workflows/gh_release.yml +16 -0
  5. data/.github/workflows/release_request.yml +15 -0
  6. data/.github/workflows/ruby.yml +1 -1
  7. data/.github/workflows/services.yml +28 -0
  8. data/.rubocop.yml +8 -0
  9. data/Gemfile +7 -7
  10. data/Makefile +14 -10
  11. data/README.md +13 -10
  12. data/Rakefile +3 -3
  13. data/adyen-ruby-api-library.gemspec +6 -3
  14. data/bin/console +2 -2
  15. data/lib/adyen/client.rb +96 -76
  16. data/lib/adyen/errors.rb +23 -18
  17. data/lib/adyen/hash_with_accessors.rb +12 -7
  18. data/lib/adyen/services/balanceControlService.rb +7 -14
  19. data/lib/adyen/services/balancePlatform/account_holders_api.rb +22 -38
  20. data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +48 -79
  21. data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +6 -13
  22. data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +6 -13
  23. data/lib/adyen/services/balancePlatform/grant_offers_api.rb +12 -22
  24. data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +16 -29
  25. data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +26 -45
  26. data/lib/adyen/services/balancePlatform/platform_api.rb +12 -22
  27. data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +21 -37
  28. data/lib/adyen/services/balancePlatform.rb +38 -40
  29. data/lib/adyen/services/binLookup.rb +12 -22
  30. data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +11 -21
  31. data/lib/adyen/services/checkout/modifications_api.rb +31 -53
  32. data/lib/adyen/services/checkout/orders_api.rb +16 -29
  33. data/lib/adyen/services/checkout/payment_links_api.rb +16 -29
  34. data/lib/adyen/services/checkout/payments_api.rb +40 -53
  35. data/lib/adyen/services/checkout/recurring_api.rb +13 -23
  36. data/lib/adyen/services/checkout/utility_api.rb +11 -21
  37. data/lib/adyen/services/checkout.rb +32 -34
  38. data/lib/adyen/services/dataProtection.rb +7 -14
  39. data/lib/adyen/services/dispute.rb +6 -5
  40. data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +21 -37
  41. data/lib/adyen/services/legalEntityManagement/documents_api.rb +21 -37
  42. data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +16 -29
  43. data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +26 -45
  44. data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +21 -37
  45. data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +25 -29
  46. data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +21 -37
  47. data/lib/adyen/services/legalEntityManagement.rb +32 -34
  48. data/lib/adyen/services/management/account_company_level_api.rb +18 -31
  49. data/lib/adyen/services/management/account_merchant_level_api.rb +22 -38
  50. data/lib/adyen/services/management/account_store_level_api.rb +43 -71
  51. data/lib/adyen/services/management/allowed_origins_company_level_api.rb +21 -37
  52. data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +21 -37
  53. data/lib/adyen/services/management/api_credentials_company_level_api.rb +22 -38
  54. data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +22 -38
  55. data/lib/adyen/services/management/api_key_company_level_api.rb +6 -13
  56. data/lib/adyen/services/management/api_key_merchant_level_api.rb +6 -13
  57. data/lib/adyen/services/management/client_key_company_level_api.rb +6 -13
  58. data/lib/adyen/services/management/client_key_merchant_level_api.rb +6 -13
  59. data/lib/adyen/services/management/my_api_credential_api.rb +26 -45
  60. data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +32 -54
  61. data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +26 -45
  62. data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +92 -0
  63. data/lib/adyen/services/management/terminal_actions_company_level_api.rb +24 -40
  64. data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +6 -13
  65. data/lib/adyen/services/management/terminal_orders_company_level_api.rb +55 -89
  66. data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +55 -89
  67. data/lib/adyen/services/management/terminal_settings_company_level_api.rb +23 -39
  68. data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +23 -39
  69. data/lib/adyen/services/management/terminal_settings_store_level_api.rb +45 -73
  70. data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +21 -37
  71. data/lib/adyen/services/management/terminals_terminal_level_api.rb +7 -14
  72. data/lib/adyen/services/management/users_company_level_api.rb +22 -38
  73. data/lib/adyen/services/management/users_merchant_level_api.rb +22 -38
  74. data/lib/adyen/services/management/webhooks_company_level_api.rb +37 -62
  75. data/lib/adyen/services/management/webhooks_merchant_level_api.rb +37 -62
  76. data/lib/adyen/services/management.rb +99 -96
  77. data/lib/adyen/services/marketpay.rb +42 -36
  78. data/lib/adyen/services/payment/general_api.rb +56 -0
  79. data/lib/adyen/services/payment/modifications_api.rb +83 -0
  80. data/lib/adyen/services/payment.rb +10 -158
  81. data/lib/adyen/services/payout/initialization_api.rb +16 -29
  82. data/lib/adyen/services/payout/instant_payouts_api.rb +6 -13
  83. data/lib/adyen/services/payout/reviewing_api.rb +11 -21
  84. data/lib/adyen/services/payout.rb +19 -21
  85. data/lib/adyen/services/posTerminalManagement.rb +27 -46
  86. data/lib/adyen/services/recurring.rb +32 -54
  87. data/lib/adyen/services/service.rb +5 -4
  88. data/lib/adyen/services/storedValue.rb +32 -54
  89. data/lib/adyen/services/transfers/capital_api.rb +38 -0
  90. data/lib/adyen/services/transfers/transactions_api.rb +12 -22
  91. data/lib/adyen/services/transfers/transfers_api.rb +6 -13
  92. data/lib/adyen/services/transfers.rb +20 -17
  93. data/lib/adyen/utils/hmac_validator.rb +9 -9
  94. data/lib/adyen/version.rb +3 -3
  95. data/lib/adyen-ruby-api-library.rb +21 -21
  96. data/spec/account_spec.rb +20 -20
  97. data/spec/balance_control_spec.rb +28 -29
  98. data/spec/balance_platform_spec.rb +108 -102
  99. data/spec/bin_lookup_spec.rb +50 -50
  100. data/spec/checkout_spec.rb +581 -515
  101. data/spec/client_spec.rb +118 -71
  102. data/spec/data_protection_spec.rb +4 -4
  103. data/spec/dispute_spec.rb +7 -7
  104. data/spec/errors_spec.rb +37 -17
  105. data/spec/fund_spec.rb +10 -10
  106. data/spec/hash_with_accessors_spec.rb +18 -8
  107. data/spec/hop_spec.rb +4 -4
  108. data/spec/lem_spec.rb +44 -49
  109. data/spec/management_spec.rb +46 -48
  110. data/spec/notification_spec.rb +9 -9
  111. data/spec/payments_spec.rb +31 -32
  112. data/spec/payouts_spec.rb +29 -32
  113. data/spec/pos_terminal_management_spec.rb +30 -32
  114. data/spec/recurring_spec.rb +8 -8
  115. data/spec/service_spec.rb +4 -0
  116. data/spec/spec_helper.rb +37 -35
  117. data/spec/stored_value_spec.rb +28 -27
  118. data/spec/transfers_spec.rb +48 -47
  119. data/spec/utils/hmac_validator_spec.rb +15 -14
  120. data/templates/api-single.mustache +13 -15
  121. data/templates/api-small.mustache +8 -15
  122. data/templates/api.mustache +7 -14
  123. metadata +27 -18
  124. data/.github/dependabot.yml +0 -8
  125. /data/spec/mocks/responses/Webhooks/{backslash_notification.json → backslash_webhook.json} +0 -0
  126. /data/spec/mocks/responses/Webhooks/{colon_notification.json → colon_webhook.json} +0 -0
  127. /data/spec/mocks/responses/Webhooks/{forwardslash_notification.json → forwardslash_webhook.json} +0 -0
  128. /data/spec/mocks/responses/Webhooks/{mixed_notification.json → mixed_webhook.json} +0 -0
@@ -1,637 +1,703 @@
1
- require "spec_helper"
2
- require "json"
1
+ require 'spec_helper'
2
+ require 'json'
3
3
 
4
- # rubocop:disable Metrics/BlockLength
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: "Checkout",
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 "makes a payment_methods call" do
16
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods.json"))
17
-
18
- response_body = json_from_file("mocks/responses/Checkout/payment_methods.json")
19
-
20
- url = @shared_values[:client].service_url(@shared_values[:service], "paymentMethods", @shared_values[:client].checkout.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
- )
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 "makes a paymentMethods/balance call" do
46
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods_balance.json"))
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("mocks/responses/Checkout/payment_methods_balance.json")
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], "paymentMethods/balance", @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
- )
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["balance"]).
75
- to eq("100")
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 "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", @shared_values[:client].checkout.version)
85
- WebMock.stub_request(:post, url).
86
- with(
87
- body: request_body,
88
- headers: {
89
- "x-api-key" => @shared_values[:client].api_key
90
- }
91
- ).
92
- to_return(
93
- body: response_body
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["resultCode"]).
109
- to eq("RedirectShopper")
110
- expect(response_hash.resultCode).
111
- to eq("RedirectShopper")
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 "makes a payments/result call" do
116
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment-result.json"))
117
-
118
- response_body = json_from_file("mocks/responses/Checkout/payment-result.json")
119
-
120
- url = @shared_values[:client].service_url(@shared_values[:service], "payments/result", @shared_values[:client].checkout.version)
121
- WebMock.stub_request(:post, url).
122
- with(
123
- body: request_body,
124
- headers: {
125
- "x-api-key" => @shared_values[:client].api_key
126
- }
127
- ).
128
- to_return(
129
- body: response_body
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["resultCode"]).
144
- to eq("Authorised")
145
- expect(response_hash.resultCode).
146
- to eq("Authorised")
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 "makes a paymentLinks call" do
151
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_links.json"))
152
-
153
- response_body = json_from_file("mocks/responses/Checkout/payment_links.json")
154
-
155
- url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks", @shared_values[:client].checkout.version)
156
- WebMock.stub_request(:post, url).
157
- with(
158
- body: request_body,
159
- headers: {
160
- "x-api-key" => @shared_values[:client].api_key
161
- }
162
- ).
163
- to_return(
164
- body: response_body
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 "makes a get paymentLinks/{linkId} call" do
182
- response_body = json_from_file("mocks/responses/Checkout/get-payment-link.json")
183
-
184
- url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
185
- WebMock.stub_request(:get, url).
186
- with(
187
- headers: {
188
- "x-api-key" => @shared_values[:client].api_key
189
- }
190
- ).
191
- to_return(
192
- body: response_body
193
- )
194
-
195
- result = @shared_values[:client].checkout.payment_links_api.get_payment_link("1")
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["status"]).
207
- to eq("active")
208
- expect(response_hash.id).
209
- to eq("MockId")
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 "makes a patch paymentLinks/{linkId} call" do
217
+ it 'makes a patch paymentLinks/{linkId} call' do
214
218
  request_body = {
215
- :status => "expired",
219
+ status: 'expired'
216
220
  }
217
221
 
218
- response_body = json_from_file("mocks/responses/Checkout/update-payment-link.json")
219
-
220
- url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
221
- WebMock.stub_request(:patch, url).
222
- with(
223
- body: request_body,
224
- headers: {
225
- "x-api-key" => @shared_values[:client].api_key
226
- }
227
- ).
228
- to_return(
229
- body: response_body
230
- )
231
-
232
- result = @shared_values[:client].checkout.payment_links_api.update_payment_link(request_body, "1")
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["status"]).
244
- to eq("expired")
245
- expect(response_hash.id).
246
- to eq("MockId")
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 "makes an orders call" do
250
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/orders.json"))
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("mocks/responses/Checkout/orders.json")
257
+ response_body = json_from_file('mocks/responses/Checkout/orders.json')
253
258
 
254
- url = @shared_values[:client].service_url(@shared_values[:service], "orders", @shared_values[:client].checkout.version)
255
- WebMock.stub_request(:post, url).
256
- with(
257
- body: request_body,
258
- headers: {
259
- "x-api-key" => @shared_values[:client].api_key
260
- }
261
- ).
262
- to_return(
263
- body: response_body
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["remainingAmount"]["value"]).
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 "makes an orders/cancel call" do
282
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/orders_cancel.json"))
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("mocks/responses/Checkout/orders_cancel.json")
290
+ response_body = json_from_file('mocks/responses/Checkout/orders_cancel.json')
285
291
 
286
- url = @shared_values[:client].service_url(@shared_values[:service], "orders/cancel", @shared_values[:client].checkout.version)
287
- WebMock.stub_request(:post, url).
288
- with(
289
- body: request_body,
290
- headers: {
291
- "x-api-key" => @shared_values[:client].api_key
292
- }
293
- ).
294
- to_return(
295
- body: response_body
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["resultCode"]).
310
- to eq("cancelled")
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 "makes an applePay/sessions call" do
314
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/apple_pay_sessions.json"))
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("mocks/responses/Checkout/apple_pay_sessions.json")
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], "applePay/sessions", @shared_values[:client].checkout.version)
319
- WebMock.stub_request(:post, url).
320
- with(
321
- body: request_body,
322
- headers: {
323
- "x-api-key" => @shared_values[:client].api_key
324
- }
325
- ).
326
- to_return(
327
- body: response_body
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["data"]).
342
- to eq("LARGE_BLOB_HERE")
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 "makes a sessions call" do
346
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/sessions.json"))
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("mocks/responses/Checkout/sessions-success.json")
356
+ response_body = json_from_file('mocks/responses/Checkout/sessions-success.json')
349
357
 
350
- url = @shared_values[:client].service_url(@shared_values[:service], "sessions", @shared_values[:client].checkout.version)
351
- WebMock.stub_request(:post, url).
352
- with(
353
- body: request_body,
354
- headers: {
355
- "x-api-key" => @shared_values[:client].api_key
356
- }
357
- )
358
- .to_return(body: response_body, status: 201)
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 "makes a capture call" do
374
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/capture.json"))
375
-
376
- response_body = json_from_file("mocks/responses/Checkout/capture.json")
377
-
378
- url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/captures", @shared_values[:client].checkout.version)
379
- WebMock.stub_request(:post, url).
380
- with(
381
- body: request_body,
382
- headers: {
383
- "x-api-key" => @shared_values[:client].api_key
384
- }
385
- )
386
- .to_return(body: response_body, status: 201)
387
-
388
- result = @shared_values[:client].checkout.modifications_api.capture_authorised_payment(request_body, "12345")
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("123456789")
401
- expect(response_hash.pspReference).
402
- to eq("12345")
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 "makes a psp specific cancel call" do
406
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json"))
407
-
408
- response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json")
409
-
410
- url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/cancels", @shared_values[:client].checkout.version)
411
- WebMock.stub_request(:post, url).
412
- with(
413
- body: request_body,
414
- headers: {
415
- "x-api-key" => @shared_values[:client].api_key
416
- }
417
- )
418
- .to_return(body: response_body, status: 201)
419
-
420
- result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment_by_psp_reference(request_body, "12345")
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("123456789")
433
- expect(response_hash.pspReference).
434
- to eq("12345")
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 "makes a psp specific refunds call" do
438
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/refund.json"))
439
-
440
- response_body = json_from_file("mocks/responses/Checkout/refund.json")
441
-
442
- url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/refunds", @shared_values[:client].checkout.version)
443
- WebMock.stub_request(:post, url).
444
- with(
445
- body: request_body,
446
- headers: {
447
- "x-api-key" => @shared_values[:client].api_key
448
- }
449
- )
450
- .to_return(body: response_body, status: 201)
451
-
452
- result = @shared_values[:client].checkout.modifications_api.refund_captured_payment(request_body, "12345")
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("123456789")
465
- expect(response_hash.pspReference).
466
- to eq("12345")
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 "makes a psp specific reversals call" do
470
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json"))
471
-
472
- response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json")
473
-
474
- url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/reversals", @shared_values[:client].checkout.version)
475
- WebMock.stub_request(:post, url).
476
- with(
477
- body: request_body,
478
- headers: {
479
- "x-api-key" => @shared_values[:client].api_key
480
- }
481
- )
482
- .to_return(body: response_body, status: 201)
483
-
484
- result = @shared_values[:client].checkout.modifications_api.refund_or_cancel_payment(request_body, "12345")
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("123456789")
497
- expect(response_hash.pspReference).
498
- to eq("12345")
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 "makes a psp specific amountUpdates call" do
502
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/amount_updates.json"))
503
-
504
- response_body = json_from_file("mocks/responses/Checkout/amount_updates.json")
505
-
506
- url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/amountUpdates", @shared_values[:client].checkout.version)
507
- WebMock.stub_request(:post, url).
508
- with(
509
- body: request_body,
510
- headers: {
511
- "x-api-key" => @shared_values[:client].api_key
512
- }
513
- )
514
- .to_return(body: response_body, status: 201)
515
-
516
- result = @shared_values[:client].checkout.modifications_api.update_authorised_amount(request_body, "12345")
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("123456789")
529
- expect(response_hash.pspReference).
530
- to eq("12345")
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 "makes a generic cancel call" do
534
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/generic_cancel.json"))
535
-
536
- response_body = json_from_file("mocks/responses/Checkout/generic_cancel.json")
537
-
538
- url = @shared_values[:client].service_url(@shared_values[:service], "cancels", @shared_values[:client].checkout.version)
539
- WebMock.stub_request(:post, url).
540
- with(
541
- body: request_body,
542
- headers: {
543
- "x-api-key" => @shared_values[:client].api_key
544
- }
545
- )
546
- .to_return(body: response_body, status: 201)
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("123456789")
561
- expect(response_hash.pspReference).
562
- to eq("12345")
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 "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"})
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["shopperReference"]).
591
- to eq("test-1234")
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 "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)
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 "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"})
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
- 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'})
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