-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
Visa CardType providing invalid format Cards #313
Comments
Hi Cameron, Thank you for posting an issue. A few more questions: What is invalid about the 13 digit Visa number? Is the problem that Bogus generated a 13 digit card number for Visa? Or is the checksum digit wrong? From the looks of it, it seems that a 13 digit card number can be a valid length for a Visa credit card number. |
I was going based on the Wikipedia entry which shows only 16 digits as valid: https://en.wikipedia.org/wiki/Payment_card_number Also based on Faker changing it to "Retired Visa" fzaninotto/Faker#1400 |
Hi Cameron, Thank you very much for the links; they helped a lot. I was looking at the Wikipedia link and this caught my eye:
Searching for Visa's test plan for credit card acceptance devices we find traces of PAN lengths: Visa Transaction Acceptance Device Guide - Version 3.0 - May 15 2015https://technologypartner.visa.com/download.aspx?id=32 Visa Transaction Acceptance Device Guide - Version 3.2 - January 2020https://technologypartner.visa.com/Download.aspx?id=573 From the information I gathered, it seems that a system accepting Visa should allow 13 digit PANs. As a result of the findings above, I'm inclined to keep the current codebase as-is. However, if others start making the same requests I'm open to changing it in the future. WorkaroundIf you'd like a workaround for the issue; you can generate 16 digit PANs for Visa as shown below:
using Bogus.Extensions.Extras
void Main()
{
var f = new Faker();
f.Finance.Visa16Digit().Dump();
}
public static class ExtensionsForFinance
{
public static string Visa16Digit(this Bogus.DataSets.Finance finance)
{
const string format = "4##############";
return finance.Random.ReplaceNumbers(format).AppendCheckDigit();
}
}
Let me know your thoughts. Thanks, |
Nice, from what I can tell this should work from a solid workaround standpoint while still providing backwards compatibility to the older versions. Thanks for the information! |
Thank you for your feedback and for raising the issue, Cameron. I'll keep an eye on this issue and if we find more people looking for 16 digit-only Visa numbers, we'll consider making the change. I like to wait until we get more hits on a particular issue before we start making changes to the API and diverging from Also, leveraging C# extension methods on the DataSets or the Thanks again for posting the issue. |
Version Information
What locale are you using with Bogus?
EN
What is the expected behavior?
Generating a Valid Visa credit card
What is the actual behavior?
50/50 shot of an invalid 13 digit card number
Any possible solutions?
Change line: https://github.com/bchavez/Bogus/blob/master/Source/Bogus/data/en.locale.json#L10266 to "4##############L" or remove it all together
How do you reproduce the issue?
Generate a CardType.Visa Credit card more than a few times
Do you have a unit test that can demonstrate the bug?
The current unit test should fail
Can you identify the location in Bogus' source code where the problem exists?
https://github.com/bchavez/Bogus/blob/master/Source/Bogus/data/en.locale.json#L10266
If the bug is confirmed, would you be willing to submit a PR?
Yes / No (Help can be provided if you need assistance submitting a PR)
The text was updated successfully, but these errors were encountered: