From 654839e8045ff15e61b55bf761e2a886afcc2d25 Mon Sep 17 00:00:00 2001 From: Dustin A Haefele <45601251+DustinHaefele@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:50:06 -0400 Subject: [PATCH] Add luhn10 check to naranja (#5217) --- CHANGELOG | 1 + lib/active_merchant/billing/credit_card_methods.rb | 2 +- test/unit/credit_card_methods_test.rb | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3e102903375..04092c63140 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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). diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb index 619601cb2d3..dd524d3f814 100644 --- a/lib/active_merchant/billing/credit_card_methods.rb +++ b/lib/active_merchant/billing/credit_card_methods.rb @@ -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' diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb index 735d512d708..cc9ffa9753f 100644 --- a/test/unit/credit_card_methods_test.rb +++ b/test/unit/credit_card_methods_test.rb @@ -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. @@ -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