Code Monkey home page Code Monkey logo

creditcard's Introduction

Creditcard

Creditcard number parsing, validation and information extraction. The source code has been commented using JSDoc and converted to documentation which can be found in the docs folder.

Installation

The module is available in the NPM registry. It can be installed using the npm command line utility.

npm install --save creditcard

Once you have installed the module you can simply require inside of your Node.js application and use it's exported methods.

var creditcard = require('creditcard');

creditcard.validate(4111111111111);

Documentation

The documentation of this module has been automatically generated from the JSDocs that is used to comment the source code. It should give a clear understanding of the methods that are available in this module and how it should be used. The documentation can be found in the docs folder

License

MIT

creditcard's People

Contributors

3rd-eden avatar beastbytes avatar steven10172 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

creditcard's Issues

Cvv encode string

Embossing:
Card holder : L. PADILLA
Card number*: 1234 5678 9012 3445
Expiration : 01/99
*The card number (PAN) uses, as most of the credit and debit cards, the Luhn Check Digit Algorithm. Valid numbers must comply with the following rule. If the card number has an even number of digits, then the adding up of the even numbered digits plus the odd numbered digits doubled (minus 9 if the doubled digit is greater than 9) has to be multiple of 10. If the card number has an odd number of digits, then the same applies but doubling even (instead of odd) numbered digits. Using the example above:
2 x 1 + 2 + 2 x 3 + 4 + 2 x 5 - 9 + 6 + 2 x 7 - 9 + 8 + 2 x 9 - 9 + 0 + 2 x 1 + 2 + 2 x 3 + 4 + 2 x 4 + 5 = 70 and therefore the number in the example is a valid number for a credit or debit card.
Actually is the other way round, the last digit of the card number is calculated so that the whole number complies with Luhn Check, therefore the last digit is called check digit.

Track 1:
%B1234567890123445^PADILLA/L. ^99011200000000000000XXX****?*
^^^ ^^ ^^ ^ ^ ^ ^^
|||_ Card number ||_ Card holder || | | |_ CVV** ||_ LRC
||_ Format code |_ Field separator || | | |_ End sentinel
|_ Start sentinel Field separator || | | Discretionary data
Expiration | | Service code
Track 2:
;1234567890123445=99011200XXXX00000000?*
^^ ^^ ^ ^ ^^
||_ Card number || | |_ Encrypted||_ LRC
|_ Start sentinel|| | PIN*** |_ End sentinel
|| |_ Service code
Field separator || Expiration
Track 3:
;011234567890123445=724724100000000000030300XXXX040400099010=********************==1=0000000000000000?
^^ ^ ^^ ^ ^ ^ ^ ^ ^^ ^ ^ ^^ ^^^^^ ^^
|| | || | |_ Currency | | | || | | ||_ First subsidiary |||||_ Additional ||
|| | || | exponent | | | || | | | account number (FSAN)|||| data ||
|| |_ Card number || |_ Currency | | | || | | |_ Field separator ||||_ Field ||_ LRC
||_ Format code || (Peseta) | | | || | |_ Expiration ||| separator |_ End sentinel
|_ Start sentinel ||_ Country (Spain) | | | || |_ FSAN service restriction |||_ Relay marker
|_ Field separator | | | ||_ PAN service restriction ||_ Field separator
Cycle length | | | | Interchange control |_ Field separator
Retry count | | Encrypted PIN

**The CVV (Card Verification Value) is a cryptographic signature of the card number, the expiration date and the service code to verify the integrity of these data in the track. It is calculated with an algorithm similar to that of PIN encryption.

***The PIN (Personal Identification Number) is basically encrypted as follows. The card number is taken as an hexadecimal number and is encrypted with the DES algorithm using a secret key, which is called the "PIN key". The first four digits are decimalized (i.e., A = 0, B = 1, ...) and are called the "natural PIN". An offset is added (without carry) to the natural PIN in order to obtain the customer PIN. The customer PIN may be changed but the natural PIN cannot. The offset is what is written in track 3 and I called the "encrypted PIN". Here you have an example:
Card number: 1234567890123445hex input for DES.
PIN key: 0123456789ABCDEFhex key for DES.
Encrypted card number: 9A466AD30DFE0381hex output from DES.
Natural PIN: 9046.
Offset: 2298 (this number is written on track 3).
Customer PIN: 1234.
See also the original VISA scheme and a discussion on other systems. See the two much more detailed and complete documents linked in my main page for magnetic stripe cards.
Caja Madrid VISA or VISA Electron card:

Embossing or printing:
Card holder: L. PADILLA
Card number: 1234 5678 9012 3445
Expiration : 01/99
Track 1:
%B1234567890123445^PADILLA/L. ^99011X100000000000000XXX000000?
^^^ ^^ ^^ ^ ^ ^ ^^
|||_ Card number ||_ Card holder || | | |_ CVV ||_ LRC
||_ Format code |_ Field separator || | | |_ End sentinel
|_ Start sentinel Field separator || | | Discretionary data
Expiration | | Service code: 101 for VISA and 121 for VISA Electron
Track 2:
;1234567890123445=99011X10XXXXXXX00000?*
^^ ^^ ^ ^ ^ ^^
||_ Card number || | | |_ CVV ||_ LRC
|_ Start sentinel|| | | |_ End sentinel
Field separator || | | Encrypted PIN (except if duplicate card)
Expiration | | Service code: 101 for VISA and 121 for VISA Electron
Track 3:
;011234567890123445=724724000000000***00300XXXX020200099010=******************==1=100000000000000000?
^^ ^ ^^ ^ ^ ^ ^ ^^ ^ ^ ^^ ^^^^^ ^^
|| | || |_ Currency | | | || | | ||_ FSAN ||||| ||
|| |_ Card number || (Peseta) | | | || | | |_ Field separator |||||_ Additional data ||_ LRC
||_ Format code ||_ Country | | | || | |_ Expiration ||||_ Field separator |_ End sentinel
|_ Start sentinel | (Spain) | | | || |_ FSAN service restriction |||_ Relay marker
|_ Field | | | ||_ PAN service restriction ||_ Field separator
separator | | | |_ Interchange control |_ Field separator
Validity date | | | Encrypted PIN (except if duplicate card)
(except if duplicate card) |_ Retry count
Uno-e VISA Electron card:

Printing:
Card holder: L. PADILLA
Card number: 1234 5678 9012 3445
Expiration : 01/99
Track 1:
%B1234567890123445^PADILLA/L. ^99011211XXXX0000000XXX0000?
^^^ ^^ ^^ ^ ^^ ^ ^ ^^
|||_ Card number ||_ Card holder || | || |_ Discr. |_ CVV ||_ LRC
||_ Format code |_ Field separator || | || data |_ End sentinel
|_ Start sentinel Field separator || | || PVV*
Expiration | | | PVV key indicator
|_ Service code
Track 2:
;1234567890123445=99011211XXXXXXX00***?*
^^ ^^ ^ ^^ ^ ^^
||_ Card number || | || |_ CVV ||_ LRC
|_ Start sentinel|| | ||_ PVV* |_ End sentinel
Field separator || | | PVV key indicator
Expiration | | Service code
Track 3:

Credit card length

Hello,
You should totally check card number length too. Since checking if card is valid without it is kinda strange. I can get 6 digit card numbers easily.

npm publish

any plans on publishing changes from 0.1.2 to npm?

thanks

Include Mastercard "Series 2" BINs

Mastercard are to issue cards later this year with new Bank Identification Numbers starting with 2 (hence series 2). Details here

The regex used for card type identification needs updating to include them.

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.