BankCard / CreditCard
Description
This gem contains
-
validation methods to check card number with Luhn method, card expiration date
-
brand detection method for Visa, MasterCard, JCB, Discover, Maestro, Diners Club, American Express.
Example
class CreditCard < ActiveRecord::Base
include BankCard::Validations
include BankCard::Brands
validates :number, :luhn => true
validates_expiration_of :date
before_create :set_brand
private
def set_brand
self.brand = detect_brand(number)
end
end
You can get more info from specs
Licence
released under the MIT license.