11
11
use Magento \Sales \Model \Order ;
12
12
use Magento \Sales \Model \Order \StatusResolver ;
13
13
14
+ /**
15
+ * Class RegisterCaptureNotificationCommand
16
+ *
17
+ * @package Magento\Sales\Model\Order\Payment\State
18
+ */
14
19
class RegisterCaptureNotificationCommand implements CommandInterface
15
20
{
16
21
/**
@@ -23,19 +28,24 @@ class RegisterCaptureNotificationCommand implements CommandInterface
23
28
*/
24
29
public function __construct (StatusResolver $ statusResolver = null )
25
30
{
26
- $ this ->statusResolver = $ statusResolver
27
- ? : ObjectManager::getInstance ()->get (StatusResolver::class);
31
+ $ this ->statusResolver = $ statusResolver ?: ObjectManager::getInstance ()->get (StatusResolver::class);
28
32
}
29
33
30
34
/**
35
+ * Registers a capture event for this payment
36
+ *
31
37
* @param OrderPaymentInterface $payment
32
38
* @param string|float|int $amount
33
39
* @param OrderInterface $order
34
40
* @return string
35
41
*/
36
42
public function execute (OrderPaymentInterface $ payment , $ amount , OrderInterface $ order )
37
43
{
38
- $ state = $ order ->getState () ?: Order::STATE_PROCESSING ;
44
+ $ state = $ order ->getState ();
45
+ if (!$ state || $ state === Order::STATE_NEW || $ state === Order::STATE_PENDING_PAYMENT ) {
46
+ $ state = Order::STATE_PROCESSING ;
47
+ }
48
+
39
49
$ status = null ;
40
50
$ message = 'Registered notification about captured amount of %1. ' ;
41
51
@@ -61,6 +71,8 @@ public function execute(OrderPaymentInterface $payment, $amount, OrderInterface
61
71
}
62
72
63
73
/**
74
+ * Sets the state and status of the order
75
+ *
64
76
* @deprecated 100.2.0 Replaced by a StatusResolver class call.
65
77
*
66
78
* @param Order $order
0 commit comments