adyen-ruby-api-library 4.0.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CODEOWNERS +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +7 -0
- data/.github/dependabot.yml +8 -0
- data/.gitignore +2 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +2 -2
- data/README.md +28 -2
- data/docs/checkout.html +17 -0
- data/lib/adyen-ruby-api-library.rb +4 -11
- data/lib/adyen/client.rb +30 -9
- data/lib/adyen/errors.rb +44 -2
- data/lib/adyen/services/bin_lookup.rb +18 -0
- data/lib/adyen/services/checkout.rb +12 -7
- data/lib/adyen/services/data_protection.rb +17 -0
- data/lib/adyen/services/dispute.rb +20 -0
- data/lib/adyen/services/marketpay.rb +18 -0
- data/lib/adyen/services/payments.rb +10 -4
- data/lib/adyen/services/postfmapi.rb +19 -0
- data/lib/adyen/services/service.rb +2 -2
- data/lib/adyen/version.rb +1 -1
- data/renovate.json +5 -0
- data/spec/bin_lookup_spec.rb +15 -0
- data/spec/checkout_spec.rb +1 -0
- data/spec/data_protection_spec.rb +14 -0
- data/spec/dispute_spec.rb +17 -0
- data/spec/errors_spec.rb +33 -3
- data/spec/hop_spec.rb +14 -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/payment_links.json +9 -0
- data/spec/mocks/requests/DataProtectionService/request_subject_erasure.json +5 -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/Hop/get_onboarding_url.json +4 -0
- data/spec/mocks/requests/Payment/donate.json +10 -0
- data/spec/mocks/requests/Terminal/assign_terminals.json +6 -0
- data/spec/mocks/requests/Terminal/find_terminal.json +3 -0
- data/spec/mocks/requests/Terminal/get_terminals_under_account.json +4 -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/payment_links.json +9 -0
- data/spec/mocks/responses/DataProtectionService/request_subject_erasure.json +3 -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/Hop/get_onboarding_url.json +7 -0
- data/spec/mocks/responses/Payment/donate.json +4 -0
- data/spec/mocks/responses/Terminal/assign_terminals.json +5 -0
- data/spec/mocks/responses/Terminal/find_terminal.json +6 -0
- data/spec/mocks/responses/Terminal/get_terminals_under_account.json +11 -0
- data/spec/payments_spec.rb +2 -1
- data/spec/postfmapi_spec.rb +16 -0
- data/spec/service_spec.rb +3 -0
- data/spec/spec_helper.rb +19 -12
- metadata +45 -4
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'service'
|
2
|
+
|
3
|
+
module Adyen
|
4
|
+
class BinLookup < Service
|
5
|
+
attr_accessor :version
|
6
|
+
DEFAULT_VERSION = 50
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
service = 'BinLookup'
|
10
|
+
method_names = [
|
11
|
+
:get_3ds_availability,
|
12
|
+
:get_cost_estimate
|
13
|
+
]
|
14
|
+
|
15
|
+
super(client, version, service, method_names)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,17 +1,22 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "service"
|
2
2
|
|
3
3
|
module Adyen
|
4
4
|
class Checkout < Service
|
5
5
|
DEFAULT_VERSION = 50
|
6
6
|
|
7
7
|
def initialize(client, version = DEFAULT_VERSION)
|
8
|
-
service =
|
8
|
+
service = "Checkout"
|
9
9
|
method_names = [
|
10
10
|
:payment_methods,
|
11
|
-
:payment_session
|
11
|
+
:payment_session,
|
12
|
+
:payment_links,
|
13
|
+
]
|
14
|
+
with_application_info = [
|
15
|
+
:payment_session,
|
16
|
+
:payment_links,
|
12
17
|
]
|
13
18
|
|
14
|
-
super(client, version, service, method_names)
|
19
|
+
super(client, version, service, method_names, with_application_info)
|
15
20
|
end
|
16
21
|
|
17
22
|
# This method can't be dynamically defined because
|
@@ -24,16 +29,16 @@ module Adyen
|
|
24
29
|
when 0
|
25
30
|
Adyen::CheckoutDetail.new(@client, @version)
|
26
31
|
else
|
27
|
-
action =
|
32
|
+
action = "payments"
|
28
33
|
args[1] ||= {} # optional headers arg
|
29
|
-
@client.call_adyen_api(@service, action, args[0], args[1], @version)
|
34
|
+
@client.call_adyen_api(@service, action, args[0], args[1], @version, true)
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
34
39
|
class CheckoutDetail < Service
|
35
40
|
def initialize(client, version = DEFAULT_VERSION)
|
36
|
-
@service =
|
41
|
+
@service = "Checkout"
|
37
42
|
@client = client
|
38
43
|
@version = version
|
39
44
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'service'
|
2
|
+
|
3
|
+
module Adyen
|
4
|
+
class DataProtection < Service
|
5
|
+
attr_accessor :version
|
6
|
+
DEFAULT_VERSION = 1
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
service = 'DataProtectionService'
|
10
|
+
method_names = [
|
11
|
+
:request_subject_erasure
|
12
|
+
]
|
13
|
+
|
14
|
+
super(client, version, service, method_names)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'service'
|
2
|
+
|
3
|
+
module Adyen
|
4
|
+
class Dispute < Service
|
5
|
+
attr_accessor :version
|
6
|
+
DEFAULT_VERSION = 30
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
service = 'DisputeService'
|
10
|
+
method_names = [
|
11
|
+
:retrieve_applicable_defense_reasons,
|
12
|
+
:supply_defense_document,
|
13
|
+
:delete_dispute_defense_document,
|
14
|
+
:defend_dispute,
|
15
|
+
]
|
16
|
+
|
17
|
+
super(client, version, service, method_names)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -21,6 +21,10 @@ module Adyen
|
|
21
21
|
def notification
|
22
22
|
@notification ||= Adyen::Marketpay::Notification.new(@client)
|
23
23
|
end
|
24
|
+
|
25
|
+
def hop
|
26
|
+
@hop ||= Adyen::Marketpay::Hop.new(@client)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
class Account < Service
|
@@ -88,5 +92,19 @@ module Adyen
|
|
88
92
|
super(client, version, service, method_names)
|
89
93
|
end
|
90
94
|
end
|
95
|
+
|
96
|
+
class Hop < Service
|
97
|
+
attr_accessor :version
|
98
|
+
DEFAULT_VERSION = 1
|
99
|
+
|
100
|
+
def initialize(client, version = DEFAULT_VERSION)
|
101
|
+
service = 'Hop'
|
102
|
+
method_names = [
|
103
|
+
:get_onboarding_url
|
104
|
+
]
|
105
|
+
|
106
|
+
super(client, version, service, method_names)
|
107
|
+
end
|
108
|
+
end
|
91
109
|
end
|
92
110
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "service"
|
2
2
|
|
3
3
|
module Adyen
|
4
4
|
class Payments < Service
|
@@ -6,7 +6,7 @@ module Adyen
|
|
6
6
|
DEFAULT_VERSION = 50
|
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,
|
@@ -15,10 +15,16 @@ module Adyen
|
|
15
15
|
:cancel,
|
16
16
|
:refund,
|
17
17
|
:cancel_or_refund,
|
18
|
-
:adjust_authorisation
|
18
|
+
:adjust_authorisation,
|
19
|
+
:donate,
|
20
|
+
]
|
21
|
+
with_application_info = [
|
22
|
+
:authorise,
|
23
|
+
:authorise3d,
|
24
|
+
:authorise3ds2,
|
19
25
|
]
|
20
26
|
|
21
|
-
super(client, version, service, method_names)
|
27
|
+
super(client, version, service, method_names, with_application_info)
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'service'
|
2
|
+
|
3
|
+
module Adyen
|
4
|
+
class PosTerminalManagement < Service
|
5
|
+
attr_accessor :version
|
6
|
+
DEFAULT_VERSION = 1
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
service = 'Terminal'
|
10
|
+
method_names = [
|
11
|
+
:assign_terminals,
|
12
|
+
:find_terminal,
|
13
|
+
:get_terminals_under_account
|
14
|
+
]
|
15
|
+
|
16
|
+
super(client, version, service, method_names)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -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
@@ -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
@@ -110,6 +110,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
|
|
110
110
|
# format is defined in spec_helper
|
111
111
|
test_sets = [
|
112
112
|
["payment_session", "publicKeyToken", "8115054323780109"],
|
113
|
+
["payment_links", "url", "https://checkoutshopper-test.adyen.com"],
|
113
114
|
["payments", "resultCode", "Authorised"]
|
114
115
|
]
|
115
116
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Adyen::DataProtection, service: "Data Protection 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
|
+
["request_subject_erasure", "result", "SUCCESS"],
|
11
|
+
]
|
12
|
+
|
13
|
+
generate_tests(client, "DataProtectionService", test_sets, client.data_protection)
|
14
|
+
end
|
@@ -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/errors_spec.rb
CHANGED
@@ -3,15 +3,45 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Adyen::AdyenError do
|
6
|
+
before(:all) do
|
7
|
+
@shared_values = {
|
8
|
+
request: {
|
9
|
+
amount: {
|
10
|
+
currency: "USD",
|
11
|
+
value: 1000
|
12
|
+
},
|
13
|
+
reference: "Your order number",
|
14
|
+
paymentMethod: {
|
15
|
+
type: "scheme",
|
16
|
+
number: "4111111111111111",
|
17
|
+
expiryMonth: "10",
|
18
|
+
expiryYear: "2020",
|
19
|
+
holderName: "John Smith",
|
20
|
+
cvc: "737"
|
21
|
+
},
|
22
|
+
returnUrl: "https://your-company.com/",
|
23
|
+
merchantAccount: "YOUR_MERCHANT_ACCOUNT"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
6
28
|
describe '#to_s' do
|
7
29
|
it 'describes using the error properties' do
|
8
|
-
expect(Adyen::AdyenError.new(
|
30
|
+
expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').to_s).to eq("Adyen::AdyenError code:code, msg:message, request:#{@shared_values[:request]}, response:response")
|
9
31
|
end
|
10
32
|
it 'skips the null properties' do
|
11
|
-
expect(Adyen::AdyenError.new(
|
33
|
+
expect(Adyen::AdyenError.new(@shared_values[:request], nil, nil, 'code').to_s).to eq("Adyen::AdyenError code:code, request:#{@shared_values[:request]}")
|
12
34
|
end
|
13
35
|
it 'uses the proper error class name' do
|
14
|
-
expect(Adyen::PermissionError.new('
|
36
|
+
expect(Adyen::PermissionError.new('message', @shared_values[:request]).to_s).to eq("Adyen::PermissionError code:403, msg:message, request:#{@shared_values[:request]}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
describe '#masking' do
|
40
|
+
it 'masks card number when logging request in errors' do
|
41
|
+
expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:number]).to eq('411111******1111')
|
42
|
+
end
|
43
|
+
it 'masks CVC when logging request in errors' do
|
44
|
+
expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
|
15
45
|
end
|
16
46
|
end
|
17
47
|
end
|
data/spec/hop_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Adyen::Payments, service: "marketpay hop 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_onboarding_url", "pspReference", "8815850625171183"]
|
11
|
+
]
|
12
|
+
|
13
|
+
generate_tests(client, "Hop", test_sets, client.marketpay.hop)
|
14
|
+
end
|
@@ -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
|
+
}
|