npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adyen-client

v2.0.12

Published

Adyen client for node.js integrations.

Downloads

37

Readme

Adyen Client

Greenkeeper badge

Dependency Status

Adyen client

Getting started

Install the module with: npm install adyen-client

var adyenClient = require('adyen-client')
var aClient = adyenClient({
    frontKey: 'YOUR FRONT END KEY', //Only used for the initCCForm
    merchantAccount: 'YOUR MERCHANT ACCOUNT'
    username: 'YOUR USERNAME',
    password: 'YOUR PASSWORD',
    version: 'v30', // by default is v12
    development: true
});

aClient
    .getRecurringData({
        "shopperReference": "SimonHopper1",
        "recurring": {
            "contract": "RECURRING"
        }
    }).then(function (response) {
        console.log(util.inspect(response, false, 20, true));
    })
    .fail(function (error) {
        console.log(util.inspect(error, false, 20, true));
    });

Documentation

First of all you need to initialize the client passing your merchant account, username, password and front end key (only if you need to do the frontend initialization).

var adyenClient = require('adyen-client');

/*
    opts = {
        frontKey: 'YOUR FRONT END KEY', //Only used for the initCCForm
        merchantAccount: 'YOUR MERCHANT ACCOUNT'
        username: 'YOUR USERNAME',
        password: 'YOUR PASSWORD'
        version: 'VERSION', // URL versions by default is v12
        development: Boolean //TRUE or FALSE indicates that your are on development, for production is not neccesary
    }

*/
var aClient = adyenClient(opts);

Then you have the client initialized, now you have access to this methods, every method return a promise, and you need to follow the adyen documentation to know how pass the data:

  • initCCForm: Promise that returns the structure you need for the CSE encryption in frontend.

    aClient.initCCForm().then(function(data) {
        console.log(data);
        /*
            {
                "key": '10008|927D950...', // your Front-end key
                "generationTime": '2016-01-01T00:00:00.000Z' // ISO date string
            }
             */
    });
  • authorizePayment

    aClient
        .authorizePayment({
            shopperEmail: '[email protected]',
            shopperReference: 'SimonHopper1',
            recurring: {
                contract: 'RECURRING'
            },
            reference: 'authorize-simonhopper1',
            amount: {
                value: '0',
                currency: 'EUR'
            },
            additionalData: {
                'card.encrypted.json': 'adyenjs_0_1_15$......'
            }
        })
        .then(function(data) {
            console.log(data);
        });
  • authorize3dPayment

    aClient.authorize3dPayment({
        "md": 'nOw6sWy2Kbu+bmg......'
        "paResponse":"eNqtmFmTo7iygN/5FRU9......",
        "browserInfo": {
            "userAgent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
            "acceptHeader": "application/json, text/plain, */*"
        }
    })
        .then(function(data){
            console.log(data)
        })
  • getRecurringData

    aClient
        .getRecurringData({
            shopperReference: 'SimonHopper1',
            recurring: {
                contract: 'RECURRING'
            }
        })
        .then(function(data) {
            console.log(data);
        });
  • disableRecurring

    aClient
        .disableRecurring({
            shopperReference: 'SimonHopper1',
            recurringDetailReference: 'CC TOKENIZED' //if you need to remove a specific one
        })
        .then(function(data) {
            console.log(data);
        });
  • capture

    aClient
        .capture({
            modificationAmount: {
                currency: 'EUR',
                value: '0'
            },
            originalReference: 'YOUR AUTH REFERENCE',
            reference: 'capture-' + data.transactionId
        })
        .then(function(data) {
            console.log(data);
        });
  • refund

    aClient
        .refund({
            modificationAmount: {
                currency: 'EUR',
                value: '0'
            },
            originalReference: 'YOUR REFERENCE'
        })
        .then(function(data) {
            console.log(data);
        });
  • cancelOrRefund:

    aClient
        .cancelOrRefund({
            originalReference: 'YOUR REFERENCE'
        })
        .then(function(data) {
            console.log(data);
        });

Responses

The initCCForm returns the data example and the others returns this:

{
    success: Boolean, //TRUE or FALSE
    data: {},//The Response from Adyen
    lastResponse: {}, //Axios RAW response
    lastRequest: {} //Axios RAW request
}

Development

Run npm install;npm run dev to watch the proyect, and compile the code automatically. Run npm build to build the module.

Release History

(2.0.11)

  • Update dependecies (Axios ^0.18)
  • Added posibility to pass the version in the contructor

(2.0.10)

  • Update dependecies (Axios ^0.16)
  • Added authorize3dPayment for handling 3D Secure authorization (Thanks @grimor)

(2.0.7)

  • Update dependencies
  • Added success field in response
  • Fix issues
  • Internal refractor (ES6)
  • Docs Changed
  • Responses now returns the RAW request, and response

(1.0.8)

  • Internal Refactor
  • Added more methods
  • Better docs

(1.0.7)

  • Fix dependencies
  • Firsts step.
  • Added basic methods

License

Licensed under the MIT license. 2018