DiUS / java-faker

Brings the popular ruby faker gem to Java
http://dius.github.io/java-faker
Other
4.76k stars 847 forks source link

Wrong credit card numbers #747

Open MRezaNasirloo opened 2 years ago

MRezaNasirloo commented 2 years ago

Describe the bug Some generated credit card numbers for CreditCardType.VISA and CreditCardType.DISCOVER are wrong

To Reproduce

repeat(1000) {
    val creditCard = Faker.instance().finance().creditCard(CreditCardType.DISCOVER).replace("-", "")
    if (creditCard.length == 20 || creditCard.length == 13) {
        println(creditCard)
    }
}

Expected behavior

Versions:

bodiam commented 2 years ago

Hi @MRezaNasirloo , could you please try out Datafaker.net, an active fork of this library? We did some improvements recently on the credit card generation in 1.7.0-SNAPSHOT, which might fix this issue, and we would love to hear your feedback on this.

MRezaNasirloo commented 2 years ago

Hi @bodiam, Same issue, you can try the above snippet

bodiam commented 2 years ago

@MRezaNasirloo according to this info here: https://moneytips.com/anatomy-of-a-credit-card/, Visa cards:

Visa cards begin with a 4 and have 13 or 16 digits

The same information can be found here: https://en.wikipedia.org/wiki/Payment_card_number

MRezaNasirloo commented 2 years ago

@bodiam You're right, however, these are not in circulation anymore, I guess.

While the vast majority of Visa's account ranges describe 16 digit card numbers there are still a few account ranges (forty as of 11 December 2013) dedicated to 13 digit PANs and several (439 as of 11 Dec. 2013) account ranges where the issuer can mix 13 and 16 digit card numbers. Visa's VPay brand can specify PAN lengths from 13 to 19 digits and so card numbers of more than 16 digits are now being seen.

What about DISCOVER? Max length should be 19 not 20

bodiam commented 2 years ago

Can you give the snapshot version of Datafaker a try? I believe I fixed all the credit card issues, but if you find an issue, can you please make a new issue in the Datafaker repo for this? Thanks!