module CreditCardValidations
CreditCardValidations
Detector
¶ ↑
class provides credit card number validations
CreditCardValidations
Factory
¶ ↑
Generates card number that passes validation
random
CreditCardValidations::Factory.random
or particular brand
CreditCardValidations::Factory.random(:maestro) # "6010430241237266856"
CreditCardValidations
Luhn
¶ ↑
simple class to validate Luhn
numbers.
Luhn.valid? 4111111111111111
CreditCardValidations
Mmi
¶ ↑
Implements Major Industry Identifier (MII) detection
The first digit of a credit card number is the Major Industry Identifier (MII), which represents the category of entity which issued the card. MII digits represent the following issuer categories: 0 – ISO/TC 68 and other future industry assignments 1 – Airlines 2 – Airlines and other future industry assignments 3 – Travel and entertainment and banking/financial 4 – Banking and financial 5 – Banking and financial 6 – Merchandising and banking/financial 7 – Petroleum and other future industry assignments 8 – Healthcare, telecommunications and other future industry assignments 9 – National assignment For example, American Express, Diner's Club, Carte Blanche, and JCB are in the travel and entertainment category; VISA, MasterCard, and Discover are in the banking and financial category (Discover being in the Merchandising and banking/financial category); and Sun Oil and Exxon are in the petroleum category.
Constants
- DATA
- VERSION
Public Class Methods
# File lib/credit_card_validations.rb, line 18 def self.add_brand(key, rules, options = {}) Detector.add_brand(key, rules, options) end
# File lib/credit_card_validations.rb, line 24 def self.reload! Detector.brands = {} DATA.sort.each do |key, data| add_brand(key, data.fetch(:rules), data.fetch(:options, {})) end end