Skip to content

Commit b2bbe9d

Browse files
committed
ACP2E-1120: extend new statuses that can apply for new placed order with free payment
1 parent 5d6e11c commit b2bbe9d

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
<allowspecific>0</allowspecific>
4141
<group>offline</group>
4242
</cashondelivery>
43-
<free>
44-
<group>offline</group>
45-
<payment_action>authorize_capture</payment_action>
46-
</free>
4743
</payment>
4844
</default>
4945
</config>

app/code/Magento/Payment/Model/Method/Free.php

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
*/
66
namespace Magento\Payment\Model\Method;
77

8-
use Magento\Framework\App\ObjectManager;
98
use Magento\Framework\Pricing\PriceCurrencyInterface;
10-
use Magento\Sales\Model\Order\Config;
11-
use Magento\Sales\Model\Order\Status;
129

1310
/**
1411
* Free payment method
@@ -18,22 +15,21 @@
1815
* Magento contains special flow for handling this payment method.
1916
* Inheritance is allowed to modify it behavior.
2017
*
21-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2218
* @api
2319
* @since 100.0.2
2420
*/
2521
class Free extends \Magento\Payment\Model\Method\AbstractMethod
2622
{
27-
public const PAYMENT_METHOD_FREE_CODE = 'free';
23+
const PAYMENT_METHOD_FREE_CODE = 'free';
2824

2925
/**
3026
* XML Paths for configuration constants
3127
*/
32-
public const XML_PATH_PAYMENT_FREE_ACTIVE = 'payment/free/active';
28+
const XML_PATH_PAYMENT_FREE_ACTIVE = 'payment/free/active';
3329

34-
public const XML_PATH_PAYMENT_FREE_ORDER_STATUS = 'payment/free/order_status';
30+
const XML_PATH_PAYMENT_FREE_ORDER_STATUS = 'payment/free/order_status';
3531

36-
public const XML_PATH_PAYMENT_FREE_PAYMENT_ACTION = 'payment/free/payment_action';
32+
const XML_PATH_PAYMENT_FREE_PAYMENT_ACTION = 'payment/free/payment_action';
3733

3834
/**
3935
* Payment Method features
@@ -54,11 +50,6 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod
5450
*/
5551
protected $priceCurrency;
5652

57-
/**
58-
* @var Config|null
59-
*/
60-
private $config;
61-
6253
/**
6354
* @param \Magento\Framework\Model\Context $context
6455
* @param \Magento\Framework\Registry $registry
@@ -71,7 +62,6 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod
7162
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
7263
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
7364
* @param array $data
74-
* @param Config|null $config
7565
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7666
*/
7767
public function __construct(
@@ -85,8 +75,7 @@ public function __construct(
8575
PriceCurrencyInterface $priceCurrency,
8676
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
8777
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
88-
array $data = [],
89-
Config $config = null
78+
array $data = []
9079
) {
9180
parent::__construct(
9281
$context,
@@ -101,7 +90,6 @@ public function __construct(
10190
$data
10291
);
10392
$this->priceCurrency = $priceCurrency;
104-
$this->config = $config ?: ObjectManager::getInstance()->create(Config::class);
10593
}
10694

10795
/**
@@ -113,10 +101,10 @@ public function __construct(
113101
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
114102
{
115103
return parent::isAvailable(
116-
$quote
117-
) && null !== $quote && $this->priceCurrency->round(
118-
$quote->getGrandTotal()
119-
) == 0;
104+
$quote
105+
) && null !== $quote && $this->priceCurrency->round(
106+
$quote->getGrandTotal()
107+
) == 0;
120108
}
121109

122110
/**
@@ -131,19 +119,12 @@ public function isAvailableInConfig($quote = null)
131119
}
132120

133121
/**
134-
* Get config payment action, do nothing if status is pending or status is assigned to new[Pending] state
122+
* Get config payment action, do nothing if status is pending
135123
*
136124
* @return string|null
137125
*/
138126
public function getConfigPaymentAction()
139127
{
140-
$newStateStatuses = $this->config->getStateStatuses('new');
141-
$configNewOrderStatus = $this->getConfigData('order_status');
142-
$paymentAction = parent::getConfigPaymentAction();
143-
144-
return
145-
array_key_exists($configNewOrderStatus, $newStateStatuses) &&
146-
$configNewOrderStatus != 'processing'
147-
? null : $paymentAction;
128+
return $this->getConfigData('order_status') == 'pending' ? null : parent::getConfigPaymentAction();
148129
}
149130
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<model>Magento\Payment\Model\Method\Free</model>
1414
<order_status>pending</order_status>
1515
<title>No Payment Information Required</title>
16-
<payment_action>authorize</payment_action>
1716
<allowspecific>0</allowspecific>
1817
<sort_order>1</sort_order>
1918
</free>

0 commit comments

Comments
 (0)