adyen-ruby-api-library 9.3.0 → 9.5.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: ff449a394e4dd652d0efd6591ab71af8063e0177d13aae02e78c7bc3af7ddc4b
4
- data.tar.gz: 707f7d2440f5fc78badd977b592b268e803733093c96d6884cf3a55367562faf
3
+ metadata.gz: 3cc53bf5f369e14c157b891bdf7bae1a1d31d5044e0fc1f982d77a295eac8ce1
4
+ data.tar.gz: e2b54affbaa09674a1dded7f27a5eb1edfdc6d050c8950bae1dc2c6261076d8f
5
5
  SHA512:
6
- metadata.gz: 8106d7ea42e37fb28ff345794bae7211fbc1780fadce4964c7e73fcc7f2cca08bbc2b13ac68377715d44e050c1936f4e22b9fdf713a16932263eea88109fb1a3
7
- data.tar.gz: b5cadf38c7088d82876cb7502b4dcdf78042accf5b6f7f8b6a420169856a98ea51f37fb8ac1d1a508a3beaaecc337d55645d802c19a85e1254360389e8727e7d
6
+ metadata.gz: 634257fab7e168b36f446c69c165afe03bcaf24e8ae4fe741782bb523af8d97f886edfe59f393befe22fcb665926384d66ecda6507abfc44dee90ec581f6e37b
7
+ data.tar.gz: a8608fc1b33fa60a8507eedaad9a7662083288ef0df4f54fe13774467282fa6dc56b66228dffbee6cbc039b03e6f3fae680c9b4192b7e1856615aa02c682ff47
data/README.md CHANGED
@@ -22,7 +22,9 @@ This library supports the following:
22
22
  | [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | v46 | Manage both online and point-of-sale gift cards and other stored-value cards. | [StoredValue](lib/adyen/services/storedValue.rb) |
23
23
  | [Transfers API](https://docs.adyen.com/api-explorer/transfers/4/overview) | v4 | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | [Transfers](lib/adyen/services/transfers.rb) |
24
24
  | [Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/terminal-api-reference/) | - | Our point-of-sale integration. | [TerminalCloudAPI](lib/adyen/services/terminalCloudAPI.rb) |
25
- | [Disputes API](https://docs.adyen.com/api-explorer/Disputes/30/overview) | v30 | You can use the [Disputes API](https://docs.adyen.com/risk-management/disputes-api) to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes. | [Disputes](lib/adyen/services/disputes.rb) |
25
+ | [Disputes API](https://docs.adyen.com/api-explorer/Disputes/30/overview) | v30 | You can use the [Disputes API](https://docs.adyen.com/risk-management/disputes-api) to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes. | [Disputes](lib/adyen/services/disputes.rb) |
26
+ | [POS Mobile API](https://docs.adyen.com/api-explorer/possdk/68/overview) | v68 | The POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOS [POS Mobile SDK](https://docs.adyen.com/point-of-sale/ipp-mobile/) and the Adyen payments platform. The POS Mobile SDK for Android or iOS devices enables businesses to accept in-person payments using a commercial off-the-shelf (COTS) device like a phone. For example, Tap to Pay transactions, or transactions on a mobile device in combination with a card reader. | [POS Mobile](lib/adyen/services/posMobile.rb) |
27
+
26
28
 
27
29
  For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
28
30
 
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 9.3.0
1
+ 9.5.0
2
2
 
@@ -0,0 +1,47 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+ class ManageSCADevicesApi < Service
4
+ attr_accessor :service, :version
5
+
6
+ def initialize(client, version = DEFAULT_VERSION)
7
+ super(client, version, 'BalancePlatform')
8
+ end
9
+
10
+ def complete_registration_of_sca_device(request, id, headers: {})
11
+ endpoint = '/registeredDevices/{id}'.gsub(/{.+?}/, '%s')
12
+ endpoint = endpoint.gsub(%r{^/}, '')
13
+ endpoint = format(endpoint, id)
14
+
15
+ action = { method: 'patch', url: endpoint }
16
+ @client.call_adyen_api(@service, action, request, headers, @version)
17
+ end
18
+
19
+ def delete_registration_of_sca_device(id, headers: {}, query_params: {})
20
+ endpoint = '/registeredDevices/{id}'.gsub(/{.+?}/, '%s')
21
+ endpoint = endpoint.gsub(%r{^/}, '')
22
+ endpoint = format(endpoint, id)
23
+ endpoint += create_query_string(query_params)
24
+ action = { method: 'delete', url: endpoint }
25
+ @client.call_adyen_api(@service, action, {}, headers, @version)
26
+ end
27
+
28
+ def initiate_registration_of_sca_device(request, headers: {})
29
+ endpoint = '/registeredDevices'.gsub(/{.+?}/, '%s')
30
+ endpoint = endpoint.gsub(%r{^/}, '')
31
+ endpoint = format(endpoint)
32
+
33
+ action = { method: 'post', url: endpoint }
34
+ @client.call_adyen_api(@service, action, request, headers, @version)
35
+ end
36
+
37
+ def list_registered_sca_devices(headers: {}, query_params: {})
38
+ endpoint = '/registeredDevices'.gsub(/{.+?}/, '%s')
39
+ endpoint = endpoint.gsub(%r{^/}, '')
40
+ endpoint = format(endpoint)
41
+ endpoint += create_query_string(query_params)
42
+ action = { method: 'get', url: endpoint }
43
+ @client.call_adyen_api(@service, action, {}, headers, @version)
44
+ end
45
+
46
+ end
47
+ end
@@ -5,6 +5,7 @@ require_relative 'balancePlatform/card_orders_api'
5
5
  require_relative 'balancePlatform/grant_accounts_api'
6
6
  require_relative 'balancePlatform/grant_offers_api'
7
7
  require_relative 'balancePlatform/manage_card_pin_api'
8
+ require_relative 'balancePlatform/manage_sca_devices_api'
8
9
  require_relative 'balancePlatform/network_tokens_api'
9
10
  require_relative 'balancePlatform/payment_instrument_groups_api'
10
11
  require_relative 'balancePlatform/payment_instruments_api'
@@ -51,6 +52,10 @@ module Adyen
51
52
  @manage_card_pin_api ||= Adyen::ManageCardPINApi.new(@client, @version)
52
53
  end
53
54
 
55
+ def manage_sca_devices_api
56
+ @manage_sca_devices_api ||= Adyen::ManageSCADevicesApi.new(@client, @version)
57
+ end
58
+
54
59
  def network_tokens_api
55
60
  @network_tokens_api ||= Adyen::NetworkTokensApi.new(@client, @version)
56
61
  end
@@ -34,6 +34,15 @@ module Adyen
34
34
  @client.call_adyen_api(@service, action, {}, headers, @version)
35
35
  end
36
36
 
37
+ def reprocess_android_app(company_id, id, headers: {})
38
+ endpoint = '/companies/{companyId}/androidApps/{id}'.gsub(/{.+?}/, '%s')
39
+ endpoint = endpoint.gsub(%r{^/}, '')
40
+ endpoint = format(endpoint, company_id, id)
41
+
42
+ action = { method: 'patch', url: endpoint }
43
+ @client.call_adyen_api(@service, action, {}, headers, @version)
44
+ end
45
+
37
46
  def upload_android_app(company_id, headers: {})
38
47
  endpoint = '/companies/{companyId}/androidApps'.gsub(/{.+?}/, '%s')
39
48
  endpoint = endpoint.gsub(%r{^/}, '')
@@ -0,0 +1,21 @@
1
+ require_relative './service'
2
+ module Adyen
3
+ class PosMobile < Service
4
+ attr_accessor :service, :version
5
+
6
+ DEFAULT_VERSION = 68
7
+ def initialize(client, version = DEFAULT_VERSION)
8
+ super(client, version, 'PosMobile')
9
+ end
10
+
11
+ def create_communication_session(request, headers: {})
12
+ endpoint = '/sessions'.gsub(/{.+?}/, '%s')
13
+ endpoint = endpoint.gsub(%r{^/}, '')
14
+ endpoint = format(endpoint)
15
+
16
+ action = { method: 'post', url: endpoint }
17
+ @client.call_adyen_api(@service, action, request, headers, @version)
18
+ end
19
+
20
+ end
21
+ end
@@ -13,6 +13,13 @@ module Adyen
13
13
  valid_webhook_hmac?(notification_request_item, hmac_key)
14
14
  end
15
15
 
16
+ # validates the HMAC signature of the NotificationRequestItem object. Use for webhooks that provide the
17
+ # hmacSignature as part of the payload `AdditionalData` (i.e. Payments)
18
+ #
19
+ # @param webhook_request_item [Object] The webhook request item.
20
+ # @param hmac_key [String] The HMAC key used to validate the payload.
21
+
22
+ # @return [Boolean] Returns true if the HMAC signature is valid, otherwise false.
16
23
  def valid_webhook_hmac?(webhook_request_item, hmac_key)
17
24
  expected_sign = calculate_webhook_hmac(webhook_request_item, hmac_key)
18
25
  merchant_sign =
@@ -21,12 +28,32 @@ module Adyen
21
28
  expected_sign == merchant_sign
22
29
  end
23
30
 
31
+ # validates the HMAC signature of a payload against an expected signature. Use for webhooks that provide the
32
+ # hmacSignature in the HTTP header (i.e. Banking, Management API)
33
+ #
34
+ # @param hmac_signature [String] The HMAC signature to validate.
35
+ # @param hmac_key [String] The HMAC key used to validate the payload.
36
+ # @param payload [String] The webhook payload.
37
+
38
+ # @return [Boolean] Returns true if the HMAC signature is valid, otherwise false.
39
+ def valid_webhook_payload_hmac?(hmac_signature, hmac_key, payload)
40
+ expected_sign = calculate_webhook_payload_hmac(payload, hmac_key)
41
+ puts(expected_sign)
42
+ expected_sign == hmac_signature
43
+ end
44
+
24
45
  # <b>DEPRECATED:</b> Please use calculate_webhook_hmac() instead.
25
46
  def calculate_notification_hmac(notification_request_item, hmac_key)
26
47
  calculate_webhook_hmac(notification_request_item, hmac_key)
27
48
  end
28
49
 
29
50
 
51
+ def calculate_webhook_payload_hmac(data, hmac_key)
52
+ Base64.strict_encode64(
53
+ OpenSSL::HMAC.digest(HMAC_ALGORITHM, [hmac_key].pack('H*'), data)
54
+ )
55
+ end
56
+
30
57
  def calculate_webhook_hmac(webhook_request_item, hmac_key)
31
58
  data = data_to_sign(webhook_request_item)
32
59
 
@@ -35,6 +62,7 @@ module Adyen
35
62
  )
36
63
  end
37
64
 
65
+
38
66
  # TODO: Deprecate instead of aliasing
39
67
  alias valid_notification_hmac? valid_webhook_hmac?
40
68
  alias calculate_notification_hmac calculate_webhook_hmac
data/lib/adyen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Adyen
2
2
  NAME = 'adyen-ruby-api-library'.freeze
3
- VERSION = '9.3.0'.freeze
3
+ VERSION = '9.5.0'.freeze
4
4
  end
@@ -62,6 +62,21 @@ RSpec.describe Adyen::Utils::HmacValidator do
62
62
  webhook = JSON.parse(json_from_file('mocks/responses/Webhooks/mixed_webhook.json'))
63
63
  expect(validator.valid_webhook_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
64
64
  end
65
+
66
+ it 'should have an invalid payload hmac' do
67
+ hmac_signature = "wrong signature"
68
+ payload = json_from_file('mocks/responses/Webhooks/mixed_webhook.json')
69
+
70
+ expect(validator.valid_webhook_payload_hmac?(hmac_signature, key, payload)).to be false
71
+ end
72
+
73
+ it 'should have an valid payload hmac' do
74
+ hmac_signature = "93Av9t6OVkYCrVHU/xgiTkWGbulJz+Vcm2qO4TYQH2Q="
75
+ payload = json_from_file('mocks/responses/Webhooks/mixed_webhook.json')
76
+
77
+ expect(validator.valid_webhook_payload_hmac?(hmac_signature, key, payload)).to be true
78
+ end
79
+
65
80
  end
66
81
  end
67
82
  # rubocop:enable Metrics/BlockLength
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: 9.3.0
4
+ version: 9.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-11 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -127,6 +127,7 @@ files:
127
127
  - lib/adyen/services/balancePlatform/grant_accounts_api.rb
128
128
  - lib/adyen/services/balancePlatform/grant_offers_api.rb
129
129
  - lib/adyen/services/balancePlatform/manage_card_pin_api.rb
130
+ - lib/adyen/services/balancePlatform/manage_sca_devices_api.rb
130
131
  - lib/adyen/services/balancePlatform/network_tokens_api.rb
131
132
  - lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb
132
133
  - lib/adyen/services/balancePlatform/payment_instruments_api.rb
@@ -189,6 +190,7 @@ files:
189
190
  - lib/adyen/services/payout/initialization_api.rb
190
191
  - lib/adyen/services/payout/instant_payouts_api.rb
191
192
  - lib/adyen/services/payout/reviewing_api.rb
193
+ - lib/adyen/services/posMobile.rb
192
194
  - lib/adyen/services/posTerminalManagement.rb
193
195
  - lib/adyen/services/recurring.rb
194
196
  - lib/adyen/services/service.rb
@@ -443,7 +445,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
443
445
  - !ruby/object:Gem::Version
444
446
  version: '0'
445
447
  requirements: []
446
- rubygems_version: 3.5.3
448
+ rubygems_version: 3.5.9
447
449
  signing_key:
448
450
  specification_version: 4
449
451
  summary: Official Adyen Ruby API Library