Giter VIP home page Giter VIP logo

itransact-node's Introduction

iTransact 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 iTransact 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 itransact-node

iTransact SDK on NPM

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 iTransact SDK

DIY Example

Post transaction with iTransact SDK

"use strict";
const itransact = require('itransact-core');

// Store these somewhere safe.
const api_username = 'test_user';
const api_key = 'test_key';

// You can use your own JSON Model, or use the included models.
const cardData = new itransact.cardDataModel();
cardData.name = 'Greg';
cardData.number = '4111111111111111';
cardData.cvv = '123';
cardData.exp_month = '11';
cardData.exp_year = '2020';

// Address is optional, unless using loopback /sandbox / demo account.
const addressData = new itransact.addressDataModel();
addressData.postal_code = '84025';

const payload = new itransact.transactionPostPayloadModel();
payload.amount = '1000';
payload.card = cardData;

let fooCallback = function (response) {
    // Do something with response here
};

itransact.postCardTransaction(payload, api_username, api_key, fooCallback);

Signing payload with iTransact SDK (doesn't post transaction)

"use strict";
const itransact = require('itransact-core');

// Store this somewhere safe.
const api_key = 'test_key';

// You can use your own JSON Model, or use the included models.
const payload = {
    amount: '1000',
    card:{
        name: 'Greg',
        number: '4111111111111111',
        cvv: '123',
        exp_month: '11',
        exp_year: '2020'
    },
    'address': { // Address is optional, unless using loopback /sandbox / demo account.
        'postal_code': '84025'
    }
};

// IF you want to just sign the payload
let payloadSignature = itransact.signPayload(api_key, payload);

Note - expected signature changes every time the api_username, api_key, and payload changes in any way. It is only included here for testing.

Demo Account Note - Loopback, Sandbox, and Demo accounts require postal_code, otherwise you will see an error similar to - "ZIP REQUIRED FOR KEYED TRANSACTION"

Example Response

Example successful postResult using the example above will return a 201 with the following fields / value types:

{
  "id": "string",
  "amount": 0,
  "status": "string",
  "settled": "string",
  "instrument": "string",
  "metadata": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "payment_source": {
    "name": "string",
    "default": "string",
    "type": "string",
    "expired": "string",
    "month": "string",
    "year": "string",
    "brand": "string",
    "last_four_digits": "string",
    "sec_code": "string"
  },
  "credits": {
    "amount": 0,
    "state": "string"
  },
  "credited_amount": "string"
}

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

itransact-node's People

Contributors

xavisavvy avatar

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.