Skip to content

Commit 5ae0633

Browse files
committed
Merge branch '2.3-develop' into feature/271-Customer-Attributes-Validation
Conflicts: app/code/Magento/CustomerGraphQl/Model/Customer/CreateCustomerAccount.php app/code/Magento/CustomerGraphQl/Model/Customer/UpdateCustomerAccount.php
2 parents 0b4c496 + 72f72dd commit 5ae0633

File tree

670 files changed

+14824
-6313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

670 files changed

+14824
-6313
lines changed

CHANGELOG.md

+612
Large diffs are not rendered by default.

app/code/Magento/Authorization/Model/Role.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Role extends \Magento\Framework\Model\AbstractModel
4040
* @param \Magento\Authorization\Model\ResourceModel\Role\Collection $resourceCollection
4141
* @param array $data
4242
*/
43-
public function __construct(
43+
public function __construct( //phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
4444
\Magento\Framework\Model\Context $context,
4545
\Magento\Framework\Registry $registry,
4646
\Magento\Authorization\Model\ResourceModel\Role $resource,
@@ -52,28 +52,18 @@ public function __construct(
5252

5353
/**
5454
* @inheritDoc
55-
*
56-
* @SuppressWarnings(PHPMD.SerializationAware)
57-
* @deprecated Do not use PHP serialization.
5855
*/
5956
public function __sleep()
6057
{
61-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
62-
6358
$properties = parent::__sleep();
6459
return array_diff($properties, ['_resource', '_resourceCollection']);
6560
}
6661

6762
/**
6863
* @inheritDoc
69-
*
70-
* @SuppressWarnings(PHPMD.SerializationAware)
71-
* @deprecated Do not use PHP serialization.
7264
*/
7365
public function __wakeup()
7466
{
75-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
76-
7767
parent::__wakeup();
7868
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
7969
$this->_resource = $objectManager->get(\Magento\Authorization\Model\ResourceModel\Role::class);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontVerifySecureURLRedirectAuthorizenet">
12+
<annotations>
13+
<features value="Authorizenet"/>
14+
<stories value="Storefront Secure URLs"/>
15+
<title value="Verify Secure URLs For Storefront Authorizenet Pages"/>
16+
<description value="Verify that the Secure URL configuration applies to the Authorizenet pages on the Storefront"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-15610"/>
19+
<group value="authorizenet"/>
20+
<group value="configuration"/>
21+
<group value="secure_storefront_url"/>
22+
</annotations>
23+
<before>
24+
<createData entity="Simple_US_Customer" stepKey="customer"/>
25+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefront">
26+
<argument name="Customer" value="$$customer$$"/>
27+
</actionGroup>
28+
<executeJS function="return window.location.host" stepKey="hostname"/>
29+
<magentoCLI command="config:set web/secure/base_url https://{$hostname}/" stepKey="setSecureBaseURL"/>
30+
<magentoCLI command="config:set web/secure/use_in_frontend 1" stepKey="useSecureURLsOnStorefront"/>
31+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
32+
</before>
33+
<after>
34+
<magentoCLI command="config:set web/secure/use_in_frontend 0" stepKey="dontUseSecureURLsOnStorefront"/>
35+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
36+
<deleteData createDataKey="customer" stepKey="deleteCustomer"/>
37+
</after>
38+
<executeJS function="return window.location.host" stepKey="hostname"/>
39+
<amOnUrl url="http://{$hostname}/authorizenet" stepKey="goToUnsecureAuthorizenetURL"/>
40+
<seeCurrentUrlEquals url="https://{$hostname}/authorizenet" stepKey="seeSecureAuthorizenetURL"/>
41+
</test>
42+
</tests>

app/code/Magento/AuthorizenetAcceptjs/etc/adminhtml/di.xml

+5
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@
3131
</argument>
3232
</arguments>
3333
</virtualType>
34+
<virtualType name="AuthorizenetAcceptjsAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
35+
<arguments>
36+
<argument name="validator" xsi:type="object">AuthorizenetAcceptjsTransactionValidator</argument>
37+
</arguments>
38+
</virtualType>
3439
</config>

app/code/Magento/AuthorizenetAcceptjs/etc/di.xml

+2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
<arguments>
135135
<argument name="requestBuilder" xsi:type="object">AuthorizenetAcceptjsRefundRequest</argument>
136136
<argument name="handler" xsi:type="object">AuthorizenetAcceptjsRefundSettledHandler</argument>
137+
<argument name="validator" xsi:type="object">AuthorizenetAcceptjsTransactionValidator</argument>
137138
</arguments>
138139
</virtualType>
139140
<virtualType name="AuthorizenetAcceptjsCaptureCommand" type="Magento\AuthorizenetAcceptjs\Gateway\Command\CaptureStrategyCommand">
@@ -145,6 +146,7 @@
145146
<arguments>
146147
<argument name="requestBuilder" xsi:type="object">AuthorizenetAcceptjsCaptureRequest</argument>
147148
<argument name="handler" xsi:type="object">AuthorizenetAcceptjsCaptureTransactionHandler</argument>
149+
<argument name="validator" xsi:type="object">AuthorizenetAcceptjsTransactionValidator</argument>
148150
</arguments>
149151
</virtualType>
150152
<virtualType name="AuthorizenetAcceptjsVoidCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">

app/code/Magento/AuthorizenetAcceptjs/view/adminhtml/templates/payment/script.phtml

+16-9
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66

77
/** @var Magento\AuthorizenetAcceptjs\Block\Payment $block */
88
?>
9-
<script type="text/x-magento-init">
10-
{
11-
"#payment_form_<?= $block->escapeJs($block->escapeHtml($block->getMethodCode())) ?>": {
12-
"Magento_AuthorizenetAcceptjs/js/payment-form": {
13-
"config": <?= /* @noEscape */ $block->getPaymentConfig() ?>
14-
}
15-
}
16-
}
17-
</script>
9+
<script>
10+
//<![CDATA[
11+
require(
12+
[
13+
'Magento_AuthorizenetAcceptjs/js/authorizenet',
14+
'jquery',
15+
'domReady!'
16+
], function(AuthorizenetAcceptjs, $) {
17+
var config = <?= /* @noEscape */ $block->getPaymentConfig() ?>,
18+
form = $('#payment_form_<?= /* @noEscape */ $block->escapeJs($block->escapeHtml($block->getMethodCode())) ?>');
19+
20+
config.active = form.length > 0 && !form.is(':hidden');
21+
new AuthorizenetAcceptjs(config);
22+
});
23+
//]]>
24+
</script>

app/code/Magento/AuthorizenetAcceptjs/view/adminhtml/web/js/payment-form.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ define([
88
], function (AuthorizenetAcceptjs, $) {
99
'use strict';
1010

11-
return function (data, element) {
12-
var $form = $(element),
13-
config = data.config;
11+
return function (config, element) {
12+
var $form = $(element);
1413

1514
config.active = $form.length > 0 && !$form.is(':hidden');
1615
new AuthorizenetAcceptjs(config);

app/code/Magento/AuthorizenetAcceptjs/view/frontend/web/template/payment/authorizenet-acceptjs.html

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<button class="action primary checkout"
3636
type="submit"
3737
click="beforePlaceOrder"
38+
css="disabled: !isPlaceOrderActionAllowed()"
3839
attr="title: $t('Place Order')"
3940
>
4041
<span translate="'Place Order'"></span>

app/code/Magento/AuthorizenetCardinal/Gateway/Request/Authorize3DSecureBuilder.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
1212
use Magento\AuthorizenetCardinal\Model\Config;
13-
use Magento\CardinalCommerce\Model\Response\JwtParser;
13+
use Magento\CardinalCommerce\Model\Response\JwtParserInterface;
1414
use Magento\Payment\Gateway\Request\BuilderInterface;
1515
use Magento\Sales\Model\Order\Payment;
1616

@@ -30,19 +30,19 @@ class Authorize3DSecureBuilder implements BuilderInterface
3030
private $config;
3131

3232
/**
33-
* @var JwtParser
33+
* @var JwtParserInterface
3434
*/
3535
private $jwtParser;
3636

3737
/**
3838
* @param SubjectReader $subjectReader
3939
* @param Config $config
40-
* @param JwtParser $jwtParser
40+
* @param JwtParserInterface $jwtParser
4141
*/
4242
public function __construct(
4343
SubjectReader $subjectReader,
4444
Config $config,
45-
JwtParser $jwtParser
45+
JwtParserInterface $jwtParser
4646
) {
4747
$this->subjectReader = $subjectReader;
4848
$this->config = $config;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AuthorizenetCardinal\Gateway\Validator;
10+
11+
use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
12+
use Magento\AuthorizenetCardinal\Model\Config;
13+
use Magento\Payment\Gateway\Validator\AbstractValidator;
14+
use Magento\Payment\Gateway\Validator\ResultInterface;
15+
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
16+
17+
/**
18+
* Validates cardholder authentication verification response code.
19+
*/
20+
class CavvResponseValidator extends AbstractValidator
21+
{
22+
/**
23+
* The result code that authorize.net returns if CAVV passed validation.
24+
*/
25+
private const RESULT_CODE_SUCCESS = '2';
26+
27+
/**
28+
* @var SubjectReader
29+
*/
30+
private $subjectReader;
31+
32+
/**
33+
* @var ResultInterfaceFactory
34+
*/
35+
private $resultFactory;
36+
37+
/**
38+
* @var Config
39+
*/
40+
private $config;
41+
42+
/**
43+
* @param ResultInterfaceFactory $resultFactory
44+
* @param SubjectReader $subjectReader
45+
* @param Config $config
46+
*/
47+
public function __construct(
48+
ResultInterfaceFactory $resultFactory,
49+
SubjectReader $subjectReader,
50+
Config $config
51+
) {
52+
parent::__construct($resultFactory);
53+
54+
$this->resultFactory = $resultFactory;
55+
$this->subjectReader = $subjectReader;
56+
$this->config = $config;
57+
}
58+
59+
/**
60+
* @inheritdoc
61+
*/
62+
public function validate(array $validationSubject): ResultInterface
63+
{
64+
if ($this->config->isActive() === false) {
65+
return $this->createResult(true);
66+
}
67+
68+
$response = $this->subjectReader->readResponse($validationSubject);
69+
$transactionResponse = $response['transactionResponse'];
70+
71+
$cavvResultCode = $transactionResponse['cavvResultCode'] ?? '';
72+
$isValid = $cavvResultCode === self::RESULT_CODE_SUCCESS;
73+
$errorCodes = [];
74+
$errorMessages = [];
75+
76+
if (!$isValid) {
77+
$errorCodes[] = $transactionResponse['cavvResultCode'];
78+
$errorMessages[] = 'CAVV failed validation';
79+
}
80+
81+
return $this->createResult($isValid, $errorMessages, $errorCodes);
82+
}
83+
}

app/code/Magento/AuthorizenetCardinal/etc/di.xml

+16
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,20 @@
1313
</argument>
1414
</arguments>
1515
</virtualType>
16+
<virtualType name="Magento\AuthorizenetCardinal\Gateway\Validator\VirtualTransactionValidator" type="Magento\Payment\Gateway\Validator\ValidatorComposite">
17+
<arguments>
18+
<argument name="chainBreakingValidators" xsi:type="array">
19+
<item name="general" xsi:type="boolean">true</item>
20+
</argument>
21+
<argument name="validators" xsi:type="array">
22+
<item name="general" xsi:type="string">AuthorizenetAcceptjsTransactionValidator</item>
23+
<item name="cavv_response" xsi:type="string">Magento\AuthorizenetCardinal\Gateway\Validator\CavvResponseValidator</item>
24+
</argument>
25+
</arguments>
26+
</virtualType>
27+
<virtualType name="AuthorizenetAcceptjsAuthorizeCommand">
28+
<arguments>
29+
<argument name="validator" xsi:type="object">Magento\AuthorizenetCardinal\Gateway\Validator\VirtualTransactionValidator</argument>
30+
</arguments>
31+
</virtualType>
1632
</config>

app/code/Magento/AuthorizenetCardinal/view/frontend/web/js/authorizenet-accept-mixin.js

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ define([
5656
},
5757

5858
/**
59+
* Adds cardinal response JWT to payment additional data.
60+
*
5961
* @returns {Object}
6062
*/
6163
getData: function () {

app/code/Magento/AuthorizenetGraphQl/etc/schema.graphqls

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright © Magento, Inc. All rights reserved.
22
# See COPYING.txt for license details.
33

4-
input PaymentMethodAdditionalDataInput {
4+
input PaymentMethodInput {
55
authorizenet_acceptjs: AuthorizenetInput @doc(description: "Defines the required attributes for Authorize.Net payments")
66
}
77

app/code/Magento/Backend/Block/Context.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Backend\Block;
77

8+
use Magento\Framework\Cache\LockGuardedCacheLoader;
9+
810
/**
911
* Constructor modification point for Magento\Backend\Block\AbstractBlock.
1012
*
@@ -17,7 +19,7 @@
1719
* the classes they were introduced for.
1820
*
1921
* @api
20-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
* @SuppressWarnings(PHPMD)
2123
* @since 100.0.2
2224
*/
2325
class Context extends \Magento\Framework\View\Element\Context
@@ -44,8 +46,9 @@ class Context extends \Magento\Framework\View\Element\Context
4446
* @param \Magento\Framework\Escaper $escaper
4547
* @param \Magento\Framework\Filter\FilterManager $filterManager
4648
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
47-
* @param \Magento\Framework\AuthorizationInterface $authorization
4849
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
50+
* @param \Magento\Framework\AuthorizationInterface $authorization
51+
* @param LockGuardedCacheLoader|null $lockQuery
4952
*
5053
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5154
*/
@@ -67,7 +70,8 @@ public function __construct(
6770
\Magento\Framework\Filter\FilterManager $filterManager,
6871
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
6972
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
70-
\Magento\Framework\AuthorizationInterface $authorization
73+
\Magento\Framework\AuthorizationInterface $authorization,
74+
LockGuardedCacheLoader $lockQuery = null
7175
) {
7276
$this->_authorization = $authorization;
7377
parent::__construct(
@@ -87,7 +91,8 @@ public function __construct(
8791
$escaper,
8892
$filterManager,
8993
$localeDate,
90-
$inlineTranslation
94+
$inlineTranslation,
95+
$lockQuery
9196
);
9297
}
9398

0 commit comments

Comments
 (0)