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

Add luhn10 check to naranja #5217

Merged
merged 1 commit into from
Aug 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading