Regular expressions for the known card companies.
References:
# File lib/active_merchant/billing/credit_card_methods.rb, line 58 58: def card_companies 59: CARD_COMPANIES 60: end
# File lib/active_merchant/billing/credit_card_methods.rb, line 87 87: def last_digits(number) 88: number.to_s.length <= 4 ? number : number.to_s.slice(4..1) 89: end
# File lib/active_merchant/billing/credit_card_methods.rb, line 91 91: def mask(number) 92: "XXXX-XXXX-XXXX-#{last_digits(number)}" 93: end
Checks to see if the calculated type matches the specified type
# File lib/active_merchant/billing/credit_card_methods.rb, line 96 96: def matching_type?(number, type) 97: type?(number) == type 98: end
Returns a string containing the type of card from the list of known information below. Need to check the cards in a particular order, as there is some overlap of the allowable ranges
# File lib/active_merchant/billing/credit_card_methods.rb, line 75 75: def type?(number) 76: return 'bogus' if valid_test_mode_card_number?(number) 77: 78: card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern| 79: return company.dup if number =~ pattern 80: end 81: 82: return 'maestro' if number =~ card_companies['maestro'] 83: 84: return nil 85: end
Returns true if it validates. Optionally, you can pass a card type as an argument and make sure it is of the correct type.
References:
# File lib/active_merchant/billing/credit_card_methods.rb, line 47 47: def valid_number?(number) 48: valid_test_mode_card_number?(number) || 49: valid_card_number_length?(number) && 50: valid_checksum?(number) 51: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.