adyen-ruby-api-library 9.2.0 → 9.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/VERSION +1 -1
- data/lib/adyen/services/balancePlatform/manage_sca_devices_api.rb +47 -0
- data/lib/adyen/services/balancePlatform.rb +5 -0
- data/lib/adyen/services/management/android_files_company_level_api.rb +9 -0
- data/lib/adyen/services/posMobile.rb +21 -0
- data/lib/adyen/utils/hmac_validator.rb +28 -0
- data/lib/adyen/version.rb +1 -1
- data/spec/utils/hmac_validator_spec.rb +15 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf587eb5a52ec919b8350e31713947a7054d6b4a04ba498cd022ef34c4b1d37
|
4
|
+
data.tar.gz: 8a87040a48a4c56185bb3d845f8e773d733ade4fedb698a1d9304bf57ede34b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32837f501c49e01d69692e9bbb25c384a202f3867aec1c858dc1e4317729cd30496adaf798c4d78837dedcfd6fe8f139eb85990a5ba124c4fe284bbb60de3753
|
7
|
+
data.tar.gz: 1eba0cde36d9a7b3fe352fbdd2927875bbdfa239caf757d72348a3d4e7d8a32cbe2eb1cbe6df5fd45464c0de9fd2c0c704477839838025b4bb1de6985a6a1fba
|
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.
|
1
|
+
9.4.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
|
@@ -43,5 +43,14 @@ module Adyen
|
|
43
43
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
44
44
|
end
|
45
45
|
|
46
|
+
def upload_android_certificate(company_id, headers: {})
|
47
|
+
endpoint = '/companies/{companyId}/androidCertificates'.gsub(/{.+?}/, '%s')
|
48
|
+
endpoint = endpoint.gsub(%r{^/}, '')
|
49
|
+
endpoint = format(endpoint, company_id)
|
50
|
+
|
51
|
+
action = { method: 'post', url: endpoint }
|
52
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
47
56
|
end
|
@@ -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
@@ -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.
|
4
|
+
version: 9.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: 2024-
|
11
|
+
date: 2024-05-16 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.
|
448
|
+
rubygems_version: 3.5.9
|
447
449
|
signing_key:
|
448
450
|
specification_version: 4
|
449
451
|
summary: Official Adyen Ruby API Library
|