Skip to content

Commit

Permalink
Add Cartes Bancaires bin ranges (#4398)
Browse files Browse the repository at this point in the history
Add bin ranges so that we can identify the French card brand Cartes Bancaires
  • Loading branch information
leahriffell authored Apr 15, 2022
1 parent f5ba1db commit eda06d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
* NMI: Update post URL [jherreraa] #4380
* Multiple Gateways: Resolve when/case bug [naashton] #4399
* Airwallex: Add 3DS MPI support [drkjc] #4395
* Add Cartes Bancaires card bin ranges [leahriffell] #4398

== Version 1.125.0 (January 20, 2022)
* Wompi: support gateway [therufs] #4173
Expand Down
12 changes: 12 additions & 0 deletions lib/active_merchant/billing/credit_card_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module CreditCardMethods
CARNET_BINS.any? { |bin| num.slice(0, bin.size) == bin }
)
},
'cartes_bancaires' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), CARTES_BANCAIRES_RANGES) },
'olimpica' => ->(num) { num =~ /^636853\d{10}$/ },
'creditel' => ->(num) { num =~ /^601933\d{10}$/ },
'confiable' => ->(num) { num =~ /^560718\d{10}$/ },
Expand Down Expand Up @@ -73,6 +74,17 @@ module CreditCardMethods
]
)

CARTES_BANCAIRES_RANGES = [
(507589..507590),
(507593..507595),
[507597],
[560408],
[581752],
(585402..585405),
(585501..585505),
(585577..585582)
]

# https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
MASTERCARD_RANGES = [
(222100..272099),
Expand Down
7 changes: 7 additions & 0 deletions test/unit/credit_card_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ def test_carnet_cards
end
end

def test_should_detect_cartes_bancaires_cards
assert_equal 'cartes_bancaires', CreditCard.brand?('5855010000000000')
assert_equal 'cartes_bancaires', CreditCard.brand?('5075935000000000')
assert_equal 'cartes_bancaires', CreditCard.brand?('5075901100000000')
assert_equal 'cartes_bancaires', CreditCard.brand?('5075890130000000')
end

def test_electron_cards
# return the card number so assert failures are easy to isolate
electron_test = Proc.new do |card_number|
Expand Down

0 comments on commit eda06d0

Please sign in to comment.