Skip to content

Commit 52c69a7

Browse files
Merge pull request #167 from Adyen/automation/release
Release v7.1.0
2 parents 22b68b9 + 51f4c09 commit 52c69a7

File tree

15 files changed

+379
-4
lines changed

15 files changed

+379
-4
lines changed

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This library supports the following:
2121
| [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
2222
| [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) |
2323
| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | v3 | 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+
| [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) |
2425

2526
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
2627

@@ -99,6 +100,121 @@ To run the tests use :
99100
bundle install --with development
100101
~~~~
101102

103+
## Using the Cloud Terminal API Integration
104+
In order to submit In-Person requests with [Terminal API over Cloud](https://docs.adyen.com/point-of-sale/design-your-integration/choose-your-architecture/cloud/) you need to initialize the client in the same way as explained above for Ecommerce transactions:
105+
``` ruby
106+
# Step 1: Require the parts of the module you want to use
107+
require 'adyen-ruby-api-library'
108+
109+
# Step 2: Initialize the client object
110+
adyen = Adyen::Client.new(api_key: 'YOUR_API_KEY', env: :test)
111+
112+
# Step 3: Create the request
113+
serviceID = "123456789"
114+
saleID = "POS-SystemID12345"
115+
POIID = "Your Device Name(eg V400m-123456789)"
116+
117+
# Use a unique transaction for every transaction you perform
118+
transactionID = "TransactionID"
119+
120+
request =
121+
{
122+
"SaleToPOIRequest": {
123+
"MessageHeader": {
124+
"MessageClass": "Service",
125+
"MessageCategory": "Payment",
126+
"MessageType": "Request",
127+
"ServiceID": serviceID,
128+
"SaleID": saleID,
129+
"POIID": POIID,
130+
"ProtocolVersion": "3.0"
131+
},
132+
"PaymentRequest": {
133+
"SaleData": {
134+
"SaleTransactionID": {
135+
"TransactionID": transactionID,
136+
"TimeStamp": "2023-08-23T09:48:55"
137+
},
138+
"SaleToAcquirerData": "eyJhcHBsaWNhdGlvbkluZm8iOnsiYWR5ZW5MaWJyYXJ5Ijp7Im5hbWUiOiJhZ....",
139+
"TokenRequestedType": "Transaction"
140+
},
141+
"PaymentTransaction": {
142+
"AmountsReq": {
143+
"Currency": "EUR",
144+
"RequestedAmount": 10
145+
}
146+
}
147+
}
148+
}
149+
}
150+
151+
# Step 4: Make the request
152+
response = adyen.terminal_cloud_api.sync(request)
153+
```
154+
155+
### Optional: perform an abort request
156+
157+
To perform an [abort request](https://docs.adyen.com/point-of-sale/basic-tapi-integration/cancel-a-transaction/) you can use the following example:
158+
``` ruby
159+
abortRequest =
160+
{
161+
"MessageHeader": {
162+
"MessageClass": "Service",
163+
"MessageCategory": "Abort",
164+
"MessageType": "Request",
165+
"ServiceID": serviceID,
166+
"SaleID": saleID,
167+
"POIID": POIID,
168+
"ProtocolVersion": "3.0"
169+
},
170+
"AbortRequest": {
171+
"AbortReason": "MerchantAbort",
172+
"MessageReference": {
173+
"MessageCategory": "Payment",
174+
"SaleID": saleID,
175+
# Service ID of the payment you're aborting
176+
"ServiceID": serviceID,
177+
"POIID": POIID
178+
}
179+
}
180+
}
181+
182+
response = adyen.terminal_cloud_api.sync(abortRequest)
183+
```
184+
185+
### Optional: perform a status request
186+
187+
To perform a [status request](https://docs.adyen.com/point-of-sale/basic-tapi-integration/verify-transaction-status/) you can use the following example:
188+
``` ruby
189+
statusRequest =
190+
{
191+
"MessageHeader": {
192+
"MessageClass": "Service",
193+
"MessageCategory": "TransactionStatus",
194+
"MessageType": "Request",
195+
"ServiceID": serviceID,
196+
"SaleID": saleID,
197+
"POIID": POIID,
198+
"ProtocolVersion": "3.0"
199+
},
200+
"TransactionStatusRequest": {
201+
"ReceiptReprintFlag": true,
202+
"DocumentQualifier": [
203+
"CashierReceipt",
204+
"CustomerReceipt"
205+
],
206+
"MessageReference": {
207+
"SaleID": saleID,
208+
# serviceID of the transaction you want the status update for
209+
"ServiceID": serviceID,
210+
"MessageCategory": "Payment"
211+
}
212+
}
213+
}
214+
215+
response = adyen.terminal_cloud_api.sync(statusRequest)
216+
```
217+
102218
## Feedback
103219
We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out [our feedback form](https://forms.gle/A4EERrR6CWgKWe5r9) to share your thoughts, suggestions or ideas.
104220

lib/adyen-ruby-api-library.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
require_relative 'adyen/services/management'
2020
require_relative 'adyen/services/storedValue'
2121
require_relative 'adyen/services/balanceControlService'
22+
require_relative 'adyen/services/terminalCloudAPI'

lib/adyen/client.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def service_url_base(service)
7575
when 'Management'
7676
url = "https://management-#{@env}.adyen.com"
7777
supports_live_url_prefix = false
78+
when 'TerminalCloudAPI'
79+
url = "https://terminal-api-#{@env}.adyen.com"
80+
supports_live_url_prefix = false
7881
else
7982
raise ArgumentError, 'Invalid service specified'
8083
end
@@ -98,6 +101,8 @@ def service_url_base(service)
98101
def service_url(service, action, version)
99102
if service == "Checkout" && @env == :live
100103
return "#{service_url_base(service)}/checkout/v#{version}/#{action}"
104+
elsif version == nil
105+
return "#{service_url_base(service)}/#{action}"
101106
else
102107
return "#{service_url_base(service)}/v#{version}/#{action}"
103108
end
@@ -221,6 +226,9 @@ def call_adyen_api(service, action, request_data, headers, version, _with_applic
221226
# delete has no response.body (unless it throws an error)
222227
if response.body.nil? || response.body === ''
223228
AdyenResult.new('{}', response.headers, response.status)
229+
# terminal API async call returns always 'ok'
230+
elsif response.body === 'ok'
231+
AdyenResult.new('{}', response.headers, response.status)
224232
else
225233
AdyenResult.new(response.body, response.headers, response.status)
226234
end
@@ -286,6 +294,10 @@ def stored_value
286294
def balance_control_service
287295
@balance_control_service ||= Adyen::BalanceControlService.new(self)
288296
end
297+
298+
def terminal_cloud_api
299+
@terminal_cloud_api ||= Adyen::TerminalCloudAPI.new(self)
300+
end
289301
end
290302
end
291303
# rubocop:enable all

lib/adyen/services/balancePlatform.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_relative 'balancePlatform/bank_account_validation_api'
44
require_relative 'balancePlatform/grant_accounts_api'
55
require_relative 'balancePlatform/grant_offers_api'
6+
require_relative 'balancePlatform/network_tokens_api'
67
require_relative 'balancePlatform/payment_instrument_groups_api'
78
require_relative 'balancePlatform/payment_instruments_api'
89
require_relative 'balancePlatform/platform_api'
@@ -39,6 +40,10 @@ def grant_offers_api
3940
@grant_offers_api ||= Adyen::GrantOffersApi.new(@client, @version)
4041
end
4142

43+
def network_tokens_api
44+
@network_tokens_api ||= Adyen::NetworkTokensApi.new(@client, @version)
45+
end
46+
4247
def payment_instrument_groups_api
4348
@payment_instrument_groups_api ||= Adyen::PaymentInstrumentGroupsApi.new(@client, @version)
4449
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require_relative '../service'
2+
module Adyen
3+
class NetworkTokensApi < Service
4+
attr_accessor :service, :version
5+
6+
def initialize(client, version = DEFAULT_VERSION)
7+
super(client, version, 'BalancePlatform')
8+
end
9+
10+
def get_network_token(network_token_id, headers: {})
11+
endpoint = '/networkTokens/{networkTokenId}'.gsub(/{.+?}/, '%s')
12+
endpoint = endpoint.gsub(%r{^/}, '')
13+
endpoint = format(endpoint, network_token_id)
14+
15+
action = { method: 'get', url: endpoint }
16+
@client.call_adyen_api(@service, action, {}, headers, @version)
17+
end
18+
19+
def update_network_token(request, network_token_id, headers: {})
20+
endpoint = '/networkTokens/{networkTokenId}'.gsub(/{.+?}/, '%s')
21+
endpoint = endpoint.gsub(%r{^/}, '')
22+
endpoint = format(endpoint, network_token_id)
23+
24+
action = { method: 'patch', url: endpoint }
25+
@client.call_adyen_api(@service, action, request, headers, @version)
26+
end
27+
28+
end
29+
end

lib/adyen/services/balancePlatform/payment_instruments_api.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ def get_payment_instrument(id, headers: {})
1616
@client.call_adyen_api(@service, action, {}, headers, @version)
1717
end
1818

19+
def list_network_tokens(id, headers: {})
20+
endpoint = '/paymentInstruments/{id}/networkTokens'.gsub(/{.+?}/, '%s')
21+
endpoint = endpoint.gsub(%r{^/}, '')
22+
endpoint = format(endpoint, id)
23+
24+
action = { method: 'get', url: endpoint }
25+
@client.call_adyen_api(@service, action, {}, headers, @version)
26+
end
27+
1928
def get_pan_of_payment_instrument(id, headers: {})
2029
endpoint = '/paymentInstruments/{id}/reveal'.gsub(/{.+?}/, '%s')
2130
endpoint = endpoint.gsub(%r{^/}, '')

lib/adyen/services/checkout/recurring_api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ def initialize(client, version = DEFAULT_VERSION)
77
super(client, version, 'Checkout')
88
end
99

10-
def delete_token_for_stored_payment_details(recurring_id, headers: {}, query_params: {})
11-
endpoint = '/storedPaymentMethods/{recurringId}'.gsub(/{.+?}/, '%s')
10+
def delete_token_for_stored_payment_details(stored_payment_method_id, headers: {}, query_params: {})
11+
endpoint = '/storedPaymentMethods/{storedPaymentMethodId}'.gsub(/{.+?}/, '%s')
1212
endpoint = endpoint.gsub(%r{^/}, '')
13-
endpoint = format(endpoint, recurring_id)
13+
endpoint = format(endpoint, stored_payment_method_id)
1414
endpoint += create_query_string(query_params)
1515
action = { method: 'delete', url: endpoint }
1616
@client.call_adyen_api(@service, action, {}, headers, @version)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require_relative './service'
2+
module Adyen
3+
class TerminalCloudAPI < Service
4+
attr_accessor :service
5+
6+
def initialize(client)
7+
super(client, nil ,'TerminalCloudAPI')
8+
end
9+
10+
def connected_terminals(request, headers: {})
11+
endpoint = '/connectedTerminals'.gsub(/{.+?}/, '%s')
12+
endpoint = endpoint.gsub(%r{^/}, '')
13+
endpoint = format(endpoint)
14+
15+
action = { method: 'post', url: endpoint }
16+
@client.call_adyen_api(@service, action, request, headers, @version)
17+
end
18+
19+
def sync(request, headers: {})
20+
endpoint = '/sync'.gsub(/{.+?}/, '%s')
21+
endpoint = endpoint.gsub(%r{^/}, '')
22+
endpoint = format(endpoint)
23+
24+
action = { method: 'post', url: endpoint }
25+
@client.call_adyen_api(@service, action, request, headers, @version)
26+
end
27+
28+
def async(request, headers: {})
29+
endpoint = '/async'.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+
end
38+
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'.freeze
3-
VERSION = '7.0.3'.freeze
3+
VERSION = '7.1.0'.freeze
44
end

spec/client_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,23 @@
236236
expect(client.service_url('PosTerminalManagement', 'assignTerminals', '1'))
237237
.to eq('https://postfmapi-test.adyen.com/postfmapi/terminal/v1/assignTerminals')
238238
end
239+
240+
it 'checks the creation of TerminalCloudAPI sync url' do
241+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
242+
expect(client.service_url('TerminalCloudAPI', 'sync', nil))
243+
.to eq('https://terminal-api-test.adyen.com/sync')
244+
end
245+
246+
it 'checks the creation of TerminalCloudAPI async url' do
247+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
248+
expect(client.service_url('TerminalCloudAPI', 'async', nil))
249+
.to eq('https://terminal-api-test.adyen.com/async')
250+
end
251+
252+
it 'checks the creation of TerminalCloudAPI connectedTerminals url' do
253+
client = Adyen::Client.new(api_key: 'api_key', env: :test)
254+
expect(client.service_url('TerminalCloudAPI', 'connectedTerminals', nil))
255+
.to eq('https://terminal-api-test.adyen.com/connectedTerminals')
256+
257+
end
239258
end

0 commit comments

Comments
 (0)