Implementation
/**
* Run command
*
* @param OrderPaymentInterface $payment
* @param string|float|int $amount
* @param OrderInterface $order
* @return string
*/
public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order)
{
/**
* @var $payment Payment
*/
$state = Order::STATE_PROCESSING;
$status = false;
$formattedAmount = $order->getBaseCurrency()->formatTxt($amount);
if ($payment->getIsTransactionPending()) {
$message = __(
'An amount of %1 will be captured after being approved at the payment gateway.',
$formattedAmount
);
$state = Order::STATE_PAYMENT_REVIEW;
} else {
$message = __('Registered notification about captured amount of %1.', $formattedAmount);
}
if ($payment->getIsFraudDetected()) {
$state = Order::STATE_PAYMENT_REVIEW;
$message = __(
'Order is suspended as its capture amount %1 is suspected to be fraudulent.',
$formattedAmount
);
$status = Order::STATUS_FRAUD;
}
$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#L886-L890