PAYONE-GmbH /
magento-2
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
||
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
||
| 6 | * the Free Software Foundation, either version 3 of the License, or |
||
| 7 | * (at your option) any later version. |
||
| 8 | * |
||
| 9 | * PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | * GNU Lesser General Public License for more details. |
||
| 13 | * |
||
| 14 | * You should have received a copy of the GNU Lesser General Public License |
||
| 15 | * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
||
| 16 | * |
||
| 17 | * PHP version 5 |
||
| 18 | * |
||
| 19 | * @category Payone |
||
| 20 | * @package Payone_Magento2_Plugin |
||
| 21 | * @author FATCHIP GmbH <[email protected]> |
||
| 22 | * @copyright 2003 - 2019 Payone GmbH |
||
| 23 | * @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
||
| 24 | * @link http://www.payone.de |
||
| 25 | */ |
||
| 26 | |||
| 27 | namespace Payone\Core\Model\Plugins; |
||
| 28 | |||
| 29 | use Magento\Sales\Model\ResourceModel\Order\Handler\State as OrigState; |
||
|
0 ignored issues
–
show
|
|||
| 30 | use Magento\Sales\Model\Order; |
||
|
0 ignored issues
–
show
The type
Magento\Sales\Model\Order was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 31 | use Payone\Core\Model\Methods\PayoneMethod; |
||
| 32 | |||
| 33 | class State |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * Payone shop helper |
||
| 37 | * |
||
| 38 | * @var \Payone\Core\Helper\Shop |
||
| 39 | */ |
||
| 40 | protected $shopHelper = null; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Constructor |
||
| 44 | * |
||
| 45 | * @param \Payone\Core\Helper\Shop $shopHelper |
||
| 46 | */ |
||
| 47 | public function __construct(\Payone\Core\Helper\Shop $shopHelper) { |
||
| 48 | $this->shopHelper = $shopHelper; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Closed status bug exists since Magento 2.3.1 |
||
| 53 | * So if the used payment method is not a Payone method or the shop-version is 2.3.0 or lower, the original method can be used |
||
| 54 | * Version-condition must be completed with an endversion when the problem is solved in Mage2 core! |
||
| 55 | * |
||
| 56 | * Plugin method will only be used for virtual orders payed with Payone for Magento2 shops 2.3.1 and higher |
||
| 57 | * Otherwise the core method is used |
||
| 58 | * |
||
| 59 | * @param OrigState $subject |
||
| 60 | * @param callable $proceed |
||
| 61 | * @param Order $order |
||
| 62 | * @return OrigState |
||
| 63 | */ |
||
| 64 | public function aroundCheck(OrigState $subject, callable $proceed, Order $order) { |
||
| 65 | if (version_compare($this->shopHelper->getMagentoVersion(), '2.3.0', '<=') || !$order->getPayment()->getMethodInstance() instanceof PayoneMethod) { |
||
| 66 | return $proceed($order); |
||
| 67 | } |
||
| 68 | |||
| 69 | $currentState = $order->getState(); |
||
| 70 | if ($currentState == Order::STATE_NEW && $order->getIsInProcess()) { |
||
| 71 | $order->setState(Order::STATE_PROCESSING)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)); |
||
| 72 | $currentState = Order::STATE_PROCESSING; |
||
| 73 | } |
||
| 74 | |||
| 75 | if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice()) { |
||
| 76 | // Virtual orders were being falsely set to closed here for authorization orders when the appointed status arrived because canCreditmemo is faulty in Mage 2.3.1 - 2.3.5 |
||
| 77 | // and because canShip will return false when the order is virtual therefore setStatus(Closed) was removed here for virtual orders |
||
| 78 | // PLUS: Authorization orders where shipment was created before invoice was paid were falsely set to CLOSED status |
||
| 79 | if (in_array($currentState, [Order::STATE_PROCESSING, Order::STATE_COMPLETE]) && !$order->canCreditmemo() && !$order->canShip() && !$order->getIsVirtual()) { |
||
| 80 | if ($order->getTotalDue() == 0) { |
||
| 81 | $order->setState(Order::STATE_CLOSED)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED)); |
||
| 82 | } |
||
| 83 | } elseif ($currentState === Order::STATE_PROCESSING && !$order->canShip()) { |
||
| 84 | $order->setState(Order::STATE_COMPLETE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_COMPLETE)); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | return $subject; |
||
| 89 | } |
||
| 90 | } |
||
| 91 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths