public function findTransactionIdByPaymentId($paymentId) { $transactions = $this->manager->searchByFilterName($this->transactionClassName, 'loadByPaymentId', array('>paymentId' => $paymentId)); if (count($transactions) !== 1) { throw new Exception("Transaction could not be loaded by payment id."); } $transaction = end($transactions); if (!$transaction instanceof Customweb_Payment_Entity_AbstractTransaction) { throw new Exception("Transaction must be of type Customweb_Payment_Entity_AbstractTransaction"); } return $transaction->getTransactionId(); }
/** * This method loads the given entity. The cache flag can be used to by pass the entity * managers cache. * * @param string $space * @param string $key * @param boolean $cache * @return Customweb_Storage_Backend_Database_AbstractKeyEntity */ public function loadEntity($space, $key, $cache = true) { $entities = $this->entityManager->searchByFilterName($this->entityClassName, 'loadByKeyAndSpace', array('>key' => $key, '>space' => $space), $cache); if (count($entities) > 0) { $entity = current($entities); return $entity; } else { return null; } }
public function onAfterLoad(Customweb_Database_Entity_IManager $entityManager) { if ($this->getTransactionObject() !== null && $this->getTransactionObject() instanceof Customweb_Payment_Authorization_ITransaction) { $context = $this->getTransactionObject()->getTransactionContext()->getPaymentCustomerContext(); if ($context instanceof Customweb_Payment_Entity_AbstractPaymentCustomerContext) { $contexts = $entityManager->searchByFilterName(get_class($context), 'loadByCustomerId', array('>customerId' => $this->getCustomerId())); if (count($contexts) > 0) { $currentContext = current($contexts); $context->setCustomerId($currentContext->getCustomerId()); $context->setContextId($currentContext->getContextId()); $context->setStoreMap($currentContext->getStoreMap()); $context->setContext($currentContext->getContext()); } } } }