Skip to content

Advance the order state to processing when a capture notification is received #25876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\StatusResolver;

/**
* Class RegisterCaptureNotificationCommand
*
* @package Magento\Sales\Model\Order\Payment\State
*/
class RegisterCaptureNotificationCommand implements CommandInterface
{
/**
Expand All @@ -23,19 +28,24 @@ class RegisterCaptureNotificationCommand implements CommandInterface
*/
public function __construct(StatusResolver $statusResolver = null)
{
$this->statusResolver = $statusResolver
? : ObjectManager::getInstance()->get(StatusResolver::class);
$this->statusResolver = $statusResolver ?: ObjectManager::getInstance()->get(StatusResolver::class);
}

/**
* Registers a capture event for this payment
*
* @param OrderPaymentInterface $payment
* @param string|float|int $amount
* @param OrderInterface $order
* @return string
*/
public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order)
{
$state = $order->getState() ?: Order::STATE_PROCESSING;
$state = $order->getState();
if (!$state || $state === Order::STATE_NEW || $state === Order::STATE_PENDING_PAYMENT) {
$state = Order::STATE_PROCESSING;
}

$status = null;
$message = 'Registered notification about captured amount of %1.';

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

/**
* Sets the state and status of the order
*
* @deprecated 100.2.0 Replaced by a StatusResolver class call.
*
* @param Order $order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public function commandResultDataProvider()
$this->newOrderStatus,
'Registered notification about captured amount of %1.',
],
[
false,
false,
Order::STATE_NEW,
Order::STATE_PROCESSING,
$this->newOrderStatus,
'Registered notification about captured amount of %1.',
],
[
false,
false,
Order::STATE_PENDING_PAYMENT,
Order::STATE_PROCESSING,
$this->newOrderStatus,
'Registered notification about captured amount of %1.',
],
[
true,
false,
Expand Down