Skip to content

Commit 8dafb2c

Browse files
author
heyitsroberthe
committed
MAGETWO-68868: [Backport] Updated Discover and Maestro/Mastercard BINs - for 2.0.x
1 parent 0aabab8 commit 8dafb2c

File tree

6 files changed

+214
-22
lines changed

6 files changed

+214
-22
lines changed

app/code/Magento/Authorizenet/Model/Source/Cctype.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class Cctype extends PaymentCctype
1717
*/
1818
public function getAllowedTypes()
1919
{
20-
return ['VI', 'MC', 'AE', 'DI', 'OT'];
20+
return ['VI', 'MC', 'AE', 'DI'];
2121
}
2222
}

app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-number-validator/credit-card-type.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define(
2626
{
2727
title: 'MasterCard',
2828
type: 'MC',
29-
pattern: '^5([1-5]\\d*)?$',
29+
pattern: '^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$',
3030
gaps: [4, 8, 12],
3131
lengths: [16],
3232
code: {
@@ -49,9 +49,9 @@ define(
4949
{
5050
title: 'Diners',
5151
type: 'DN',
52-
pattern: '^3((0([0-5]\\d*)?)|[689]\\d*)?$',
52+
pattern: '^(3(0[0-5]|095|6|[8-9]))\\d*$',
5353
gaps: [4, 10],
54-
lengths: [14],
54+
lengths: [14, 16, 17, 18, 19],
5555
code: {
5656
name: 'CVV',
5757
size: 3
@@ -60,9 +60,9 @@ define(
6060
{
6161
title: 'Discover',
6262
type: 'DI',
63-
pattern: '^6(0|01|011\\d*|5\\d*|4|4[4-9]\\d*)?$',
63+
pattern: '^(6011(0|[2-4]|74|7[7-9]|8[6-9]|9)|6(4[4-9]|5))\\d*$',
6464
gaps: [4, 8, 12],
65-
lengths: [16],
65+
lengths: [16, 17, 18, 19],
6666
code: {
6767
name: 'CID',
6868
size: 3
@@ -71,9 +71,9 @@ define(
7171
{
7272
title: 'JCB',
7373
type: 'JCB',
74-
pattern: '^((2|21|213|2131\\d*)|(1|18|180|1800\\d*)|(3|35\\d*))$',
74+
pattern: '^35(2[8-9]|[3-8])\\d*$',
7575
gaps: [4, 8, 12],
76-
lengths: [16],
76+
lengths: [16, 17, 18, 19],
7777
code: {
7878
name: 'CVV',
7979
size: 3
@@ -82,7 +82,7 @@ define(
8282
{
8383
title: 'UnionPay',
8484
type: 'UN',
85-
pattern: '^6(2\\d*)?$',
85+
pattern: '^(622(1(2[6-9]|[3-9])|[3-8]|9([[0-1]|2[0-5]))|62[4-6]|628([2-8]))\\d*?$',
8686
gaps: [4, 8, 12],
8787
lengths: [16, 17, 18, 19],
8888
code: {

app/code/Magento/Paypal/Model/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ public function getWppCcTypesAsOptionArray()
12651265
public function getWppPeCcTypesAsOptionArray()
12661266
{
12671267
return $this->_cctypeFactory->create()->setAllowedTypes(
1268-
['VI', 'MC', 'SM', 'SO', 'OT', 'AE']
1268+
['VI', 'MC', 'SM', 'SO', 'AE']
12691269
)->toOptionArray();
12701270
}
12711271

@@ -1276,7 +1276,7 @@ public function getWppPeCcTypesAsOptionArray()
12761276
*/
12771277
public function getPayflowproCcTypesAsOptionArray()
12781278
{
1279-
return $this->_cctypeFactory->create()->setAllowedTypes(['AE', 'VI', 'MC', 'JCB', 'DI'])->toOptionArray();
1279+
return $this->_cctypeFactory->create()->setAllowedTypes(['AE', 'VI', 'MC', 'JCB', 'DI', 'DN'])->toOptionArray();
12801280
}
12811281

12821282
/**

dev/tests/js/JsTestDriver/testsuite/mage/validation/test-validation.js

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,24 +414,41 @@ test( "testValidateGroupedQty", function() {
414414
});
415415

416416
test( "testValidateCCTypeSelect", function() {
417-
expect(6);
417+
expect(14);
418418
var visaValid = $('<input id="visa-valid" type="text" value="4916808263499650"/>');
419419
var visaInvalid = $('<input id="visa-invalid" type="text" value="1234567890123456"/>');
420420
var mcValid = $('<input id="mc-valid" type="text" value="5203731841177490"/>');
421421
var mcInvalid = $('<input id="mc-invalid" type="text" value="1111222233334444"/>');
422422
var aeValid = $('<input id="ae-valid" type="text" value="376244899619217"/>');
423423
var aeInvalid = $('<input id="ae-invalid" type="text" value="123451234512345"/>');
424424

425+
var diValid = $('<input id="di-valid" type="text" value="6011050000000009"/>');
426+
var diInvalid = $('<input id="di-invalid" type="text" value="6011199900000005"/>');
427+
var dnValid = $('<input id="dn-valid" type="text" value="3095434000000001"/>');
428+
var dnInvalid = $('<input id="dn-invalid" type="text" value="3799999900000003"/>');
429+
var jcbValid = $('<input id="jcb-valid" type="text" value="3528000000000007"/>');
430+
var jcbInvalid = $('<input id="jcb-invalid" type="text" value="359000001111118"/>');
431+
var upValid = $('<input id="up-valid" type="text" value="6221260000000000"/>');
432+
var upInvalid = $('<input id="up-invalid" type="text" value="6229260000000002"/>');
433+
425434
ok($.validator.methods['validate-cc-type-select'].call(this, 'VI', null, visaValid));
426435
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'VI', null, visaInvalid));
427436
ok($.validator.methods['validate-cc-type-select'].call(this, 'MC', null, mcValid));
428437
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'MC', null, mcInvalid));
429438
ok($.validator.methods['validate-cc-type-select'].call(this, 'AE', null, aeValid));
430439
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'AE', null, aeInvalid));
440+
ok($.validator.methods['validate-cc-type-select'].call(this, 'DI', null, diValid));
441+
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'DI', null, diInvalid));
442+
ok($.validator.methods['validate-cc-type-select'].call(this, 'DN', null, dnValid));
443+
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'DN', null, dnInvalid));
444+
ok($.validator.methods['validate-cc-type-select'].call(this, 'JCB', null, jcbValid));
445+
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'JCB', null, jcbInvalid));
446+
ok($.validator.methods['validate-cc-type-select'].call(this, 'UP', null, upValid));
447+
ok(!$.validator.methods['validate-cc-type-select'].call(this, 'UP', null, upInvalid));
431448
});
432449

433450
test( "testValidateCCNumber", function() {
434-
expect(8);
451+
expect(37);
435452
ok($.validator.methods['validate-cc-number'].call(this, '4916835098995909', null, null));
436453
ok($.validator.methods['validate-cc-number'].call(this, '5265071363284878', null, null));
437454
ok($.validator.methods['validate-cc-number'].call(this, '6011120623356953', null, null));
@@ -440,16 +457,48 @@ test( "testValidateCCNumber", function() {
440457
ok(!$.validator.methods['validate-cc-number'].call(this, '5265071363284870', null, null));
441458
ok(!$.validator.methods['validate-cc-number'].call(this, '6011120623356951', null, null));
442459
ok(!$.validator.methods['validate-cc-number'].call(this, '371293266574619', null, null));
460+
ok($.validator.methods['validate-cc-number'].call(this, '2221220000000003', null, null));
461+
ok(!$.validator.methods['validate-cc-number'].call(this, '2721220000000008', null, null));
462+
ok($.validator.methods['validate-cc-number'].call(this, '601109020000000003', null, null));
463+
ok(!$.validator.methods['validate-cc-number'].call(this, '6011111144444444', null, null));
464+
ok($.validator.methods['validate-cc-number'].call(this, '6011222233334444', null, null));
465+
ok(!$.validator.methods['validate-cc-number'].call(this, '6011522233334447', null, null));
466+
ok($.validator.methods['validate-cc-number'].call(this, '601174455555553', null, null));
467+
ok(!$.validator.methods['validate-cc-number'].call(this, '6011745555555550', null, null));
468+
ok($.validator.methods['validate-cc-number'].call(this, '601177455555556', null, null));
469+
ok(!$.validator.methods['validate-cc-number'].call(this, '601182455555556', null, null));
470+
ok($.validator.methods['validate-cc-number'].call(this, '601187999555558', null, null));
471+
ok(!$.validator.methods['validate-cc-number'].call(this, '601287999555556', null, null));
472+
ok($.validator.methods['validate-cc-number'].call(this, '6444444444444443', null, null));
473+
ok(!$.validator.methods['validate-cc-number'].call(this, '6644444444444441', null, null));
474+
ok($.validator.methods['validate-cc-number'].call(this, '3044444444444444', null, null));
475+
ok(!$.validator.methods['validate-cc-number'].call(this, '3064444444444449', null, null));
476+
ok($.validator.methods['validate-cc-number'].call(this, '3095444444444442', null, null));
477+
ok(!$.validator.methods['validate-cc-number'].call(this, '3096444444444441', null, null));
478+
ok($.validator.methods['validate-cc-number'].call(this, '3696444444444445', null, null));
479+
ok(!$.validator.methods['validate-cc-number'].call(this, '3796444444444444', null, null));
480+
ok($.validator.methods['validate-cc-number'].call(this, '3896444444444443', null, null));
481+
ok($.validator.methods['validate-cc-number'].call(this, '3528444444444449', null, null));
482+
ok(!$.validator.methods['validate-cc-number'].call(this, '3529444444444448', null, null));
483+
ok($.validator.methods['validate-cc-number'].call(this, '6221262244444440', null, null));
484+
ok(!$.validator.methods['validate-cc-number'].call(this, '6229981111111111', null, null));
485+
ok($.validator.methods['validate-cc-number'].call(this, '6249981111111117', null, null));
486+
ok(!$.validator.methods['validate-cc-number'].call(this, '6279981111111110', null, null));
487+
ok($.validator.methods['validate-cc-number'].call(this, '6282981111111115', null, null));
488+
ok(!$.validator.methods['validate-cc-number'].call(this, '6289981111111118', null, null));
443489
});
444490

445491
test( "testValidateCCType", function() {
446-
expect(8);
492+
expect(14);
447493
var select = $('<select id="cc-type">' +
448494
'<option value="">' +
449495
'</option><option value="VI">' +
450496
'</option><option value="MC">' +
451497
'</option><option value="AE">' +
452498
'</option><option value="DI">' +
499+
'</option><option value="DN">' +
500+
'</option><option value="JCB">' +
501+
'</option><option value="UP">' +
453502
'</option>' +
454503
'</select>');
455504

@@ -463,8 +512,17 @@ test( "testValidateCCType", function() {
463512
ok($.validator.methods['validate-cc-type'].call(this, '371293266574617', null, select));
464513
ok(!$.validator.methods['validate-cc-type'].call(this, '5265071363284878', null, select));
465514
select.val('DI');
466-
ok($.validator.methods['validate-cc-type'].call(this, '6011000990139424', null, select));
467-
ok(!$.validator.methods['validate-cc-type'].call(this, '4916835098995909', null, select));
515+
ok($.validator.methods['validate-cc-type'].call(this, '6011050000000009', null, select));
516+
ok(!$.validator.methods['validate-cc-type'].call(this, '371293266574617', null, select));
517+
select.val('DN');
518+
ok($.validator.methods['validate-cc-type'].call(this, '3095434000000001', null, select));
519+
ok(!$.validator.methods['validate-cc-type'].call(this, '6011050000000009', null, select));
520+
select.val('JCB');
521+
ok($.validator.methods['validate-cc-type'].call(this, '3528000000000007', null, select));
522+
ok(!$.validator.methods['validate-cc-type'].call(this, '3095434000000001', null, select));
523+
select.val('UP');
524+
ok($.validator.methods['validate-cc-type'].call(this, '6221260000000000', null, select));
525+
ok(!$.validator.methods['validate-cc-type'].call(this, '3528000000000007', null, select));
468526
});
469527

470528
test( "testValidateCCExp", function() {
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery',
7+
'mage/validation'
8+
], function ($) {
9+
'use strict';
10+
11+
describe('Testing credit card validation', function () {
12+
it('Card type matches credit card number', function () {
13+
expect($.validator.methods['validate-cc-type-select'].call(
14+
this, 'VI', null, $('<input id="visa-valid" type="text" value="4916808263499650"/>'))
15+
).toEqual(true);
16+
expect($.validator.methods['validate-cc-type-select'].call(
17+
this, 'VI', null, $('<input id="visa-invalid" type="text" value="1234567890123456"/>'))
18+
).toEqual(false);
19+
expect($.validator.methods['validate-cc-type-select'].call(
20+
this, 'MC', null, $('<input id="mc-valid" type="text" value="5203731841177490"/>'))
21+
).toEqual(true);
22+
expect($.validator.methods['validate-cc-type-select'].call(
23+
this, 'MC', null, $('<input id="mc-invalid" type="text" value="1111222233334444"/>'))
24+
).toEqual(false);
25+
expect($.validator.methods['validate-cc-type-select'].call(
26+
this, 'MC', null, $('<input id="mc-valid" type="text" value="2221220000000003"/>'))
27+
).toEqual(true);
28+
expect($.validator.methods['validate-cc-type-select'].call(
29+
this, 'MC', null, $('<input id="mc-invalid" type="text" value="2721220000000008"/>'))
30+
).toEqual(false);
31+
expect($.validator.methods['validate-cc-type-select'].call(
32+
this, 'AE', null, $('<input id="ae-valid" type="text" value="376244899619217"/>'))
33+
).toEqual(true);
34+
expect($.validator.methods['validate-cc-type-select'].call(
35+
this, 'AE', null, $('<input id="ae-invalid" type="text" value="123451234512345"/>'))
36+
).toEqual(false);
37+
expect($.validator.methods['validate-cc-type-select'].call(
38+
this, 'DI', null, $('<input id="di-valid" type="text" value="601109020000000003"/>'))
39+
).toEqual(true);
40+
expect($.validator.methods['validate-cc-type-select'].call(
41+
this, 'DI', null, $('<input id="di-invalid" type="text" value="6011111144444444"/>'))
42+
).toEqual(false);
43+
expect($.validator.methods['validate-cc-type-select'].call(
44+
this, 'DI', null, $('<input id="di-valid" type="text" value="6011222233334444"/>'))
45+
).toEqual(true);
46+
expect($.validator.methods['validate-cc-type-select'].call(
47+
this, 'DI', null, $('<input id="di-invalid" type="text" value="6011522233334447"/>'))
48+
).toEqual(false);
49+
expect($.validator.methods['validate-cc-type-select'].call(
50+
this, 'DI', null, $('<input id="di-valid" type="text" value="601174455555553"/>'))
51+
).toEqual(true);
52+
expect($.validator.methods['validate-cc-type-select'].call(
53+
this, 'DI', null, $('<input id="di-invalid" type="text" value="6011755555555550"/>'))
54+
).toEqual(false);
55+
expect($.validator.methods['validate-cc-type-select'].call(
56+
this, 'DI', null, $('<input id="di-valid" type="text" value="601177455555556"/>'))
57+
).toEqual(true);
58+
expect($.validator.methods['validate-cc-type-select'].call(
59+
this, 'DI', null, $('<input id="di-invalid" type="text" value="601182455555556"/>'))
60+
).toEqual(false);
61+
expect($.validator.methods['validate-cc-type-select'].call(
62+
this, 'DI', null, $('<input id="di-valid" type="text" value="601187999555558"/>'))
63+
).toEqual(true);
64+
expect($.validator.methods['validate-cc-type-select'].call(
65+
this, 'DI', null, $('<input id="di-invalid" type="text" value="601287999555556"/>'))
66+
).toEqual(false);
67+
expect($.validator.methods['validate-cc-type-select'].call(
68+
this, 'DI', null, $('<input id="di-valid" type="text" value="6444444444444443"/>'))
69+
).toEqual(true);
70+
expect($.validator.methods['validate-cc-type-select'].call(
71+
this, 'DI', null, $('<input id="di-invalid" type="text" value="6644444444444441"/>'))
72+
).toEqual(false);
73+
expect($.validator.methods['validate-cc-type-select'].call(
74+
this, 'DN', null, $('<input id="dn-valid" type="text" value="3095434000000001"/>'))
75+
).toEqual(true);
76+
expect($.validator.methods['validate-cc-type-select'].call(
77+
this, 'DN', null, $('<input id="dn-invalid" type="text" value="3799999900000003"/>'))
78+
).toEqual(false);
79+
expect($.validator.methods['validate-cc-type-select'].call(
80+
this, 'DN', null, $('<input id="dn-valid" type="text" value="3044444444444444"/>'))
81+
).toEqual(true);
82+
expect($.validator.methods['validate-cc-type-select'].call(
83+
this, 'DN', null, $('<input id="dn-invalid" type="text" value="3064444444444449"/>'))
84+
).toEqual(false);
85+
expect($.validator.methods['validate-cc-type-select'].call(
86+
this, 'DN', null, $('<input id="dn-valid" type="text" value="3095444444444442"/>'))
87+
).toEqual(true);
88+
expect($.validator.methods['validate-cc-type-select'].call(
89+
this, 'DN', null, $('<input id="dn-invalid" type="text" value="3096444444444441"/>'))
90+
).toEqual(false);
91+
expect($.validator.methods['validate-cc-type-select'].call(
92+
this, 'DN', null, $('<input id="dn-valid" type="text" value="3696444444444445"/>'))
93+
).toEqual(true);
94+
expect($.validator.methods['validate-cc-type-select'].call(
95+
this, 'DN', null, $('<input id="dn-invalid" type="text" value="3796444444444444"/>'))
96+
).toEqual(false);
97+
expect($.validator.methods['validate-cc-type-select'].call(
98+
this, 'DN', null, $('<input id="dn-valid" type="text" value="3696444444444445"/>'))
99+
).toEqual(true);
100+
expect($.validator.methods['validate-cc-type-select'].call(
101+
this, 'DN', null, $('<input id="dn-valid" type="text" value="3896444444444443"/>'))
102+
).toEqual(true);
103+
expect($.validator.methods['validate-cc-type-select'].call(
104+
this, 'DN', null, $('<input id="dn-invalid" type="text" value="3796444444444444"/>'))
105+
).toEqual(false);
106+
expect($.validator.methods['validate-cc-type-select'].call(
107+
this, 'JCB', null, $('<input id="jcb-valid" type="text" value="3528444444444449"/>'))
108+
).toEqual(true);
109+
expect($.validator.methods['validate-cc-type-select'].call(
110+
this, 'JCB', null, $('<input id="jcb-invalid" type="text" value="3527444444444448"/>'))
111+
).toEqual(false);
112+
expect($.validator.methods['validate-cc-type-select'].call(
113+
this, 'JCB', null, $('<input id="jcb-invalid" type="text" value="3590444444444448"/>'))
114+
).toEqual(false);
115+
expect($.validator.methods['validate-cc-type-select'].call(
116+
this, 'UN', null, $('<input id="un-valid" type="text" value="6221262244444440"/>'))
117+
).toEqual(true);
118+
expect($.validator.methods['validate-cc-type-select'].call(
119+
this, 'UN', null, $('<input id="un-invalid" type="text" value="6229981111111111"/>'))
120+
).toEqual(false);
121+
expect($.validator.methods['validate-cc-type-select'].call(
122+
this, 'UN', null, $('<input id="un-valid" type="text" value="6249981111111117"/>'))
123+
).toEqual(true);
124+
expect($.validator.methods['validate-cc-type-select'].call(
125+
this, 'UN', null, $('<input id="un-invalid" type="text" value="6279981111111110"/>'))
126+
).toEqual(false);
127+
expect($.validator.methods['validate-cc-type-select'].call(
128+
this, 'UN', null, $('<input id="un-valid" type="text" value="6282981111111115"/>'))
129+
).toEqual(true);
130+
expect($.validator.methods['validate-cc-type-select'].call(
131+
this, 'UN', null, $('<input id="un-invalid" type="text" value="6289981111111118"/>'))
132+
).toEqual(false);
133+
});
134+
});
135+
});

0 commit comments

Comments
 (0)