No release in over 3 years
Low commit activity in last 3 years
A ruby gem for validating credit card numbers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.9
>= 0
~> 10.5
 Project Readme

Credit card detector

Gem provides credit card number validator and type detector.

It checks whether or not a given number actually falls within the ranges of possible numbers for given brands and provides an optional Luhn check.

More info about card BIN numbers http://en.wikipedia.org/wiki/Bank_card_number

Installation

Add this line to your application's Gemfile:

gem 'credit_card_detector'

And then execute:

$ bundle

Or install it yourself as:

$ gem install credit_card_detector

Usage

The following issuing institutes are accepted:

Name   |    Key     | 

--------------------- | ------------| American Express | :amex China UnionPay | :unionpay Dankort | :dankort Diners Club | :diners
Elo | :elo Discover | :discover
Hipercard | :hipercard
JCB | :jcb Maestro | :maestro MasterCard | :mastercard MIR | :mir Rupay | :rupay Solo | :solo Switch | :switch Visa | :visa

Examples

    number = "4111111111111111"
    detector = CreditCardDetector::Detector.new(number)
    detector.brand # Visa brand
    detector.brand_name # Visa
    detector.valid?(:mastercard, :maestro) #false
    detector.valid?(:visa, :mastercard) #true

Check luhn

    CreditCardDetector::Detector.new(number).valid_luhn?

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Original version

credit_card_validations - provides more extended API, but depends on activemodel and activesupport.