adyen-ruby-api-library 4.3.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/workflows/ruby.yml +20 -0
- data/.gitignore +4 -0
- data/README.md +73 -124
- data/docs/marketpay.html +2 -0
- data/lib/adyen/client.rb +43 -24
- data/lib/adyen/services/{checkout_utility.rb → bin_lookup.rb} +6 -4
- data/lib/adyen/services/checkout.rb +89 -8
- data/lib/adyen/services/dispute.rb +20 -0
- data/lib/adyen/services/marketpay.rb +10 -7
- data/lib/adyen/services/payments.rb +14 -5
- data/lib/adyen/services/payouts.rb +3 -2
- data/lib/adyen/services/recurring.rb +3 -2
- data/lib/adyen/services/service.rb +2 -2
- data/lib/adyen/version.rb +1 -1
- data/lib/adyen-ruby-api-library.rb +2 -1
- data/spec/account_spec.rb +4 -1
- data/spec/bin_lookup_spec.rb +15 -0
- data/spec/checkout_spec.rb +275 -5
- data/spec/dispute_spec.rb +17 -0
- data/spec/fund_spec.rb +2 -1
- data/spec/mocks/requests/Account/check_account_holder.json +5 -0
- data/spec/mocks/requests/Account/delete_payout_methods.json +6 -0
- data/spec/mocks/requests/Account/delete_signatories.json +6 -0
- data/spec/mocks/requests/BinLookup/get_3ds_availability.json +4 -0
- data/spec/mocks/requests/BinLookup/get_cost_estimate.json +8 -0
- data/spec/mocks/requests/Checkout/orders.json +6 -0
- data/spec/mocks/requests/Checkout/orders_cancel.json +7 -0
- data/spec/mocks/requests/Checkout/origin_keys.json +3 -0
- data/spec/mocks/requests/Checkout/payment_methods_balance.json +9 -0
- data/spec/mocks/requests/Checkout/sessions.json +10 -0
- data/spec/mocks/requests/DisputeService/defend_dispute.json +5 -0
- data/spec/mocks/requests/DisputeService/delete_dispute_defense_document.json +5 -0
- data/spec/mocks/requests/DisputeService/retrieve_applicable_defense_reasons.json +4 -0
- data/spec/mocks/requests/DisputeService/supply_defense_document.json +11 -0
- data/spec/mocks/requests/Fund/refund_funds_transfer.json +7 -0
- data/spec/mocks/requests/Payment/get_authentication_result.json +4 -0
- data/spec/mocks/requests/Payment/retrieve_3ds2_result.json +4 -0
- data/spec/mocks/requests/Payment/technical_cancel.json +4 -0
- data/spec/mocks/requests/Payment/void_pending_refund.json +4 -0
- data/spec/mocks/requests/Payout/payout.json +8 -0
- data/spec/mocks/requests/Recurring/schedule_account_updater.json +12 -0
- data/spec/mocks/responses/Account/check_account_holder.json +3 -0
- data/spec/mocks/responses/Account/delete_payout_methods.json +3 -0
- data/spec/mocks/responses/Account/delete_signatories.json +3 -0
- data/spec/mocks/responses/BinLookup/get_3ds_availability.json +8 -0
- data/spec/mocks/responses/BinLookup/get_cost_estimate.json +8 -0
- data/spec/mocks/responses/Checkout/get-payment-link.json +11 -0
- data/spec/mocks/responses/Checkout/orders.json +8 -0
- data/spec/mocks/responses/Checkout/orders_cancel.json +4 -0
- data/spec/mocks/responses/Checkout/origin_keys.json +5 -0
- data/spec/mocks/responses/Checkout/payment_methods_balance.json +3 -0
- data/spec/mocks/responses/Checkout/sessions-success.json +11 -0
- data/spec/mocks/responses/Checkout/update-payment-link.json +11 -0
- data/spec/mocks/responses/DisputeService/defend_dispute.json +5 -0
- data/spec/mocks/responses/DisputeService/delete_dispute_defense_document.json +5 -0
- data/spec/mocks/responses/DisputeService/retrieve_applicable_defense_reasons.json +28 -0
- data/spec/mocks/responses/DisputeService/supply_defense_document.json +5 -0
- data/spec/mocks/responses/Fund/refund_funds_transfer.json +5 -0
- data/spec/mocks/responses/Payment/get_authentication_result.json +5 -0
- data/spec/mocks/responses/Payment/retrieve_3ds2_result.json +5 -0
- data/spec/mocks/responses/Payment/technical_cancel.json +3 -0
- data/spec/mocks/responses/Payment/void_pending_refund.json +3 -0
- data/spec/mocks/responses/Payout/payout.json +3 -0
- data/spec/mocks/responses/Recurring/schedule_account_updater.json +4 -0
- data/spec/payments_spec.rb +5 -1
- data/spec/payouts_spec.rb +2 -1
- data/spec/recurring_spec.rb +2 -1
- data/spec/service_spec.rb +1 -0
- data/spec/spec_helper.rb +18 -12
- metadata +52 -8
- data/.travis.yml +0 -14
- data/spec/checkout_utility_spec.rb +0 -29
- data/spec/mocks/requests/CheckoutUtility/origin_keys.json +0 -7
- data/spec/mocks/responses/CheckoutUtility/origin_keys.json +0 -7
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "service"
|
2
2
|
|
3
3
|
module Adyen
|
4
4
|
class Payments < Service
|
5
5
|
attr_accessor :version
|
6
|
-
DEFAULT_VERSION =
|
6
|
+
DEFAULT_VERSION = 64
|
7
7
|
|
8
8
|
def initialize(client, version = DEFAULT_VERSION)
|
9
|
-
service =
|
9
|
+
service = "Payment"
|
10
10
|
method_names = [
|
11
11
|
:authorise,
|
12
12
|
:authorise3d,
|
@@ -16,10 +16,19 @@ module Adyen
|
|
16
16
|
:refund,
|
17
17
|
:cancel_or_refund,
|
18
18
|
:adjust_authorisation,
|
19
|
-
:donate
|
19
|
+
:donate,
|
20
|
+
:get_authentication_result,
|
21
|
+
:technical_cancel,
|
22
|
+
:void_pending_refund,
|
23
|
+
:retrieve_3ds2_result
|
24
|
+
]
|
25
|
+
with_application_info = [
|
26
|
+
:authorise,
|
27
|
+
:authorise3d,
|
28
|
+
:authorise3ds2
|
20
29
|
]
|
21
30
|
|
22
|
-
super(client, version, service, method_names)
|
31
|
+
super(client, version, service, method_names, with_application_info)
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
@@ -3,7 +3,7 @@ require_relative 'service'
|
|
3
3
|
module Adyen
|
4
4
|
class Payouts < Service
|
5
5
|
attr_accessor :version
|
6
|
-
DEFAULT_VERSION =
|
6
|
+
DEFAULT_VERSION = 64
|
7
7
|
|
8
8
|
def initialize(client, version = DEFAULT_VERSION)
|
9
9
|
service = 'Payout'
|
@@ -12,7 +12,8 @@ module Adyen
|
|
12
12
|
:store_detail_and_submit_third_party,
|
13
13
|
:submit_third_party,
|
14
14
|
:confirm_third_party,
|
15
|
-
:decline_third_party
|
15
|
+
:decline_third_party,
|
16
|
+
:payout
|
16
17
|
]
|
17
18
|
|
18
19
|
super(client, version, service, method_names)
|
@@ -3,14 +3,15 @@ require_relative 'service'
|
|
3
3
|
module Adyen
|
4
4
|
class Recurring < Service
|
5
5
|
attr_accessor :version
|
6
|
-
DEFAULT_VERSION =
|
6
|
+
DEFAULT_VERSION = 49
|
7
7
|
|
8
8
|
def initialize(client, version = DEFAULT_VERSION)
|
9
9
|
service = 'Recurring'
|
10
10
|
method_names = [
|
11
11
|
:list_recurring_details,
|
12
12
|
:disable,
|
13
|
-
:store_token
|
13
|
+
:store_token,
|
14
|
+
:schedule_account_updater
|
14
15
|
]
|
15
16
|
|
16
17
|
super(client, version, service, method_names)
|
@@ -11,7 +11,7 @@ module Adyen
|
|
11
11
|
method_name.to_s.gsub(/_./) { |x| x[1].upcase }
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(client, version, service, method_names)
|
14
|
+
def initialize(client, version, service, method_names, with_application_info = [])
|
15
15
|
@client = client
|
16
16
|
@version = version
|
17
17
|
@service = service
|
@@ -20,7 +20,7 @@ module Adyen
|
|
20
20
|
method_names.each do |method_name|
|
21
21
|
define_singleton_method method_name do |request, headers = {}|
|
22
22
|
action = self.class.action_for_method_name(method_name)
|
23
|
-
@client.call_adyen_api(@service, action, request, headers, @version)
|
23
|
+
@client.call_adyen_api(@service, action, request, headers, @version, with_application_info.include?(method_name))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/adyen/version.rb
CHANGED
@@ -2,7 +2,6 @@ require_relative "adyen/version"
|
|
2
2
|
require_relative "adyen/client"
|
3
3
|
require_relative "adyen/errors"
|
4
4
|
require_relative "adyen/services/checkout"
|
5
|
-
require_relative "adyen/services/checkout_utility"
|
6
5
|
require_relative "adyen/services/payments"
|
7
6
|
require_relative "adyen/services/payouts"
|
8
7
|
require_relative "adyen/services/recurring"
|
@@ -10,5 +9,7 @@ require_relative "adyen/services/marketpay"
|
|
10
9
|
require_relative "adyen/services/postfmapi"
|
11
10
|
require_relative "adyen/services/service"
|
12
11
|
require_relative "adyen/services/data_protection"
|
12
|
+
require_relative "adyen/services/dispute"
|
13
|
+
require_relative "adyen/services/bin_lookup"
|
13
14
|
require_relative "adyen/hash_with_accessors"
|
14
15
|
require_relative "adyen/utils/hmac_validator"
|
data/spec/account_spec.rb
CHANGED
@@ -20,7 +20,10 @@ RSpec.describe Adyen::Payments, service: "marketpay account service" do
|
|
20
20
|
["upload_document", "pspReference", "9914762681460244"],
|
21
21
|
["get_uploaded_documents", "pspReference", "9914694369860322"],
|
22
22
|
["delete_bank_accounts", "pspReference", "9914694372670551"],
|
23
|
-
["delete_shareholders", "pspReference", "9914694372990637"]
|
23
|
+
["delete_shareholders", "pspReference", "9914694372990637"],
|
24
|
+
["delete_signatories", "pspReference", "9914694372990637"],
|
25
|
+
["delete_payout_methods", "pspReference", "9914694372990637"],
|
26
|
+
["check_account_holder", "pspReference", "9914694372990637"],
|
24
27
|
]
|
25
28
|
|
26
29
|
generate_tests(client, "Account", test_sets, client.marketpay.account)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Adyen::BinLookup, service: "BIN lookup service" do
|
4
|
+
# client instance to be used in dynamically generated tests
|
5
|
+
client = create_client(:basic)
|
6
|
+
|
7
|
+
# methods / values to test for
|
8
|
+
# format is defined in spec_helper
|
9
|
+
test_sets = [
|
10
|
+
["get_3ds_availability", "threeDS2supported", false],
|
11
|
+
["get_cost_estimate", "resultCode", "Success"]
|
12
|
+
]
|
13
|
+
|
14
|
+
generate_tests(client, "BinLookup", test_sets, client.bin_lookup)
|
15
|
+
end
|
data/spec/checkout_spec.rb
CHANGED
@@ -13,9 +13,79 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
13
13
|
|
14
14
|
# must be created manually because every field in the response is an array
|
15
15
|
it "makes a payment_methods call" do
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].checkout.payment_methods(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
|
45
|
+
it "makes a paymentMethods/balance call" do
|
46
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods_balance.json"))
|
47
|
+
request_body[:applicationInfo] = {}
|
48
|
+
request_body[:applicationInfo][:adyenPaymentSource] = {
|
49
|
+
:name => "adyen-test",
|
50
|
+
:version => "1.0.0",
|
51
|
+
}
|
52
|
+
|
53
|
+
@shared_values[:client].add_application_info(request_body)
|
54
|
+
|
55
|
+
response_body = json_from_file("mocks/responses/Checkout/payment_methods_balance.json")
|
56
|
+
|
57
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentMethods/balance", @shared_values[:client].checkout.version)
|
58
|
+
WebMock.stub_request(:post, url).
|
59
|
+
with(
|
60
|
+
body: request_body,
|
61
|
+
headers: {
|
62
|
+
"x-api-key" => @shared_values[:client].api_key
|
63
|
+
}
|
64
|
+
).
|
65
|
+
to_return(
|
66
|
+
body: response_body
|
67
|
+
)
|
68
|
+
|
69
|
+
result = @shared_values[:client].checkout.payment_methods.balance(request_body)
|
70
|
+
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
71
|
+
response_hash = result.response
|
72
|
+
|
73
|
+
expect(request_body[:applicationInfo][:adyenLibrary][:name]).
|
74
|
+
to eq(Adyen::NAME)
|
75
|
+
expect(request_body[:applicationInfo][:adyenLibrary][:version]).
|
76
|
+
to eq(Adyen::VERSION)
|
77
|
+
expect(request_body[:applicationInfo][:adyenPaymentSource][:name]).
|
78
|
+
to eq("adyen-test")
|
79
|
+
expect(result.status).
|
80
|
+
to eq(200)
|
81
|
+
expect(response_hash).
|
82
|
+
to eq(JSON.parse(response_body))
|
83
|
+
expect(response_hash).
|
84
|
+
to be_a Adyen::HashWithAccessors
|
85
|
+
expect(response_hash).
|
86
|
+
to be_a_kind_of Hash
|
87
|
+
expect(response_hash["balance"]).
|
88
|
+
to eq("100")
|
19
89
|
end
|
20
90
|
|
21
91
|
# must be created manually due to payments/details format
|
@@ -103,6 +173,206 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
103
173
|
to eq("Authorised")
|
104
174
|
end
|
105
175
|
|
176
|
+
# must be created manually due to paymentsLinks format
|
177
|
+
it "makes a paymentLinks call" do
|
178
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_links.json"))
|
179
|
+
request_body[:applicationInfo] = {}
|
180
|
+
request_body[:applicationInfo][:adyenPaymentSource] = {
|
181
|
+
:name => "adyen-test",
|
182
|
+
:version => "1.0.0",
|
183
|
+
}
|
184
|
+
|
185
|
+
@shared_values[:client].add_application_info(request_body)
|
186
|
+
|
187
|
+
response_body = json_from_file("mocks/responses/Checkout/payment_links.json")
|
188
|
+
|
189
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks", @shared_values[:client].checkout.version)
|
190
|
+
WebMock.stub_request(:post, url).
|
191
|
+
with(
|
192
|
+
body: request_body,
|
193
|
+
headers: {
|
194
|
+
"x-api-key" => @shared_values[:client].api_key
|
195
|
+
}
|
196
|
+
).
|
197
|
+
to_return(
|
198
|
+
body: response_body
|
199
|
+
)
|
200
|
+
|
201
|
+
result = @shared_values[:client].checkout.payment_links(request_body)
|
202
|
+
response_hash = result.response
|
203
|
+
|
204
|
+
expect(result.status).
|
205
|
+
to eq(200)
|
206
|
+
expect(response_hash).
|
207
|
+
to eq(JSON.parse(response_body))
|
208
|
+
expect(response_hash).
|
209
|
+
to be_a Adyen::HashWithAccessors
|
210
|
+
expect(response_hash).
|
211
|
+
to be_a_kind_of Hash
|
212
|
+
end
|
213
|
+
|
214
|
+
# must be created manually due to paymentsLinks/{linkId} format
|
215
|
+
it "makes a get paymentLinks/{linkId} call" do
|
216
|
+
response_body = json_from_file("mocks/responses/Checkout/get-payment-link.json")
|
217
|
+
|
218
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
|
219
|
+
WebMock.stub_request(:get, url).
|
220
|
+
with(
|
221
|
+
headers: {
|
222
|
+
"x-api-key" => @shared_values[:client].api_key
|
223
|
+
}
|
224
|
+
).
|
225
|
+
to_return(
|
226
|
+
body: response_body
|
227
|
+
)
|
228
|
+
|
229
|
+
result = @shared_values[:client].checkout.payment_links.get("1")
|
230
|
+
response_hash = result.response
|
231
|
+
|
232
|
+
expect(result.status).
|
233
|
+
to eq(200)
|
234
|
+
expect(response_hash).
|
235
|
+
to eq(JSON.parse(response_body))
|
236
|
+
expect(response_hash).
|
237
|
+
to be_a Adyen::HashWithAccessors
|
238
|
+
expect(response_hash).
|
239
|
+
to be_a_kind_of Hash
|
240
|
+
expect(response_hash["status"]).
|
241
|
+
to eq("active")
|
242
|
+
expect(response_hash.id).
|
243
|
+
to eq("MockId")
|
244
|
+
end
|
245
|
+
|
246
|
+
# must be created manually due to paymentsLinks/{linkId} format
|
247
|
+
it "makes a patch paymentLinks/{linkId} call" do
|
248
|
+
request_body = {
|
249
|
+
:status => "expired",
|
250
|
+
}
|
251
|
+
|
252
|
+
@shared_values[:client].add_application_info(request_body)
|
253
|
+
response_body = json_from_file("mocks/responses/Checkout/update-payment-link.json")
|
254
|
+
|
255
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
|
256
|
+
WebMock.stub_request(:patch, url).
|
257
|
+
with(
|
258
|
+
body: request_body,
|
259
|
+
headers: {
|
260
|
+
"x-api-key" => @shared_values[:client].api_key
|
261
|
+
}
|
262
|
+
).
|
263
|
+
to_return(
|
264
|
+
body: response_body
|
265
|
+
)
|
266
|
+
|
267
|
+
result = @shared_values[:client].checkout.payment_links.update("1", request_body)
|
268
|
+
response_hash = result.response
|
269
|
+
|
270
|
+
expect(result.status).
|
271
|
+
to eq(200)
|
272
|
+
expect(response_hash).
|
273
|
+
to eq(JSON.parse(response_body))
|
274
|
+
expect(response_hash).
|
275
|
+
to be_a Adyen::HashWithAccessors
|
276
|
+
expect(response_hash).
|
277
|
+
to be_a_kind_of Hash
|
278
|
+
expect(response_hash["status"]).
|
279
|
+
to eq("expired")
|
280
|
+
expect(response_hash.id).
|
281
|
+
to eq("MockId")
|
282
|
+
end
|
283
|
+
|
284
|
+
it "makes an orders call" do
|
285
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/orders.json"))
|
286
|
+
|
287
|
+
response_body = json_from_file("mocks/responses/Checkout/orders.json")
|
288
|
+
|
289
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "orders", @shared_values[:client].checkout.version)
|
290
|
+
WebMock.stub_request(:post, url).
|
291
|
+
with(
|
292
|
+
body: request_body,
|
293
|
+
headers: {
|
294
|
+
"x-api-key" => @shared_values[:client].api_key
|
295
|
+
}
|
296
|
+
).
|
297
|
+
to_return(
|
298
|
+
body: response_body
|
299
|
+
)
|
300
|
+
|
301
|
+
result = @shared_values[:client].checkout.orders(request_body)
|
302
|
+
response_hash = result.response
|
303
|
+
|
304
|
+
expect(result.status).
|
305
|
+
to eq(200)
|
306
|
+
expect(response_hash).
|
307
|
+
to eq(JSON.parse(response_body))
|
308
|
+
expect(response_hash).
|
309
|
+
to be_a Adyen::HashWithAccessors
|
310
|
+
expect(response_hash).
|
311
|
+
to be_a_kind_of Hash
|
312
|
+
expect(response_hash["remainingAmount"]["value"]).
|
313
|
+
to eq(100)
|
314
|
+
end
|
315
|
+
|
316
|
+
it "makes an orders/cancel call" do
|
317
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/orders_cancel.json"))
|
318
|
+
|
319
|
+
response_body = json_from_file("mocks/responses/Checkout/orders_cancel.json")
|
320
|
+
|
321
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "orders/cancel", @shared_values[:client].checkout.version)
|
322
|
+
WebMock.stub_request(:post, url).
|
323
|
+
with(
|
324
|
+
body: request_body,
|
325
|
+
headers: {
|
326
|
+
"x-api-key" => @shared_values[:client].api_key
|
327
|
+
}
|
328
|
+
).
|
329
|
+
to_return(
|
330
|
+
body: response_body
|
331
|
+
)
|
332
|
+
|
333
|
+
result = @shared_values[:client].checkout.orders.cancel(request_body)
|
334
|
+
response_hash = result.response
|
335
|
+
|
336
|
+
expect(result.status).
|
337
|
+
to eq(200)
|
338
|
+
expect(response_hash).
|
339
|
+
to eq(JSON.parse(response_body))
|
340
|
+
expect(response_hash).
|
341
|
+
to be_a Adyen::HashWithAccessors
|
342
|
+
expect(response_hash).
|
343
|
+
to be_a_kind_of Hash
|
344
|
+
expect(response_hash["resultCode"]).
|
345
|
+
to eq("cancelled")
|
346
|
+
end
|
347
|
+
|
348
|
+
it "makes a sessions call" do
|
349
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/sessions.json"))
|
350
|
+
|
351
|
+
response_body = json_from_file("mocks/responses/Checkout/sessions-success.json")
|
352
|
+
|
353
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "sessions", @shared_values[:client].checkout.version)
|
354
|
+
WebMock.stub_request(:post, url).
|
355
|
+
with(
|
356
|
+
body: request_body,
|
357
|
+
headers: {
|
358
|
+
"x-api-key" => @shared_values[:client].api_key
|
359
|
+
}
|
360
|
+
)
|
361
|
+
.to_return(body: response_body, status: 201)
|
362
|
+
|
363
|
+
result = @shared_values[:client].checkout.sessions(request_body)
|
364
|
+
response_hash = result.response
|
365
|
+
|
366
|
+
expect(result.status).
|
367
|
+
to eq(201)
|
368
|
+
expect(response_hash).
|
369
|
+
to eq(JSON.parse(response_body))
|
370
|
+
expect(response_hash).
|
371
|
+
to be_a Adyen::HashWithAccessors
|
372
|
+
expect(response_hash).
|
373
|
+
to be_a_kind_of Hash
|
374
|
+
end
|
375
|
+
|
106
376
|
# create client for automated tests
|
107
377
|
client = create_client(:api_key)
|
108
378
|
|
@@ -110,8 +380,8 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
110
380
|
# format is defined in spec_helper
|
111
381
|
test_sets = [
|
112
382
|
["payment_session", "publicKeyToken", "8115054323780109"],
|
113
|
-
["
|
114
|
-
["
|
383
|
+
["payments", "resultCode", "Authorised"],
|
384
|
+
["origin_keys", "originKeys", { "https://adyen.com" => "mocked_origin_key" }]
|
115
385
|
]
|
116
386
|
|
117
387
|
generate_tests(client, "Checkout", test_sets, client.checkout)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Adyen::Dispute, service: "dispute service" do
|
4
|
+
# client instance to be used in dynamically generated tests
|
5
|
+
client = create_client(:basic)
|
6
|
+
|
7
|
+
# methods / values to test for
|
8
|
+
# format is defined in spec_helper
|
9
|
+
test_sets = [
|
10
|
+
["retrieve_applicable_defense_reasons", "disputeServiceResult", { "success" => true }],
|
11
|
+
["supply_defense_document", "disputeServiceResult", { "success" => true }],
|
12
|
+
["delete_dispute_defense_document", "disputeServiceResult", { "success" => true }],
|
13
|
+
["defend_dispute", "disputeServiceResult", { "success" => true }],
|
14
|
+
]
|
15
|
+
|
16
|
+
generate_tests(client, "DisputeService", test_sets, client.dispute)
|
17
|
+
end
|
data/spec/fund_spec.rb
CHANGED
@@ -12,7 +12,8 @@ RSpec.describe Adyen::Payments, service: "marketpay fund service" do
|
|
12
12
|
["account_holder_transaction_list", "pspReference", "9914721175530029"],
|
13
13
|
["refund_not_paid_out_transfers", "pspReference", "9915090894215323"],
|
14
14
|
["setup_beneficiary", "pspReference", "9914860354282596"],
|
15
|
-
["transfer_funds", "pspReference", "9915090893984580"]
|
15
|
+
["transfer_funds", "pspReference", "9915090893984580"],
|
16
|
+
["refund_funds_transfer", "pspReference", "9915090893984580"]
|
16
17
|
]
|
17
18
|
|
18
19
|
generate_tests(client, "Fund", test_sets, client.marketpay.fund)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"defenseDocuments": [
|
3
|
+
{
|
4
|
+
"content": "JVBERi0xLjMKJcTl8uXrp...",
|
5
|
+
"contentType": "application/pdf",
|
6
|
+
"defenseDocumentTypeCode": "MerchandiseDescription"
|
7
|
+
}
|
8
|
+
],
|
9
|
+
"disputePspReference": "9913486733050065",
|
10
|
+
"merchantAccountCode": "YOUR_MERCHANT_ACCOUNT"
|
11
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"card": {
|
3
|
+
"number": "4111111111111111",
|
4
|
+
"expiryMonth": "8",
|
5
|
+
"expiryYear": "2018",
|
6
|
+
"cvc": "737",
|
7
|
+
"holderName": "John Smith"
|
8
|
+
},
|
9
|
+
"reference": "Merchant Reference",
|
10
|
+
"merchantAccount": "TestMerchant",
|
11
|
+
"shopperReference": "shopperReference"
|
12
|
+
}
|