IBX SDK for NodeJS
As a quick helper for our NodeJS community to get up and running even faster in your favorite dependency manager, we have created this API / SDK wrapper specifically tailored for NodeJS and Express.
More details at IBX Developer API
Features
Usage
If there is a platform you would like to see in addition to npm
for dependency management, let us know.
NPM Install
Run the following command at the root fo your project
npm install ibx-node
Manual Install
Download the zip, or use git submodules to pull the SDK into your project.
Import Example
Here is an example implementation:
(see /examples
for more)
DIY Example without IBX SDK
Post transaction with IBX SDK
"use strict";const ibx = ;const util = ;const xml2js = ; // You can use your own JSON Model, or use the included models.const cardData = ;cardDataname = 'Barney Rubble';cardDatanumber = '4242424242424242';cardDatacvv = '999';cardDataexp_month = '12';cardDataexp_year = '20'; // Address is optional, unless using loopback /sandbox / demo account.const addressData = ;addressDatapostal_code = '84025'; const metaData = ;metaDataemail = "example@ibxpays.com"; let payload = ;payloadamount = '1000';payloadcard = cardData;payloadaddress = addressData; let { // Do something with response here console} let { // Do something with response here console payload = ; ibx;} // If you want to post a card transactionlet { if responseerror console return; // Do something with response here console payload = ; payloadtoken = responseExtDataCardSafeToken; payloadamount = Math * 100; payloadtransaction_type = 'sale'; payloadext_data = ''; ibx;}; ibx;ibx;ibx; // That's it!
Example Response
Example successful processCard
using the example above will return the following JSON object as a response:
Check out the files in /examples
for other ideas for implementation.
Testing
Unit tests on this project are run using Mocha. You can find each test in the /test
folder.
After doing an npm install mocha, and chai will be available to run using the following command.
npm test
Alternative Methods:
npm test-report
npm test-check-coverage
./node_modules/.bin/mocha --reporter spec