Passed
Pull Request — master (#58)
by Raúl
04:51 queued 02:05
created
controllers/front/notify.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     private function getPagantisOrderId()
206 206
     {
207 207
         try {
208
-            $this->pagantisOrderId= Db::getInstance()->getValue(
208
+            $this->pagantisOrderId = Db::getInstance()->getValue(
209 209
                 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId
210 210
             );
211 211
 
@@ -278,20 +278,20 @@  discard block
 block discarded – undo
278 278
         $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0];
279 279
         if ($totalAmount != $merchantAmount) {
280 280
             try {
281
-                $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0);
281
+                $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0);
282 282
 
283 283
                 $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount();
284 284
                 $pgTotalAmount = substr_replace(
285 285
                     $pgTotalAmountInCents,
286 286
                     '.',
287
-                    (Tools::strlen($pgTotalAmountInCents) -2),
287
+                    (Tools::strlen($pgTotalAmountInCents) - 2),
288 288
                     0
289 289
                 );
290 290
 
291
-                $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId .
292
-                    ' compared with Pagantis Order: ' . $this->pagantisOrderId .
293
-                    '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' .
294
-                    $pgTotalAmount . ' PLEASE REVIEW THE ORDER';
291
+                $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId.
292
+                    ' compared with Pagantis Order: '.$this->pagantisOrderId.
293
+                    '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '.
294
+                    $pgTotalAmount.' PLEASE REVIEW THE ORDER';
295 295
                 $this->saveLog(array(
296 296
                     'message' => $this->amountMismatchError
297 297
                 ));
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
                 Configuration::get('PS_OS_PAYMENT'),
323 323
                 $this->merchantOrder->getOrderTotal(true),
324 324
                 $this->module->displayName,
325
-                'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' .
326
-                'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() .
327
-                $this->amountMismatchError .
325
+                'pagantisOrderId: '.$this->pagantisOrder->getId().' '.
326
+                'pagantisOrderStatus: '.$this->pagantisOrder->getStatus().
327
+                $this->amountMismatchError.
328 328
                 $metadataInfo,
329 329
                 array('transaction_id' => $this->pagantisOrderId),
330 330
                 null,
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
             $this->orderClient->confirmOrder($this->pagantisOrderId);
348 348
             try {
349 349
                 $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION';
350
-                $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode .
351
-                    '. Pagantis OrderId=' . $this->pagantisOrderId .
352
-                    '. Prestashop OrderId=' . $this->merchantOrderId;
350
+                $message = 'Order CONFIRMED. The order was confirmed by a '.$mode.
351
+                    '. Pagantis OrderId='.$this->pagantisOrderId.
352
+                    '. Prestashop OrderId='.$this->merchantOrderId;
353 353
                 $this->saveLog(array(
354 354
                     'message' => $message
355 355
                 ));
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
             );
397 397
             $resultSeconds = Db::getInstance()->getValue($query);
398 398
             $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0;
399
-            $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
399
+            $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
400 400
 
401 401
             $logMessage = sprintf(
402 402
                 "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             $this->saveLog(array(
409 409
                 'message' => $logMessage
410 410
             ));
411
-            sleep($secondsToExpire+1);
411
+            sleep($secondsToExpire + 1);
412 412
             // After waiting...user continue the confirmation, hoping that previous call have finished.
413 413
             return true;
414 414
         }
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
     {
424 424
         try {
425 425
             if (is_null($orderId)) {
426
-                Db::getInstance()->delete('pagantis_cart_process', 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT));
426
+                Db::getInstance()->delete('pagantis_cart_process', 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT));
427 427
                 return;
428 428
             }
429
-            Db::getInstance()->delete('pagantis_cart_process', 'id = \'' . $this->merchantOrderId . '\'');
429
+            Db::getInstance()->delete('pagantis_cart_process', 'id = \''.$this->merchantOrderId.'\'');
430 430
         } catch (\Exception $exception) {
431
-            var_dump("ha petado el unblock".$exception->getMessage());die;
431
+            var_dump("ha petado el unblock".$exception->getMessage()); die;
432 432
             throw new ConcurrencyException();
433 433
         }
434 434
     }
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
         $data = array(
450 450
             'merchantOrderId' => $this->merchantOrderId,
451 451
             'pagantisOrderId' => $this->pagantisOrderId,
452
-            'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message',
453
-            'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode',
452
+            'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message',
453
+            'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode',
454 454
             'method' => $method,
455 455
             'file' => __FILE__,
456 456
             'line' => $line,
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
             'id_cart' => $this->merchantOrderId,
475 475
             'key' => $this->config['secureKey'],
476 476
             'id_module' => $this->module->id,
477
-            'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null,
477
+            'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null,
478 478
         );
479
-        $url = ($error)? $this->config['urlKO'] : $this->config['urlOK'];
479
+        $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK'];
480 480
         return $this->redirect($url, $parameters);
481 481
     }
482 482
 }
483 483
\ No newline at end of file
Please login to merge, or discard this patch.