adyen-ruby-api-library 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d77315c126cb7ae2f8600f5bc8e853fd868a6bc6c30c36add08cfbe93285488
4
- data.tar.gz: bf4c1f6498020da769aecba45b4fe6ce43f017ca71e083723b2bfa8903d3932e
3
+ metadata.gz: e483ea1b71301634db57072423fd8cea1483b160eec7c1ba85fcf62ccbac0414
4
+ data.tar.gz: fa6dd93d1fe95ccf9ce3e9cc4a9956e523e6f25a20ae49fb2529e560c1aec14a
5
5
  SHA512:
6
- metadata.gz: dd3c31163dae11854ef0d921ff772ddd3d5b526c2bef106a26edd150e2f517fd306cde43e7839313e134dd72f86eb6f0c37a2a19cb52efc169892e8849b9ceb0
7
- data.tar.gz: c51e518693653f525a5dc06ee71d859614f5a741b4109ded91a29e9327c768c9b7c0c5f1783fdceeb740b1e6f95074bfc7f0336b7228eb1a3e66a34bd3730bd1
6
+ metadata.gz: 50f51f247bb68817b56ef596ad2b435280fedb1dc06806665a5e48b4c1cfb67fda4c1060f882929c0c40c8b225635cc19d36d6f90be4ae1e0e7149dc8f8638bd
7
+ data.tar.gz: 15273291ffb0122fab7050dc1263028c6a38d6634519c744057d1b3756b62461c028de7982d5c36adfb04e50f25a7d121541d1ef496a91c3c63bd67ee75c7829
data/.gitignore CHANGED
@@ -11,3 +11,5 @@ design.txt
11
11
 
12
12
  .bundle
13
13
  .ruby-version
14
+
15
+ .DS_Store
data/README.md CHANGED
@@ -15,6 +15,8 @@ The Library supports all APIs under the following services:
15
15
  * marketpay
16
16
  * postfmapi
17
17
  * data_protection
18
+ * dispute
19
+ * bin_lookup
18
20
 
19
21
  ## Requirements
20
22
 
@@ -151,6 +153,16 @@ adyen.checkout.version = 50
151
153
  **data_protection:**
152
154
  - request_subject_erasure
153
155
 
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
+
154
166
  ## Support
155
167
  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).
156
168
 
@@ -10,5 +10,7 @@ require_relative "adyen/services/marketpay"
10
10
  require_relative "adyen/services/postfmapi"
11
11
  require_relative "adyen/services/service"
12
12
  require_relative "adyen/services/data_protection"
13
+ require_relative "adyen/services/dispute"
14
+ require_relative "adyen/services/bin_lookup"
13
15
  require_relative "adyen/hash_with_accessors"
14
16
  require_relative "adyen/utils/hmac_validator"
@@ -48,13 +48,13 @@ module Adyen
48
48
  when "Account", "Fund", "Notification", "Hop"
49
49
  url = "https://cal-#{@env}.adyen.com/cal/services"
50
50
  supports_live_url_prefix = false
51
- when "Recurring", "Payment", "Payout"
51
+ when "Recurring", "Payment", "Payout", "BinLookup"
52
52
  url = "https://pal-#{@env}.adyen.com/pal/servlet"
53
53
  supports_live_url_prefix = true
54
54
  when "Terminal"
55
55
  url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
56
56
  supports_live_url_prefix = false
57
- when "DataProtectionService"
57
+ when "DataProtectionService", "DisputeService"
58
58
  url = "https://ca-#{@env}.adyen.com/ca/services"
59
59
  supports_live_url_prefix = false
60
60
  else
@@ -80,7 +80,7 @@ module Adyen
80
80
  end
81
81
 
82
82
  # 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)
84
84
  # get URL for requested endpoint
85
85
  url = service_url(service, action, version)
86
86
 
@@ -125,7 +125,7 @@ module Adyen
125
125
  end
126
126
 
127
127
  # add application only on checkout service
128
- if service == 'Checkout' || service == 'CheckoutUtility'
128
+ if with_application_info
129
129
  add_application_info(request_data)
130
130
  end
131
131
 
@@ -157,16 +157,15 @@ module Adyen
157
157
  # add application_info for analytics
158
158
  def add_application_info(request_data)
159
159
  adyenLibrary = {
160
- :name => Adyen::NAME,
161
- :version => Adyen::VERSION.to_s
160
+ :name => Adyen::NAME,
161
+ :version => Adyen::VERSION.to_s,
162
162
  }
163
163
 
164
164
  if request_data[:applicationInfo].nil?
165
- request_data[:applicationInfo] = {};
165
+ request_data[:applicationInfo] = {}
166
166
  end
167
167
 
168
168
  request_data[:applicationInfo][:adyenLibrary] = adyenLibrary
169
- request_data[:applicationInfo][:adyenLibraryTest] = adyenLibrary
170
169
  end
171
170
 
172
171
  # services
@@ -201,5 +200,13 @@ module Adyen
201
200
  def data_protection
202
201
  @data_protection ||= Adyen::DataProtection.new(self)
203
202
  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
204
211
  end
205
212
  end
@@ -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,18 +1,22 @@
1
- require_relative 'service'
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 = 'Checkout'
8
+ service = "Checkout"
9
9
  method_names = [
10
10
  :payment_methods,
11
11
  :payment_session,
12
- :payment_links
12
+ :payment_links,
13
+ ]
14
+ with_application_info = [
15
+ :payment_session,
16
+ :payment_links,
13
17
  ]
14
18
 
15
- super(client, version, service, method_names)
19
+ super(client, version, service, method_names, with_application_info)
16
20
  end
17
21
 
18
22
  # This method can't be dynamically defined because
@@ -25,16 +29,16 @@ module Adyen
25
29
  when 0
26
30
  Adyen::CheckoutDetail.new(@client, @version)
27
31
  else
28
- action = 'payments'
32
+ action = "payments"
29
33
  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)
31
35
  end
32
36
  end
33
37
  end
34
38
 
35
39
  class CheckoutDetail < Service
36
40
  def initialize(client, version = DEFAULT_VERSION)
37
- @service = 'Checkout'
41
+ @service = "Checkout"
38
42
  @client = client
39
43
  @version = version
40
44
  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
@@ -1,4 +1,4 @@
1
- require_relative 'service'
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 = 'Payment'
9
+ service = "Payment"
10
10
  method_names = [
11
11
  :authorise,
12
12
  :authorise3d,
@@ -16,10 +16,15 @@ module Adyen
16
16
  :refund,
17
17
  :cancel_or_refund,
18
18
  :adjust_authorisation,
19
- :donate
19
+ :donate,
20
+ ]
21
+ with_application_info = [
22
+ :authorise,
23
+ :authorise3d,
24
+ :authorise3ds2,
20
25
  ]
21
26
 
22
- super(client, version, service, method_names)
27
+ super(client, version, service, method_names, with_application_info)
23
28
  end
24
29
  end
25
30
  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
@@ -1,4 +1,4 @@
1
1
  module Adyen
2
2
  NAME = "adyen-ruby-api-library"
3
- VERSION = "4.3.0".freeze
3
+ VERSION = "4.4.0".freeze
4
4
  end
@@ -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
@@ -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
@@ -0,0 +1,4 @@
1
+ {
2
+ "merchantAccount": "TestMerchant",
3
+ "cardNumber": "4111111111111111"
4
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "amount": {
3
+ "currency": "EUR",
4
+ "value": 1000
5
+ },
6
+ "cardNumber": "5101180000000007",
7
+ "merchantAccount": "TestMerchant"
8
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "disputePspReference": "9913486733050065",
3
+ "defenseReasonCode": "SupplyDefenseMaterial",
4
+ "merchantAccountCode": "YOUR_MERCHANT_ACCOUNT"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "disputePspReference": "9913486733050065",
3
+ "merchantAccountCode": "YOUR_MERCHANT_ACCOUNT",
4
+ "defenseDocumentType": "MerchandiseDescription"
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
3
+ "disputePspReference": "9913486733050065"
4
+ }
@@ -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,8 @@
1
+ {
2
+ "binDetails": {
3
+ "issuerCountry": "NL"
4
+ },
5
+ "threeDS1Supported": true,
6
+ "threeDS2CardRangeDetails": [],
7
+ "threeDS2supported": false
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "costEstimateAmount": {
3
+ "currency": "EUR",
4
+ "value": 1000
5
+ },
6
+ "resultCode": "Success",
7
+ "surchargeType": "PASSTHROUGH"
8
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "disputeServiceResult": {
3
+ "success": true
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "disputeServiceResult": {
3
+ "success": true
4
+ }
5
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "defenseReasons": [
3
+ {
4
+ "defenseDocumentTypes": [
5
+ {
6
+ "available": false,
7
+ "defenseDocumentTypeCode": "TIDorInvoice",
8
+ "requirementLevel": "Optional"
9
+ },
10
+ {
11
+ "available": false,
12
+ "defenseDocumentTypeCode": "DefenseMaterial",
13
+ "requirementLevel": "Required"
14
+ },
15
+ {
16
+ "available": false,
17
+ "defenseDocumentTypeCode": "AlternativeDefenseMaterial",
18
+ "requirementLevel": "AlternativeRequired"
19
+ }
20
+ ],
21
+ "defenseReasonCode": "SupplyDefenseMaterial",
22
+ "satisfied": false
23
+ }
24
+ ],
25
+ "disputeServiceResult": {
26
+ "success": true
27
+ }
28
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "disputeServiceResult": {
3
+ "success": true
4
+ }
5
+ }
@@ -18,20 +18,27 @@ def create_test(client, service, method_name, parent_object)
18
18
  request_body = JSON.parse(json_from_file("mocks/requests/#{service}/#{method_name}.json"))
19
19
  response_body = json_from_file("mocks/responses/#{service}/#{method_name}.json")
20
20
 
21
-
22
- if service == 'Checkout' || service == 'CheckoutUtility'
21
+ with_application_info = [
22
+ "authorise",
23
+ "authorise3d",
24
+ "authorise3ds2",
25
+ "payments",
26
+ "payment_session",
27
+ "payment_links",
28
+ ]
29
+ if with_application_info.include?(method_name)
23
30
  client.add_application_info(request_body)
24
31
  end
25
32
 
26
33
  # client-generated headers
27
34
  headers = {
28
- 'Content-Type'.to_sym => 'application/json'
35
+ "Content-Type".to_sym => "application/json",
29
36
  }
30
37
 
31
38
  # authentication headers
32
- if not client.api_key.nil? then
39
+ if not client.api_key.nil?
33
40
  headers["x-api-key"] = client.api_key
34
- elsif not client.ws_user.nil? and not client.ws_password.nil? then
41
+ elsif not client.ws_user.nil? and not client.ws_password.nil?
35
42
  auth_header = "Basic " + Base64::encode64("#{client.ws_user}:#{client.ws_password}")
36
43
  headers["Authorization"] = auth_header.strip
37
44
  else
@@ -43,12 +50,12 @@ def create_test(client, service, method_name, parent_object)
43
50
  url = client.service_url(service, action, parent_object.version)
44
51
  WebMock.stub_request(:post, url).
45
52
  with(
46
- body: request_body,
47
- headers: headers
48
- ).
53
+ body: request_body,
54
+ headers: headers,
55
+ ).
49
56
  to_return(
50
- body: response_body
51
- )
57
+ body: response_body,
58
+ )
52
59
  result = parent_object.public_send(method_name, request_body)
53
60
 
54
61
  # result.response is already a Ruby object (Adyen::HashWithAccessors) (rather than an unparsed JSON string)
@@ -86,10 +93,10 @@ def create_client(auth_type)
86
93
  client = Adyen::Client.new
87
94
  client.env = :mock
88
95
 
89
- if auth_type == :basic then
96
+ if auth_type == :basic
90
97
  client.ws_user = "user"
91
98
  client.ws_password = "password"
92
- elsif auth_type == :api_key then
99
+ elsif auth_type == :api_key
93
100
  client.api_key = "api_key"
94
101
  else
95
102
  raise ArgumentError "Invalid auth type for test client"
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.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -111,9 +111,11 @@ files:
111
111
  - lib/adyen/errors.rb
112
112
  - lib/adyen/hash_with_accessors.rb
113
113
  - lib/adyen/result.rb
114
+ - lib/adyen/services/bin_lookup.rb
114
115
  - lib/adyen/services/checkout.rb
115
116
  - lib/adyen/services/checkout_utility.rb
116
117
  - lib/adyen/services/data_protection.rb
118
+ - lib/adyen/services/dispute.rb
117
119
  - lib/adyen/services/marketpay.rb
118
120
  - lib/adyen/services/payments.rb
119
121
  - lib/adyen/services/payouts.rb
@@ -124,10 +126,12 @@ files:
124
126
  - lib/adyen/version.rb
125
127
  - renovate.json
126
128
  - spec/account_spec.rb
129
+ - spec/bin_lookup_spec.rb
127
130
  - spec/checkout_spec.rb
128
131
  - spec/checkout_utility_spec.rb
129
132
  - spec/client_spec.rb
130
133
  - spec/data_protection_spec.rb
134
+ - spec/dispute_spec.rb
131
135
  - spec/errors_spec.rb
132
136
  - spec/fund_spec.rb
133
137
  - spec/hash_with_accessors_spec.rb
@@ -146,6 +150,8 @@ files:
146
150
  - spec/mocks/requests/Account/update_account_holder.json
147
151
  - spec/mocks/requests/Account/update_account_holder_state.json
148
152
  - spec/mocks/requests/Account/upload_document.json
153
+ - spec/mocks/requests/BinLookup/get_3ds_availability.json
154
+ - spec/mocks/requests/BinLookup/get_cost_estimate.json
149
155
  - spec/mocks/requests/Checkout/payment-details.json
150
156
  - spec/mocks/requests/Checkout/payment-result.json
151
157
  - spec/mocks/requests/Checkout/payment_links.json
@@ -155,6 +161,10 @@ files:
155
161
  - spec/mocks/requests/Checkout/verify.json
156
162
  - spec/mocks/requests/CheckoutUtility/origin_keys.json
157
163
  - spec/mocks/requests/DataProtectionService/request_subject_erasure.json
164
+ - spec/mocks/requests/DisputeService/defend_dispute.json
165
+ - spec/mocks/requests/DisputeService/delete_dispute_defense_document.json
166
+ - spec/mocks/requests/DisputeService/retrieve_applicable_defense_reasons.json
167
+ - spec/mocks/requests/DisputeService/supply_defense_document.json
158
168
  - spec/mocks/requests/Fund/account_holder_balance.json
159
169
  - spec/mocks/requests/Fund/account_holder_transaction_list.json
160
170
  - spec/mocks/requests/Fund/payout_account_holder.json
@@ -202,6 +212,8 @@ files:
202
212
  - spec/mocks/responses/Account/update_account_holder.json
203
213
  - spec/mocks/responses/Account/update_account_holder_state.json
204
214
  - spec/mocks/responses/Account/upload_document.json
215
+ - spec/mocks/responses/BinLookup/get_3ds_availability.json
216
+ - spec/mocks/responses/BinLookup/get_cost_estimate.json
205
217
  - spec/mocks/responses/Checkout/payment-details.json
206
218
  - spec/mocks/responses/Checkout/payment-result.json
207
219
  - spec/mocks/responses/Checkout/payment_links.json
@@ -211,6 +223,10 @@ files:
211
223
  - spec/mocks/responses/Checkout/verify.json
212
224
  - spec/mocks/responses/CheckoutUtility/origin_keys.json
213
225
  - spec/mocks/responses/DataProtectionService/request_subject_erasure.json
226
+ - spec/mocks/responses/DisputeService/defend_dispute.json
227
+ - spec/mocks/responses/DisputeService/delete_dispute_defense_document.json
228
+ - spec/mocks/responses/DisputeService/retrieve_applicable_defense_reasons.json
229
+ - spec/mocks/responses/DisputeService/supply_defense_document.json
214
230
  - spec/mocks/responses/Fund/account_holder_balance.json
215
231
  - spec/mocks/responses/Fund/account_holder_transaction_list.json
216
232
  - spec/mocks/responses/Fund/payout_account_holder.json