Skip to content
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

New MasterCard prefix is not supported #5

Open
ribasushi opened this issue Apr 20, 2017 · 5 comments
Open

New MasterCard prefix is not supported #5

ribasushi opened this issue Apr 20, 2017 · 5 comments

Comments

@ribasushi
Copy link

The current validation routine for credit cards has no provision for "2-series" master card numbers, like e.g. 2521 0000 0000 0006

Rollout begins in couple months: https://www.mastercard.us/en-us/issuers/get-support/2-series-bin-expansion.html

@gquipster
Copy link
Contributor

Looking at: https://en.wikipedia.org/wiki/Payment_card_number#Issuer_identification_number_.28IIN.29

It looks like the constraint at line 657 needs changing roughly (this being done off top of my head in notepad) as follows:

return undef if (
	($card_type =~ /^v/i && substr($the_card, 0, 1) ne "4") # Visa
	|| (
		$card_type =~ /^m/i
		&& substr($the_card, 0, 4) !~ /^\d{4}$/
		&& (
			substr($the_card, 0, 4) < 2221
			&& substr($the_card, 0, 4) > 2720
		) # New 2017 range
		&& (
			substr($the_card, 0, 2) < 51
			&& substr($the_card, 0, 2) > 55
		) # Original range
	) # Mastercard
	|| (
		$card_type =~ /^d/i
		&& substr($the_card, 0, 4) ne "6011"
		&& substr($the_card, 0, 6) !~ /^\d{6}$/
		&& (
			substr($the_card, 0, 6) < 622126
			&& substr($the_card, 0, 6) > 622925
		)
		&& (
			substr($the_card, 0, 3) < 644
			&& substr($the_card, 0, 3) > 649
		)
		&& substr($the_card, 0, 2) ne "65"
	) # Discover Card
	|| (
		$card_type =~ /^a/i
		&& substr($the_card, 0, 2) ne "34"
		&& substr($the_card, 0, 2) ne "37"
	) # American Express
);

@ribasushi
Copy link
Author

@dnmfarrell have you had a chance to look at this?

@dnmfarrell
Copy link
Owner

Uh no, sorry. I should update my GitHub notification settings. @ribasushi I'll look soon

@dnmfarrell
Copy link
Owner

I think 2cc14697d3c8d345b7748fbad3b272cd4d141acc addresses this. Looking at the code, I have some other concerns: I think it might be better if DFV used a module like Business::CreditCard to provide CC validation. Ideally, DFV wouldn't have any specific validation code beyond setting up the structures and routines to perform validation, but I think that horse has bolted...

@ribasushi
Copy link
Author

@dnmfarrell if your medium-term goal is to move to Business::CreditCard - yes then 2cc1469 is a sufficient fix at this stage and should be released when you have time.

However if you do not have the time to follow through on that in the near future, I'd strongly recommend adopting @gquipster's solution higher up in this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants