Skip to content

Commit 45592e2

Browse files
committed
Sets the order to state processing also if the order is in state new or pending_payment
1 parent f6405d5 commit 45592e2

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

app/code/Magento/Sales/Model/Order/Payment/State/RegisterCaptureNotificationCommand.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
use Magento\Sales\Model\Order;
1212
use Magento\Sales\Model\Order\StatusResolver;
1313

14+
/**
15+
* Class RegisterCaptureNotificationCommand
16+
*
17+
* @package Magento\Sales\Model\Order\Payment\State
18+
*/
1419
class RegisterCaptureNotificationCommand implements CommandInterface
1520
{
1621
/**
@@ -23,19 +28,24 @@ class RegisterCaptureNotificationCommand implements CommandInterface
2328
*/
2429
public function __construct(StatusResolver $statusResolver = null)
2530
{
26-
$this->statusResolver = $statusResolver
27-
? : ObjectManager::getInstance()->get(StatusResolver::class);
31+
$this->statusResolver = $statusResolver ?: ObjectManager::getInstance()->get(StatusResolver::class);
2832
}
2933

3034
/**
35+
* Registers a capture event for this payment
36+
*
3137
* @param OrderPaymentInterface $payment
3238
* @param string|float|int $amount
3339
* @param OrderInterface $order
3440
* @return string
3541
*/
3642
public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order)
3743
{
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+
3949
$status = null;
4050
$message = 'Registered notification about captured amount of %1.';
4151

@@ -61,6 +71,8 @@ public function execute(OrderPaymentInterface $payment, $amount, OrderInterface
6171
}
6272

6373
/**
74+
* Sets the state and status of the order
75+
*
6476
* @deprecated 100.2.0 Replaced by a StatusResolver class call.
6577
*
6678
* @param Order $order

app/code/Magento/Sales/Test/Unit/Model/Order/Payment/State/RegisterCaptureNotificationCommandTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ public function commandResultDataProvider()
8080
$this->newOrderStatus,
8181
'Registered notification about captured amount of %1.',
8282
],
83+
[
84+
false,
85+
false,
86+
Order::STATE_NEW,
87+
Order::STATE_PROCESSING,
88+
$this->newOrderStatus,
89+
'Registered notification about captured amount of %1.',
90+
],
91+
[
92+
false,
93+
false,
94+
Order::STATE_PENDING_PAYMENT,
95+
Order::STATE_PROCESSING,
96+
$this->newOrderStatus,
97+
'Registered notification about captured amount of %1.',
98+
],
8399
[
84100
true,
85101
false,

0 commit comments

Comments
 (0)