Giter Site home page Giter Site logo

adyen-node-api-library's Introduction

Adyen Node.js API Library

Node.js CI Coverage Status Downloads npm bundle size (scoped) Version Quality Gate Status Total alerts Language grade: JavaScript

This is the officially supported NodeJS library for using Adyen's APIs.

Integration

The Library supports all APIs under the following services:

For more information, refer to our documentation or the API Explorer.

Prerequisites

Installation

You can use NPM to add our library to your project

NPM

npm install --save @adyen/api-library

Alternatively, you can download the release on GitHub.

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:

    const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});

General use with API key for live environment

    const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"});

General use with basic auth

    const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"});

Custom HTTP Client Configuration

By default, NodeJS https 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:

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:

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. 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 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.

Licence

This repository is available under the MIT license.

See also

adyen-node-api-library's People

Contributors

adyen-gc avatar aldulea avatar christianverardi avatar coderunner avatar cyattilakiss avatar dependabot-preview[bot] avatar dependabot[bot] avatar dmfilipenko avatar hansottowirtz avatar kadobot avatar lukenorris avatar msilvagarcia avatar peterojo avatar renovate-bot avatar rikterbeek avatar samcottle avatar smafre avatar wboereboom avatar zaiddreakh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.