Skip to content

Commit

Permalink
Add luhn10 check to naranja
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinHaefele committed Aug 14, 2024
1 parent 0f2ae6f commit daa1d50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/credit_card_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def sodexo_no_luhn?(numbers)
def valid_by_algorithm?(brand, numbers) #:nodoc:
case brand
when 'naranja'
valid_naranja_algo?(numbers)
valid_naranja_algo?(numbers) || valid_luhn?(numbers)
when 'creditel'
valid_creditel_algo?(numbers)
when 'alia', 'confiable', 'maestro_no_luhn', 'anda', 'tarjeta-d', 'hipercard'
Expand Down
9 changes: 6 additions & 3 deletions test/unit/credit_card_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ def test_should_detect_naranja_card
assert_equal 'naranja', CreditCard.brand?('5895627823453005')
assert_equal 'naranja', CreditCard.brand?('5895620000000002')
assert_equal 'naranja', CreditCard.brand?('5895626746595650')
assert_equal 'naranja', CreditCard.brand?('5895628637412581')
assert_equal 'naranja', CreditCard.brand?('5895627087232438')
end

# Alelo BINs beginning with the digit 4 overlap with Visa's range of valid card numbers.
Expand Down Expand Up @@ -445,9 +447,10 @@ def test_matching_invalid_card
end

def test_matching_valid_naranja
number = '5895627823453005'
assert_equal 'naranja', CreditCard.brand?(number)
assert CreditCard.valid_number?(number)
%w[5895627823453005 5895627087232438 5895628637412581].each do |number|
assert_equal 'naranja', CreditCard.brand?(number)
assert CreditCard.valid_number?(number)
end
end

def test_matching_valid_creditel
Expand Down

0 comments on commit daa1d50

Please sign in to comment.