Skip to content

Commit

Permalink
ENGCOM-3889: Add Brazilian Credit Cards Support #47
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
magento-engcom-team committed Feb 7, 2019
2 parents b46b8be + 4222ec2 commit a60c0d8
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/code/Magento/Payment/Model/Method/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Magento\Quote\Model\Quote\Payment;

/**
* Credit Card payment method legacy implementation.
*
* @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @deprecated 100.0.8
Expand Down Expand Up @@ -93,6 +95,7 @@ public function __construct(
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function validate()
{
Expand Down Expand Up @@ -148,6 +151,22 @@ public function validate()
'JCB' => '/^35(2[8-9][0-9]{12,15}|[3-8][0-9]{13,16})/',
'MI' => '/^(5(0|[6-9])|63|67(?!59|6770|6774))\d*$/',
'MD' => '/^(6759(?!24|38|40|6[3-9]|70|76)|676770|676774)\d*$/',

//Hipercard
'HC' => '/^((606282)|(637095)|(637568)|(637599)|(637609)|(637612))\d*$/',
//Elo
'ELO' => '/^((509091)|(636368)|(636297)|(504175)|(438935)|(40117[8-9])|(45763[1-2])|' .
'(457393)|(431274)|(50990[0-2])|(5099[7-9][0-9])|(50996[4-9])|(509[1-8][0-9][0-9])|' .
'(5090(0[0-2]|0[4-9]|1[2-9]|[24589][0-9]|3[1-9]|6[0-46-9]|7[0-24-9]))|' .
'(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]))|' .
'(6504(0[5-9]|1[0-9]|2[0-9]|3[0-9]))|' .
'(6504(8[5-9]|9[0-9])|6505(0[0-9]|1[0-9]|2[0-9]|3[0-8]))|' .
'(6505(4[1-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-8]))|' .
'(6507(0[0-9]|1[0-8]))|(65072[0-7])|(6509(0[1-9]|1[0-9]|20))|' .
'(6516(5[2-9]|6[0-9]|7[0-9]))|(6550(0[0-9]|1[0-9]))|' .
'(6550(2[1-9]|3[0-9]|4[0-9]|5[0-8])))\d*$/',
//Aura
'AU' => '/^5078\d*$/'
];

$ccNumAndTypeMatches = isset(
Expand Down Expand Up @@ -189,6 +208,8 @@ public function validate()
}

/**
* Check if verification should be used.
*
* @return bool
* @api
*/
Expand All @@ -202,6 +223,8 @@ public function hasVerification()
}

/**
* Get list of credit cards verification reg exp.
*
* @return array
* @api
*/
Expand All @@ -226,6 +249,8 @@ public function getVerificationRegEx()
}

/**
* Validate expiration date
*
* @param string $expYear
* @param string $expMonth
* @return bool
Expand Down Expand Up @@ -276,6 +301,8 @@ public function assignData(\Magento\Framework\DataObject $data)
}

/**
* Get code for "other" credit cards.
*
* @param string $type
* @return bool
* @api
Expand Down
9 changes: 9 additions & 0 deletions app/code/Magento/Payment/etc/payment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,14 @@
<type id="MD" order="100">
<label>Maestro Domestic</label>
</type>
<type id="HC" order="110">
<label>Hipercard</label>
</type>
<type id="ELO" order="120">
<label>Elo</label>
</type>
<type id="AU" order="130">
<label>Aura</label>
</type>
</credit_cards>
</payment>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,48 @@ define([
name: 'CVC',
size: 3
}
},
{
title: 'Hipercard',
type: 'HC',
pattern: '^((606282)|(637095)|(637568)|(637599)|(637609)|(637612))\\d*$',
gaps: [4, 8, 12],
lengths: [13, 16],
code: {
name: 'CVC',
size: 3
}
},
{
title: 'Elo',
type: 'ELO',
pattern: '^((509091)|(636368)|(636297)|(504175)|(438935)|(40117[8-9])|(45763[1-2])|' +
'(457393)|(431274)|(50990[0-2])|(5099[7-9][0-9])|(50996[4-9])|(509[1-8][0-9][0-9])|' +
'(5090(0[0-2]|0[4-9]|1[2-9]|[24589][0-9]|3[1-9]|6[0-46-9]|7[0-24-9]))|' +
'(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]))|' +
'(6504(0[5-9]|1[0-9]|2[0-9]|3[0-9]))|' +
'(6504(8[5-9]|9[0-9])|6505(0[0-9]|1[0-9]|2[0-9]|3[0-8]))|' +
'(6505(4[1-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-8]))|' +
'(6507(0[0-9]|1[0-8]))|(65072[0-7])|(6509(0[1-9]|1[0-9]|20))|' +
'(6516(5[2-9]|6[0-9]|7[0-9]))|(6550(0[0-9]|1[0-9]))|' +
'(6550(2[1-9]|3[0-9]|4[0-9]|5[0-8])))\\d*$',
gaps: [4, 8, 12],
lengths: [16],
code: {
name: 'CVC',
size: 3
}
},
{
title: 'Aura',
type: 'AU',
pattern: '^5078\\d*$',
gaps: [4, 8, 12],
lengths: [19],
code: {
name: 'CVC',
size: 3
}
}
];

Expand Down

0 comments on commit a60c0d8

Please sign in to comment.