hpoom / iinChecker

Issuer identification number checker which returns details about a credit/debit card

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IIN Checker for payment cards

Build Status Coverage Status 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' );
var iin = new IinChecker( {} );

iin.lookup( '543210', function( err, result ) {
	if ( err ) {
		console.log( 'Error:', err );
	} else {
		console.log( 'Result:', result );
	}
} );

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.

License

Copyright (c) 2014 Shortbreaks 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

About

Issuer identification number checker which returns details about a credit/debit card

License:MIT License


Languages

Language:JavaScript 100.0%