GithubHelp home page GithubHelp logo

danibram / adyen-client Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 6.0 263 KB

Basic adyen client for nodeJs Integrations

Home Page: https://github.com/danibram/adyen-client

License: MIT License

JavaScript 100.00%
adyen payment-integration

adyen-client's Introduction

Warning: If you are looking for a modern solution you must use the oficial one -> https://github.com/Adyen/adyen-node-api-library

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

adyen-client's People

Contributors

danibram avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

adyen-client's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

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.