Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit a60c0d8

Browse files
ENGCOM-3889: Add Brazilian Credit Cards Support #47
- Merge Pull Request magento-commerce/payment-improvements#47 from williankeller/payment-improvements:PI-1 - Merged commits: 1. 2793844 2. 6c1b144 3. 8832267 4. 6ffb464 5. 4222ec2
2 parents b46b8be + 4222ec2 commit a60c0d8

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-0
lines changed

app/code/Magento/Payment/Model/Method/Cc.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Quote\Model\Quote\Payment;
1111

1212
/**
13+
* Credit Card payment method legacy implementation.
14+
*
1315
* @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes()
1416
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1517
* @deprecated 100.0.8
@@ -93,6 +95,7 @@ public function __construct(
9395
* @throws \Magento\Framework\Exception\LocalizedException
9496
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9597
* @SuppressWarnings(PHPMD.NPathComplexity)
98+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
9699
*/
97100
public function validate()
98101
{
@@ -148,6 +151,22 @@ public function validate()
148151
'JCB' => '/^35(2[8-9][0-9]{12,15}|[3-8][0-9]{13,16})/',
149152
'MI' => '/^(5(0|[6-9])|63|67(?!59|6770|6774))\d*$/',
150153
'MD' => '/^(6759(?!24|38|40|6[3-9]|70|76)|676770|676774)\d*$/',
154+
155+
//Hipercard
156+
'HC' => '/^((606282)|(637095)|(637568)|(637599)|(637609)|(637612))\d*$/',
157+
//Elo
158+
'ELO' => '/^((509091)|(636368)|(636297)|(504175)|(438935)|(40117[8-9])|(45763[1-2])|' .
159+
'(457393)|(431274)|(50990[0-2])|(5099[7-9][0-9])|(50996[4-9])|(509[1-8][0-9][0-9])|' .
160+
'(5090(0[0-2]|0[4-9]|1[2-9]|[24589][0-9]|3[1-9]|6[0-46-9]|7[0-24-9]))|' .
161+
'(5067(0[0-24-8]|1[0-24-9]|2[014-9]|3[0-379]|4[0-9]|5[0-3]|6[0-5]|7[0-8]))|' .
162+
'(6504(0[5-9]|1[0-9]|2[0-9]|3[0-9]))|' .
163+
'(6504(8[5-9]|9[0-9])|6505(0[0-9]|1[0-9]|2[0-9]|3[0-8]))|' .
164+
'(6505(4[1-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-8]))|' .
165+
'(6507(0[0-9]|1[0-8]))|(65072[0-7])|(6509(0[1-9]|1[0-9]|20))|' .
166+
'(6516(5[2-9]|6[0-9]|7[0-9]))|(6550(0[0-9]|1[0-9]))|' .
167+
'(6550(2[1-9]|3[0-9]|4[0-9]|5[0-8])))\d*$/',
168+
//Aura
169+
'AU' => '/^5078\d*$/'
151170
];
152171

153172
$ccNumAndTypeMatches = isset(
@@ -189,6 +208,8 @@ public function validate()
189208
}
190209

191210
/**
211+
* Check if verification should be used.
212+
*
192213
* @return bool
193214
* @api
194215
*/
@@ -202,6 +223,8 @@ public function hasVerification()
202223
}
203224

204225
/**
226+
* Get list of credit cards verification reg exp.
227+
*
205228
* @return array
206229
* @api
207230
*/
@@ -226,6 +249,8 @@ public function getVerificationRegEx()
226249
}
227250

228251
/**
252+
* Validate expiration date
253+
*
229254
* @param string $expYear
230255
* @param string $expMonth
231256
* @return bool
@@ -276,6 +301,8 @@ public function assignData(\Magento\Framework\DataObject $data)
276301
}
277302

278303
/**
304+
* Get code for "other" credit cards.
305+
*
279306
* @param string $type
280307
* @return bool
281308
* @api

app/code/Magento/Payment/etc/payment.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,14 @@
4141
<type id="MD" order="100">
4242
<label>Maestro Domestic</label>
4343
</type>
44+
<type id="HC" order="110">
45+
<label>Hipercard</label>
46+
</type>
47+
<type id="ELO" order="120">
48+
<label>Elo</label>
49+
</type>
50+
<type id="AU" order="130">
51+
<label>Aura</label>
52+
</type>
4453
</credit_cards>
4554
</payment>
Loading
Loading
Loading

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,48 @@ define([
110110
name: 'CVC',
111111
size: 3
112112
}
113+
},
114+
{
115+
title: 'Hipercard',
116+
type: 'HC',
117+
pattern: '^((606282)|(637095)|(637568)|(637599)|(637609)|(637612))\\d*$',
118+
gaps: [4, 8, 12],
119+
lengths: [13, 16],
120+
code: {
121+
name: 'CVC',
122+
size: 3
123+
}
124+
},
125+
{
126+
title: 'Elo',
127+
type: 'ELO',
128+
pattern: '^((509091)|(636368)|(636297)|(504175)|(438935)|(40117[8-9])|(45763[1-2])|' +
129+
'(457393)|(431274)|(50990[0-2])|(5099[7-9][0-9])|(50996[4-9])|(509[1-8][0-9][0-9])|' +
130+
'(5090(0[0-2]|0[4-9]|1[2-9]|[24589][0-9]|3[1-9]|6[0-46-9]|7[0-24-9]))|' +
131+
'(5067(0[0-24-8]|1[0-24-9]|2[014-9]|3[0-379]|4[0-9]|5[0-3]|6[0-5]|7[0-8]))|' +
132+
'(6504(0[5-9]|1[0-9]|2[0-9]|3[0-9]))|' +
133+
'(6504(8[5-9]|9[0-9])|6505(0[0-9]|1[0-9]|2[0-9]|3[0-8]))|' +
134+
'(6505(4[1-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-8]))|' +
135+
'(6507(0[0-9]|1[0-8]))|(65072[0-7])|(6509(0[1-9]|1[0-9]|20))|' +
136+
'(6516(5[2-9]|6[0-9]|7[0-9]))|(6550(0[0-9]|1[0-9]))|' +
137+
'(6550(2[1-9]|3[0-9]|4[0-9]|5[0-8])))\\d*$',
138+
gaps: [4, 8, 12],
139+
lengths: [16],
140+
code: {
141+
name: 'CVC',
142+
size: 3
143+
}
144+
},
145+
{
146+
title: 'Aura',
147+
type: 'AU',
148+
pattern: '^5078\\d*$',
149+
gaps: [4, 8, 12],
150+
lengths: [19],
151+
code: {
152+
name: 'CVC',
153+
size: 3
154+
}
113155
}
114156
];
115157

0 commit comments

Comments
 (0)