Skip to content

Commit

Permalink
Merge pull request magento#3549 from magento-tsg/2.2-develop-pr64
Browse files Browse the repository at this point in the history
[TSG] Backporting for 2.2 (pr64) (2.2.8)
  • Loading branch information
xmav authored Dec 19, 2018
2 parents 7ae4f5d + 7ad2106 commit 6b109f4
Show file tree
Hide file tree
Showing 54 changed files with 1,244 additions and 107 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Authorizenet\Block\Adminhtml\Order\View\Info;

use Magento\Framework\Phrase;
use Magento\Payment\Block\ConfigurableInfo;

/**
* Payment information block for Authorize.net payment method.
*/
class PaymentDetails extends ConfigurableInfo
{
/**
* Returns localized label for payment info block.
*
* @param string $field
* @return string | Phrase
*/
protected function getLabel($field)
{
return __($field);
}
}
28 changes: 21 additions & 7 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
/**
* @var string
*/
protected $_infoBlockType = \Magento\Payment\Block\Info::class;
protected $_infoBlockType = \Magento\Authorizenet\Block\Adminhtml\Order\View\Info\PaymentDetails::class;

/**
* Payment Method feature
Expand Down Expand Up @@ -371,8 +371,7 @@ public function void(\Magento\Payment\Model\InfoInterface $payment)
}

/**
* Refund the amount
* Need to decode last 4 digits for request.
* Refund the amount need to decode last 4 digits for request.
*
* @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment
* @param float $amount
Expand Down Expand Up @@ -626,6 +625,14 @@ protected function fillPaymentByResponse(\Magento\Framework\DataObject $payment)
$payment->setIsTransactionPending(true)
->setIsFraudDetected(true);
}

$additionalInformationKeys = explode(',', $this->getValue('paymentInfoKeys'));
foreach ($additionalInformationKeys as $paymentInfoKey) {
$paymentInfoValue = $response->getDataByKey($paymentInfoKey);
if ($paymentInfoValue !== null) {
$payment->setAdditionalInformation($paymentInfoKey, $paymentInfoValue);
}
}
}

/**
Expand Down Expand Up @@ -682,6 +689,7 @@ protected function matchAmount($amount)

/**
* Operate with order using information from Authorize.net.
*
* Authorize order or authorize and capture it.
*
* @param \Magento\Sales\Model\Order $order
Expand Down Expand Up @@ -858,7 +866,7 @@ public function getConfigInterface()
* Getter for specified value according to set payment method code
*
* @param mixed $key
* @param null $storeId
* @param int|string|null|\Magento\Store\Model\Store $storeId
* @return mixed
*/
public function getValue($key, $storeId = null)
Expand Down Expand Up @@ -918,10 +926,13 @@ public function fetchTransactionInfo(\Magento\Payment\Model\InfoInterface $payme
$payment->setIsTransactionDenied(true);
}
$this->addStatusCommentOnUpdate($payment, $response, $transactionId);
return [];

return $response->getData();
}

/**
* Add statuc comment on update.
*
* @param \Magento\Sales\Model\Order\Payment $payment
* @param \Magento\Framework\DataObject $response
* @param string $transactionId
Expand Down Expand Up @@ -996,8 +1007,9 @@ protected function getTransactionResponse($transactionId)
}

/**
* @return \Psr\Log\LoggerInterface
* Get psr logger.
*
* @return \Psr\Log\LoggerInterface
* @deprecated 100.1.0
*/
private function getPsrLogger()
Expand Down Expand Up @@ -1038,7 +1050,9 @@ private function getOrderIncrementId(): string
}

/**
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
* Checks if filter action is Report Only.
*
* Transactions that trigger this filter are processed as normal,
* but are also reported in the Merchant Interface as triggering this filter.
*
* @param string $fdsFilterAction
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Authorizenet/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<cgi_url>https://secure.authorize.net/gateway/transact.dll</cgi_url>
<cgi_url_td_test_mode>https://apitest.authorize.net/xml/v1/request.api</cgi_url_td_test_mode>
<cgi_url_td>https://api2.authorize.net/xml/v1/request.api</cgi_url_td>
<paymentInfoKeys>x_card_type,x_account_number,x_avs_code,x_auth_code,x_response_reason_text,x_cvv2_resp_code</paymentInfoKeys>
</authorizenet_directpost>
</payment>
</default>
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Authorizenet/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
</argument>
</arguments>
</type>
<type name="Magento\Authorizenet\Block\Adminhtml\Order\View\Info\PaymentDetails">
<arguments>
<argument name="config" xsi:type="object">Magento\Authorizenet\Model\Directpost</argument>
</arguments>
</type>
</config>
6 changes: 6 additions & 0 deletions app/code/Magento/Authorizenet/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ Debug,Debug
"Minimum Order Total","Minimum Order Total"
"Maximum Order Total","Maximum Order Total"
"Sort Order","Sort Order"
"x_card_type","Credit Card Type"
"x_account_number", "Credit Card Number"
"x_avs_code","AVS Response Code"
"x_auth_code","Processor Authentication Code"
"x_response_reason_text","Processor Response Text"
"x_cvv2_resp_code","CVV2 Response Code"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']"/>
<element name="productTaxClass" type="select" selector="select[name='product[tax_class_id]']"/>
<element name="productTaxClassUseDefault" type="checkbox" selector="input[name='use_default[tax_class_id]']"/>
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ public function save(StockItemInterface $stockItem)
$typeId = $product->getTypeId() ?: $product->getTypeInstance()->getTypeId();
$isQty = $this->stockConfiguration->isQty($typeId);
if ($isQty) {
$this->changeIsInStockIfNecessary($stockItem);
$isInStock = $this->stockStateProvider->verifyStock($stockItem);
if ($stockItem->getManageStock() && !$isInStock) {
$stockItem->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true);
}
// if qty is below notify qty, update the low stock date to today date otherwise set null
$stockItem->setLowStockDate(null);
if ($this->stockStateProvider->verifyNotification($stockItem)) {
Expand Down Expand Up @@ -257,29 +260,4 @@ private function getStockRegistryStorage()
}
return $this->stockRegistryStorage;
}

/**
* Change is_in_stock value if necessary.
*
* @param StockItemInterface $stockItem
*
* @return void
*/
private function changeIsInStockIfNecessary(StockItemInterface $stockItem)
{
$isInStock = $this->stockStateProvider->verifyStock($stockItem);
if ($stockItem->getManageStock() && !$isInStock) {
$stockItem->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true);
}

if ($stockItem->getManageStock()
&& $isInStock
&& !$stockItem->getIsInStock()
&& $stockItem->getQty() > 0
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) <= 0
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) !== null
) {
$stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
}
}
}
10 changes: 10 additions & 0 deletions app/code/Magento/CatalogInventory/Model/StockRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ public function updateStockItemBySku($productSku, \Magento\CatalogInventory\Api\
$productId = $this->resolveProductId($productSku);
$websiteId = $stockItem->getWebsiteId() ?: null;
$origStockItem = $this->getStockItem($productId, $websiteId);

if ($stockItem->getManageStock()
&& !$stockItem->getIsInStock()
&& $stockItem->getQty() > 0
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) <= 0
&& $stockItem->getOrigData(\Magento\CatalogInventory\Api\Data\StockItemInterface::QTY) !== null
) {
$stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
}

$data = $stockItem->getData();
if ($origStockItem->getItemId()) {
unset($data['item_id']);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<!-- Change Maximum Qty Allowed in Shopping Cart config -->
<entity name="ProductStockOptions" type="catalog_inventory_product_stock_options">
<requiredEntity type="max_qty_to_cart">MaxQtyAllowInCartChange</requiredEntity>
</entity>
<entity name="MaxQtyAllowInCartChange" type="max_qty_to_cart">
<data key="value">0</data>
</entity>
<!-- Maximum Qty Allowed in Shopping Cart to default config -->
<entity name="DefaultProductStockOptions" type="catalog_inventory_product_stock_options">
<requiredEntity type="max_qty_to_cart">MaxQtyAllowInCartDefault</requiredEntity>
</entity>
<entity name="MaxQtyAllowInCartDefault" type="max_qty_to_cart">
<data key="value">10000</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
<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">
<object key="groups" dataType="catalog_inventory_product_stock_options">
<object key="item_options" dataType="catalog_inventory_product_stock_options">
<object key="fields" dataType="catalog_inventory_product_stock_options">
<object key="max_sale_qty" dataType="max_qty_to_cart">
<field key="value">string</field>
</object>
</object>
</object>
</object>
</operation>
</operations>
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function testSave()
->method('verifyStock')
->with($this->stockItemMock)
->willReturn(false);
$this->stockItemMock->expects($this->exactly(2))->method('getManageStock')->willReturn(true);
$this->stockItemMock->expects($this->once())->method('getManageStock')->willReturn(true);
$this->stockItemMock->expects($this->once())->method('setIsInStock')->with(false)->willReturnSelf();
$this->stockItemMock->expects($this->once())
->method('setStockStatusChangedAutomaticallyFlag')
Expand Down
Loading

0 comments on commit 6b109f4

Please sign in to comment.