Skip to content

Commit a52323e

Browse files
committed
Add SessionAuthentication API
1 parent 8d0e7db commit a52323e

File tree

7 files changed

+68
-1
lines changed

7 files changed

+68
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This library supports the following:
1616
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](lib/adyen/services/legalEntityManagement.rb) |
1717
| [Management API](https://docs.adyen.com/api-explorer/Management/3/overview) | v3 | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | [Management](lib/adyen/services/management.rb) |
1818
| [OpenBanking API](https://docs.adyen.com/api-explorer/open-banking/1/overview) | v1 | Securely share financial data and services with third parties. | [OpenBanking](lib/adyen/services/openBanking.rb) |
19+
| [SessionAuthentication API](https://docs.adyen.com/api-explorer/sessionauthentication/1/overview) | v1 | The Session authentication API enables you to create and manage the JSON Web Tokens (JWT) required for integrating components. | [SessionAuthentication](lib/adyen/services/sessionAuthentication.rb) |
1920
| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | v68 | Our classic integration for online payments. | [Classic Integration API](lib/adyen/services/payment.rb) |
2021
| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](lib/adyen/services/payout.rb) |
2122
| [POS Terminal Management API](https://docs.adyen.com/api-explorer/postfmapi/1/overview) | ~~v1~~ | ~~Endpoints for managing your point-of-sale payment terminals.~~ ‼️ **Deprecated**: use instead the [Management API](https://docs.adyen.com/api-explorer/Management/latest/overview) for the management of your terminal fleet. | ~~[TerminalManagement](lib/adyen/services/posTerminalManagement.rb)~~ || [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |

lib/adyen-ruby-api-library.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222
require_relative 'adyen/services/terminalCloudAPI'
2323
require_relative 'adyen/services/posMobile'
2424
require_relative 'adyen/services/openBanking'
25+
require_relative 'adyen/services/sessionAuthentication'
26+

lib/adyen/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ def open_banking
308308
@open_banking ||= Adyen::OpenBanking.new(self)
309309
end
310310

311+
def session_authentication
312+
@open_banking ||= Adyen::SessionAuthentication.new(self)
313+
end
314+
311315
private
312316

313317
def auth_header(auth_type, faraday)

lib/adyen/services/sessionAuthentication/session_authentication_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(client, version = DEFAULT_VERSION)
1313
end
1414

1515
# Create a session token
16-
def create_authentication_session(request, authentication_session_request, headers: {})
16+
def create_authentication_session(request, headers: {})
1717
endpoint = '/sessions'.gsub(/{.+?}/, '%s')
1818
endpoint = endpoint.gsub(%r{^/}, '')
1919
endpoint = format(endpoint)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"allowOrigin": "https://www.your-website.com",
3+
"product": "platform",
4+
"policy": {
5+
"resources": [
6+
{
7+
"type": "accountHolder",
8+
"accountHolderId": "AH00000000000000000000001"
9+
}
10+
],
11+
"roles": [
12+
"Transactions Overview Component: View",
13+
"Payouts Overview Component: View"
14+
]
15+
}
16+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"sessionToken": "long_session_token_string",
3+
"expiresAt": "2025-10-07T12:00:00Z"
4+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'spec_helper'
2+
require 'json'
3+
4+
RSpec.describe Adyen::SessionAuthentication, service: 'SessionAuthentication' do
5+
before(:all) do
6+
@shared_values = {
7+
client: create_client(:api_key),
8+
service: 'SessionAuthentication'
9+
}
10+
end
11+
12+
it 'makes a create_authentication_session POST call' do
13+
request_body = JSON.parse(json_from_file('mocks/requests/SessionAuthentication/create_authentication_session.json'))
14+
response_body = json_from_file('mocks/responses/SessionAuthentication/create_authentication_session.json')
15+
16+
url = @shared_values[:client].service_url(
17+
@shared_values[:service],
18+
'sessions',
19+
@shared_values[:client].session_authentication.version
20+
)
21+
WebMock.stub_request(:post, url)
22+
.with(
23+
body: request_body,
24+
headers: {
25+
'x-api-key' => @shared_values[:client].api_key
26+
}
27+
)
28+
.to_return(
29+
body: response_body
30+
)
31+
32+
result = @shared_values[:client].session_authentication.session_authentication_api.create_authentication_session(request_body)
33+
response_hash = result.response
34+
35+
expect(result.status).to eq(200)
36+
expect(response_hash).to eq(JSON.parse(response_body))
37+
expect(response_hash).to be_a Adyen::HashWithAccessors
38+
expect(response_hash).to be_a_kind_of Hash
39+
end
40+
end

0 commit comments

Comments
 (0)