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;
     }
 }
예제 #2
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);
 }
예제 #3
0
 public function write($space, $key, $value)
 {
     $entity = $this->loadEntity($space, $key, false);
     if ($entity === null) {
         $className = $this->entityClassName;
         $entity = new $className();
     }
     $entity->setKeyName($key)->setKeySpace($space)->setKeyValue($value);
     $this->entityManager->persist($entity);
 }
 /**
  * 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
             }
         }
     }
 }
 public function persistTransactionObject($transactionId, Customweb_Payment_Authorization_ITransaction $transactionObject)
 {
     $transaction = $this->loadTransaction($transactionId)->setTransactionObject($transactionObject);
     $this->manager->persist($transaction);
 }