Esempio n. 1
0
 /**
  * Find one transaction by ID or type
  *
  * @param string $txnId
  * @param bool|string $txnType
  * @return Transaction|false
  */
 protected function _lookupTransaction($txnId, $txnType = false)
 {
     if (!$txnId) {
         if ($txnType && $this->getId()) {
             $collection = $this->_transactionCollectionFactory->create()->setOrderFilter($this->getOrder())->addPaymentIdFilter($this->getId())->addTxnTypeFilter($txnType)->setOrder('created_at', \Magento\Framework\Data\Collection::SORT_ORDER_DESC)->setOrder('transaction_id', \Magento\Framework\Data\Collection::SORT_ORDER_DESC);
             foreach ($collection as $txn) {
                 $txn->setOrderPaymentObject($this);
                 $this->_transactionsLookup[$txn->getTxnId()] = $txn;
                 return $txn;
             }
         }
         return false;
     }
     if (isset($this->_transactionsLookup[$txnId])) {
         return $this->_transactionsLookup[$txnId];
     }
     $txn = $this->_transactionFactory->create()->setOrderPaymentObject($this)->loadByTxnId($txnId);
     if ($txn->getId()) {
         $this->_transactionsLookup[$txnId] = $txn;
     } else {
         $this->_transactionsLookup[$txnId] = false;
     }
     return $this->_transactionsLookup[$txnId];
 }
Esempio n. 2
0
 /**
  * Parent transaction getter
  * May attempt to load it.
  *
  * @param bool $shouldLoad
  * @return bool|\Magento\Sales\Model\Order\Payment\Transaction
  */
 public function getParentTransaction($shouldLoad = true)
 {
     if (null === $this->_parentTransaction) {
         $this->_verifyThisTransactionExists();
         $this->_parentTransaction = false;
         $parentId = $this->getParentId();
         if ($parentId) {
             $this->_parentTransaction = $this->_transactionFactory->create();
             if ($shouldLoad) {
                 $this->_parentTransaction->setOrderPaymentObject($this->_paymentObject)->load($parentId);
                 if (!$this->_parentTransaction->getId()) {
                     $this->_parentTransaction = false;
                 } else {
                     $this->_parentTransaction->hasChildTransaction(true);
                 }
             }
         }
     }
     return $this->_parentTransaction;
 }
Esempio n. 3
0
 /**
  * Return option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     return $this->_transactionFactory->create()->getTransactionTypes();
 }