iin-checker

0.6.0 • Public • Published

IIN Checker for payment cards

Circle CI Dependency status Dev Dependency Status

NPM

About

Issuer identification number checker which returns details about a credit/debit and other payment cards

Additional resources and links

Installation

The module is available in the NPM registery. It can be installed using the npm commandline utlity.

npm install iin-checker

Once you have installed the module you can simply require inside of your Node.js application and use it's exported methods. Here is a simple example of that which gets the card details back as an object:

var IinChecker = require( 'iin-checker' );
// Initialise with default options no caching
var iin = new IinChecker( {} );
 
// Initialise with caching
var iin = new IinChecker( {
    cache: {
      set: function( iin, cardDetails ) {...},
      get: function( iin ) {..}
    }
} );
 
 
 
iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    console.log( 'Result:', result );
  }
} );

Caching

Caching is turned off by default. It can be turned on by passing in options a cache object with your functions to set and get the cache'.

Card Type Detection

If you want to test to see if the card is a Credit or Debit card you can can achive this in the following way:

var IinChecker = require( 'iin-checker' );
var iin = new IinChecker( {} );
 
iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    var isDebit = ( result.type === iin.types.DEBIT )
    console.log( 'Debit?:', isDebit );
  }
} );

Possible values for iin.types are DEBIT, CREDIT and UNKNOWN.

Card Brand Detection

If you want to test to see which brand the card is, you can can achive this in the following way:

var IinChecker = require( 'iin-checker' );
var iin = new IinChecker( {} );
 
iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    var isMastercard = ( result.brand === iin.brands.MASTERCARD )
    console.log( 'Mastercard?:', isMastercard );
  }
} );

Possible values for iin.brands are VISA, MASTERCARD, AMEX, DISCOVER, JCB, MAESTRO and LASER. In future more card brands will be supported, if you need a brand adding please raise an issue.

Changelog

Contributing

License

Copyright (c) 2016 Holiday Extras Ltd Licensed under the MIT license.

Todo

  • Get non-provider RegEx alternative
  • Read providers from configs (as the tests do)
  • Allow preference of providers to be passed into options
  • Support caching

Readme

Keywords

none

Package Sidebar

Install

npm i iin-checker

Weekly Downloads

1

Version

0.6.0

License

MIT

Last publish

Collaborators

  • shortbreaks