module ActiveMerchant::Billing::CreditCardMethods
Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
Constants
- ALELO_RANGES
Alelo provides BIN ranges by e-mailing them out periodically. The BINs beginning with the digit 4 overlap with Visa’s range of valid card numbers. By placing the ‘alelo’ entry in
CARD_COMPANY_DETECTORS
below the ‘visa’ entry, we identify these cards as Visa. This works because transactions with such cards will run on Visa rails.- CABAL_RANGES
- CARD_COMPANY_DETECTORS
- CARNET_BINS
- CARNET_RANGES
- CARTES_BANCAIRES_RANGES
- ELECTRON_RANGES
- ELO_RANGES
dev.elo.com.br/apis/tabela-de-bins, download csv from left sidebar
- HIPERCARD_RANGES
- JCB_RANGES
- MADA_RANGES
- MAESTRO_BINS
- MAESTRO_RANGES
www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 79
- MASTERCARD_RANGES
www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
- NARANJA_RANGES
- PANAL_RANGES
- SODEXO_BINS
- SODEXO_NO_LUHN
- UNIONPAY_RANGES
www.discoverglobalnetwork.com/content/dam/discover/en_us/dgn/pdfs/IPP-VAR-Enabler-Compliance.pdf
- VERVE_RANGES
Public Class Methods
# File lib/active_merchant/billing/credit_card_methods.rb, line 311 def self.in_bin_range?(number, ranges) bin = number.to_i ranges.any? do |range| range.include?(bin) end end
# File lib/active_merchant/billing/credit_card_methods.rb, line 307 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
# File lib/active_merchant/billing/credit_card_methods.rb, line 351 def card_verification_value_length(brand) case brand when 'american_express' 4 when 'maestro' 0 else 3 end end
# File lib/active_merchant/billing/credit_card_methods.rb, line 322 def credit_card? true end
Returns if the card matches known Electron BINs
# File lib/active_merchant/billing/credit_card_methods.rb, line 367 def electron? self.class.electron?(number) end
Credit card providers have 3 digit verification values This isn’t standardised, these are called various names such as CVC, CVV, CID, CSC and more See: en.wikipedia.org/wiki/Card_security_code American Express is the exception with 4 digits
Below are links from the card providers with their requirements visa: usa.visa.com/personal/security/3-digit-security-code.jsp master: www.mastercard.com/ca/merchant/en/getstarted/Anatomy_MasterCard.html jcb: www.jcbcard.com/security/info.html diners_club: www.dinersclub.com/assets/DinersClub_card_ID_features.pdf discover: www.discover.com/credit-cards/help-center/glossary.html american_express: online.americanexpress.com/myca/fuidfyp/us/action?request_type=un_fuid&Face=en_US
# File lib/active_merchant/billing/credit_card_methods.rb, line 347 def valid_card_verification_value?(cvv, brand) cvv.to_s =~ /^\d{#{card_verification_value_length(brand)}}$/ end
# File lib/active_merchant/billing/credit_card_methods.rb, line 326 def valid_expiry_year?(year) (Time.now.year..Time.now.year + 20).cover?(year.to_i) end
# File lib/active_merchant/billing/credit_card_methods.rb, line 362 def valid_issue_number?(number) (number.to_s =~ /^\d{1,2}$/) end
# File lib/active_merchant/billing/credit_card_methods.rb, line 318 def valid_month?(month) (1..12).cover?(month.to_i) end
# File lib/active_merchant/billing/credit_card_methods.rb, line 330 def valid_start_year?(year) ((year.to_s =~ /^\d{4}$/) && (year.to_i > 1987)) end