Skip to content

Commit 6b109f4

Browse files
authored
Merge pull request #3549 from magento-tsg/2.2-develop-pr64
[TSG] Backporting for 2.2 (pr64) (2.2.8)
2 parents 7ae4f5d + 7ad2106 commit 6b109f4

File tree

54 files changed

+1244
-107
lines changed

Some content is hidden

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

54 files changed

+1244
-107
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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\Authorizenet\Block\Adminhtml\Order\View\Info;
9+
10+
use Magento\Framework\Phrase;
11+
use Magento\Payment\Block\ConfigurableInfo;
12+
13+
/**
14+
* Payment information block for Authorize.net payment method.
15+
*/
16+
class PaymentDetails extends ConfigurableInfo
17+
{
18+
/**
19+
* Returns localized label for payment info block.
20+
*
21+
* @param string $field
22+
* @return string | Phrase
23+
*/
24+
protected function getLabel($field)
25+
{
26+
return __($field);
27+
}
28+
}

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
2727
/**
2828
* @var string
2929
*/
30-
protected $_infoBlockType = \Magento\Payment\Block\Info::class;
30+
protected $_infoBlockType = \Magento\Authorizenet\Block\Adminhtml\Order\View\Info\PaymentDetails::class;
3131

3232
/**
3333
* Payment Method feature
@@ -371,8 +371,7 @@ public function void(\Magento\Payment\Model\InfoInterface $payment)
371371
}
372372

373373
/**
374-
* Refund the amount
375-
* Need to decode last 4 digits for request.
374+
* Refund the amount need to decode last 4 digits for request.
376375
*
377376
* @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment
378377
* @param float $amount
@@ -626,6 +625,14 @@ protected function fillPaymentByResponse(\Magento\Framework\DataObject $payment)
626625
$payment->setIsTransactionPending(true)
627626
->setIsFraudDetected(true);
628627
}
628+
629+
$additionalInformationKeys = explode(',', $this->getValue('paymentInfoKeys'));
630+
foreach ($additionalInformationKeys as $paymentInfoKey) {
631+
$paymentInfoValue = $response->getDataByKey($paymentInfoKey);
632+
if ($paymentInfoValue !== null) {
633+
$payment->setAdditionalInformation($paymentInfoKey, $paymentInfoValue);
634+
}
635+
}
629636
}
630637

631638
/**
@@ -682,6 +689,7 @@ protected function matchAmount($amount)
682689

683690
/**
684691
* Operate with order using information from Authorize.net.
692+
*
685693
* Authorize order or authorize and capture it.
686694
*
687695
* @param \Magento\Sales\Model\Order $order
@@ -858,7 +866,7 @@ public function getConfigInterface()
858866
* Getter for specified value according to set payment method code
859867
*
860868
* @param mixed $key
861-
* @param null $storeId
869+
* @param int|string|null|\Magento\Store\Model\Store $storeId
862870
* @return mixed
863871
*/
864872
public function getValue($key, $storeId = null)
@@ -918,10 +926,13 @@ public function fetchTransactionInfo(\Magento\Payment\Model\InfoInterface $payme
918926
$payment->setIsTransactionDenied(true);
919927
}
920928
$this->addStatusCommentOnUpdate($payment, $response, $transactionId);
921-
return [];
929+
930+
return $response->getData();
922931
}
923932

924933
/**
934+
* Add statuc comment on update.
935+
*
925936
* @param \Magento\Sales\Model\Order\Payment $payment
926937
* @param \Magento\Framework\DataObject $response
927938
* @param string $transactionId
@@ -996,8 +1007,9 @@ protected function getTransactionResponse($transactionId)
9961007
}
9971008

9981009
/**
999-
* @return \Psr\Log\LoggerInterface
1010+
* Get psr logger.
10001011
*
1012+
* @return \Psr\Log\LoggerInterface
10011013
* @deprecated 100.1.0
10021014
*/
10031015
private function getPsrLogger()
@@ -1038,7 +1050,9 @@ private function getOrderIncrementId(): string
10381050
}
10391051

10401052
/**
1041-
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
1053+
* Checks if filter action is Report Only.
1054+
*
1055+
* Transactions that trigger this filter are processed as normal,
10421056
* but are also reported in the Merchant Interface as triggering this filter.
10431057
*
10441058
* @param string $fdsFilterAction

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<cgi_url>https://secure.authorize.net/gateway/transact.dll</cgi_url>
3333
<cgi_url_td_test_mode>https://apitest.authorize.net/xml/v1/request.api</cgi_url_td_test_mode>
3434
<cgi_url_td>https://api2.authorize.net/xml/v1/request.api</cgi_url_td>
35+
<paymentInfoKeys>x_card_type,x_account_number,x_avs_code,x_auth_code,x_response_reason_text,x_cvv2_resp_code</paymentInfoKeys>
3536
</authorizenet_directpost>
3637
</payment>
3738
</default>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@
3535
</argument>
3636
</arguments>
3737
</type>
38+
<type name="Magento\Authorizenet\Block\Adminhtml\Order\View\Info\PaymentDetails">
39+
<arguments>
40+
<argument name="config" xsi:type="object">Magento\Authorizenet\Model\Directpost</argument>
41+
</arguments>
42+
</type>
3843
</config>

app/code/Magento/Authorizenet/i18n/en_US.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ Debug,Debug
6767
"Minimum Order Total","Minimum Order Total"
6868
"Maximum Order Total","Maximum Order Total"
6969
"Sort Order","Sort Order"
70+
"x_card_type","Credit Card Type"
71+
"x_account_number", "Credit Card Number"
72+
"x_avs_code","AVS Response Code"
73+
"x_auth_code","Processor Authentication Code"
74+
"x_response_reason_text","Processor Response Text"
75+
"x_cvv2_resp_code","CVV2 Response Code"

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
2222
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
2323
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']"/>
24+
<element name="productTaxClass" type="select" selector="select[name='product[tax_class_id]']"/>
2425
<element name="productTaxClassUseDefault" type="checkbox" selector="input[name='use_default[tax_class_id]']"/>
2526
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>
2627
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>

app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ public function save(StockItemInterface $stockItem)
161161
$typeId = $product->getTypeId() ?: $product->getTypeInstance()->getTypeId();
162162
$isQty = $this->stockConfiguration->isQty($typeId);
163163
if ($isQty) {
164-
$this->changeIsInStockIfNecessary($stockItem);
164+
$isInStock = $this->stockStateProvider->verifyStock($stockItem);
165+
if ($stockItem->getManageStock() && !$isInStock) {
166+
$stockItem->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true);
167+
}
165168
// if qty is below notify qty, update the low stock date to today date otherwise set null
166169
$stockItem->setLowStockDate(null);
167170
if ($this->stockStateProvider->verifyNotification($stockItem)) {
@@ -257,29 +260,4 @@ private function getStockRegistryStorage()
257260
}
258261
return $this->stockRegistryStorage;
259262
}
260-
261-
/**
262-
* Change is_in_stock value if necessary.
263-
*
264-
* @param StockItemInterface $stockItem
265-
*
266-
* @return void
267-
*/
268-
private function changeIsInStockIfNecessary(StockItemInterface $stockItem)
269-
{
270-
$isInStock = $this->stockStateProvider->verifyStock($stockItem);
271-
if ($stockItem->getManageStock() && !$isInStock) {
272-
$stockItem->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true);
273-
}
274-
275-
if ($stockItem->getManageStock()
276-
&& $isInStock
277-
&& !$stockItem->getIsInStock()
278-
&& $stockItem->getQty() > 0
279-
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) <= 0
280-
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) !== null
281-
) {
282-
$stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
283-
}
284-
}
285263
}

app/code/Magento/CatalogInventory/Model/StockRegistry.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ public function updateStockItemBySku($productSku, \Magento\CatalogInventory\Api\
171171
$productId = $this->resolveProductId($productSku);
172172
$websiteId = $stockItem->getWebsiteId() ?: null;
173173
$origStockItem = $this->getStockItem($productId, $websiteId);
174+
175+
if ($stockItem->getManageStock()
176+
&& !$stockItem->getIsInStock()
177+
&& $stockItem->getQty() > 0
178+
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) <= 0
179+
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) !== null
180+
) {
181+
$stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
182+
}
183+
174184
$data = $stockItem->getData();
175185
if ($origStockItem->getItemId()) {
176186
unset($data['item_id']);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<!-- Change Maximum Qty Allowed in Shopping Cart config -->
12+
<entity name="ProductStockOptions" type="catalog_inventory_product_stock_options">
13+
<requiredEntity type="max_qty_to_cart">MaxQtyAllowInCartChange</requiredEntity>
14+
</entity>
15+
<entity name="MaxQtyAllowInCartChange" type="max_qty_to_cart">
16+
<data key="value">0</data>
17+
</entity>
18+
<!-- Maximum Qty Allowed in Shopping Cart to default config -->
19+
<entity name="DefaultProductStockOptions" type="catalog_inventory_product_stock_options">
20+
<requiredEntity type="max_qty_to_cart">MaxQtyAllowInCartDefault</requiredEntity>
21+
</entity>
22+
<entity name="MaxQtyAllowInCartDefault" type="max_qty_to_cart">
23+
<data key="value">10000</data>
24+
</entity>
25+
</entities>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
10+
<operation name="CatalogInventoryProductStockSetup" dataType="catalog_inventory_product_stock_options" type="create" auth="adminFormKey" url="/admin/system_config/save/section/cataloginventory/" successRegex="/messages-message-success/" method="POST">
11+
<object key="groups" dataType="catalog_inventory_product_stock_options">
12+
<object key="item_options" dataType="catalog_inventory_product_stock_options">
13+
<object key="fields" dataType="catalog_inventory_product_stock_options">
14+
<object key="max_sale_qty" dataType="max_qty_to_cart">
15+
<field key="value">string</field>
16+
</object>
17+
</object>
18+
</object>
19+
</object>
20+
</operation>
21+
</operations>

0 commit comments

Comments
 (0)