public function process() { if ($this->transactionId == null) { return; } if ($this->getUpdateAdapter() === null) { return; } $this->getTransactionHandler()->beginTransaction(); $transactionObject = $this->getTransactionHandler()->findTransactionByTransactionId($this->transactionId); if ($transactionObject == null) { $this->getHandler()->log(Customweb_Util_String::formatString("No transaction found for transaction id '!id'.", array('!id' => $this->transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR); } else { try { $this->getUpdateAdapter()->updateTransaction($transactionObject); $this->getHandler()->log(Customweb_Util_String::formatString("Transaction with id '!id' successful updated.", array('!id' => $this->transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_INFO); } catch (Exception $e) { $this->getHandler()->log($e->getMessage(), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR); } $this->getTransactionHandler()->persistTransactionObject($transactionObject); } $this->getTransactionHandler()->commitTransaction(); }
private function executeUpdate($transactionId) { if (!$this->getTransactionHandler()->isTransactionRunning()) { $this->getTransactionHandler()->beginTransaction(); } $transactionObject = $this->getTransactionHandler()->findTransactionByTransactionId($transactionId); if ($transactionObject == null) { $this->getHandler()->log(Customweb_Util_String::formatString("No transaction found for transaction id '!id'.", array('!id' => $transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR); } else { if ($transactionObject->getUpdateExecutionDate() !== null && $transactionObject->getUpdateExecutionDate()->getTimestamp() <= time()) { // $lastUpdateDate = $transactionObject->getUpdateExecutionDate(); try { if (method_exists($transactionObject, 'setUpdateExecutionDate')) { $transactionObject->setUpdateExecutionDate(null); } $this->getUpdateAdapter()->updateTransaction($transactionObject); $this->getHandler()->log(Customweb_Util_String::formatString("Transaction with id '!id' successful updated.", array('!id' => $transactionId)), Customweb_Payment_Update_IHandler::LOG_TYPE_INFO); } catch (Exception $e) { $this->getHandler()->log($e->getMessage(), Customweb_Payment_Update_IHandler::LOG_TYPE_ERROR); // Reschedule the transaction of the update. // The API should handle all Exceptions. // We catch the unexpected ones, therefore it was a fatal error and we stop // the pulling for this transaction, as it will most likely fail again. // if (method_exists($transactionObject, 'setUpdateExecutionDate')) { // $transactionObject->setUpdateExecutionDate($lastUpdateDate); // } } } $this->getTransactionHandler()->persistTransactionObject($transactionObject); } $this->getTransactionHandler()->commitTransaction(); }