MasterCard has introduced a new 2-series to their Bank Identification Numbers (BINs). Up until now, MasterCard BINs have only been in the 5-series range, but they began issuing the 2-series BINs this year. The range is from 222100 to 272099. The new BIN range is subject to the same rules as the existing MasterCard 5-series BIN range.

The logic in Drupal Commerce that validates credit card numbers resides in modules/payment/includes/commerce_payment.credit_card.inc. It needs to be updated ASAP to allow the new MasterCard numbers, but we should also use this opportunity to review all of our credit card rules so both 1.x and 2.x are using the latest rules.

Comments

rszrama created an issue. See original summary.

bojanz’s picture

2.x code: https://github.com/drupalcommerce/commerce/blob/8.x-2.x/modules/payment/...

Note that 2.x uses a more declarative approach, while 1.x is more imperative. If we could sync the 1.x logic with 2.x, it would be easier to keep the datasets in sync.

dhare23’s picture

Status: Active » Needs review
StatusFileSize
new851 bytes

Quick fix to validate 2-series BIN cards.

mglaman’s picture

StatusFileSize
new20.44 KB

Here is a direct backport (CreditCard -> CommercePaymentCreditCard, unit test as well.) Switch, Laser, and Solo removed as no longer active.

mglaman’s picture

Assigned: Unassigned » rszrama

Assigning to rszrama to review.

bojanz’s picture

Good job.

You've changed the diners club machine name, that should be synced back.

We also lost Visa Electron (2.x has just Visa), not sure if that's relevant (I modeled the list after the stripe/braintree lists)

Also, we probably don't need to mention that something is a 2.x backport. It's all us, and there will hopefuly be more.

mglaman’s picture

Assigned: rszrama » mglaman
+++ b/modules/payment/includes/commerce_payment.credit_card.inc
@@ -272,149 +272,13 @@ function commerce_payment_credit_card_validate($details, $settings) {
-          return 'dci';
...
-          return 'dc';

@@ -545,45 +374,273 @@ function commerce_payment_validate_credit_card_issue($issue) {
-    'dc' => t("Diners Club"),
-    'dci' => t("Diners Club International"),
...
-    'visaelectron' => t('Visa Electron'),

2.x DC/DCi are combined. Reroll to address this

mglaman’s picture

Assigned: mglaman » Unassigned
StatusFileSize
new20.45 KB
new2.05 KB

Added Visa Electron back. Kept DC/DCi/CB combined. I think maybe we should also write a change record which states Laser, Switch/Solo removed as they are no longer active. DCi/CB merged into DC.

We also don't need Visa Electron explicitly defined because it starts with 4

mglaman’s picture

Created a draft CR here https://www.drupal.org/node/2887698

  • mglaman committed fcf5265 on 7.x-1.x
    Issue #2887414 by mglaman, rszrama, bojanz, dhare23: Update our credit...
mglaman’s picture

Status: Needs review » Fixed

Committed! Yay, first 2.x work backport to update 1.x

jsacksick’s picture

Status: Fixed » Needs review

Reverted the commit since it was containing unrelated code... :p

  • jsacksick committed 5183b94 on 7.x-1.x authored by mglaman
    Issue #2887414 by mglaman, rszrama, bojanz, dhare23: Update our cretdit...
jsacksick’s picture

Status: Needs review » Fixed

Just committed the right patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jsacksick’s picture

Status: Closed (fixed) » Needs work

It appears there's an issue with commerce_payment_validate_credit_card_type(), I always get the following error: "You have entered a credit card number that does not match the type selected." when entering valid test credit card numbers.

commerce_payment_validate_credit_card_type() used to return a string, now it returns an array, hence the check performed in commerce_payment_credit_card_validate() doesn't pass.

We could either update commerce_payment_credit_card_validate() to expect an array or make commerce_payment_validate_credit_card_type() return the credit card type (a.k.a id) string, or FALSE when not valid.

Additionally, the $card_types array argument is not used in the function.

  • jsacksick committed 3dd7404 on 7.x-1.x
    Issue #2887414: Fix a regression introduced in...
jsacksick’s picture

Status: Needs work » Fixed
StatusFileSize
new1002 bytes

Since various payment contrib modules are calling commerce_payment_validate_credit_card_type, I think we should make it return the card type string instead of an array (See patch attached):

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.