5
5
*/
6
6
namespace Magento \Payment \Model \Method ;
7
7
8
- use Magento \Framework \App \ObjectManager ;
9
8
use Magento \Framework \Pricing \PriceCurrencyInterface ;
10
- use Magento \Sales \Model \Order \Config ;
11
- use Magento \Sales \Model \Order \Status ;
12
9
13
10
/**
14
11
* Free payment method
18
15
* Magento contains special flow for handling this payment method.
19
16
* Inheritance is allowed to modify it behavior.
20
17
*
21
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22
18
* @api
23
19
* @since 100.0.2
24
20
*/
25
21
class Free extends \Magento \Payment \Model \Method \AbstractMethod
26
22
{
27
- public const PAYMENT_METHOD_FREE_CODE = 'free ' ;
23
+ const PAYMENT_METHOD_FREE_CODE = 'free ' ;
28
24
29
25
/**
30
26
* XML Paths for configuration constants
31
27
*/
32
- public const XML_PATH_PAYMENT_FREE_ACTIVE = 'payment/free/active ' ;
28
+ const XML_PATH_PAYMENT_FREE_ACTIVE = 'payment/free/active ' ;
33
29
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 ' ;
35
31
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 ' ;
37
33
38
34
/**
39
35
* Payment Method features
@@ -54,11 +50,6 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod
54
50
*/
55
51
protected $ priceCurrency ;
56
52
57
- /**
58
- * @var Config|null
59
- */
60
- private $ config ;
61
-
62
53
/**
63
54
* @param \Magento\Framework\Model\Context $context
64
55
* @param \Magento\Framework\Registry $registry
@@ -71,7 +62,6 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod
71
62
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
72
63
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
73
64
* @param array $data
74
- * @param Config|null $config
75
65
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
76
66
*/
77
67
public function __construct (
@@ -85,8 +75,7 @@ public function __construct(
85
75
PriceCurrencyInterface $ priceCurrency ,
86
76
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
87
77
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
88
- array $ data = [],
89
- Config $ config = null
78
+ array $ data = []
90
79
) {
91
80
parent ::__construct (
92
81
$ context ,
@@ -101,7 +90,6 @@ public function __construct(
101
90
$ data
102
91
);
103
92
$ this ->priceCurrency = $ priceCurrency ;
104
- $ this ->config = $ config ?: ObjectManager::getInstance ()->create (Config::class);
105
93
}
106
94
107
95
/**
@@ -113,10 +101,10 @@ public function __construct(
113
101
public function isAvailable (\Magento \Quote \Api \Data \CartInterface $ quote = null )
114
102
{
115
103
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 ;
120
108
}
121
109
122
110
/**
@@ -131,19 +119,12 @@ public function isAvailableInConfig($quote = null)
131
119
}
132
120
133
121
/**
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
135
123
*
136
124
* @return string|null
137
125
*/
138
126
public function getConfigPaymentAction ()
139
127
{
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 ();
148
129
}
149
130
}
0 commit comments