Socket
Book a DemoInstallSign in
Socket

cybersource-api

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cybersource-api

Module for connect with CyberSource by soap methods.

latest
npmnpm
Version
1.0.8
Version published
Weekly downloads
27
-42.55%
Maintainers
2
Weekly downloads
 
Created
Source

Cybersource API :)

NodeJs module for connect to cybersource using soap, with predefined functions.

  • Features
  • Install
  • How it works

Features

  • Very simple API
  • Using asyncronous functions for requesting
  • WS-Security inserted in soap

Install

Install with npm:

  npm install cybersource-api

How it works

Instantiate CybersourceApi

To start using this module it is only necessary to import and instantiate a CybersourceApi object, for versions check https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor/.

const CybersourceApi = require('cybersource-api');
let password = "<password provided by cybersource>";
let merchantID = "<merchandID provided by cybersource>";
let enviroment = "<enviroment for test or production>"; //use "production" or "development"
let language = "<language for message from api>"; // use "es" or "en"
let version = "<soap url version of cybersource>"; // ej: "1.151". check  https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor/ for versions
let currency = "<currency definition for transactions>";

let cybersourceApi = new CybersourceApi(password,merchantID,enviroment,language,version,currency);

Type of transactions

Authorize and Capture Transaction

For authorize charge use next example, this will return an authorization that will be used later to capture

// Create object of type BillTo with required data
let billTo = new cybersourceApi.Models.BillTo("firstName","lastName","address","city","state","postalCode","country","email");

//Create object of type Card with required data
let card = new cybersourceApi.Models.Card("4111111111111111","02","2020","001");

//Create object of type AuthorizationRequest with previus objects created
let authorizationRequest = new cybersourceApi.Models.AuthorizationRequest("referenceCode",billTo,card);

//Call method authorizeCharge parsing the authorizationRequest object and amount to authorize
cybersourceApi.authorizeCharge(authorizationRequest,200).then(res=>{
  console.log("Authorization Response: ",res);
  /*
  res = { 
    message: 'Success',
    code: 100,
    authorization: '5543146435356332104008' // <== save this for capture amount after
  }
  */
}).catch(e=>{
  console.log("Authorization Reqest: ",e);
  /*
  e = { 
    message: <message error>,
    code: <code error>,
    data: <object with more error info>
  }
  */
});

For capture charge use next example, use authorization obtained in the previous step

let authorization = "1232313123123123";// authorization obtained in authorizationRequest
let captureRequest = new cybersourceApi.Models.CaptureRequest("referenceCode",authorization);
  cybersourceApi.captureCharge(captureRequest,200).then(resCapture=>
    console.log("Capture Request: ",resCapture)
    /*
    resCapture = { 
      message: 'Success',
      code: 100
    }
    */
  ).catch(e=>{
    console.log("Capture Request: ",e);
    /*
    e = { 
      message: <message error>,
      code: <code error>,
      data: <object with more error info>
    }
    */
  });

Charge card

// Create object of type BillTo with required data
let billTo = new cybersourceApi.Models.BillTo("firstName","lastName","address","city","state","postalCode","country","email");

//Create object of type Card with required data
let card = new cybersourceApi.Models.Card("4111111111111111","02","2020","001");

//Create object of type ChargeRequest with previus objects created
let chargeRequest = new cybersourceApi.Models.ChargeRequest("referenceCode",billTo,card);

//Call method chargeCard parsing the chargeRequest object and amount to charge
cybersourceApi.chargeCard(chargeRequest,200).then(res=>{
  console.log("Charge Card Response: ",res);
  /*
  res = { 
    message: 'Success',
    code: 100
  }
  */
}).catch(e=>{
  console.log("Authorization Reqest: ",e);
  /*
  e = { 
    message: <message error>,
    code: <code error>,
    data: <object with more error info>
  }
  */
});

Keywords

cybersource

FAQs

Package last updated on 07 May 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.