sualeh / creditcardnumber

Java library that can provide details of a bank issued credit card number
Other
70 stars 31 forks source link

Mastercard regex coverage issue #135

Open sesser opened 2 months ago

sesser commented 2 months ago

Issue

The regex pattern used to detect MasterCard excludes a portion of cards (according to the range 2221 - 2720). Specifically, 2230 - 2299. Also, according to MC simplified BIN account range, the min BIN is 222635. You can download the list from https://www.mastercard.us/en-us/business/issuers/get-support/simplified-bin-account-range-table.html

I can't speak to BINs that start with 2221-2225. I have not researched.

  • CardBrand.from("223557******") yields Unknown when it should be MasterCard
  • I think this can be solved with a minor adjustment to the regex pattern

^(?:5[1-5][0-9]{2}|222[1-9]|2[2-6][0-9]{2}|27[01][0-9]|2720)[0-9]*

Environment

Specify the

  • version of Credit Card Number: 4.0.4
  • version of Java: 17
  • operating system and version: Alpine/macOS
sualeh commented 1 month ago

@sesser Sorry - for some reason I saw this very late. Let me evaluate and fix.