コード例 #1
0
 public function onBeforeSave(Customweb_Database_Entity_IManager $entityManager)
 {
     if ($this->getContextId() !== null) {
         $currentContext = $entityManager->fetch(get_class($this), $this->getContextId());
         $newMap = $this->context->applyUpdatesOnMap($currentContext->getMap());
         $this->setStoreMap($newMap);
     } else {
         $this->setStoreMap($this->context->getMap());
     }
 }
コード例 #2
0
 public function cleanUp()
 {
     $maxEndtime = Customweb_Core_Util_System::getScriptExecutionEndTime() - 4;
     $where = '(updatedOn < NOW() - INTERVAL 2 MONTH AND authorizationStatus = "' . Customweb_Payment_Authorization_ITransaction::AUTHORIZATION_STATUS_FAILED . '") OR (updatedOn < NOW() - INTERVAL 6 MONTH AND authorizationStatus = "' . Customweb_Payment_Authorization_ITransaction::AUTHORIZATION_STATUS_PENDING . '" ) OR (updatedOn < NOW() - INTERVAL 1 MONTH AND (authorizationStatus = "" OR authorizationStatus IS NULL )) LIMIT 0,40';
     $removable = $this->manager->searchPrimaryKey($this->transactionClassName, $where);
     foreach ($removable as $remove) {
         if ($maxEndtime > time()) {
             $this->manager->removeByPrimaryKey($this->transactionClassName, $remove);
         } else {
             break;
         }
     }
 }
コード例 #3
0
 public function cleanUp()
 {
     $maxEndtime = Customweb_Core_Util_System::getScriptExecutionEndTime() - 4;
     // Remove all contexts which are not changed in the last 2 days and the state is not completed.
     $where = 'updatedOn < NOW() - INTERVAL 2 DAY AND state != "completed" LIMIT 0,40';
     $entities = $this->entityManager->search($this->contextEntityName, $where);
     foreach ($entities as $entity) {
         if ($maxEndtime > time()) {
             $this->entityManager->remove($entity);
         } else {
             break;
         }
     }
 }
コード例 #4
0
 public function createOrder(Customweb_Payment_ExternalCheckout_IContext $context)
 {
     if (!$context instanceof Customweb_Payment_ExternalCheckout_AbstractContext) {
         throw new Customweb_Core_Exception_CastException('Customweb_Payment_ExternalCheckout_AbstractContext');
     }
     try {
         if ($context->getState() == Customweb_Payment_ExternalCheckout_IContext::STATE_COMPLETED) {
             $transcationId = $context->getTransactionId();
             if (empty($transcationId)) {
                 throw new Exception("Invalid state. The context can not be in state COMPLETED without transaction id set.");
             }
             return $this->getTransactionHandler()->findTransactionByTransactionId($transcationId);
         } else {
             if ($context->getState() == Customweb_Payment_ExternalCheckout_IContext::STATE_FAILED) {
                 throw new Exception("A failed context cannot be completed.");
             }
         }
         $this->checkContextCompleteness($context);
         $this->getTransactionHandler()->beginTransaction();
         $transactionContext = $this->createTransactionContextFromContext($context);
         $transactionObject = $this->getProviderService()->createTransaction($transactionContext, $context);
         $this->getTransactionHandler()->persistTransactionObject($transactionObject);
         $context->setTransactionId($transactionObject->getTransactionContext()->getTransactionId());
         $context->setState(Customweb_Payment_ExternalCheckout_IContext::STATE_COMPLETED);
         $this->entityManager->persist($context);
         $this->getTransactionHandler()->commitTransaction();
         return $transactionObject;
     } catch (Exception $e) {
         if ($this->getTransactionHandler()->isTransactionRunning()) {
             $this->getTransactionHandler()->rollbackTransaction();
         }
         throw $e;
     }
 }
コード例 #5
0
 protected function loadTransaction($transactionId)
 {
     $transaction = $this->manager->fetch($this->transactionClassName, $transactionId);
     if (!$transaction instanceof Customweb_Payment_Entity_AbstractTransaction) {
         throw new Exception("Transaction must be of type Customweb_Payment_Entity_AbstractTransaction");
     }
     return $transaction;
 }
コード例 #6
0
 /**
  * Deactivates the alias. It is not selected anymore by getAliasTransactions().
  *
  * @param int $transactionId
  * @throws Exception
  */
 public function deactivateAlias($transactionId)
 {
     $transaction = $this->manager->fetch($this->transactionClassName, $transactionId);
     if (!$transaction instanceof Customweb_Payment_Entity_AbstractTransaction) {
         throw new Exception("Transaction must be of type Customweb_Payment_Entity_AbstractTransaction");
     }
     $transaction->setAliasActive(false);
     $this->manager->persist($transaction);
 }
コード例 #7
0
 /**
  * Subclasses which overwrite this method must make sure they check the isSkipOnSafeMethods flag and act accordingly
  * It's recommend that the subclass resets the setSkipOnSaveMethods flag, if it does not call the parent method
  * 
  * @param Customweb_Database_Entity_IManager $entityManager
  */
 public function onAfterSave(Customweb_Database_Entity_IManager $entityManager)
 {
     if ($this->isSkipOnSafeMethods()) {
         $this->setSkipOnSaveMethods(false);
         true;
     }
     if ($this->getTransactionObject() !== null && $this->getTransactionObject() instanceof Customweb_Payment_Authorization_ITransaction) {
         $paymentCustomerContext = $this->getTransactionObject()->getTransactionContext()->getPaymentCustomerContext();
         if ($paymentCustomerContext instanceof Customweb_Payment_Entity_AbstractPaymentCustomerContext) {
             try {
                 $paymentCustomerContext->setCustomerId($this->getCustomerId());
                 $entityManager->persist($paymentCustomerContext);
             } catch (Exception $e) {
                 // Ignore
             }
         }
     }
 }
コード例 #8
0
 /**
  * Returns the schema to use this storage backend. The resulting SQL string must be
  * executed prior to use this backend.
  *
  * @return string
  */
 public function generateSchema()
 {
     return $this->entityManager->generateEntitySchema($this->entityClassName);
 }