Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated new BIN ranges of Maestro, Discover, Switch and Solo cards. #48

Merged
1 commit merged into from Nov 4, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/active_merchant/billing/credit_card_methods.rb
Expand Up @@ -5,14 +5,14 @@ module CreditCardMethods
CARD_COMPANIES = {
'visa' => /^4\d{12}(\d{3})?$/,
'master' => /^(5[1-5]\d{4}|677189)\d{10}$/,
'discover' => /^(6011|65\d{2})\d{12}$/,
'discover' => /^(6011|65\d{2}|64[4-9]\d{1})\d{12}|(622\d{13})$/,
'american_express' => /^3[47]\d{13}$/,
'diners_club' => /^3(0[0-5]|[68]\d)\d{11}$/,
'jcb' => /^35(28|29|[3-8]\d)\d{12}$/,
'switch' => /^6759\d{12}(\d{2,3})?$/,
'solo' => /^6767\d{12}(\d{2,3})?$/,
'switch' => /^((6759|4903|4905|4911|4936|6333)\d{12}|(564182|633110)\d{10})(\d{2,3})?$/,
'solo' => /^(6767|6334)\d{12}(\d{2,3})?$/,
'dankort' => /^5019\d{12}$/,
'maestro' => /^(5[06-8]|6\d)\d{10,17}$/,
'maestro' => /^(5018|5020|5038|6761|6763)\d{8,15}|(5[06-8]|6\d)\d{10,17}$/,
'forbrugsforeningen' => /^600722\d{10}$/,
'laser' => /^(6304|6706|6771|6709)\d{8}(\d{4}|\d{6,7})?$/
}
Expand Down Expand Up @@ -122,4 +122,4 @@ def valid_checksum?(number) #:nodoc:
end
end
end
end
end
21 changes: 17 additions & 4 deletions test/unit/credit_card_methods_test.rb
Expand Up @@ -11,6 +11,7 @@ def maestro_card_numbers
%w[
5000000000000000 5099999999999999 5600000000000000
5899999999999999 6000000000000000 6999999999999999
6761999999999999 6763000000000000 5038999999999999
]
end

Expand Down Expand Up @@ -165,11 +166,13 @@ def test_detecting_full_range_of_maestro_card_numbers
end

def test_matching_discover_card
assert CreditCard.matching_type?('6011000000000000', 'discover')
assert CreditCard.matching_type?('6500000000000000', 'discover')
assert_equal 'discover', CreditCard.type?('6011000000000000')
assert_equal 'discover', CreditCard.type?('6500000000000000')
assert_equal 'discover', CreditCard.type?('6221260000000000')
assert_equal 'discover', CreditCard.type?('6450000000000000')

assert_false CreditCard.matching_type?('6010000000000000', 'discover')
assert_false CreditCard.matching_type?('6600000000000000', 'discover')
assert_not_equal 'discover', CreditCard.type?('6010000000000000')
assert_not_equal 'discover', CreditCard.type?('6600000000000000')
end

def test_16_digit_maestro_uk
Expand All @@ -189,4 +192,14 @@ def test_19_digit_maestro_uk
assert_equal 19, number.length
assert_equal 'switch', CreditCard.type?(number)
end

def test_matching_switch_card
assert_equal 'switch', CreditCard.type?('4903000000000000')
assert_equal 'switch', CreditCard.type?('5641820000000000')
assert_equal 'switch', CreditCard.type?('6331100000000000')
assert_equal 'switch', CreditCard.type?('6759000000000000')

assert_not_equal 'switch', CreditCard.type?('67590000000000000') #17 digits
assert_not_equal 'switch', CreditCard.type?('67590000000000000000') #20 digits
end
end