mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-03-10 08:01:20 +00:00
* Generate models and add services * Makefile changes and document * PW-6847: Mocks * Update src/__tests__/legalEntityManagement.spec.ts Co-authored-by: Michael Paul <michael@michaelpaul.com.br> * small fix and renames * Update src/__tests__/balancePlatform.spec.ts Co-authored-by: Wouter Boereboom <62436079+wboereboom@users.noreply.github.com> * modified README and index * Update src/services/resource/legalEntityManagementResource.ts Co-authored-by: Wouter Boereboom <62436079+wboereboom@users.noreply.github.com> * Update src/services/resource/legalEntityManagementResource.ts Co-authored-by: Wouter Boereboom <62436079+wboereboom@users.noreply.github.com> Co-authored-by: michaelpa <michael.paul@adyen.com> Co-authored-by: Michael Paul <michael@michaelpaul.com.br> Co-authored-by: Wouter Boereboom <62436079+wboereboom@users.noreply.github.com>
140 lines
7.7 KiB
Markdown
140 lines
7.7 KiB
Markdown
# Adyen Node.js API Library
|
|

|
|
[](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=main)
|
|
[](https://www.npmjs.com/package/@adyen/api-library)
|
|

|
|
[](https://www.npmjs.com/package/@adyen/api-library)
|
|
[](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library)
|
|
[](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/alerts/)
|
|
[](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/context:javascript)
|
|
|
|
This is the officially supported NodeJS library for using Adyen's APIs.
|
|
|
|
## Integration
|
|
The Library supports all APIs under the following services:
|
|
|
|
* [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview): The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Current supported version: **v52**
|
|
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview): Our latest integration for accepting online payments. Current supported version: **v69**
|
|
* [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview): The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. Current supported verison: **v2**
|
|
* [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v2/overview): Manage legal entities that contain information required for verification. Current supported version: **v2**
|
|
* [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference): Our point-of-sale integration.
|
|
* [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview): Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Current supported version **v1**
|
|
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview): Our classic integration for online payments. Current supported version: **v68**
|
|
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview): Endpoints for sending funds to your customers. Current supported version: **v68**
|
|
* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms. This API is used for the classic integration.
|
|
* [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**
|
|
* [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6**
|
|
* [Hosted onboarding API](https://docs.adyen.com/api-explorer/#/Hop/v6/overview): Current supported version: **v6**
|
|
* [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6**
|
|
* [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Endpoints for managing your point-of-sale payment terminals. Current supported version **v1**
|
|
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview): Endpoints for managing saved payment details. Current supported version: **v68**
|
|
* [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api): Manage both online and point-of-sale gift cards and other stored-value cards. Current supported version: **v46**
|
|
|
|
* [Platforms Notifications Webhooks](https://docs.adyen.com/api-explorer/#/NotificationService/v6/overview) Current supported version: **v6**
|
|
|
|
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
|
|
|
## Prerequisites
|
|
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
|
|
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
|
|
- Node 12 or higher
|
|
|
|
## Installation
|
|
|
|
You can use NPM to add our library to your project
|
|
|
|
### NPM
|
|
|
|
```bash
|
|
npm install --save @adyen/api-library
|
|
```
|
|
|
|
Alternatively, you can download the [release on GitHub](https://github.com/Adyen/adyen-node-api-library/releases).
|
|
|
|
|
|
## Using the library
|
|
|
|
### General use with API key
|
|
|
|
Set up the client as a singleton resource; you can then use it to create service objects for the API calls that you make to Adyen:
|
|
|
|
```typescript
|
|
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
|
|
```
|
|
### General use with API key for live environment
|
|
```typescript
|
|
const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"});
|
|
```
|
|
### General use with basic auth
|
|
```typescript
|
|
const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"});
|
|
```
|
|
|
|
### Custom HTTP Client Configuration
|
|
By default, NodeJS [https](https://nodejs.org/api/https.html) will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance. In the example below, we use `axios`:
|
|
|
|
```javascript
|
|
const {Client, Config} = require('@adyen/api-library');
|
|
const axios = require("axios");
|
|
...
|
|
const config = new Config();
|
|
const client = new Client({
|
|
config,
|
|
httpClient: {
|
|
async request(endpoint, json, config, isApiKeyRequired, requestOptions) {
|
|
const response = await axios({
|
|
method: 'POST',
|
|
url: endpoint,
|
|
data: JSON.parse(json),
|
|
headers: {
|
|
"X-API-Key": config.apiKey,
|
|
"Content-type": "application/json"
|
|
},
|
|
});
|
|
|
|
return response.data;
|
|
}
|
|
}
|
|
});
|
|
...
|
|
```
|
|
|
|
## Proxy configuration
|
|
|
|
You can configure a proxy connection by injecting your own HttpURLConnectionClient on your client instance and changing the `proxy` setter value.
|
|
|
|
Example:
|
|
```javascript
|
|
const {HttpURLConnectionClient, Client, Config} = require('@adyen/api-library');
|
|
...
|
|
const config = new Config();
|
|
const client = new Client({ config });
|
|
const httpClient = new HttpURLConnectionClient();
|
|
httpClient.proxy = { host: "http://google.com", port: 8888, };
|
|
|
|
client.setEnvironment('TEST');
|
|
client.httpClient = httpClient;
|
|
...
|
|
```
|
|
|
|
### Example integration
|
|
|
|
For a closer look at how our NodeJS library works, clone our [example integration](https://github.com/adyen-examples/adyen-node-online-payments). This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.
|
|
|
|
## Contributing
|
|
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
|
|
* New features and functionality
|
|
* Resolved bug fixes and issues
|
|
* Any general improvements
|
|
|
|
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how to create a pull request.
|
|
|
|
## Support
|
|
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://www.adyen.help).
|
|
|
|
## Licence
|
|
This repository is available under the [MIT license](LICENSE).
|
|
|
|
## See also
|
|
* [example integration](https://github.com/adyen-examples/adyen-node-online-payments)
|