Skip to content

Commit f48e46f

Browse files
authored
Merge branch 'main' into lem-v4-generation
2 parents a59bf33 + 3c8cafc commit f48e46f

File tree

149 files changed

+4035
-915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+4035
-915
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @Adyen/developer-relations
1+
* @Adyen/developer-relations @Adyen/api-library-maintainers

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
schedule:
55
- cron: '0 21 * * 4'
66

7+
permissions:
8+
contents: read
9+
security-events: write
10+
711
jobs:
812
CodeQL-Build:
913

.github/workflows/label_new_issues.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
issues:
44
types: [opened]
55

6+
permissions:
7+
issues: write
8+
69
jobs:
710
add-label:
811
runs-on: ubuntu-latest

.github/workflows/node-ci.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,3 @@ jobs:
6161
run: npm install
6262
- name: Run tests with coverage
6363
run: npm run test:coverage
64-
65-
node-sonarqube:
66-
runs-on: ubuntu-latest
67-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
68-
needs: node-test
69-
permissions:
70-
pull-requests: write
71-
72-
steps:
73-
- uses: actions/checkout@v4
74-
with:
75-
fetch-depth: 0
76-
- name: SonarQube Scan
77-
uses: SonarSource/sonarqube-scan-action@v5
78-
env:
79-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/npm-debug.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
release:
77
types: [published]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
publish-npm:
1114
runs-on: ubuntu-latest

.github/workflows/npmpublish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
release:
88
types: [published]
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
publish-npm:
1215
runs-on: ubuntu-latest

.github/workflows/sonarcloud.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Sonarcloud CI
2+
3+
on:
4+
schedule:
5+
# Every day at midnight
6+
- cron: '0 0 * * *'
7+
workflow_dispatch: {}
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
13+
jobs:
14+
node-sonarqube:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run tests with coverage
31+
run: npm run test:coverage
32+
33+
- name: Cache SonarCloud packages
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.sonar/cache
37+
key: ${{ runner.os }}-sonar
38+
restore-keys: ${{ runner.os }}-sonar
39+
40+
- name: Run SonarCloud Analysis
41+
env:
42+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43+
run: |
44+
npx sonar-scanner \
45+
-Dsonar.projectKey=Adyen_adyen-node-api-library \
46+
-Dsonar.organization=adyen \
47+
-Dsonar.sources=. \
48+
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
49+
-Dsonar.host.url=https://sonarcloud.io

.github/workflows/stale.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
schedule:
44
- cron: '30 8 * * *'
55

6+
permissions:
7+
issues: write
8+
pull-requests: write
9+
610
jobs:
711
stale:
812
runs-on: ubuntu-latest

README.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
![Node js](https://user-images.githubusercontent.com/62436079/207373079-9cf9377f-f530-4b02-a515-9b64ef7b06e7.png)
33

44
# Adyen API library for Node.js
5+
[![Version](https://img.shields.io/npm/v/@adyen/api-library.svg)](https://www.npmjs.com/package/@adyen/api-library)
56
[![Build Status](https://github.com/adyen/Adyen-node-api-library/actions/workflows/npmpublish.yml/badge.svg)](https://github.com/Adyen/adyen-node-api-library/actions/workflows/npmpublish.yml)
67
[![Coverage Status](https://coveralls.io/repos/github/Adyen/adyen-node-api-library/badge.svg?branch=main)](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=main)
78
[![Downloads](https://img.shields.io/npm/dm/@adyen/api-library.svg)](https://www.npmjs.com/package/@adyen/api-library)
89
![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@adyen/api-library.svg)
9-
[![Version](https://img.shields.io/npm/v/@adyen/api-library.svg)](https://www.npmjs.com/package/@adyen/api-library)
1010
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Adyen_adyen-node-api-library&metric=alert_status)](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library)
1111

1212
This is the official Adyen API library for Node.js that we recommend for integrating with Adyen APIs.
@@ -24,6 +24,7 @@ This library supports the following:
2424
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](/src/services/legalEntityManagement/index.ts) |
2525
| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference) | - | Our point-of-sale integration. | [TerminalLocalAPI](/src/services/terminalLocalAPI.ts) or [TerminalCloudAPI](/src/services/terminalCloudAPI.ts) |
2626
| [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](/src/services/management/index.ts) |
27+
| [Open Banking API](https://docs.adyen.com/api-explorer/open-banking/1/overview) | v1 | The Open Banking API provides secure endpoints to share financial data and services with third parties. | [Open Banking](/src/services/openbanking/index.ts) |
2728
| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | v68 | Our classic integration for online payments. | [ClassicIntegrationAPI](/src/services/paymentApi.ts) |
2829
| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](/src/services/payout/index.ts) |
2930
| [Platforms APIs](https://docs.adyen.com/platforms/api) | - | Set of APIs when using Adyen for Platforms. This API is used for the classic integration. | [Platforms](/src/services/platforms.ts) |
@@ -253,12 +254,12 @@ Alternatively, you can use the `Types` included in this module for Typescript an
253254
#### Deserializing JSON Strings
254255
In some setups you might need to deserialize JSON strings to request objects. For example, when using the libraries in combination with [Dropin/Components](https://github.com/Adyen/adyen-web). Please use the built-in deserialization functions:
255256
``` typescript
256-
// Import the required model class
257-
import { checkout } from "../typings";
257+
// Import the models
258+
import { Types } from "@adyen/api-library";
258259

259260
// Deserialize using built-in ObjectSerializer class
260261
const requestJson: JSON = JSON.parse(`YOUR_JSON_STRING`);
261-
const paymentRequest: checkout.PaymentRequest = await checkout.ObjectSerializer.deserialize(requestJson,"PaymentRequest");
262+
const paymentRequest: Types.checkout.PaymentRequest = await Types.checkout.ObjectSerializer.deserialize(requestJson,"PaymentRequest");
262263
```
263264

264265
### Custom HTTP client configuration
@@ -298,24 +299,32 @@ const client = new Client({
298299
### Parsing and Authenticating Banking Webhooks
299300
Parse an AccountHolderNotificationRequest webhook;
300301
``` typescript
301-
let bankingWebhookHandler = new BankingWebhookHandler(YOUR_BANKING_WEBHOOK);
302-
const accountHolderNotificationRequest: AccountHolderNotificationRequest = bankingWebhookHandler.getAccountHolderNotificationRequest();
303-
const genericWebhook = bankingWebhookHandler.getGenericWebhook();
302+
// import models
303+
import { Types, ConfigurationWebhooksHandler } from "@adyen/api-library";
304+
305+
const configurationWebhooksHandler = new ConfigurationWebhooksHandler(YOUR_BANKING_WEBHOOK);
306+
const accountHolderNotificationRequest: Types.configurationWebhooks.AccountHolderNotificationRequest = configurationWebhooksHandler.getAccountHolderNotificationRequest();
304307
```
305308
You can also parse the webhook with a generic type, in case you do not know the webhook type in advance. In this case you can check the instance of the webhook in order to parse it to the respective type (or just use it dynamically);
306309
``` typescript
307-
let bankingWebhookHandler = new BankingWebhookHandler(YOUR_BANKING_WEBHOOK);
308-
const genericWebhook = bankingWebhookHandler.getGenericWebhook();
310+
const configurationWebhooksHandler = new ConfigurationWebhooksHandler(YOUR_BANKING_WEBHOOK);
311+
const genericWebhook = configurationWebhooksHandler.getGenericWebhook();
312+
313+
if ("accountHolderCode" in genericWebhook) {
314+
console.log("This is an AccountHolderNotificationRequest");
315+
} else if ("balanceAccountId" in genericWebhook) {
316+
console.log("This is a BalanceAccountNotificationRequest");
317+
}
309318
```
310319
Verify the authenticity (where you retrieve the hmac key from the CA and the signature from the webhook header);
311320
``` typescript
312321
const isValid = hmacValidator.validateBankingHMAC("YOUR_HMAC_KEY", "YOUR_HMAC_SIGNATURE", jsonString)
313322
```
314323
### Management Webhooks
315-
Management webhooks are verified the exact same way as the banking webhooks. To parse them however, instead you use:
324+
Management webhooks are also parsed with the same approach, using `ManagementWebhooksHandler`:
316325
``` typescript
317-
let managementWebhookHandler = new ManagementWebhookHandler(YOUR_MANAGEMENT_WEBHOOK);
318-
const genericWebhook = managementWebhookHandler.getGenericWebhook();
326+
const managementWebhooksHandler = new ManagementWebhooksHandler(YOUR_MANAGEMENT_WEBHOOK);
327+
const genericWebhook = managementWebhooksHandler.getGenericWebhook();
319328
```
320329

321330
### Proxy configuration
@@ -325,14 +334,12 @@ To configure a proxy connection, set the `proxy` property of your `HttpURLConnec
325334
For example:
326335

327336
``` javascript
328-
const {HttpURLConnectionClient, Client, Config} = require('@adyen/api-library');
337+
const {HttpURLConnectionClient, Client, Config, EnvironmentEnum} = require('@adyen/api-library');
329338
// ... more code
330-
const config = new Config();
331-
const client = new Client({ config });
339+
const client = new Client({apiKey: "YOUR_API_KEY", environment: EnvironmentEnum.TEST});
332340
const httpClient = new HttpURLConnectionClient();
333341
httpClient.proxy = { host: "http://google.com", port: 8888, };
334342

335-
client.setEnvironment(EnvironmentEnum.TEST);
336343
client.httpClient = httpClient;
337344

338345
// ... more code
@@ -490,7 +497,7 @@ const paymentRequest: SaleToPOIRequest = {
490497
}
491498

492499
// Step 6: Make the request
493-
const terminalApiResponse: terminal.TerminalApiResponse = await terminalLocalAPI.request(paymentRequest, securityKey);
500+
const terminalApiResponse: Types.terminal.TerminalApiResponse = await terminalLocalAPI.request(paymentRequest, securityKey);
494501
```
495502
## Using the Local Terminal API Integration without Encryption (Only on TEST)
496503
If you wish to develop the Local Terminal API integration parallel to your encryption implementation, you can opt for the unencrypted version. Be sure to remove any encryption details from the CA terminal config page.
@@ -513,18 +520,19 @@ const paymentRequest: SaleToPOIRequest = {
513520
}
514521

515522
// Step 5: Make the request
516-
const terminalApiResponse: terminal.TerminalApiResponse = await terminalLocalAPI.request(paymentRequest);
523+
const terminalApiResponse: Types.terminal.TerminalApiResponse = await terminalLocalAPI.request(paymentRequest);
517524
```
518525
### Using the Cloud Terminal API Integration (async)
519526
If you choose to integrate [Terminal API over Cloud](https://docs.adyen.com/point-of-sale/design-your-integration/choose-your-architecture/cloud/) **asynchronously**, you need to follow similar steps to initialize the client and prepare the request object. However the response will be asynchronous:
520527
* a successful request will return `200` status code and `ok` as response body. Make sure to setup the [event notifications](https://docs.adyen.com/point-of-sale/design-your-integration/notifications/event-notifications/)
521528
* a request that fails will return `200` status code and the `TerminalApiResponse` as response body
522529
``` typescript
523530
// Step 1: Require the parts of the module you want to use
524-
const {Client, TerminalCloudAPI} from "@adyen/api-library";
531+
const {Client, TerminalCloudAPI, EnvironmentEnum} from "@adyen/api-library";
525532

526533
// Step 2: Initialize the client object
527-
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
534+
const client = new Client({apiKey: "YOUR_API_KEY", environment: EnvironmentEnum.TEST});
535+
528536

529537
// Step 3: Initialize the API object
530538
const terminalCloudAPI = new TerminalCloudAPI(client);

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
28.1.0
1+
29.1.0

0 commit comments

Comments
 (0)