Skip to content

Commit ec13581

Browse files
Merge branch 2.3-develop into ENGCOM-4698-magento-magento2-22205
2 parents d9b094d + 07e57ac commit ec13581

File tree

169 files changed

+5145
-3686
lines changed

Some content is hidden

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

169 files changed

+5145
-3686
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.
77

88
## Magento System Requirements
9-
[Magento System Requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html).
9+
[Magento System Requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements.html).
1010

1111
## Install Magento
1212

app/code/Magento/Backend/Controller/Adminhtml/Dashboard/ProductsViewed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
*/
77
namespace Magento\Backend\Controller\Adminhtml\Dashboard;
88

9-
use Magento\Framework\App\Action\HttpGetActionInterface;
9+
use Magento\Framework\App\Action\HttpPostActionInterface;
1010

1111
/**
1212
* Get most viewed products controller.
1313
*/
14-
class ProductsViewed extends AjaxBlock implements HttpGetActionInterface
14+
class ProductsViewed extends AjaxBlock implements HttpPostActionInterface
1515
{
1616
/**
1717
* Gets most viewed products list
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="SetWebsiteCountryOptionsToDefaultActionGroup">
12+
<conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation3"/>
13+
<waitForElementVisible selector="{{CountryOptionsSection.topDestinations}}" stepKey="waitCheckboxToBeVisible3"/>
14+
<checkOption selector="{{CountryOptionsSection.generalCountryAllowInherit}}" stepKey="setToDefault1"/>
15+
<checkOption selector="{{CountryOptionsSection.generalCountryDefaultInherit}}" stepKey="setToDefault2"/>
16+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveDefaultConfig"/>
17+
<waitForPageLoad stepKey="waitForSavingSystemConfiguration"/>
18+
<see userInput="You saved the configuration." stepKey="seeSuccessMessage"/>
19+
</actionGroup>
20+
</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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="CountryOptionsSection">
12+
<element name="allowedCountries" type="select" selector="#general_country_allow"/>
13+
<element name="notAllowedCountry" type="button" selector="#general_country_allow option:not([selected])"/>
14+
<element name="generalCountryAllowInherit" type="checkbox" selector="#general_country_allow_inherit"/>
15+
<element name="generalCountryDefaultInherit" type="checkbox" selector="#general_country_default_inherit"/>
16+
<element name="generalCountryDefault" type="select" selector="#general_country_default"/>
17+
</section>
18+
</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": "*",

app/code/Magento/Braintree/etc/config.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<paymentInfoKeys>cc_type,cc_number,avsPostalCodeResponseCode,avsStreetAddressResponseCode,cvvResponseCode,processorAuthorizationCode,processorResponseCode,processorResponseText,liabilityShifted,liabilityShiftPossible,riskDataId,riskDataDecision</paymentInfoKeys>
4343
<avs_ems_adapter>Magento\Braintree\Model\AvsEmsCodeMapper</avs_ems_adapter>
4444
<cvv_ems_adapter>Magento\Braintree\Model\CvvEmsCodeMapper</cvv_ems_adapter>
45-
<group>braintree</group>
45+
<group>braintree_group</group>
4646
</braintree>
4747
<braintree_paypal>
4848
<model>BraintreePayPalFacade</model>
@@ -68,7 +68,7 @@
6868
<privateInfoKeys>processorResponseCode,processorResponseText,paymentId</privateInfoKeys>
6969
<paymentInfoKeys>processorResponseCode,processorResponseText,paymentId,payerEmail</paymentInfoKeys>
7070
<supported_locales>en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,nl_NL,no_NO,pl_PL,es_ES,sv_SE,tr_TR,pt_BR,ja_JP,id_ID,ko_KR,pt_PT,ru_RU,th_TH,zh_CN,zh_TW</supported_locales>
71-
<group>braintree</group>
71+
<group>braintree_group</group>
7272
</braintree_paypal>
7373
<braintree_cc_vault>
7474
<model>BraintreeCreditCardVaultFacade</model>
@@ -78,7 +78,7 @@
7878
<tokenFormat>Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter</tokenFormat>
7979
<additionalInformation>Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider</additionalInformation>
8080
</instant_purchase>
81-
<group>braintree</group>
81+
<group>braintree_group</group>
8282
</braintree_cc_vault>
8383
<braintree_paypal_vault>
8484
<model>BraintreePayPalVaultFacade</model>
@@ -88,7 +88,7 @@
8888
<tokenFormat>Magento\Braintree\Model\InstantPurchase\PayPal\TokenFormatter</tokenFormat>
8989
<additionalInformation>Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider</additionalInformation>
9090
</instant_purchase>
91-
<group>braintree</group>
91+
<group>braintree_group</group>
9292
</braintree_paypal_vault>
9393
</payment>
9494
</default>

app/code/Magento/Braintree/etc/frontend/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@
6161
<argument name="resolver" xsi:type="object">Magento\Braintree\Model\LocaleResolver</argument>
6262
</arguments>
6363
</type>
64+
<type name="Magento\Multishipping\Model\Checkout\Type\Multishipping\PlaceOrderPool">
65+
<arguments>
66+
<argument name="services" xsi:type="array">
67+
<item name="braintree" xsi:type="string">Magento\Braintree\Model\Multishipping\PlaceOrder</item>
68+
<item name="braintree_paypal" xsi:type="string">Magento\Braintree\Model\Multishipping\PlaceOrder</item>
69+
</argument>
70+
</arguments>
71+
</type>
6472
</config>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88
<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">
1010
<groups>
11-
<group id="braintree">
11+
<group id="braintree_group">
1212
<label>Braintree</label>
1313
</group>
1414
</groups>
15+
<methods>
16+
<method name="braintree">
17+
<allow_multiple_address>1</allow_multiple_address>
18+
</method>
19+
<method name="braintree_paypal">
20+
<allow_multiple_address>1</allow_multiple_address>
21+
</method>
22+
</methods>
1523
</payment>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
10+
<body>
11+
<referenceBlock name="checkout_billing">
12+
<arguments>
13+
<argument name="form_templates" xsi:type="array">
14+
<item name="braintree" xsi:type="string">Magento_Braintree::multishipping/form.phtml</item>
15+
<item name="braintree_paypal" xsi:type="string">Magento_Braintree::multishipping/form_paypal.phtml</item>
16+
</argument>
17+
</arguments>
18+
</referenceBlock>
19+
</body>
20+
</page>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<script>
8+
require([
9+
'uiLayout',
10+
'jquery'
11+
], function (layout, $) {
12+
$(function () {
13+
var paymentMethodData = {
14+
method: 'braintree'
15+
};
16+
layout([
17+
{
18+
component: 'Magento_Braintree/js/view/payment/method-renderer/multishipping/hosted-fields',
19+
name: 'payment_method_braintree',
20+
method: paymentMethodData.method,
21+
item: paymentMethodData
22+
}
23+
]);
24+
25+
$('body').trigger('contentUpdated');
26+
})
27+
})
28+
</script>
29+
<!-- ko template: getTemplate() --><!-- /ko -->
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<script>
8+
require([
9+
'uiLayout',
10+
'jquery'
11+
], function (layout, $) {
12+
$(function () {
13+
var paymentMethodData = {
14+
method: 'braintree_paypal'
15+
};
16+
layout([
17+
{
18+
component: 'Magento_Braintree/js/view/payment/method-renderer/multishipping/paypal',
19+
name: 'payment_method_braintree_paypal',
20+
method: paymentMethodData.method,
21+
item: paymentMethodData
22+
}
23+
]);
24+
25+
$('body').trigger('contentUpdated');
26+
})
27+
})
28+
</script>
29+
<!-- ko template: getTemplate() --><!-- /ko -->

0 commit comments

Comments
 (0)