Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adyen

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adyen

NodeJS module for the Adyen payment provider

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
170
decreased by-26.72%
Maintainers
2
Weekly downloads
 
Created
Source

adyen

Build Status

Non official npm module for the Adyen Payment service.

Installation

$ npm install adyen

What is HPP?

Adyen Hosted Payment Pages (HPPs)

For more information please check the Adyen's documenation http://www.adyen.com/developers/documentation/

Example for the HPP payment

// Init payment
var
  HPP = require('adyen').HPP;

  hppPayment = new HPP({
    test: true,                                     // optional: true for Adyen test environment

    HMACKey: 'YourHMAC_Key',                          

    // Required for the payment
    merchantReference: 'DummyPaymentID',            // optional (lib do this)
                                                    //    default: 'PAYMENT-YYYY-MM-DDThh:mm:ssTZD'
    paymentAmount: 100,                             // EUR 1,00 = 100
    currencyCode: 'EUR',                            // optional (lib do this), default: 'EUR'
    shipBeforeDate: 2014-01-25                      // 'YYYY-MM-DD'
    skinCode: 'YourSkinCode',                         
    merchantAccount: 'YourMerchantAccountName',       
    sessionValidity: 'YYYY-MM-DDThh:mm:ssZ',        // optional (lib do this), default: 24h

    // Optional for the payment
    recurringContract: 'RECURRING',                 // For recurring payments (see Adyen documentation)
    shopperLocale: 'nl_NL',                         // optional: 'en_US'
    orderData: 'XY 1 year subscription',            // optional
    merchantReturnData: '',                         // optional
    countryCode: 'NL',                              // optional
    shopperEmail: 'test@test.com',                  // optional
    shopperReference: 'shopperID'                   // optional
    // allowedMethods                               // optional: check the Adyen documentation
    // blockedMethods                               // optional: check the Adyen documentation
    // offset                                       // optional: check the Adyen documentation
    // offerEmail                                   // optional: check the Adyen documentation
    // shopperStatement: ''                         // optional
    
    // if skipSelection is enabled the user will not be asked for a payment method but directly comes
    // to the payment page for the method specified by brandCode (e.g. paypal)
    // brandCode                                    // optional
    // skipSelection                                // optional
    
    // for redirecting the user to your custom page instead of the adyen confirmation page
    // resURL                                       // optional
  });
  


// Get URL to the payment window
hppPayment.generateRequest(function (err, url, merchantReference) {
  if (err) {
    return console.error(err);
  }

  console.log(merchantReference);
  console.log(url);
});

Example for the HPP validation

// Init validator
// Use the decodeURIComponent() values
var
  ValidateHPP = require('adyen').ValidateHPP;

  validateHPP = new ValidateHPP({
    HMACKey: 'YourHMAC_Key',

    // Required for the validation
    skinCode: 'SkinCode From the callback url',
    authResult: 'STATUS From the callback url',
    pspReference: 'pspReference From the callback url',
    merchantReference: 'merchantReference From the callback url',
    merchantSig: 'merchantSig From the callback url'
    shopperLocale: 'shopperLocale From the callback url'
    paymentMethod: 'paymentMethod From the callback url'

    // Optional for the validation
    merchantReturnData: ''                          // optional
  });


  // true if valid
  var isValid = validateHPP.validatePayment();
  console.log(isValid);

Example for Recurring Contract creation

// Init validator
var
  CreateRecurringContract = require('adyen').CreateRecurringContract;

var createRecurringContract = new CreateRecurringContract ( {
    test: true,                                     // optional: true for Adyen test environment

    auth: {
        login: 'YourWSUser,
        password: 'YourWSPassword+4w?cQTJGs~EsPn9J'
    },

    merchantAccount: 'yourMerchantAccount',         // The merchant account you want to process this payment with.
    shopperEmail: 'test@test.com',
    shopperReference: 'shopperID',                  // Your unique ID for the shopper.
                                                    //    * This shopperReference must be the same as the shopperReference used in the initial payment.
    recurringContract: 'RECURRING',                 // The type of recurring contract to be used. "ONECLICK" or "RECURRING"
    selectedRecurringDetailReference: "LATEST",
    reference: "DummyPaymentID",
    paymentAmount: 100,                             // EUR 1,00 = 100
    currencyCode: 'EUR',                            // optional (lib do this), default: 'EUR'
    shopperIP: '111.222.111.222',                   // recommended: The shopper's IP address.
    // fraudOffset                                  // optional: An integer that is added to the normal fraud score.
    // cardCVC                                      // optional: The card validation code. (only required for OneClick card payments)
} );

// Create the recurring contract
createRecurringContract.create ( function ( error, data )
{
    if ( error )
    {
        console.log ( error );
    }

    console.log ( data );
} );

Example for retrieving a Recurring Contract

// Init validator
var
  RetrieveRecurringContract = require ( 'adyen' ).RetrieveRecurringContract;

var
  retrieveRecurringContract = new RetrieveRecurringContract ( {
    test: true,                                       // Use Adyen test env

    auth: {
        login: 'YourWSUser,
        password: 'YourWSPassword+4w?cQTJGs~EsPn9J'
    },

    merchantAccount: 'yourMerchantAccount',           // The merchant account you want to process this payment with.
    shopperReference: 'shopperID',                    // Your unique ID for the shopper.
                                                      //    * This shopperReference must be the same as the shopperReference used in the initial payment.
    recurringContract: 'RECURRING'                    // The type of recurring contract to be used. "ONECLICK" or "RECURRING"
} ),

// Retrieve the recurring contract retrieveRecurringContract.list ( function ( error, data ) { if ( error ) { console.log ( error ); }

    console.log ( data );

} );

Example for disabling a Recurring Contract

// Init validator
var
  DisableRecurringContract = require ( 'adyen' ).DisableRecurringContract;

var
  disableRecurringContract = new DisableRecurringContract ( {
    test: true,                                       // Use Adyen test env

    auth: {
        login: 'YourWSUser,
        password: 'YourWSPassword+4w?cQTJGs~EsPn9J'
    },

    merchantAccount: 'yourMerchantAccount',                   // The merchant account you want to process this payment with.
    shopperReference: 'shopperID',                            // Your unique ID for the shopper.
                                                              //    * This shopperReference must be the same as the shopperReference used in the initial payment.
    recurringDetailReference: 'yourRecurringDetailReference'  // The recurringDetailReference of the details you wish to disable. If you do
                                                              //    * not supply this field all details for the shopper will be disabled including
                                                              //    * the contract! This means that you can not add new details anymore.
} ),

// Disable the recurring contract disableRecurringContract.list ( function ( error, data ) { if ( error ) { console.log ( error ); }

    console.log ( data );

} );

TODO

  • custom HPP payment
  • add more payment method

FAQs

Package last updated on 21 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc