processInvoiceOperation = $processInvoiceOperation; parent::__construct( $stateCommand, $transactionBuilder, $transactionManager, $eventManager ); } /** * Captures payment. * * @param OrderPaymentInterface $payment * @param InvoiceInterface|null $invoice * @return OrderPaymentInterface * @throws \Magento\Framework\Exception\LocalizedException */ public function capture(OrderPaymentInterface $payment, $invoice) { /** * @var $payment Payment */ if (null === $invoice) { $invoice = $this->invoice($payment); $payment->setCreatedInvoice($invoice); if ($payment->getIsFraudDetected()) { $payment->getOrder()->setStatus(Order::STATUS_FRAUD); } return $payment; } return $this->processInvoiceOperation->execute($payment, $invoice, 'capture'); } }