Exemplo n.º 1
0
 public function checkExecutable($fileName)
 {
     $binFile = Atos::getBinDirectory() . $fileName;
     if (!is_executable($binFile)) {
         throw new FileException($this->getTranslator()->trans("The '%file' should be executable. Please check file permission", ['%file' => $binFile], Atos::MODULE_DOMAIN));
     }
 }
Exemplo n.º 2
0
 public function processAtosRequest()
 {
     $this->getLog()->addInfo($this->getTranslator()->trans("Atos-SIPS platform request received.", [], Atos::MODULE_DOMAIN));
     $binResponse = Atos::getBinDirectory() . 'response';
     if (!empty($_POST['DATA'])) {
         $data = escapeshellcmd($_POST['DATA']);
         $pathfile = Atos::getPathfilePath();
         $resultRaw = exec(sprintf("%s message=%s pathfile=%s", $binResponse, $data, $pathfile));
         if (!empty($resultRaw)) {
             $result = explode('!', $resultRaw);
             $result = $this->parseResult($result);
             $this->getLog()->addInfo($this->getTranslator()->trans('Response parameters : %resp', ['%resp' => print_r($result, true)], Atos::MODULE_DOMAIN));
             if ($result['code'] == '' && $result['error'] == '') {
                 $this->getLog()->addError($this->getTranslator()->trans('Response request not found in %response', ['%response' => $binResponse], Atos::MODULE_DOMAIN));
             } elseif (intval($result['code']) != 0) {
                 $this->getLog()->addError($this->getTranslator()->trans('Error %code while processing response, with message %message', ['%code' => intval($result['code']), '%message' => $result['error']], Atos::MODULE_DOMAIN));
             } elseif ($result['response_code'] == '00') {
                 $atos = new Atos();
                 $order = OrderQuery::create()->filterByTransactionRef($result['transaction_id'])->filterByPaymentModuleId($atos->getModuleModel()->getId())->findOne();
                 if ($order) {
                     $this->confirmPayment($order->getId());
                     $this->getLog()->addInfo($this->getTranslator()->trans("Order ID %id is confirmed.", ['%id' => $order->getId()], Atos::MODULE_DOMAIN));
                 } else {
                     $this->getLog()->addError($this->getTranslator()->trans('Cannot find an order for transaction ID "%trans"', ['%trans' => $result['transaction_id']], Atos::MODULE_DOMAIN));
                 }
             } else {
                 $this->getLog()->addError($this->getTranslator()->trans('Cannot validate order. Response code is %resp', ['%resp' => $result['response_code']], Atos::MODULE_DOMAIN));
             }
         } else {
             $this->getLog()->addError($this->getTranslator()->trans('Got empty response from executable %binary, check path and permissions', ['%binary' => $binResponse], Atos::MODULE_DOMAIN));
         }
     } else {
         $this->getLog()->addError($this->getTranslator()->trans('Request does not contains any data', [], Atos::MODULE_DOMAIN));
     }
     $this->getLog()->info($this->getTranslator()->trans("Atos platform request processing terminated.", [], Atos::MODULE_DOMAIN));
     return Response::create();
 }