Passed
Pull Request — master (#26)
by
unknown
04:42
created
catalog/ext/modules/payment/pagantis/notifyController.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -86,22 +86,22 @@  discard block
 block discarded – undo
86 86
             $jsonResponse->setException($exception);
87 87
             $this->insertLog($exception);
88 88
 
89
-            if ($this->extraConfig['PAGANTIS_URL_KO'] =! '') {
89
+            if ($this->extraConfig['PAGANTIS_URL_KO'] = !'') {
90 90
                 $koUrl = $this->extraConfig['PAGANTIS_URL_KO'];
91
-            } else {
91
+            }else {
92 92
                 $koUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false));
93 93
             }
94 94
 
95 95
             if ($this->origin == 'notify') {
96 96
                 $jsonResponse->printResponse();
97
-            } else {
97
+            }else {
98 98
                 if ($exception->getMessage() == AlreadyProcessedException::ERROR_MESSAGE) {
99
-                    if ($this->extraConfig['PAGANTIS_URL_OK']!='') {
99
+                    if ($this->extraConfig['PAGANTIS_URL_OK'] != '') {
100 100
                         $confirmationUrl = $this->extraConfig['PAGANTIS_URL_OK'];
101
-                        $confirmationUrl.="?order_id=$this->merchantOrderId";
102
-                    } else {
101
+                        $confirmationUrl .= "?order_id=$this->merchantOrderId";
102
+                    }else {
103 103
                         $confirmationUrl = trim(tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, '', 'SSL', false));
104
-                        $confirmationUrl.="?order_id=$this->merchantOrderId";
104
+                        $confirmationUrl .= "?order_id=$this->merchantOrderId";
105 105
                     }
106 106
 
107 107
                     header("Location: $confirmationUrl");
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         if ($this->origin == 'notify') {
138 138
             $jsonResponse->printResponse();
139
-        } else {
139
+        }else {
140 140
             return $jsonResponse;
141 141
         }
142 142
     }
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
         try {
214 214
             $this->checkPagantisStatus(array('AUTHORIZED'));
215 215
         } catch (\Exception $e) {
216
-            if ($this->findOscommerceOrderId()!='') {
216
+            if ($this->findOscommerceOrderId() != '') {
217 217
                 throw new AlreadyProcessedException();
218
-            } else {
218
+            }else {
219 219
                 if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
220 220
                     $status = $this->pagantisOrder->getStatus();
221
-                } else {
221
+                }else {
222 222
                     $status = '-';
223 223
                 }
224 224
                 throw new WrongStatusException($status);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     {
234 234
         global $order;
235 235
 
236
-        if ($order->info['order_status']!=='1') {
236
+        if ($order->info['order_status'] !== '1') {
237 237
             throw new AlreadyProcessedException();
238 238
         }
239 239
     }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
265 265
             if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
266 266
                 throw new UnknownException($e->getMessage());
267
-            } else {
267
+            }else {
268 268
                 $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';
269 269
                 $this->insertLog(null, $logMessage);
270 270
             }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                     self::CONCURRENCY_TIMEOUT
323 323
                 );
324 324
                 tep_db_query($query);
325
-            } elseif ($orderId!='') {
325
+            } elseif ($orderId != '') {
326 326
                 $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where id='$orderId'";
327 327
                 tep_db_query($query);
328 328
             }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             if (isset($orderRow['timestamp'])) {
344 344
                 if ($_GET['from'] == 'notify') {
345 345
                     throw new ConcurrencyException();
346
-                } else {
346
+                }else {
347 347
                     $query = sprintf(
348 348
                         "SELECT TIMESTAMPDIFF(SECOND,NOW()-INTERVAL %s SECOND, timestamp) as rest FROM %s %s",
349 349
                         self::CONCURRENCY_TIMEOUT,
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
                     $orderRow = tep_db_fetch_array($resultsSelect);
355 355
                     $resultsSeconds = $orderRow['rest'];
356 356
                     $restSeconds = isset($resultsSeconds) ? ($resultsSeconds) : 0;
357
-                    $secondsToExpire=($restSeconds>self::CONCURRENCY_TIMEOUT)? self::CONCURRENCY_TIMEOUT : $restSeconds;
357
+                    $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
358 358
                     if ($secondsToExpire > 0) {
359 359
                         sleep($secondsToExpire + 1);
360 360
                     }
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
                     $os_order_id = tep_db_fetch_array($resultsSelect);
370 370
                     if (isset($os_order_id['os_order_id'])) {
371 371
                         $redirectUrl = trim(tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, '', 'SSL', false));
372
-                        $redirectUrl.="?order_id=$this->oscommerceOrderId";
373
-                    } else {
372
+                        $redirectUrl .= "?order_id=$this->oscommerceOrderId";
373
+                    }else {
374 374
                         $redirectUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false));
375 375
                     }
376 376
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
                     header("Location: $redirectUrl");
387 387
                     exit;
388 388
                 }
389
-            } else {
389
+            }else {
390 390
                 $query = "INSERT INTO ".TABLE_PAGANTIS_CONCURRENCY." (id) VALUES ('$this->oscommerceOrderId');";
391 391
                 tep_db_query($query);
392 392
             }
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
             if (!$payed) {
417 417
                 if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
418 418
                     $status = $this->pagantisOrder->getStatus();
419
-                } else {
419
+                }else {
420 420
                     $status = '-';
421 421
                 }
422 422
                 throw new WrongStatusException($status);
423 423
             }
424
-        } else {
424
+        }else {
425 425
             throw new OrderNotFoundException();
426 426
         }
427 427
     }
@@ -467,12 +467,12 @@  discard block
 block discarded – undo
467 467
         $metadataInfo = '';
468 468
         foreach ($metadataOrder as $metadataKey => $metadataValue) {
469 469
             if ($metadataKey == 'promotedProduct') {
470
-                $metadataInfo.= "/Producto promocionado = $metadataValue";
470
+                $metadataInfo .= "/Producto promocionado = $metadataValue";
471 471
             }
472 472
         }
473 473
 
474 474
         $comment = "Pagantis id=$this->pagantisOrderId/Via=".ucfirst($this->origin)."/".$metadataInfo;
475
-        $query = "insert into ".TABLE_ORDERS_STATUS_HISTORY ."(comments, orders_id, orders_status_id, customer_notified,
475
+        $query = "insert into ".TABLE_ORDERS_STATUS_HISTORY."(comments, orders_id, orders_status_id, customer_notified,
476 476
         date_added) values ('$comment', ".$insert_id.", '2', -1, now() )";
477 477
         tep_db_query($query);
478 478
 
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
      */
503 503
     private function insertLog($exception = null, $message = null)
504 504
     {
505
-        $logEntry= new LogEntry();
505
+        $logEntry = new LogEntry();
506 506
         if ($exception instanceof \Exception) {
507 507
             $logEntryJson = $logEntry->error($exception)->toJson();
508
-        } else {
508
+        }else {
509 509
             $logEntryJson = $logEntry->info($message)->toJson();
510 510
         }
511 511
             $query = "insert into ".TABLE_PAGANTIS_LOG."(log) values ('$logEntryJson')";
Please login to merge, or discard this patch.