/** * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus * @throws Payone_Core_Exception_OrderNotFound */ public function execute(Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus) { $order = $this->getFactory()->getModelSalesOrder(); $order->loadByIncrementId($transactionStatus->getReference()); if (!$order->hasData()) { throw new Payone_Core_Exception_OrderNotFound('Reference "' . $transactionStatus->getReference() . '"."'); } // Secondary validation: is Transaction Id correct? $payment = $order->getPayment(); $lastTxId = $payment->getLastTransId(); if ($lastTxId != $transactionStatus->getTxid()) { return; // Don´t throw an exception, just abort processing. } $config = $this->helperConfig()->getConfigStore($order->getStoreId()); $transactionStatus->setStoreId($order->getStoreId()); $transactionStatus->setOrderId($order->getId()); // Update Transaction $transaction = $this->getServiceTransaction()->updateByTransactionStatus($transactionStatus); // Update Order Status $this->getServiceOrderStatus()->setConfigStore($config); $this->getServiceOrderStatus()->updateByTransactionStatus($order, $transactionStatus); // Add Order Comment $this->getServiceOrderComment()->addByTransactionStatus($order, $transactionStatus); // Store Clearing Parameters (needs to be done before the events get triggered) $this->getServiceStoreClearingParams()->execute($transactionStatus, $order); // Save before Event is triggerd $resouce = $this->getFactory()->getModelResourceTransaction(); $resouce->addObject($order); $resouce->addObject($transactionStatus); $resouce->save(); // Trigger Event $params = array(self::EVENT_PARAMETER_TRANSACTIONSTATUS => $transactionStatus, self::EVENT_PARAMETER_TRANSACTION => $transaction, self::EVENT_PARAMETER_CONFIG => $config); $this->dispatchEvent(self::EVENT_NAME_PREFIX . self::EVENT_NAME_ALL, $params); $this->dispatchEvent(self::EVENT_NAME_PREFIX . $transactionStatus->getTxaction(), $params); }