adyen-ruby-api-library 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +5 -0
- data/bin/console +1 -1
- data/docs/payout.html +1 -1
- data/lib/adyen/client.rb +6 -4
- data/lib/adyen/errors.rb +16 -29
- data/lib/adyen/services/checkout.rb +1 -1
- data/lib/adyen/services/marketpay.rb +1 -1
- data/lib/adyen/services/payments.rb +2 -1
- data/lib/adyen/services/recurring.rb +1 -1
- data/lib/adyen/version.rb +1 -1
- data/spec/errors_spec.rb +17 -0
- data/spec/mocks/requests/Payment/authorise3ds2.json +7 -0
- data/spec/mocks/responses/Payment/authorise3ds2.json +17 -0
- data/spec/payments_spec.rb +1 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 231b46c2247176df71d2d893aff31a84e8db8e30
|
4
|
+
data.tar.gz: 097565c20054e485ed2765a6dec518067517608a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357904495d8ec8afab0a4aef8151cf8d976572a4827c62070fb6737a9dda6f041892974688c6cd2412af6d1b9339adaaafb6799af9ffab93487be9903c6b16bc
|
7
|
+
data.tar.gz: 8132cc3af9c35ac41c4e5431ca783ba4c7f1fe05be5f9e30b62f65b85203c827617f8a460162dd071ef153fbb5f97c1ccd89f86886205c86bb75dd4106a2f596
|
data/README.md
CHANGED
data/bin/console
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative "../lib/adyen.rb"
|
3
|
+
require_relative "../lib/adyen-ruby-api-library.rb"
|
4
4
|
|
5
5
|
# You can add fixtures and/or initialization code here to make experimenting
|
6
6
|
# with your gem easier. You can also use a different console, if you like.
|
data/docs/payout.html
CHANGED
@@ -88,7 +88,7 @@ adyen.ws_passord = "super_secure_password123"</code></pre></p>
|
|
88
88
|
"shopperReference" : "<ShopperReference>",
|
89
89
|
"dateOfBirth" : "1990-01-01",
|
90
90
|
"entityType" : "Company",
|
91
|
-
"nationality" : "NL"
|
91
|
+
"nationality" : "NL"
|
92
92
|
}')</code></pre>
|
93
93
|
|
94
94
|
<h3 id="submitapayout">Submit a payout</h3>
|
data/lib/adyen/client.rb
CHANGED
@@ -102,12 +102,13 @@ module Adyen
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
# if json string convert to hash
|
105
|
+
# if json string convert to hash
|
106
|
+
# needed to add applicationInfo
|
106
107
|
if request_data.is_a?(String)
|
107
108
|
request_data = JSON.parse(request_data)
|
108
109
|
end
|
109
110
|
|
110
|
-
# add
|
111
|
+
# add application only on checkout service
|
111
112
|
if service == 'Checkout' || service == 'CheckoutUtility'
|
112
113
|
add_application_info(request_data)
|
113
114
|
end
|
@@ -127,14 +128,15 @@ module Adyen
|
|
127
128
|
# check for API errors
|
128
129
|
case response.status
|
129
130
|
when 401
|
130
|
-
raise Adyen::AuthenticationError.new("Invalid
|
131
|
+
raise Adyen::AuthenticationError.new("Invalid API authentication; https://docs.adyen.com/user-management/how-to-get-the-api-key", request_data)
|
131
132
|
when 403
|
132
|
-
raise Adyen::PermissionError.new("
|
133
|
+
raise Adyen::PermissionError.new("Missing user permissions; https://docs.adyen.com/user-management/user-roles", request_data)
|
133
134
|
end
|
134
135
|
|
135
136
|
response
|
136
137
|
end
|
137
138
|
|
139
|
+
# add application_info for analytics
|
138
140
|
def add_application_info(request_data)
|
139
141
|
external_platform = {
|
140
142
|
:adyenLibrary => {
|
data/lib/adyen/errors.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
module Adyen
|
2
2
|
class AdyenError < StandardError
|
3
|
-
attr_reader :code, :response, :request
|
3
|
+
attr_reader :code, :response, :request, :msg
|
4
4
|
|
5
5
|
def initialize(request = nil, response = nil, msg = nil, code = nil)
|
6
|
+
attributes = {
|
7
|
+
code: code,
|
8
|
+
request: request,
|
9
|
+
response: response,
|
10
|
+
msg: msg
|
11
|
+
}.select { |_k, v| v }.map { |k, v| "#{k}:#{v}" }.join(', ')
|
12
|
+
message = "#{self.class.name} #{attributes}"
|
13
|
+
super(message)
|
6
14
|
@code = code
|
7
15
|
@response = response
|
8
16
|
@request = request
|
@@ -12,65 +20,44 @@ module Adyen
|
|
12
20
|
|
13
21
|
class AuthenticationError < AdyenError
|
14
22
|
def initialize(msg, request)
|
15
|
-
|
16
|
-
@response = nil
|
17
|
-
@request = request
|
18
|
-
@msg = msg
|
23
|
+
super(request, nil, msg, 401)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
27
|
class PermissionError < AdyenError
|
23
28
|
def initialize(msg, request)
|
24
|
-
|
25
|
-
@response = nil
|
26
|
-
@request = request
|
27
|
-
@msg = msg
|
29
|
+
super(request, nil, msg, 403)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
class FormatError < AdyenError
|
32
34
|
def initialize(msg, request, response)
|
33
|
-
|
34
|
-
@response = response
|
35
|
-
@request = request
|
36
|
-
@msg = msg
|
35
|
+
super(request, response, msg, 422)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
class ServerError < AdyenError
|
41
40
|
def initialize(msg, request, response)
|
42
|
-
|
43
|
-
@response = response
|
44
|
-
@request = request
|
45
|
-
@msg = msg
|
41
|
+
super(request, response, msg, 500)
|
46
42
|
end
|
47
43
|
end
|
48
44
|
|
49
45
|
class ConfigurationError < AdyenError
|
50
46
|
def initialize(msg, request)
|
51
|
-
|
52
|
-
@response = nil
|
53
|
-
@request = request
|
54
|
-
@msg = msg
|
47
|
+
super(request, nil, msg, 905)
|
55
48
|
end
|
56
49
|
end
|
57
50
|
|
58
51
|
class ValidationError < AdyenError
|
59
52
|
def initialize(msg, request)
|
60
|
-
|
61
|
-
@response = nil
|
62
|
-
@request = request
|
63
|
-
@msg = msg
|
53
|
+
super(request, nil, msg, nil)
|
64
54
|
end
|
65
55
|
end
|
66
56
|
|
67
57
|
# catchall for errors which don't have more specific classes
|
68
58
|
class APIError < AdyenError
|
69
59
|
def initialize(msg, request, response, code)
|
70
|
-
|
71
|
-
@response = response
|
72
|
-
@request = request
|
73
|
-
@msg = msg
|
60
|
+
super(request, response, msg, code)
|
74
61
|
end
|
75
62
|
end
|
76
63
|
end
|
@@ -3,13 +3,14 @@ require_relative 'service'
|
|
3
3
|
module Adyen
|
4
4
|
class Payments < 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 = 'Payment'
|
10
10
|
method_names = [
|
11
11
|
:authorise,
|
12
12
|
:authorise3d,
|
13
|
+
:authorise3ds2,
|
13
14
|
:capture,
|
14
15
|
:cancel,
|
15
16
|
:refund,
|
data/lib/adyen/version.rb
CHANGED
data/spec/errors_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Adyen::AdyenError do
|
6
|
+
describe '#to_s' do
|
7
|
+
it 'describes using the error properties' do
|
8
|
+
expect(Adyen::AdyenError.new('request', 'response', 'message', 'code').to_s).to eq('Adyen::AdyenError code:code, request:request, response:response, msg:message')
|
9
|
+
end
|
10
|
+
it 'skips the null properties' do
|
11
|
+
expect(Adyen::AdyenError.new('request', nil, nil, 'code').to_s).to eq('Adyen::AdyenError code:code, request:request')
|
12
|
+
end
|
13
|
+
it 'uses the proper error class name' do
|
14
|
+
expect(Adyen::PermissionError.new('a message', 'a request').to_s).to eq('Adyen::PermissionError code:403, request:a request, msg:a message')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"additionalData":{
|
3
|
+
"threeds2.threeDS2ResponseData.dsReferenceNumber":"ADYEN-DS-SIMULATOR",
|
4
|
+
"threeds2.threeDS2ResponseData.transStatus":"C",
|
5
|
+
"threeds2.threeDS2ResponseData.acsChallengeMandated":"Y",
|
6
|
+
"threeds2.threeDS2ResponseData.acsURL":"http:\/\/localhost:8080\/threeds2simulator\/services\/ThreeDS2Simulator\/v1\/handle\/eb9c6eb3-57b3-400d-bf2f-4e72bd69dcec",
|
7
|
+
"threeds2.threeDS2ResponseData.threeDSServerTransID":"c9200190-5ffe-11e8-954f-2677777ae710",
|
8
|
+
"threeds2.threeDS2ResponseData.authenticationType":"01",
|
9
|
+
"threeds2.threeDS2ResponseData.dsTransID":"73aab3ce-eb39-49e8-8e9b-46fb77a472f1",
|
10
|
+
"threeds2.threeDS2ResponseData.messageVersion":"2.1.0",
|
11
|
+
"threeds2.threeDS2Token":"BQABAQBPCQZ98WKh3v7qGnBlUMGClVzDolIjs8w/8L64WIAqaOGZipbZod7n+E=...",
|
12
|
+
"threeds2.threeDS2ResponseData.acsTransID":"eb9c6eb3-57b3-400d-bf2f-4e72b779dcec",
|
13
|
+
"threeds2.threeDS2ResponseData.acsReferenceNumber":"ADYEN-ACS-SIMULATOR"
|
14
|
+
},
|
15
|
+
"pspReference":"9935272408577755",
|
16
|
+
"resultCode":"ChallengeShopper"
|
17
|
+
}
|
data/spec/payments_spec.rb
CHANGED
@@ -10,6 +10,7 @@ RSpec.describe Adyen::Payments, service: "payments service" do
|
|
10
10
|
["authorise", "resultCode", "Authorised"],
|
11
11
|
["adjust_authorisation", "response", "[adjustAuthorisation-received]"],
|
12
12
|
["authorise3d", "resultCode", "Authorised"],
|
13
|
+
["authorise3ds2", "resultCode", "ChallengeShopper"],
|
13
14
|
["cancel", "response", "[cancel-received]"],
|
14
15
|
["cancel_or_refund", "response", "[cancelOrRefund-received]"],
|
15
16
|
["capture", "response", "[capture-received]"],
|
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:
|
4
|
+
version: 3.0.0
|
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-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- spec/checkout_spec.rb
|
115
115
|
- spec/checkout_utility_spec.rb
|
116
116
|
- spec/client_spec.rb
|
117
|
+
- spec/errors_spec.rb
|
117
118
|
- spec/fund_spec.rb
|
118
119
|
- spec/mocks/requests/Account/close_account.json
|
119
120
|
- spec/mocks/requests/Account/close_account_holder.json
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- spec/mocks/requests/Payment/adjust_authorisation.json
|
152
153
|
- spec/mocks/requests/Payment/authorise.json
|
153
154
|
- spec/mocks/requests/Payment/authorise3d.json
|
155
|
+
- spec/mocks/requests/Payment/authorise3ds2.json
|
154
156
|
- spec/mocks/requests/Payment/cancel.json
|
155
157
|
- spec/mocks/requests/Payment/cancel_or_refund.json
|
156
158
|
- spec/mocks/requests/Payment/capture.json
|
@@ -199,6 +201,7 @@ files:
|
|
199
201
|
- spec/mocks/responses/Payment/adjust_authorisation.json
|
200
202
|
- spec/mocks/responses/Payment/authorise.json
|
201
203
|
- spec/mocks/responses/Payment/authorise3d.json
|
204
|
+
- spec/mocks/responses/Payment/authorise3ds2.json
|
202
205
|
- spec/mocks/responses/Payment/cancel.json
|
203
206
|
- spec/mocks/responses/Payment/cancel_or_refund.json
|
204
207
|
- spec/mocks/responses/Payment/capture.json
|
@@ -239,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
242
|
version: '0'
|
240
243
|
requirements: []
|
241
244
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.2.0
|
243
246
|
signing_key:
|
244
247
|
specification_version: 4
|
245
248
|
summary: Official Adyen Ruby API Library
|