0.0.2 • Published 9 years ago

card.js v0.0.2

Weekly downloads
3
License
-
Repository
github
Last release
9 years ago

Build Status Code Coverage Code Climate

card.js

card.js - parse and validate credit card number in javascript.

Features

  • Credit card type detection based on IIN number. See more on wikipedia
  • Credit card type detection for full length card number
  • Luhn algorithm validation

Loading

The library is the single JavaScript file card.js (or minified, card.min.js).

It can be loaded via a script tag in an HTML document for the browser

<script src='./relative/path/to/card.js'></script>

(check examples/browser) or as a CommonJS, Node.js.

For Node, put the card.js file into the same directory as the file that is requiring it and use

var card = require('./card.js'); 

or put it in a node_modules directory within the directory and use require('card.js'). See example in examples/nodejs.

The library is also available from the npm registry, so

$ npm install card.js

will install this directory in a node_modules directory within the current directory.

Usage

card('4111111111111111').getType(); // output: visa
card('41').getType(); // output: visa
card('4111111111111111').isValid(); // output: true

Supported browsers

  • Chrome
  • Firefox
  • Internet Explorer 9
  • Safari
  • Opera

Supported card types:

Issuing networkcard type returned by getType
Visavisa
Mastercardmastercard
American Expressamex
Maestromeastro
Diners Clubdiners
Discoverdiscover
JCBjcb
UATPuatp
InterPaymentinterpayment
InstaPaymentinstapayment
China UnionPayunionpay
Dankortdankort