How is \Magento\Sales\Model\Order\Payment\State\OrderCommand::execute() implemented and used?

Implementation

ffea3cd/app/code/Magento/Sales/Model/Order/Payment/State/OrderCommand.php#L17-L45

/**
 * Run command
 *
 * @param OrderPaymentInterface $payment
 * @param string|float|int $amount
 * @param OrderInterface $order
 * @return string
 */
public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order)
{
	$state = Order::STATE_PROCESSING;
	$status = false;
	$formattedAmount = $order->getBaseCurrency()->formatTxt($amount);
	if ($payment->getIsTransactionPending()) {
		$message = __(
			'The order amount of %1 is pending approval on the payment gateway.',
			$formattedAmount
		);
		$state = Order::STATE_PAYMENT_REVIEW;
		if ($payment->getIsFraudDetected()) {
			$status = Order::STATUS_FRAUD;
		}
	} else {
		$message = __('Ordered amount of %1', $formattedAmount);
	}
	$this->setOrderStateAndStatus($order, $status, $state);
	return $message;
}

Details:

The single usage

https://github.com/magento/magento2/blob/ffea3cd/app/code/Magento/Sales/etc/di.xml#L881-L885

See also: