Giter Site home page Giter Site logo

jerrellmarkus / credit-card-validation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from theninja/credit-card-validation

0.0 0.0 0.0 172 KB

Credit/debit card validation for browsers and Node.js, uses the Luhn algorithm and pattern matching.

License: MIT License

CSS 18.39% JavaScript 81.61%

credit-card-validation's Introduction

Credit Card Validation

This is a micro-library for credit card validation. It checks a card number is valid and detects the issuing bank (IIN). It currently supports most major card issuers.

Try the example at http://theninja.github.io/credit-card-validation/.

Import

Browser

Simply add the script (<script src="card.min.js"></script>) either just before the closing body tag or within the head of your page.

var card = CardValidate('xxxxxxxxxxxxxxxx');

Node.js

var cardvalidate = require('card'),
	card = cardvalidate('xxxxxxxxxxxxxxxx');

Usage

At the moment the script is purposefully simple and exposes only two public methods.

// returns default if unkown or the issuing bank's name (lowercase)
card.getType();
// returns true if the card is validated by Luhn algorithm
// and matches card requirements or false if not
card.isValid();

Testing

To run tests simply run npm install if you haven't already, followed by npm test.

##TODO

Possibly add CVC length and expiration date checks.

Disclaimer

This doesn't check that a credit card is real or that payment can be made with it. The Luhn algorithm is easily fooled as it's a simple mathematical formula, this just helps avoid typos and typical user errors. The only way to check if a card is actually valid (including CVC etc.), is by using a real payment provider that offers this service.

Licensing

The code is MIT licensed.

The trademarks and branding included in this project, namely those of the credit card providers, are property of their respective owners.

credit-card-validation's People

Contributors

theninja avatar

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.