Cybersource API :)
NodeJs module for connect to cybersource using soap, with predefined functions.
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 = ;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 versionslet currency = "<currency definition for transactions>"; let cybersourceApi = passwordmerchantIDenviromentlanguageversioncurrency;
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 datalet billTo = "firstName""lastName""address""city""state""postalCode""country""email"; //Create object of type Card with required datalet card = "4111111111111111""02""2020""001"; //Create object of type AuthorizationRequest with previus objects createdlet authorizationRequest = "referenceCode"billTocard; //Call method authorizeCharge parsing the authorizationRequest object and amount to authorizecybersourceApi;
For capture charge use next example, use authorization obtained in the previous step
let authorization = "1232313123123123";// authorization obtained in authorizationRequestlet captureRequest = "referenceCode"authorization; cybersourceApi;
Charge card
// Create object of type BillTo with required datalet billTo = "firstName""lastName""address""city""state""postalCode""country""email"; //Create object of type Card with required datalet card = "4111111111111111""02""2020""001"; //Create object of type ChargeRequest with previus objects createdlet chargeRequest = "referenceCode"billTocard; //Call method chargeCard parsing the chargeRequest object and amount to chargecybersourceApi;