/** * {@inheritdoc} */ public function getAuthorizationTransaction($parentTransactionId, $paymentId, $orderId) { $transaction = false; if ($parentTransactionId) { $transaction = $this->transactionRepository->getByTransactionId($parentTransactionId, $paymentId, $orderId); } return $transaction ?: $this->transactionRepository->getByTransactionType(Transaction::TYPE_AUTH, $paymentId, $orderId); }
/** * Check order payment capture action availability * * @return bool */ public function canCapture() { if (!$this->getMethodInstance()->canCapture()) { return false; } // Check Authorization transaction state $authTransaction = $this->getAuthorizationTransaction(); if ($authTransaction && $authTransaction->getIsClosed()) { $orderTransaction = $this->transactionRepository->getByTransactionType(Transaction::TYPE_ORDER, $this->getId(), $this->getOrder()->getId()); if (!$orderTransaction) { return false; } } return true; }
/** * Get transaction with type order * * @param OrderPaymentInterface $payment * * @return false|\Magento\Sales\Api\Data\TransactionInterface */ protected function getOrderTransaction($payment) { return $this->transactionRepository->getByTransactionType(Transaction::TYPE_ORDER, $payment->getId(), $payment->getOrder()->getId()); }