adyen-ruby-api-library 7.0.3 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +1 -1
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/rubygems_release.yml +1 -1
- data/.github/workflows/services.yml +1 -1
- data/README.md +116 -0
- data/lib/adyen/client.rb +12 -0
- data/lib/adyen/services/balancePlatform/network_tokens_api.rb +29 -0
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +9 -0
- data/lib/adyen/services/balancePlatform/transfer_routes_api.rb +20 -0
- data/lib/adyen/services/balancePlatform.rb +10 -0
- data/lib/adyen/services/checkout/recurring_api.rb +3 -3
- data/lib/adyen/services/management/android_files_company_level_api.rb +38 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +0 -18
- data/lib/adyen/services/management.rb +5 -0
- data/lib/adyen/services/terminalCloudAPI.rb +38 -0
- data/lib/adyen/version.rb +1 -1
- data/lib/adyen-ruby-api-library.rb +1 -0
- data/spec/client_spec.rb +19 -0
- data/spec/mocks/requests/TerminalCloudAPI/connected_terminals.json +3 -0
- data/spec/mocks/requests/TerminalCloudAPI/sync_payment.json +29 -0
- data/spec/mocks/responses/TerminalCloudAPI/connected_terminals.json +5 -0
- data/spec/mocks/responses/TerminalCloudAPI/sync_payment.json +18 -0
- data/spec/terminal_cloud_api_spec.rb +91 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc8273f0430a4f263253bff4a97356616958dbabea34e1bb46de537ee8ddc244
|
4
|
+
data.tar.gz: 3e538becadaa36c48aa4c1af68543601be2deca4dba36ec144792e68104a65a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55ee3ccc92e7615e05329cbc12439aa6862b277db43bd4d33a9b97d9baa22843d31b8e816cc970a4636db7698487baa5f423b37de25c3bae2363c18e4dedbc6e
|
7
|
+
data.tar.gz: 9c8d918b1790baf72aa4da31df12f87d6f90b97ed806d181dc32051d6f36f7a555d59bfc1e0def1fa3299f87d8494ae2d855a7a7871ddbfc485c43e7afb8eddc
|
data/.github/workflows/ruby.yml
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,7 @@ This library supports the following:
|
|
21
21
|
| [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
|
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/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) |
|
24
25
|
|
25
26
|
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
26
27
|
|
@@ -99,6 +100,121 @@ To run the tests use :
|
|
99
100
|
bundle install --with development
|
100
101
|
~~~~
|
101
102
|
|
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
|
+
|
102
218
|
## Feedback
|
103
219
|
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.
|
104
220
|
|
data/lib/adyen/client.rb
CHANGED
@@ -75,6 +75,9 @@ module Adyen
|
|
75
75
|
when 'Management'
|
76
76
|
url = "https://management-#{@env}.adyen.com"
|
77
77
|
supports_live_url_prefix = false
|
78
|
+
when 'TerminalCloudAPI'
|
79
|
+
url = "https://terminal-api-#{@env}.adyen.com"
|
80
|
+
supports_live_url_prefix = false
|
78
81
|
else
|
79
82
|
raise ArgumentError, 'Invalid service specified'
|
80
83
|
end
|
@@ -98,6 +101,8 @@ module Adyen
|
|
98
101
|
def service_url(service, action, version)
|
99
102
|
if service == "Checkout" && @env == :live
|
100
103
|
return "#{service_url_base(service)}/checkout/v#{version}/#{action}"
|
104
|
+
elsif version == nil
|
105
|
+
return "#{service_url_base(service)}/#{action}"
|
101
106
|
else
|
102
107
|
return "#{service_url_base(service)}/v#{version}/#{action}"
|
103
108
|
end
|
@@ -221,6 +226,9 @@ module Adyen
|
|
221
226
|
# delete has no response.body (unless it throws an error)
|
222
227
|
if response.body.nil? || response.body === ''
|
223
228
|
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)
|
224
232
|
else
|
225
233
|
AdyenResult.new(response.body, response.headers, response.status)
|
226
234
|
end
|
@@ -286,6 +294,10 @@ module Adyen
|
|
286
294
|
def balance_control_service
|
287
295
|
@balance_control_service ||= Adyen::BalanceControlService.new(self)
|
288
296
|
end
|
297
|
+
|
298
|
+
def terminal_cloud_api
|
299
|
+
@terminal_cloud_api ||= Adyen::TerminalCloudAPI.new(self)
|
300
|
+
end
|
289
301
|
end
|
290
302
|
end
|
291
303
|
# rubocop:enable all
|
@@ -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
|
@@ -16,6 +16,15 @@ module Adyen
|
|
16
16
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
17
|
end
|
18
18
|
|
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
|
+
|
19
28
|
def get_pan_of_payment_instrument(id, headers: {})
|
20
29
|
endpoint = '/paymentInstruments/{id}/reveal'.gsub(/{.+?}/, '%s')
|
21
30
|
endpoint = endpoint.gsub(%r{^/}, '')
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
class TransferRoutesApi < Service
|
4
|
+
attr_accessor :service, :version
|
5
|
+
|
6
|
+
def initialize(client, version = DEFAULT_VERSION)
|
7
|
+
super(client, version, 'BalancePlatform')
|
8
|
+
end
|
9
|
+
|
10
|
+
def calculate_transfer_routes(request, headers: {})
|
11
|
+
endpoint = '/transferRoutes/calculate'.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
|
+
end
|
20
|
+
end
|
@@ -3,10 +3,12 @@ require_relative 'balancePlatform/balance_accounts_api'
|
|
3
3
|
require_relative 'balancePlatform/bank_account_validation_api'
|
4
4
|
require_relative 'balancePlatform/grant_accounts_api'
|
5
5
|
require_relative 'balancePlatform/grant_offers_api'
|
6
|
+
require_relative 'balancePlatform/network_tokens_api'
|
6
7
|
require_relative 'balancePlatform/payment_instrument_groups_api'
|
7
8
|
require_relative 'balancePlatform/payment_instruments_api'
|
8
9
|
require_relative 'balancePlatform/platform_api'
|
9
10
|
require_relative 'balancePlatform/transaction_rules_api'
|
11
|
+
require_relative 'balancePlatform/transfer_routes_api'
|
10
12
|
|
11
13
|
module Adyen
|
12
14
|
class BalancePlatform
|
@@ -39,6 +41,10 @@ module Adyen
|
|
39
41
|
@grant_offers_api ||= Adyen::GrantOffersApi.new(@client, @version)
|
40
42
|
end
|
41
43
|
|
44
|
+
def network_tokens_api
|
45
|
+
@network_tokens_api ||= Adyen::NetworkTokensApi.new(@client, @version)
|
46
|
+
end
|
47
|
+
|
42
48
|
def payment_instrument_groups_api
|
43
49
|
@payment_instrument_groups_api ||= Adyen::PaymentInstrumentGroupsApi.new(@client, @version)
|
44
50
|
end
|
@@ -55,5 +61,9 @@ module Adyen
|
|
55
61
|
@transaction_rules_api ||= Adyen::TransactionRulesApi.new(@client, @version)
|
56
62
|
end
|
57
63
|
|
64
|
+
def transfer_routes_api
|
65
|
+
@transfer_routes_api ||= Adyen::TransferRoutesApi.new(@client, @version)
|
66
|
+
end
|
67
|
+
|
58
68
|
end
|
59
69
|
end
|
@@ -7,10 +7,10 @@ module Adyen
|
|
7
7
|
super(client, version, 'Checkout')
|
8
8
|
end
|
9
9
|
|
10
|
-
def delete_token_for_stored_payment_details(
|
11
|
-
endpoint = '/storedPaymentMethods/{
|
10
|
+
def delete_token_for_stored_payment_details(stored_payment_method_id, headers: {}, query_params: {})
|
11
|
+
endpoint = '/storedPaymentMethods/{storedPaymentMethodId}'.gsub(/{.+?}/, '%s')
|
12
12
|
endpoint = endpoint.gsub(%r{^/}, '')
|
13
|
-
endpoint = format(endpoint,
|
13
|
+
endpoint = format(endpoint, stored_payment_method_id)
|
14
14
|
endpoint += create_query_string(query_params)
|
15
15
|
action = { method: 'delete', url: endpoint }
|
16
16
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
class AndroidFilesCompanyLevelApi < Service
|
4
|
+
attr_accessor :service, :version
|
5
|
+
|
6
|
+
def initialize(client, version = DEFAULT_VERSION)
|
7
|
+
super(client, version, 'Management')
|
8
|
+
end
|
9
|
+
|
10
|
+
def list_android_apps(company_id, headers: {}, query_params: {})
|
11
|
+
endpoint = '/companies/{companyId}/androidApps'.gsub(/{.+?}/, '%s')
|
12
|
+
endpoint = endpoint.gsub(%r{^/}, '')
|
13
|
+
endpoint = format(endpoint, company_id)
|
14
|
+
endpoint += create_query_string(query_params)
|
15
|
+
action = { method: 'get', url: endpoint }
|
16
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_android_app(company_id, id, headers: {})
|
20
|
+
endpoint = '/companies/{companyId}/androidApps/{id}'.gsub(/{.+?}/, '%s')
|
21
|
+
endpoint = endpoint.gsub(%r{^/}, '')
|
22
|
+
endpoint = format(endpoint, company_id, id)
|
23
|
+
|
24
|
+
action = { method: 'get', url: endpoint }
|
25
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
26
|
+
end
|
27
|
+
|
28
|
+
def list_android_certificates(company_id, headers: {}, query_params: {})
|
29
|
+
endpoint = '/companies/{companyId}/androidCertificates'.gsub(/{.+?}/, '%s')
|
30
|
+
endpoint = endpoint.gsub(%r{^/}, '')
|
31
|
+
endpoint = format(endpoint, company_id)
|
32
|
+
endpoint += create_query_string(query_params)
|
33
|
+
action = { method: 'get', url: endpoint }
|
34
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -7,24 +7,6 @@ module Adyen
|
|
7
7
|
super(client, version, 'Management')
|
8
8
|
end
|
9
9
|
|
10
|
-
def list_android_apps(company_id, headers: {}, query_params: {})
|
11
|
-
endpoint = '/companies/{companyId}/androidApps'.gsub(/{.+?}/, '%s')
|
12
|
-
endpoint = endpoint.gsub(%r{^/}, '')
|
13
|
-
endpoint = format(endpoint, company_id)
|
14
|
-
endpoint += create_query_string(query_params)
|
15
|
-
action = { method: 'get', url: endpoint }
|
16
|
-
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
|
-
end
|
18
|
-
|
19
|
-
def list_android_certificates(company_id, headers: {}, query_params: {})
|
20
|
-
endpoint = '/companies/{companyId}/androidCertificates'.gsub(/{.+?}/, '%s')
|
21
|
-
endpoint = endpoint.gsub(%r{^/}, '')
|
22
|
-
endpoint = format(endpoint, company_id)
|
23
|
-
endpoint += create_query_string(query_params)
|
24
|
-
action = { method: 'get', url: endpoint }
|
25
|
-
@client.call_adyen_api(@service, action, {}, headers, @version)
|
26
|
-
end
|
27
|
-
|
28
10
|
def list_terminal_actions(company_id, headers: {}, query_params: {})
|
29
11
|
endpoint = '/companies/{companyId}/terminalActions'.gsub(/{.+?}/, '%s')
|
30
12
|
endpoint = endpoint.gsub(%r{^/}, '')
|
@@ -7,6 +7,7 @@ require_relative 'management/account_merchant_level_api'
|
|
7
7
|
require_relative 'management/account_store_level_api'
|
8
8
|
require_relative 'management/allowed_origins_company_level_api'
|
9
9
|
require_relative 'management/allowed_origins_merchant_level_api'
|
10
|
+
require_relative 'management/android_files_company_level_api'
|
10
11
|
require_relative 'management/client_key_company_level_api'
|
11
12
|
require_relative 'management/client_key_merchant_level_api'
|
12
13
|
require_relative 'management/my_api_credential_api'
|
@@ -74,6 +75,10 @@ module Adyen
|
|
74
75
|
@allowed_origins_merchant_level_api ||= Adyen::AllowedOriginsMerchantLevelApi.new(@client, @version)
|
75
76
|
end
|
76
77
|
|
78
|
+
def android_files_company_level_api
|
79
|
+
@android_files_company_level_api ||= Adyen::AndroidFilesCompanyLevelApi.new(@client, @version)
|
80
|
+
end
|
81
|
+
|
77
82
|
def client_key_company_level_api
|
78
83
|
@client_key_company_level_api ||= Adyen::ClientKeyCompanyLevelApi.new(@client, @version)
|
79
84
|
end
|
@@ -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
|
data/lib/adyen/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -236,4 +236,23 @@ RSpec.describe Adyen do
|
|
236
236
|
expect(client.service_url('PosTerminalManagement', 'assignTerminals', '1'))
|
237
237
|
.to eq('https://postfmapi-test.adyen.com/postfmapi/terminal/v1/assignTerminals')
|
238
238
|
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
|
239
258
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"SaleToPOIRequest": {
|
3
|
+
"MessageHeader": {
|
4
|
+
"MessageClass": "Service",
|
5
|
+
"MessageCategory": "Payment",
|
6
|
+
"MessageType": "Request",
|
7
|
+
"ServiceID": "1233094855",
|
8
|
+
"SaleID": "POSSystemID12345",
|
9
|
+
"POIID": "V400m-1234123412",
|
10
|
+
"ProtocolVersion": "3.0"
|
11
|
+
},
|
12
|
+
"PaymentRequest": {
|
13
|
+
"SaleData": {
|
14
|
+
"SaleTransactionID": {
|
15
|
+
"TransactionID": "123456764",
|
16
|
+
"TimeStamp": "2023-08-23T09:48:55"
|
17
|
+
},
|
18
|
+
"SaleToAcquirerData": "eyJhcHBsaWNhdGlvbkluZm8iOnsiYWR5ZW5MaWJyYXJ5Ijp7Im5hbWUiOiJhZ....",
|
19
|
+
"TokenRequestedType": "Transaction"
|
20
|
+
},
|
21
|
+
"PaymentTransaction": {
|
22
|
+
"AmountsReq": {
|
23
|
+
"Currency": "EUR",
|
24
|
+
"RequestedAmount": 10
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"SaleToPOIResponse":{
|
3
|
+
"MessageHeader":{},
|
4
|
+
"PaymentResponse":{
|
5
|
+
"POIData":{
|
6
|
+
"POITransactionID":{
|
7
|
+
"TransactionID": "oLkO0012498220087000.KHQC5N7G84BLNK43"
|
8
|
+
}
|
9
|
+
},
|
10
|
+
"Response":{
|
11
|
+
"Result":"Success",
|
12
|
+
"AdditionalResponse":"...shopperEmail=shoppersemail%40address.com..."
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"PaymentReceipt":{}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
RSpec.describe Adyen::TerminalCloudAPI, service: 'TerminalCloudAPI' do
|
5
|
+
before(:all) do
|
6
|
+
@shared_values = {
|
7
|
+
client: create_client(:api_key),
|
8
|
+
service: 'TerminalCloudAPI'
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'makes a connectedTerminals POST call' do
|
13
|
+
request_body = JSON.parse(json_from_file('mocks/requests/TerminalCloudAPI/connected_terminals.json'))
|
14
|
+
|
15
|
+
response_body = json_from_file('mocks/responses/TerminalCloudAPI/connected_terminals.json')
|
16
|
+
|
17
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'connectedTerminals', nil)
|
18
|
+
WebMock.stub_request(:post, url)
|
19
|
+
.with(
|
20
|
+
headers: {
|
21
|
+
'x-api-key' => @shared_values[:client].api_key
|
22
|
+
}
|
23
|
+
)
|
24
|
+
.to_return(
|
25
|
+
body: response_body
|
26
|
+
)
|
27
|
+
|
28
|
+
result = @shared_values[:client].terminal_cloud_api.connected_terminals(request_body)
|
29
|
+
response_hash = result.response
|
30
|
+
|
31
|
+
expect(result.status)
|
32
|
+
.to eq(200)
|
33
|
+
expect(response_hash)
|
34
|
+
.to eq(JSON.parse(response_body))
|
35
|
+
expect(response_hash)
|
36
|
+
.to be_a Adyen::HashWithAccessors
|
37
|
+
expect(response_hash)
|
38
|
+
.to be_a_kind_of Hash
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'makes a sync payment POST call' do
|
42
|
+
request_body = JSON.parse(json_from_file('mocks/requests/TerminalCloudAPI/sync_payment.json'))
|
43
|
+
|
44
|
+
response_body = json_from_file('mocks/responses/TerminalCloudAPI/sync_payment.json')
|
45
|
+
|
46
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'sync', nil)
|
47
|
+
WebMock.stub_request(:post, url)
|
48
|
+
.with(
|
49
|
+
headers: {
|
50
|
+
'x-api-key' => @shared_values[:client].api_key
|
51
|
+
}
|
52
|
+
)
|
53
|
+
.to_return(
|
54
|
+
body: response_body
|
55
|
+
)
|
56
|
+
|
57
|
+
result = @shared_values[:client].terminal_cloud_api.sync(request_body)
|
58
|
+
response_hash = result.response
|
59
|
+
|
60
|
+
expect(result.status)
|
61
|
+
.to eq(200)
|
62
|
+
expect(response_hash)
|
63
|
+
.to eq(JSON.parse(response_body))
|
64
|
+
expect(response_hash)
|
65
|
+
.to be_a Adyen::HashWithAccessors
|
66
|
+
expect(response_hash)
|
67
|
+
.to be_a_kind_of Hash
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'makes an async payment POST call' do
|
71
|
+
request_body = JSON.parse(json_from_file('mocks/requests/TerminalCloudAPI/sync_payment.json'))
|
72
|
+
|
73
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'async', nil)
|
74
|
+
WebMock.stub_request(:post, url)
|
75
|
+
.with(
|
76
|
+
headers: {
|
77
|
+
'x-api-key' => @shared_values[:client].api_key
|
78
|
+
}
|
79
|
+
)
|
80
|
+
.to_return(
|
81
|
+
body: 'ok'
|
82
|
+
)
|
83
|
+
|
84
|
+
result = @shared_values[:client].terminal_cloud_api.async(request_body)
|
85
|
+
response_hash = result.response
|
86
|
+
|
87
|
+
expect(result.status)
|
88
|
+
.to eq(200)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
# 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: 7.0
|
4
|
+
version: 7.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -126,10 +126,12 @@ files:
|
|
126
126
|
- lib/adyen/services/balancePlatform/bank_account_validation_api.rb
|
127
127
|
- lib/adyen/services/balancePlatform/grant_accounts_api.rb
|
128
128
|
- lib/adyen/services/balancePlatform/grant_offers_api.rb
|
129
|
+
- lib/adyen/services/balancePlatform/network_tokens_api.rb
|
129
130
|
- lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb
|
130
131
|
- lib/adyen/services/balancePlatform/payment_instruments_api.rb
|
131
132
|
- lib/adyen/services/balancePlatform/platform_api.rb
|
132
133
|
- lib/adyen/services/balancePlatform/transaction_rules_api.rb
|
134
|
+
- lib/adyen/services/balancePlatform/transfer_routes_api.rb
|
133
135
|
- lib/adyen/services/binLookup.rb
|
134
136
|
- lib/adyen/services/checkout.rb
|
135
137
|
- lib/adyen/services/checkout/classic_checkout_sdk_api.rb
|
@@ -155,6 +157,7 @@ files:
|
|
155
157
|
- lib/adyen/services/management/account_store_level_api.rb
|
156
158
|
- lib/adyen/services/management/allowed_origins_company_level_api.rb
|
157
159
|
- lib/adyen/services/management/allowed_origins_merchant_level_api.rb
|
160
|
+
- lib/adyen/services/management/android_files_company_level_api.rb
|
158
161
|
- lib/adyen/services/management/api_credentials_company_level_api.rb
|
159
162
|
- lib/adyen/services/management/api_credentials_merchant_level_api.rb
|
160
163
|
- lib/adyen/services/management/api_key_company_level_api.rb
|
@@ -188,6 +191,7 @@ files:
|
|
188
191
|
- lib/adyen/services/recurring.rb
|
189
192
|
- lib/adyen/services/service.rb
|
190
193
|
- lib/adyen/services/storedValue.rb
|
194
|
+
- lib/adyen/services/terminalCloudAPI.rb
|
191
195
|
- lib/adyen/services/transfers.rb
|
192
196
|
- lib/adyen/services/transfers/capital_api.rb
|
193
197
|
- lib/adyen/services/transfers/transactions_api.rb
|
@@ -298,6 +302,8 @@ files:
|
|
298
302
|
- spec/mocks/requests/Terminal/assign_terminals.json
|
299
303
|
- spec/mocks/requests/Terminal/find_terminal.json
|
300
304
|
- spec/mocks/requests/Terminal/get_terminals_under_account.json
|
305
|
+
- spec/mocks/requests/TerminalCloudAPI/connected_terminals.json
|
306
|
+
- spec/mocks/requests/TerminalCloudAPI/sync_payment.json
|
301
307
|
- spec/mocks/requests/Transfers/get_transactions.json
|
302
308
|
- spec/mocks/requests/Transfers/make_transfer.json
|
303
309
|
- spec/mocks/responses/Account/check_account_holder.json
|
@@ -394,6 +400,8 @@ files:
|
|
394
400
|
- spec/mocks/responses/Terminal/assign_terminals.json
|
395
401
|
- spec/mocks/responses/Terminal/find_terminal.json
|
396
402
|
- spec/mocks/responses/Terminal/get_terminals_under_account.json
|
403
|
+
- spec/mocks/responses/TerminalCloudAPI/connected_terminals.json
|
404
|
+
- spec/mocks/responses/TerminalCloudAPI/sync_payment.json
|
397
405
|
- spec/mocks/responses/Transfers/get_transactions.json
|
398
406
|
- spec/mocks/responses/Transfers/make_transfer.json
|
399
407
|
- spec/mocks/responses/Webhooks/backslash_webhook.json
|
@@ -408,6 +416,7 @@ files:
|
|
408
416
|
- spec/service_spec.rb
|
409
417
|
- spec/spec_helper.rb
|
410
418
|
- spec/stored_value_spec.rb
|
419
|
+
- spec/terminal_cloud_api_spec.rb
|
411
420
|
- spec/transfers_spec.rb
|
412
421
|
- spec/utils/hmac_validator_spec.rb
|
413
422
|
- templates/api-single.mustache
|