private function sendXMLOrder($stack, $id_order)
 {
     //initializes Certissim
     if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
         $order = new Order($id_order);
         $sac = new CertissimSac($order->id_shop);
     } else {
         $sac = new CertissimSac();
     }
     //sends the stream and catches the response
     $res = $sac->sendStacking($stack);
     $validstack = new CertissimValidstackResponse($res->getXML());
     //if an error occured: log
     if ($res === false) {
         //connection to Certissim failed
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "Connexion échoué pour la commande " . (int) $order->id);
         return false;
     }
     if ($validstack->hasFatalError()) {
         //connexion to Certissim failed
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "L'envoi a échoué pour la commande " . (int) $order->id);
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "Retour du script :");
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $res);
         //updates the databse entry
         self::updateCertissimOrder($id_order, array('avancement' => 'error', 'error' => $validstack->getError()));
         //swith the certisism order state to 'error'
         self::switchOrderToState($id_order, 'not concerned');
         return false;
     }
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "---- Retour de Fia-Net pour la commande " . (int) $order->id . " ----");
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "{$res}");
     CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "-----------------------------------------------------------------");
     //updates the order in the certissim table according to the certissim response
     foreach ($validstack->getResults() as $result) {
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "------");
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $result->returnAvancement());
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $result);
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "------");
         switch ($result->returnAvancement()) {
             //if order under analysis:
             case 'encours':
                 //set the avancement to 'encours'
                 self::updateCertissimOrder($id_order, array('avancement' => $result->returnAvancement()));
                 //sets the certissim order state to 'sent'
                 self::switchOrderToState($id_order, 'sent');
                 break;
                 //if an error occured during the analysis
             //if an error occured during the analysis
             case 'error':
                 //updates the databse entry
                 self::updateCertissimOrder($id_order, array('avancement' => $result->returnAvancement(), 'error' => $result->getDetail()));
                 //swith the certisism order state to 'error'
                 self::switchOrderToState($id_order, 'error');
                 break;
             default:
                 CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, 'Avancement ' . $result->returnAvancement() . ' inconnu.');
                 break;
         }
     }
     return true;
 }
 /**
  * gets all reevaluations for the shop specified and updates orders in Certissim table
  * 
  * @param mixed $id_shop, id_shop of the shop concerned, or null if no shop concerned particularly (PS 1.4 or multishop not available)
  */
 private function getReevaluations($id_shop = null)
 {
     //initializes Certissim for the shop specified (id or null)
     $sac = new CertissimSac($id_shop);
     //gets all the reevaulations
     $stack = $sac->getAlert('new');
     $reevals = new CertissimResultResponse($stack->getXML());
     CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, $reevals->returnCount() . " réévaluations trouvées.");
     //log
     //for each reevaluation found
     foreach ($reevals->getTransactions() as $transaction) {
         //update of the order in Certissim table
         $sql = "UPDATE `" . _DB_PREFIX_ . Fianetfraud::CERTISSIM_ORDER_TABLE_NAME . "`\n\t\t\t\tSET `avancement`='" . pSQL($transaction->returnAvancement()) . "', `date`='" . pSQL($transaction->getEvalDate()) . "', `score`='" . pSQL($transaction->getEval()) . "', `detail`='" . pSQL($transaction->getDetail()) . "', `profil`='" . pSQL($transaction->getEvalInfo()) . "'\n\t\t\t\tWHERE `id_order`=" . $transaction->returnRefid();
         $update = Db::getInstance()->execute($sql);
         fianetfraud::switchOrderToState($transaction->returnRefid(), 'scored');
         //log insert result
         if (!$update) {
             CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, 'Erreur de mise à jour de la commande ' . $transaction->returnRefid() . ' : ' . Db::getInstance()->getMsgError());
         } else {
             CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, 'Commande ' . $transaction->returnRefid() . ' réévaluée.');
         }
     }
 }