From 44890f787e2d4b98caccdc180d7fc590ea49251a Mon Sep 17 00:00:00 2001 From: Jesse Kaunisviita Date: Wed, 3 Nov 2010 14:39:56 -0400 Subject: [PATCH] Updated new BIN ranges of Maestro, Discover, Switch and Solo cards. --- .../billing/credit_card_methods.rb | 10 ++++----- test/unit/credit_card_methods_test.rb | 21 +++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index ab318784633..e17744a2436 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -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})?$/ } @@ -122,4 +122,4 @@ def valid_checksum?(number) #:nodoc: end end end -end \ No newline at end of file +end diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 98e882895f8..f9810f29317 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -11,6 +11,7 @@ def maestro_card_numbers %w[ 5000000000000000 5099999999999999 5600000000000000 5899999999999999 6000000000000000 6999999999999999 + 6761999999999999 6763000000000000 5038999999999999 ] end @@ -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 @@ -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