@param int $idSalesOrder
@param int $idSalesOrderItem
@param string $status

@return \Orm\Zed\Payone\Persistence\SpyPaymentPayoneTransactionStatusLog|null
177890
protected function getFirstUnprocessedTransactionStatusLog($idSalesOrder, $idSalesOrderItem, $status)
    {
        $transactionStatusLogs = $this->getUnprocessedTransactionStatusLogs($idSalesOrder, $idSalesOrderItem);

        if (empty($transactionStatusLogs)) {
            return null;
        }

        while (count($transactionStatusLogs)) {
            /** @var \Orm\Zed\Payone\Persistence\SpyPaymentPayoneTransactionStatusLog $transactionStatusLog */
            $transactionStatusLog = array_shift($transactionStatusLogs);

            if ($transactionStatusLog->getStatus() == $status) {
                return $transactionStatusLog;
            }
        }

        return null;
    }
679121
private function addStatusToOrder($id, $status)
    {
        $order = $this->_order->load($id);
        $order->addStatusToHistory($this->getStatusFromPaymentKey($status), null, true);
        $order->save();
    }
360133
public function updateStatusBatch(string $openid, string $status, array $list): array
    {
        return $this->httpClient->postJson('card/invoice/reimburse/updatestatusbatch', [
            'openid' => $openid,
            'reimburse_status' => $status,
            'invoice_list' => $list
        ]);
    }
527688
protected function hasPaymentWithStatus($status)
    {
        $hasStatus = false;
        $payments = $this->getArray();

        foreach ($payments as $payment) {
            if ($status == $payment->getStatus()) {
                $hasStatus = true;
                break;
            }
        }

        return $hasStatus;
    }
806335
public function isPaymentOther($idSalesOrder, $idSalesOrderItem)
    {
        $statusLogs = $this->getUnprocessedTransactionStatusLogs($idSalesOrder, $idSalesOrderItem);
        if (empty($statusLogs)) {
            return false;
        }

        /** @var \Orm\Zed\Payone\Persistence\SpyPaymentPayoneTransactionStatusLog $statusLog */
        $statusLog = array_shift($statusLogs);

        $statuses = [
            PayoneTransactionStatusConstants::TXACTION_PAID,
            PayoneTransactionStatusConstants::TXACTION_APPOINTED,
            PayoneTransactionStatusConstants::TXACTION_UNDERPAID,
        ];
        if (in_array($statusLog->getStatus(), $statuses)) {
            return false;
        }

        $this->saveSpyPaymentPayoneTransactionStatusLogOrderItem($idSalesOrderItem, $statusLog);

        return true;
    }
1138044
public function getOrderReference(TransactionInterface $transaction)
    {
        $order = $transaction->get('order', null);

        if ($this->getLogger()) {
            $this->getLogger()->notice(sprintf('[BasePaypalPayment::loadOrder] order=%s', $order));
        }

        return $order;
    }
1317810
public function preAuthorizePayment($idSalesOrder)
    {
        $paymentEntity = $this->getPaymentEntity($idSalesOrder);
        $paymentMethodMapper = $this->getPaymentMethodMapper($paymentEntity);
        $requestContainer = $paymentMethodMapper->mapPaymentToPreAuthorization($paymentEntity);
        $responseContainer = $this->performAuthorizationRequest($paymentEntity, $requestContainer);

        $responseMapper = new AuthorizationResponseMapper();
        $responseTransfer = $responseMapper->getAuthorizationResponseTransfer($responseContainer);

        return $responseTransfer;
    }
125824
public function depositReversal($iOrderNumber, $iPaymentNumber)
    {
        $this->_requestData[self::COMMAND] = self::$COMMAND_DEPOSIT_REVERSAL;

        $this->_setField(self::ORDER_NUMBER, $iOrderNumber);
        $this->_setField(self::PAYMENT_NUMBER, $iPaymentNumber);

        $this->_fingerprintOrder->setOrder(Array(
            self::CUSTOMER_ID,
            self::SHOP_ID,
            self::TOOLKIT_PASSWORD,
            self::SECRET,
            self::COMMAND,
            self::LANGUAGE,
            self::ORDER_NUMBER,
            self::PAYMENT_NUMBER
        ));

        return new WirecardCEE_QPay_Response_Toolkit_DepositReversal($this->_send());
    }
1142528
public function check(SpySalesOrderItem $orderItem)
    {
        $result = $this->getFacade()
            ->isPaymentNotificationAvailable($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());

        return $result;
    }
642582
protected function triggerEventsOnSuccess(PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer)
    {
        if (!$transactionStatusUpdateTransfer->getIsSuccess()) {
            return;
        }

        $orderItems = SpySalesOrderItemQuery::create()
            ->useOrderQuery()
            ->useSpyPaymentPayoneQuery()
            ->filterByTransactionId($transactionStatusUpdateTransfer->getTxid())
            ->endUse()
            ->endUse()
            ->find();
        $this->getFactory()->getOmsFacade()->triggerEvent('PaymentNotificationReceived', $orderItems, []);

        if ($transactionStatusUpdateTransfer->getTxaction() === PayoneConstants::PAYONE_TXACTION_APPOINTED) {
            $this->getFactory()->getOmsFacade()->triggerEvent('RedirectResponseAppointed', $orderItems, []);
        }
    }
1370977
protected function _setOrderTransactionErrorStatus(oxOrder $oOrder, stdClass $oData, $sStatus = null)
    {
        if (isset($oData->Error->Code) && (bool) $oData->Error->Code !== false) {
            if ($sStatus === null) {
                $sStatus = 'AMZ-Error-'.$oData->Error->Code;
            }

            $oOrder->assign(array('oxtransstatus' => $sStatus));
            $oOrder->save();

            return true;
        }

        return false;
    }
735640
public function createLastApiLogsByOrderId($idSalesOrder)
    {
        $query = $this->getFactory()->createPaymentPayoneApiLogQuery()
            ->useSpyPaymentPayoneQuery()
            ->filterByFkSalesOrder($idSalesOrder)
            ->endUse()
            ->orderByCreatedAt(Criteria::DESC)
            ->orderByIdPaymentPayoneApiLog(Criteria::DESC);

        return $query;
    }
420457
public function findByStatusIdAndUser($locale, $statusId, $user, $limit = null)
    {
        return $this->orderRepository->findByStatusIdAndUser(
            $locale,
            $statusId,
            $user,
            $limit
        );
    }
1300950
public function getPaymentState($orderIndex = 0)
    {
        $paymentAmountInfo = $this->getPaymentAmountInfo($orderIndex);
        return array_key_exists('paymentState', $paymentAmountInfo) ? $paymentAmountInfo['paymentState'] : null;
    }
769029
protected function _setOrderStatus($status)
    {
        $paymentTypeObject = $this->getPaymentType();
        $paymentType = $paymentTypeObject ? $paymentTypeObject->getFieldData('oxpaymentsid') : null;
        if ($paymentType != 'oxidpaypal' || $status != self::OEPAYPAL_TRANSACTION_STATUS_OK) {
            parent::_setOrderStatus($status);
        }
    }
269553
private function resolvePaymentsState(OrderInterface $order)
    {
        $capturedTotal = $authorizedTotal = $refundTotal = $failedTotal = 0;

        $payments = $order->getPayments();
        if (0 < $payments->count()) {
            // Gather state amounts
            foreach ($payments as $payment) {
                if ($payment->getState() == PaymentStates::STATE_CAPTURED) {
                    $capturedTotal += $payment->getAmount();
                } else if ($payment->getState() == PaymentStates::STATE_AUTHORIZED) {
                    $authorizedTotal += $payment->getAmount();
                } else if ($payment->getState() == PaymentStates::STATE_REFUNDED) {
                    $refundTotal += $payment->getAmount();
                } else if ($payment->getState() == PaymentStates::STATE_FAILED) {
                    $failedTotal += $payment->getAmount();
                }
            }

            // State by amounts
            if ($capturedTotal >= $order->getAtiTotal()) {
                return PaymentStates::STATE_CAPTURED;
            } elseif ($authorizedTotal + $capturedTotal >= $order->getAtiTotal()) {
                return PaymentStates::STATE_AUTHORIZED;
            } elseif ($refundTotal >= $order->getAtiTotal()) {
                return PaymentStates::STATE_REFUNDED;
            } elseif ($failedTotal >= $order->getAtiTotal()) {
                return PaymentStates::STATE_FAILED;
            }

            // Check for offline pending payment
            foreach ($payments as $payment) {
                if (in_array($payment->getState(), [PaymentStates::STATE_PENDING, PaymentStates::STATE_PENDING])
                    && $payment->getMethod()->getFactoryName() === 'offline') {
                    return PaymentStates::STATE_PENDING;
                }
            }
        }

        return PaymentStates::STATE_NEW;
    }
561863
public function getNotifications(AccountInterface $account, array $status = [ACTIVITY_STATUS_RECEIVED]) {
    $ids = $this->getNotificationIds($account, $status);

    return $ids;
  }