adyen-ruby-api-library 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adyen/client.rb +15 -4
- data/lib/adyen/services/checkout.rb +7 -6
- data/lib/adyen/services/checkout_utility.rb +1 -1
- data/lib/adyen/services/service.rb +2 -2
- data/lib/adyen/version.rb +1 -1
- data/spec/checkout_utility_spec.rb +1 -1
- data/spec/client_spec.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b38d6b5e903949dd5f611270b52d7d232b7446053e4af782809ec0ee80c2072c
|
4
|
+
data.tar.gz: ddb1fa60f2b6dd3d1b177c651ae59372d8065a13193f7b2ef1cbe5c3744b0312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be7130f49c9247fd8f8edb0c0ff8f11d6ed95ac19e1ffc3b15db0d9e758c092ed1850d22c64b1ec17c9b4f63fa22a0149fd3ba9dca4d5b6b7a56baca5c6b98f4
|
7
|
+
data.tar.gz: 9bb005f7548edea11ba546ee08ed045a7ecd743c1691a25aaa9c38b5940a29fbd9d8454cc894553920f20f0f4cf2174dc7e3c4fbe53c2bdf2bc606d1c5a720af
|
data/lib/adyen/client.rb
CHANGED
@@ -40,17 +40,21 @@ module Adyen
|
|
40
40
|
case service
|
41
41
|
when "Checkout"
|
42
42
|
url = "https://checkout-#{@env}.adyen.com/checkout"
|
43
|
+
supports_live_url_prefix = true
|
43
44
|
when "CheckoutUtility"
|
44
|
-
url = "https://checkout-#{@env}.adyen.com"
|
45
|
+
url = "https://checkout-#{@env}.adyen.com/checkout"
|
46
|
+
supports_live_url_prefix = true
|
45
47
|
when "Account", "Fund", "Notification"
|
46
48
|
url = "https://cal-#{@env}.adyen.com/cal/services"
|
49
|
+
supports_live_url_prefix = false
|
47
50
|
when "Recurring", "Payment", "Payout"
|
48
51
|
url = "https://pal-#{@env}.adyen.com/pal/servlet"
|
52
|
+
supports_live_url_prefix = true
|
49
53
|
else
|
50
54
|
raise ArgumentError, "Invalid service specified"
|
51
55
|
end
|
52
56
|
|
53
|
-
if @env == :live
|
57
|
+
if @env == :live && supports_live_url_prefix
|
54
58
|
url.insert(8, "#{@live_url_prefix}-")
|
55
59
|
url["adyen.com"] = "adyenpayments.com"
|
56
60
|
end
|
@@ -61,7 +65,7 @@ module Adyen
|
|
61
65
|
|
62
66
|
# construct full URL from service and endpoint
|
63
67
|
def service_url(service, action, version)
|
64
|
-
if service == "Checkout"
|
68
|
+
if service == "Checkout" || service == "CheckoutUtility"
|
65
69
|
"#{service_url_base(service)}/v#{version}/#{action}"
|
66
70
|
else
|
67
71
|
"#{service_url_base(service)}/#{service}/v#{version}/#{action}"
|
@@ -69,7 +73,7 @@ module Adyen
|
|
69
73
|
end
|
70
74
|
|
71
75
|
# send request to adyen API
|
72
|
-
def call_adyen_api(service, action, request_data, version)
|
76
|
+
def call_adyen_api(service, action, request_data, headers, version)
|
73
77
|
# get URL for requested endpoint
|
74
78
|
url = service_url(service, action, version)
|
75
79
|
|
@@ -100,8 +104,15 @@ module Adyen
|
|
100
104
|
when "api-key"
|
101
105
|
faraday.headers["x-api-key"] = @api_key
|
102
106
|
end
|
107
|
+
|
108
|
+
# add optional headers if specified in request
|
109
|
+
# will overwrite default headers if overlapping
|
110
|
+
headers.map do |key, value|
|
111
|
+
faraday.headers[key] = value
|
112
|
+
end
|
103
113
|
end
|
104
114
|
|
115
|
+
|
105
116
|
# if json string convert to hash
|
106
117
|
# needed to add applicationInfo
|
107
118
|
if request_data.is_a?(String)
|
@@ -23,9 +23,10 @@ module Adyen
|
|
23
23
|
case args.size
|
24
24
|
when 0
|
25
25
|
Adyen::CheckoutDetail.new(@client, @version)
|
26
|
-
|
26
|
+
else
|
27
27
|
action = 'payments'
|
28
|
-
|
28
|
+
args[1] ||= {} # optional headers arg
|
29
|
+
@client.call_adyen_api(@service, action, args[0], args[1], @version)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -37,14 +38,14 @@ module Adyen
|
|
37
38
|
@version = version
|
38
39
|
end
|
39
40
|
|
40
|
-
def details(request)
|
41
|
+
def details(request, headers = {})
|
41
42
|
action = "payments/details"
|
42
|
-
@client.call_adyen_api(@service, action, request, @version)
|
43
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
43
44
|
end
|
44
45
|
|
45
|
-
def result(request)
|
46
|
+
def result(request, headers = {})
|
46
47
|
action = "payments/result"
|
47
|
-
@client.call_adyen_api(@service, action, request, @version)
|
48
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -9,9 +9,9 @@ module Adyen
|
|
9
9
|
|
10
10
|
# dynamically create API methods
|
11
11
|
method_names.each do |method_name|
|
12
|
-
define_singleton_method method_name do |request|
|
12
|
+
define_singleton_method method_name do |request, headers = {}|
|
13
13
|
action = method_name.to_s.to_camel_case
|
14
|
-
@client.call_adyen_api(@service, action, request, @version)
|
14
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/adyen/version.rb
CHANGED
@@ -13,7 +13,7 @@ RSpec.describe Adyen::CheckoutUtility, service: "checkout utility" do
|
|
13
13
|
|
14
14
|
it "sets the correct service URL base" do
|
15
15
|
client = Adyen::Client.new(env: :test)
|
16
|
-
expect(client.service_url_base(@shared_values[:service])).to eq("https://checkout-test.adyen.com")
|
16
|
+
expect(client.service_url_base(@shared_values[:service])).to eq("https://checkout-test.adyen.com/checkout")
|
17
17
|
end
|
18
18
|
|
19
19
|
# must be created manually because every field in the response is an array
|
data/spec/client_spec.rb
CHANGED
@@ -37,4 +37,32 @@ RSpec.describe Adyen do
|
|
37
37
|
to raise_error(Adyen::AuthenticationError)
|
38
38
|
@shared_values[:client].api_key = "api_key"
|
39
39
|
end
|
40
|
+
|
41
|
+
it "generates the correct service URL base for CAL TEST" do
|
42
|
+
client = Adyen::Client.new(env: :test)
|
43
|
+
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
44
|
+
expect(client.service_url_base("Account")).
|
45
|
+
to eq("https://cal-test.adyen.com/cal/services")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "generates the correct service URL base for CAL LIVE" do
|
49
|
+
client = Adyen::Client.new(env: :live)
|
50
|
+
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
51
|
+
expect(client.service_url_base("Account")).
|
52
|
+
to eq("https://cal-live.adyen.com/cal/services")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "generates the correct service URL base for PAL TEST" do
|
56
|
+
client = Adyen::Client.new(env: :test)
|
57
|
+
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
58
|
+
expect(client.service_url_base("Payment")).
|
59
|
+
to eq("https://pal-test.adyen.com/pal/servlet")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "generates the correct service URL base for PAL LIVE" do
|
63
|
+
client = Adyen::Client.new(env: :live)
|
64
|
+
client.live_url_prefix = "abcdef1234567890-TestCompany"
|
65
|
+
expect(client.service_url_base("Payment")).
|
66
|
+
to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet")
|
67
|
+
end
|
40
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adyen-ruby-api-library
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|