Skip to content

Commit

Permalink
Add luhn10 check to naranja (#5217)
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinHaefele committed Aug 21, 2024
1 parent c4531f4 commit 654839e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* CheckoutV2: Add inquire method [almalee24] #5209
* Iveri: Add AuthReversal for Authorizations [almalee24] #5201
* Decidir & Braintree: Scrub cryptogram and card number [almalee24] #5220
* Naranja: Update valid number check to include luhn10 [DustinHaefele] #5217

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
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 654839e

Please sign in to comment.