Skip to content

Commit 33341f8

Browse files
authored
Merge pull request #79 from Adyen/develop
Release 4.4.0
2 parents 7952e8d + 950ce58 commit 33341f8

25 files changed

+239
-34
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ design.txt
1111

1212
.bundle
1313
.ruby-version
14+
15+
.DS_Store

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The Library supports all APIs under the following services:
1515
* marketpay
1616
* postfmapi
1717
* data_protection
18+
* dispute
19+
* bin_lookup
1820

1921
## Requirements
2022

@@ -151,6 +153,16 @@ adyen.checkout.version = 50
151153
**data_protection:**
152154
- request_subject_erasure
153155

156+
**dispute:**
157+
- retrieve_applicable_defense_reasons
158+
- supply_defense_document
159+
- delete_dispute_defense_document
160+
- defend_dispute
161+
162+
**bin_lookup:**
163+
- get_3ds_availability
164+
- get_cost_estimate
165+
154166
## Support
155167
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420).
156168

lib/adyen-ruby-api-library.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010
require_relative "adyen/services/postfmapi"
1111
require_relative "adyen/services/service"
1212
require_relative "adyen/services/data_protection"
13+
require_relative "adyen/services/dispute"
14+
require_relative "adyen/services/bin_lookup"
1315
require_relative "adyen/hash_with_accessors"
1416
require_relative "adyen/utils/hmac_validator"

lib/adyen/client.rb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def service_url_base(service)
4848
when "Account", "Fund", "Notification", "Hop"
4949
url = "https://cal-#{@env}.adyen.com/cal/services"
5050
supports_live_url_prefix = false
51-
when "Recurring", "Payment", "Payout"
51+
when "Recurring", "Payment", "Payout", "BinLookup"
5252
url = "https://pal-#{@env}.adyen.com/pal/servlet"
5353
supports_live_url_prefix = true
5454
when "Terminal"
5555
url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
5656
supports_live_url_prefix = false
57-
when "DataProtectionService"
57+
when "DataProtectionService", "DisputeService"
5858
url = "https://ca-#{@env}.adyen.com/ca/services"
5959
supports_live_url_prefix = false
6060
else
@@ -80,7 +80,7 @@ def service_url(service, action, version)
8080
end
8181

8282
# send request to adyen API
83-
def call_adyen_api(service, action, request_data, headers, version)
83+
def call_adyen_api(service, action, request_data, headers, version, with_application_info = false)
8484
# get URL for requested endpoint
8585
url = service_url(service, action, version)
8686

@@ -125,7 +125,7 @@ def call_adyen_api(service, action, request_data, headers, version)
125125
end
126126

127127
# add application only on checkout service
128-
if service == 'Checkout' || service == 'CheckoutUtility'
128+
if with_application_info
129129
add_application_info(request_data)
130130
end
131131

@@ -157,16 +157,15 @@ def call_adyen_api(service, action, request_data, headers, version)
157157
# add application_info for analytics
158158
def add_application_info(request_data)
159159
adyenLibrary = {
160-
:name => Adyen::NAME,
161-
:version => Adyen::VERSION.to_s
160+
:name => Adyen::NAME,
161+
:version => Adyen::VERSION.to_s,
162162
}
163163

164164
if request_data[:applicationInfo].nil?
165-
request_data[:applicationInfo] = {};
165+
request_data[:applicationInfo] = {}
166166
end
167167

168168
request_data[:applicationInfo][:adyenLibrary] = adyenLibrary
169-
request_data[:applicationInfo][:adyenLibraryTest] = adyenLibrary
170169
end
171170

172171
# services
@@ -201,5 +200,13 @@ def postfmapi
201200
def data_protection
202201
@data_protection ||= Adyen::DataProtection.new(self)
203202
end
203+
204+
def dispute
205+
@dispute ||= Adyen::Dispute.new(self)
206+
end
207+
208+
def bin_lookup
209+
@bin_lookup ||= Adyen::BinLookup.new(self)
210+
end
204211
end
205212
end

lib/adyen/services/bin_lookup.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/adyen/services/checkout.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
require_relative 'service'
1+
require_relative "service"
22

33
module Adyen
44
class Checkout < Service
55
DEFAULT_VERSION = 50
66

77
def initialize(client, version = DEFAULT_VERSION)
8-
service = 'Checkout'
8+
service = "Checkout"
99
method_names = [
1010
:payment_methods,
1111
:payment_session,
12-
:payment_links
12+
:payment_links,
13+
]
14+
with_application_info = [
15+
:payment_session,
16+
:payment_links,
1317
]
1418

15-
super(client, version, service, method_names)
19+
super(client, version, service, method_names, with_application_info)
1620
end
1721

1822
# This method can't be dynamically defined because
@@ -25,16 +29,16 @@ def payments(*args)
2529
when 0
2630
Adyen::CheckoutDetail.new(@client, @version)
2731
else
28-
action = 'payments'
32+
action = "payments"
2933
args[1] ||= {} # optional headers arg
30-
@client.call_adyen_api(@service, action, args[0], args[1], @version)
34+
@client.call_adyen_api(@service, action, args[0], args[1], @version, true)
3135
end
3236
end
3337
end
3438

3539
class CheckoutDetail < Service
3640
def initialize(client, version = DEFAULT_VERSION)
37-
@service = 'Checkout'
41+
@service = "Checkout"
3842
@client = client
3943
@version = version
4044
end

lib/adyen/services/dispute.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/adyen/services/payments.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
require_relative 'service'
1+
require_relative "service"
22

33
module Adyen
44
class Payments < Service
55
attr_accessor :version
66
DEFAULT_VERSION = 50
77

88
def initialize(client, version = DEFAULT_VERSION)
9-
service = 'Payment'
9+
service = "Payment"
1010
method_names = [
1111
:authorise,
1212
:authorise3d,
@@ -16,10 +16,15 @@ def initialize(client, version = DEFAULT_VERSION)
1616
:refund,
1717
:cancel_or_refund,
1818
:adjust_authorisation,
19-
:donate
19+
:donate,
20+
]
21+
with_application_info = [
22+
:authorise,
23+
:authorise3d,
24+
:authorise3ds2,
2025
]
2126

22-
super(client, version, service, method_names)
27+
super(client, version, service, method_names, with_application_info)
2328
end
2429
end
2530
end

lib/adyen/services/service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def self.action_for_method_name(method_name)
1111
method_name.to_s.gsub(/_./) { |x| x[1].upcase }
1212
end
1313

14-
def initialize(client, version, service, method_names)
14+
def initialize(client, version, service, method_names, with_application_info = [])
1515
@client = client
1616
@version = version
1717
@service = service
@@ -20,7 +20,7 @@ def initialize(client, version, service, method_names)
2020
method_names.each do |method_name|
2121
define_singleton_method method_name do |request, headers = {}|
2222
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))
2424
end
2525
end
2626
end

lib/adyen/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Adyen
22
NAME = "adyen-ruby-api-library"
3-
VERSION = "4.3.0".freeze
3+
VERSION = "4.4.0".freeze
44
end

0 commit comments

Comments
 (0)