Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
le0n4eg committed Sep 7, 2016
2 parents d22b439 + 25ee7e2 commit 32ed255
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 54 deletions.
29 changes: 14 additions & 15 deletions app/code/Magento/Payment/Model/Method/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,25 @@ public function validate()
//Solo, Switch or Maestro. International safe
'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/',
'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)' .
'|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)' .
'|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))' .
'|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))' .
'|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
'|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)' .
'|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))' .
'|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))' .
'|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
// Visa
'VI' => '/^4[0-9]{12}([0-9]{3})?$/',
// Master Card
'MC' => '/^5[1-5][0-9]{14}$/',
'MC' => '/^(?: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}$/',
// American Express
'AE' => '/^3[47][0-9]{13}$/',
// Discover
'DI' => '/^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})' .
'|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}' .
'|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}' .
'|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}' .
'|5[0-9]{14}))$/',
'DI' => '/^(6011((0|9|[2-4])[0-9]{11,14}|(74|7[7-9]|8[6-9])[0-9]{10,13})|6(4[4-9][0-9]{13,16}|' .
'5[0-9]{14,17}))/',
'DN' => '/^3(0[0-5][0-9]{13,16}|095[0-9]{12,15}|(6|[8-9])[0-9]{14,17})/',
// UnionPay
'UN' => '/^622(1(2[6-9][0-9]{10,13}|[3-9][0-9]{11,14})|[3-8][0-9]{12,15}|9([[0-1][0-9]{11,14}|' .
'2[0-5][0-9]{10,13}))|62[4-6][0-9]{13,16}|628[2-8][0-9]{12,15}/',
// JCB
'JCB' => '/^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}' .
'|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}' .
'|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}' .
'|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}' .
'|5[0-9]{14}))$/',
'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*$/',
];
Expand Down Expand Up @@ -215,6 +212,8 @@ public function getVerificationRegEx()
'MC' => '/^[0-9]{3}$/',
'AE' => '/^[0-9]{4}$/',
'DI' => '/^[0-9]{3}$/',
'DN' => '/^[0-9]{3}$/',
'UN' => '/^[0-9]{3}$/',
'SS' => '/^[0-9]{3,4}$/',
'SM' => '/^[0-9]{3,4}$/',
'SO' => '/^[0-9]{3,4}$/',
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Paypal/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<group id="other_paypal_payment_solutions" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Other PayPal Payment Solutions:</label>
<fieldset_css>paypal-top-section paypal-other-header</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
</group>
<group id="other_payment_methods" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Other Payment Methods:</label>
<fieldset_css>paypal-top-section payments-other-header</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
</group>
</section>
<section id="payment_all_paypal" showInDefault="0" showInWebsite="0" showInStore="0">
Expand Down
10 changes: 6 additions & 4 deletions app/code/Magento/Paypal/view/adminhtml/web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.payflow-settings-notice ul.options-list {list-style:disc;padding:0 2em;}
.paypal-express-section .heading {display: inline-block; background: url("images/pp-logo-200px.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
.paypal-express-section .button-container {display: inline-block; float: right;}
.paypal-express-section .config-alt {background: url("images/pp-alt.png") no-repeat; height: 26px; margin: 0.5rem 0 0; width: 158px;}
.paypal-express-section .config-alt {background: url("images/pp-alt.png") no-repeat; height: 26px; margin: .5rem 0 0; width: 158px;}
.paypal-express-section .link-more {margin-left: 5px;}
.paypal-other-section .heading {display: inline-block;}
.paypal-other-section .button-container {display: inline-block; float: right; margin: 1rem 0 0 !important;}
Expand All @@ -27,7 +27,9 @@
.paypal-top-section.active > .entry-edit-head.admin__collapsible-block {border-bottom: 1px solid #ccc;}
.paypal-top-section > .admin__collapsible-block > a {font-size: 1.4rem; font-weight: normal; text-transform: uppercase;}
.paypal-recommended-header > .admin__collapsible-block > a::before {content: "" !important;}
.paypal-other-header > .admin__collapsible-block > a.open::before {content: "\25B2" !important;}
.paypal-other-header > .admin__collapsible-block > a::before {color: #000; content: "\25BC" !important; font-size: 1rem; top: 2.2rem;}
.paypal-other-header > .admin__collapsible-block > a::before {content: '' !important; width: 0; height: 0; border-color: transparent; border-top-color: #000; border-style: solid; border-width: .8rem .5rem 0 .5rem; margin-top:1px; transition: all .2s linear;}
.paypal-other-header > .admin__collapsible-block > a.open::before {border-color: transparent; border-bottom-color: #000; border-width: 0 .5rem .8rem .5rem;}
.paypal-other-header > .admin__collapsible-block > a {color: #007bdb !important; text-align: right;}
.payments-other-header > .admin__collapsible-block > a::before {content: "" !important;}
.payments-other-header > .admin__collapsible-block > a {display: inline-block;}
.payments-other-header > .admin__collapsible-block > a::before {content: '' !important; width: 0; height: 0; border-color: transparent; border-top-color: #000; border-style: solid; border-width: .8rem .5rem 0 .5rem; margin-top:1px; transition: all .2s linear;}
.payments-other-header > .admin__collapsible-block > a.open::before {border-color: transparent; border-bottom-color: #000; border-width: 0 .5rem .8rem .5rem;}
1 change: 1 addition & 0 deletions app/code/Magento/Shipping/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,4 @@ City,City
"Apply custom Shipping Policy","Apply custom Shipping Policy"
"Shipping Policy","Shipping Policy"
"Shipping Methods","Shipping Methods"
"Track your order","Track your order"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<referenceBlock name="sales.order.view">
<block class="Magento\Shipping\Block\Tracking\Link" name="tracking-info-link" template="tracking/link.phtml">
<arguments>
<argument name="label" xsi:type="string">Track your order</argument>
<argument name="label" xsi:type="string" translate="true">Track your order</argument>
</arguments>
</block>
</referenceBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<referenceBlock name="sales.order.view">
<block class="Magento\Shipping\Block\Tracking\Link" name="tracking-info-link" template="tracking/link.phtml">
<arguments>
<argument name="label" xsi:type="string">Track your order</argument>
<argument name="label" xsi:type="string" translate="true">Track your order</argument>
</arguments>
</block>
</referenceBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<referenceBlock name="sales.order.view">
<block class="Magento\Shipping\Block\Tracking\Link" name="tracking-info-link" template="tracking/link.phtml">
<arguments>
<argument name="label" xsi:type="string">Track your order</argument>
<argument name="label" xsi:type="string" translate="true">Track your order</argument>
</arguments>
</block>
</referenceBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<referenceBlock name="sales.order.view">
<block class="Magento\Shipping\Block\Tracking\Link" name="tracking-info-link" template="tracking/link.phtml">
<arguments>
<argument name="label" xsi:type="string">Track your order</argument>
<argument name="label" xsi:type="string" translate="true">Track your order</argument>
</arguments>
</block>
</referenceBlock>
Expand Down
14 changes: 13 additions & 1 deletion app/code/Magento/Theme/view/frontend/web/js/view/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ define([
cookieMessages: [],
messages: []
},

/**
* Extends Component object by storage observable messages.
*/
initialize: function () {
this._super();

this.cookieMessages = $.cookieStorage.get('mage-messages');
this.messages = customerData.get('messages').extend({disposableCustomerData: 'messages'});
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});

// Force to clean obsolete messages
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}

$.cookieStorage.setConf({path: '/', expires: -1}).set('mage-messages', null);
}
});
Expand Down
20 changes: 11 additions & 9 deletions app/code/Magento/Vault/Model/Method/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
*/
final class Vault implements VaultPaymentInterface
{
/**
* @deprecated
*/
const TOKEN_METADATA_KEY = 'token_metadata';

/**
Expand Down Expand Up @@ -111,6 +114,8 @@ final class Vault implements VaultPaymentInterface
* @param PaymentTokenManagementInterface $tokenManagement
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
* @param string $code
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
ConfigInterface $config,
Expand Down Expand Up @@ -452,17 +457,14 @@ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
private function attachTokenExtensionAttribute(OrderPaymentInterface $orderPayment)
{
$additionalInformation = $orderPayment->getAdditionalInformation();

$tokenData = isset($additionalInformation[self::TOKEN_METADATA_KEY])
? $additionalInformation[self::TOKEN_METADATA_KEY]
: null;

if ($tokenData === null) {
throw new \LogicException("Token metadata should be defined");
if (empty($additionalInformation[PaymentTokenInterface::CUSTOMER_ID]) ||
empty($additionalInformation[PaymentTokenInterface::PUBLIC_HASH])
) {
throw new \LogicException('Customer id and public hash should be defined');
}

$customerId = $tokenData[PaymentTokenInterface::CUSTOMER_ID];
$publicHash = $tokenData[PaymentTokenInterface::PUBLIC_HASH];
$customerId = $additionalInformation[PaymentTokenInterface::CUSTOMER_ID];
$publicHash = $additionalInformation[PaymentTokenInterface::PUBLIC_HASH];

$paymentToken = $this->tokenManagement->getByPublicHash($publicHash, $customerId);

Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Vault/Observer/PaymentTokenAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function execute(Observer $observer)
}

$paymentModel->setAdditionalInformation(
Vault::TOKEN_METADATA_KEY,
[
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $tokenPublicHash
Expand Down
30 changes: 29 additions & 1 deletion app/code/Magento/Vault/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,41 @@ class UpgradeData implements UpgradeDataInterface
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$connection = $setup->getConnection();

// data update for Vault module < 2.0.1
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$connection = $setup->getConnection();
// update sets credit card as default token type
$connection->update($setup->getTable(InstallSchema::PAYMENT_TOKEN_TABLE), [
PaymentTokenInterface::TYPE => CreditCardTokenFactory::TOKEN_TYPE_CREDIT_CARD
], PaymentTokenInterface::TYPE . ' = ""');
}

// data update for Vault module < 2.0.2
if (version_compare($context->getVersion(), '2.0.2', '<')) {
// update converts additional info with token metadata to single dimensional array
$select = $connection->select()
->from($setup->getTable('sales_order_payment'), 'entity_id')
->columns(['additional_information'])
->where('additional_information LIKE ?', '%token_metadata%');

$items = $connection->fetchAll($select);
foreach ($items as $item) {
$additionalInfo = unserialize($item['additional_information']);
$additionalInfo[PaymentTokenInterface::CUSTOMER_ID] =
$additionalInfo['token_metadata'][PaymentTokenInterface::CUSTOMER_ID];
$additionalInfo[PaymentTokenInterface::PUBLIC_HASH] =
$additionalInfo['token_metadata'][PaymentTokenInterface::PUBLIC_HASH];
unset($additionalInfo['token_metadata']);

$connection->update(
$setup->getTable('sales_order_payment'),
['additional_information' => serialize($additionalInfo)],
['entity_id = ?' => $item['entity_id']]
);
}
}

$setup->endSetup();
}
}
33 changes: 22 additions & 11 deletions app/code/Magento/Vault/Test/Unit/Model/Method/VaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,39 @@ public function testAuthorizeNotOrderPayment()
}

/**
* @param array $additionalInfo
* @expectedException \LogicException
* @expectedExceptionMessage Token metadata should be defined
* @expectedExceptionMessage Customer id and public hash should be defined
* @dataProvider additionalInfoDataProvider
*/
public function testAuthorizeNoTokenMetadata()
public function testAuthorizeNoTokenMetadata(array $additionalInfo)
{
$paymentModel = $this->getMockBuilder(Payment::class)
->disableOriginalConstructor()
->getMock();

$paymentModel->expects(static::once())
->method('getAdditionalInformation')
->willReturn([]);
->willReturn($additionalInfo);

/** @var Vault $model */
$model = $this->objectManager->getObject(Vault::class);
$model->authorize($paymentModel, 0);
}

/**
* Get list of additional information variations
* @return array
*/
public function additionalInfoDataProvider()
{
return [
['additionalInfo' => []],
['additionalInfo' => ['customer_id' => 1]],
['additionalInfo' => ['public_hash' => 'df768aak12uf']],
];
}

/**
* @expectedException \LogicException
* @expectedExceptionMessage No token found
Expand All @@ -86,10 +101,8 @@ public function testAuthorizeNoToken()
->method('getAdditionalInformation')
->willReturn(
[
Vault::TOKEN_METADATA_KEY => [
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $publicHash
]
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $publicHash
]
);
$tokenManagement->expects(static::once())
Expand Down Expand Up @@ -133,10 +146,8 @@ public function testAuthorize()
->method('getAdditionalInformation')
->willReturn(
[
Vault::TOKEN_METADATA_KEY => [
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $publicHash
]
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $publicHash
]
);
$tokenManagement->expects(static::once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public function testExecuteSaveMetadata()
$paymentModel->expects(static::once())
->method('setAdditionalInformation')
->with(
Vault::TOKEN_METADATA_KEY,
[
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $publicHash
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Vault/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Vault" setup_version="2.0.1">
<module name="Magento_Vault" setup_version="2.0.2">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Store"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<group id="other_paypal_payment_solutions" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Other PayPal Payment Solutions:</label>
<fieldset_css>paypal-top-section paypal-other-header</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
</group>
<group id="other_payment_methods" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Other Payment Methods:</label>
<fieldset_css>paypal-top-section payments-other-header</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
</group>
</section>
<section id="payment_all_paypal" showInDefault="0" showInWebsite="0" showInStore="0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<group id="other_paypal_payment_solutions" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Other PayPal Payment Solutions:</label>
<fieldset_css>paypal-top-section paypal-other-header</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
</group>
<group id="other_payment_methods" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Other Payment Methods:</label>
<fieldset_css>paypal-top-section payments-other-header</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
</group>
</section>
<section id="payment_all_paypal" showInDefault="0" showInWebsite="0" showInStore="0">
Expand Down

0 comments on commit 32ed255

Please sign in to comment.