npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

itransact-node

v2.1.0

Published

This is an SDK for authenticating with iTransact's API

Downloads

41

Readme

iTransact SDK for NodeJS

CircleCI js-standard-style Try Payroc iTransact Node SDK on RunKit

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-node');

// 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';
// Note that you can access the json ready object on any custom class model by calling .toJson()
// ex: cardData.toJson(), metaData.toJson(), etc.

// MetaData is optional, customer emails will not be sent out without the following.
const metaData = new itransact.MetaDataModel();
metaData.email = "[email protected]"; // Customer's email address for receipt delivery

// 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;
payload.address = addressData; // Optional
payload.metadata = metaData; // Optional
payload.send_customer_receipt = true; // Optional - default: false

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

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

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

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

// 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'
    },
    'metadata': { // Optional
        'email': '[email protected]'
    },
    'send_customer_receipt': 'true' // Optional - default: false
};

// 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.

Note: We utilize the npm package dotenv for testing different environments. Once you add these environment variables using your own .env using the .env.default file for reference the tests will function properly. You are also able to add the required variables it to your PATH directly to achieve the same effect

Example .env file:

# Used in unit tests.
ITRANSACT_ENVIRONMENT=production
ITRANSACT_API_USERNAME=your_api_username
ITRANSACT_API_KEY=your_api_key

You can run the following commands from package.json to execute the tests.

npm test
npm test-report
npm test-check-coverage
./node_modules/.bin/mocha --reporter spec