Skip to content

Commit fd177e0

Browse files
Merge branch 2.3-develop into ENGCOM-4636-magento-magento2-21932
2 parents a133c52 + d81b399 commit fd177e0

File tree

323 files changed

+13742
-3582
lines changed

Some content is hidden

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

323 files changed

+13742
-3582
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ Tests:
785785
* Refactored controller actions in the Product area
786786
* Moved commands cache.php, indexer.php, log.php, test.php, compiler.php, singletenant\_compiler.php, generator.php, pack.php, deploy.php and file\_assembler.php to the new bin/magento CLI framework
787787
* Data Migration Tool
788-
* The Data Migraiton Tool is published in the separate [repository](https://github.com/magento/data-migration-tool-ce "Data Migration Tool repository")
788+
* The Data Migration Tool is published in the separate [repository](https://github.com/magento/data-migration-tool-ce "Data Migration Tool repository")
789789
* Fixed bugs
790790
* Fixed an issue where error appeared during placing order with virtual product
791791
* Fixed an issue where billing and shipping sections didn't contain address information on order print

app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<title value="AdvancedReportingButtonTest"/>
1414
<description value="Test log in to AdvancedReporting and tests AdvancedReportingButtonTest"/>
1515
<testCaseId value="MC-14800"/>
16+
<skip>
17+
<issueId value="MC-14800" />
18+
</skip>
1619
<severity value="CRITICAL"/>
1720
<group value="analytics"/>
1821
<group value="mtf_migrated"/>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminSuccessLoginActionGroup">
12+
<waitForElementVisible selector="{{AdminHeaderSection.adminUserAccountText}}" stepKey="waitForAdminAccountTextVisible" />
13+
</actionGroup>
14+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertMessageOnAdminLoginActionGroup">
12+
<arguments>
13+
<argument name="message" type="string" defaultValue="The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later." />
14+
<argument name="messageType" type="string" defaultValue="error" />
15+
</arguments>
16+
<see userInput="{{message}}" selector="{{AdminLoginMessagesSection.messageByType(messageType)}}" stepKey="verifyMessage" />
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="LoginAdminWithCredentialsActionGroup">
12+
<arguments>
13+
<argument name="adminUser" type="string" />
14+
<argument name="adminPassword" type="string" />
15+
</arguments>
16+
<amOnPage url="{{_ENV.MAGENTO_BACKEND_NAME}}" stepKey="navigateToAdmin"/>
17+
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{adminUser}}" stepKey="fillUsername"/>
18+
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{adminPassword}}" stepKey="fillPassword"/>
19+
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/>
20+
<closeAdminNotification stepKey="closeAdminNotification"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="LoginAsAdmin">
1212
<arguments>
13-
<argument name="adminUser" defaultValue="_ENV"/>
13+
<argument name="adminUser" type="entity" defaultValue="DefaultAdminUser"/>
1414
</arguments>
1515
<amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/>
16-
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{adminUser.MAGENTO_ADMIN_USERNAME}}" stepKey="fillUsername"/>
17-
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{adminUser.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillPassword"/>
16+
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{adminUser.username}}" stepKey="fillUsername"/>
17+
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{adminUser.password}}" stepKey="fillPassword"/>
1818
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/>
1919
<closeAdminNotification stepKey="closeAdminNotification"/>
2020
</actionGroup>

app/code/Magento/Backend/Test/Mftf/Section/AdminHeaderSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminHeaderSection">
1212
<element name="pageTitle" type="text" selector=".page-header h1.page-title"/>
13+
<element name="adminUserAccountText" type="text" selector=".page-header .admin-user-account-text" />
1314
</section>
1415
</sections>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminLoginMessagesSection">
12+
<element name="messageByType" type="block" selector=".login-content .messages .message-{{messageType}}" parameterized="true" />
13+
</section>
14+
</sections>
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Braintree\Model\Multishipping;
9+
10+
use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand;
11+
use Magento\Braintree\Model\Ui\ConfigProvider;
12+
use Magento\Braintree\Observer\DataAssignObserver;
13+
use Magento\Braintree\Model\Ui\PayPal\ConfigProvider as PaypalConfigProvider;
14+
use Magento\Multishipping\Model\Checkout\Type\Multishipping\PlaceOrderInterface;
15+
use Magento\Sales\Api\Data\OrderInterface;
16+
use Magento\Sales\Api\Data\OrderPaymentExtensionInterface;
17+
use Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory;
18+
use Magento\Sales\Api\Data\OrderPaymentInterface;
19+
use Magento\Sales\Api\OrderManagementInterface;
20+
use Magento\Vault\Api\Data\PaymentTokenInterface;
21+
22+
/**
23+
* Order payments processing for multishipping checkout flow.
24+
*
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
*/
27+
class PlaceOrder implements PlaceOrderInterface
28+
{
29+
/**
30+
* @var OrderManagementInterface
31+
*/
32+
private $orderManagement;
33+
34+
/**
35+
* @var OrderPaymentExtensionInterfaceFactory
36+
*/
37+
private $paymentExtensionFactory;
38+
39+
/**
40+
* @var GetPaymentNonceCommand
41+
*/
42+
private $getPaymentNonceCommand;
43+
44+
/**
45+
* @param OrderManagementInterface $orderManagement
46+
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
47+
* @param GetPaymentNonceCommand $getPaymentNonceCommand
48+
*/
49+
public function __construct(
50+
OrderManagementInterface $orderManagement,
51+
OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
52+
GetPaymentNonceCommand $getPaymentNonceCommand
53+
) {
54+
$this->orderManagement = $orderManagement;
55+
$this->paymentExtensionFactory = $paymentExtensionFactory;
56+
$this->getPaymentNonceCommand = $getPaymentNonceCommand;
57+
}
58+
59+
/**
60+
* @inheritdoc
61+
*/
62+
public function place(array $orderList): array
63+
{
64+
if (empty($orderList)) {
65+
return [];
66+
}
67+
68+
$errorList = [];
69+
$firstOrder = $this->orderManagement->place(array_shift($orderList));
70+
// get payment token from first placed order
71+
$paymentToken = $this->getPaymentToken($firstOrder);
72+
73+
foreach ($orderList as $order) {
74+
try {
75+
/** @var OrderInterface $order */
76+
$orderPayment = $order->getPayment();
77+
$this->setVaultPayment($orderPayment, $paymentToken);
78+
$this->orderManagement->place($order);
79+
} catch (\Exception $e) {
80+
$incrementId = $order->getIncrementId();
81+
$errorList[$incrementId] = $e;
82+
}
83+
}
84+
85+
return $errorList;
86+
}
87+
88+
/**
89+
* Sets vault payment method.
90+
*
91+
* @param OrderPaymentInterface $orderPayment
92+
* @param PaymentTokenInterface $paymentToken
93+
* @return void
94+
*/
95+
private function setVaultPayment(OrderPaymentInterface $orderPayment, PaymentTokenInterface $paymentToken): void
96+
{
97+
$vaultMethod = $this->getVaultPaymentMethod(
98+
$orderPayment->getMethod()
99+
);
100+
$orderPayment->setMethod($vaultMethod);
101+
102+
$publicHash = $paymentToken->getPublicHash();
103+
$customerId = $paymentToken->getCustomerId();
104+
$result = $this->getPaymentNonceCommand->execute(
105+
['public_hash' => $publicHash, 'customer_id' => $customerId]
106+
)
107+
->get();
108+
109+
$orderPayment->setAdditionalInformation(
110+
DataAssignObserver::PAYMENT_METHOD_NONCE,
111+
$result['paymentMethodNonce']
112+
);
113+
$orderPayment->setAdditionalInformation(
114+
PaymentTokenInterface::PUBLIC_HASH,
115+
$publicHash
116+
);
117+
$orderPayment->setAdditionalInformation(
118+
PaymentTokenInterface::CUSTOMER_ID,
119+
$customerId
120+
);
121+
}
122+
123+
/**
124+
* Returns vault payment method.
125+
*
126+
* For placing sequence of orders, we need to replace the original method on the vault method.
127+
*
128+
* @param string $method
129+
* @return string
130+
*/
131+
private function getVaultPaymentMethod(string $method): string
132+
{
133+
$vaultPaymentMap = [
134+
ConfigProvider::CODE => ConfigProvider::CC_VAULT_CODE,
135+
PaypalConfigProvider::PAYPAL_CODE => PaypalConfigProvider::PAYPAL_VAULT_CODE
136+
];
137+
138+
return $vaultPaymentMap[$method] ?? $method;
139+
}
140+
141+
/**
142+
* Returns payment token.
143+
*
144+
* @param OrderInterface $order
145+
* @return PaymentTokenInterface
146+
* @throws \BadMethodCallException
147+
*/
148+
private function getPaymentToken(OrderInterface $order): PaymentTokenInterface
149+
{
150+
$orderPayment = $order->getPayment();
151+
$extensionAttributes = $this->getExtensionAttributes($orderPayment);
152+
$paymentToken = $extensionAttributes->getVaultPaymentToken();
153+
154+
if ($paymentToken === null) {
155+
throw new \BadMethodCallException('Vault Payment Token should be defined for placed order payment.');
156+
}
157+
158+
return $paymentToken;
159+
}
160+
161+
/**
162+
* Gets payment extension attributes.
163+
*
164+
* @param OrderPaymentInterface $payment
165+
* @return OrderPaymentExtensionInterface
166+
*/
167+
private function getExtensionAttributes(OrderPaymentInterface $payment): OrderPaymentExtensionInterface
168+
{
169+
$extensionAttributes = $payment->getExtensionAttributes();
170+
if (null === $extensionAttributes) {
171+
$extensionAttributes = $this->paymentExtensionFactory->create();
172+
$payment->setExtensionAttributes($extensionAttributes);
173+
}
174+
175+
return $extensionAttributes;
176+
}
177+
}

app/code/Magento/Braintree/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"magento/module-quote": "*",
2222
"magento/module-sales": "*",
2323
"magento/module-ui": "*",
24-
"magento/module-vault": "*"
24+
"magento/module-vault": "*",
25+
"magento/module-multishipping": "*"
2526
},
2627
"suggest": {
2728
"magento/module-checkout-agreements": "*",

0 commit comments

Comments
 (0)