diff --git a/extend/application/models/fcPayOneOrder.php b/extend/application/models/fcPayOneOrder.php index 186b05e..6d7ef25 100755 --- a/extend/application/models/fcPayOneOrder.php +++ b/extend/application/models/fcPayOneOrder.php @@ -504,7 +504,15 @@ protected function _fcpoFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder) { $this->_updateOrderDate(); } - $this->_fcpoSetOrderStatus(); + /** + * OX6-160 : This parameter forces the check of DB for appointed TxStatus + * That helps preventing incorrect order status (error) when TxStatus handling finished late, at the wrong moment + */ + $blFcpoRefreshFromDb = true; + $this->_fcpoSetOrderStatus($blFcpoRefreshFromDb); + if ($blFcpoRefreshFromDb) { + $this->save(); + } // store orderid $oBasket->setOrderId($this->getId()); @@ -969,9 +977,9 @@ protected function _fcpoSaveAfterRedirect($blSaveAfterRedirect) * * @return void */ - protected function _fcpoSetOrderStatus() { + protected function _fcpoSetOrderStatus($blFcpoRefreshFromDb = false) { $blIsAmazonPending = $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoAmazonPayOrderIsPending'); - $blOrderOk = $this->_fcpoValidateOrderAgainstProblems(); + $blOrderOk = $this->_fcpoValidateOrderAgainstProblems($blFcpoRefreshFromDb); if ($blIsAmazonPending) { $this->_setOrderStatus('PENDING'); @@ -991,7 +999,12 @@ protected function _fcpoSetOrderStatus() { * @param void * @return bool */ - protected function _fcpoValidateOrderAgainstProblems() { + protected function _fcpoValidateOrderAgainstProblems($blFcpoRefreshFromDb = false) { + + if ($blFcpoRefreshFromDb) { + $this->_fcpoCheckTxid(); + } + $blOrderOk = ( $this->_fcpoGetAppointedError() === false && $this->_blOrderHasProblems === false @@ -1070,6 +1083,9 @@ protected function _fcpoCheckTxid() { $blAppointedError = false; $sTxid = $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoTxid'); + if (!$sTxid) { + $sTxid = $this->oxorder__fcpotxid->value; + } $sTestOxid = ''; if ($sTxid) { @@ -1077,13 +1093,20 @@ protected function _fcpoCheckTxid() $sTestOxid = $this->_oFcpoDb->getOne($sQuery); } + $oLang = $this->_oFcpoHelper->fcpoGetLang(); + $sCurrentRemark = $this->oxorder__oxremark->value; + $sAppointedErrorRemark = $oLang->translateString('FCPO_REMARK_APPOINTED_MISSING'); + $blAppointedRemarkExists = strpos($sCurrentRemark, $sAppointedErrorRemark); if (!$sTestOxid) { $blAppointedError = true; $this->oxorder__oxfolder = new oxField('ORDERFOLDER_PROBLEMS', oxField::T_RAW); - $oLang = $this->_oFcpoHelper->fcpoGetLang(); - $sCurrentRemark = $this->oxorder__oxremark->value; - $sAddErrorRemark = $oLang->translateString('FCPO_REMARK_APPOINTED_MISSING'); - $sNewRemark = $sCurrentRemark." ".$sAddErrorRemark; + if ($blAppointedRemarkExists === false) { + $sNewRemark = $sCurrentRemark." ".$sAppointedErrorRemark; + $this->oxorder__oxremark = new oxField($sNewRemark, oxField::T_RAW); + } + } else { + $this->oxorder__oxfolder = new oxField('ORDERFOLDER_NEW', oxField::T_RAW); + $sNewRemark = str_replace($sAppointedErrorRemark, '', $sCurrentRemark); $this->oxorder__oxremark = new oxField($sNewRemark, oxField::T_RAW); } $this->_fcpoSetAppointedError($blAppointedError);