Passed
Pull Request — master (#59)
by Raúl
03:53 queued 30s
created
controllers/front/payment.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
     {
29 29
         if (_PS_VERSION_ < 1.6) {
30 30
             Logger::addLog(
31
-                'Pagantis Exception For user ' .
32
-                $customer->email .
33
-                ' : ' .
31
+                'Pagantis Exception For user '.
32
+                $customer->email.
33
+                ' : '.
34 34
                 $exception->getMessage(),
35 35
                 3,
36 36
                 $exception->getCode(),
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
             );
41 41
         } else {
42 42
             PrestaShopLogger::addLog(
43
-                'Pagantis Exception For user ' .
44
-                $customer->email .
45
-                ' : ' .
43
+                'Pagantis Exception For user '.
44
+                $customer->email.
45
+                ' : '.
46 46
                 $exception->getMessage(),
47 47
                 3,
48 48
                 $exception->getCode(),
@@ -104,24 +104,24 @@  discard block
 block discarded – undo
104 104
         );
105 105
 
106 106
         try {
107
-            $userAddress =  new \Pagantis\OrdersApiClient\Model\Order\User\Address();
107
+            $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
108 108
             $userAddress
109 109
                 ->setZipCode($shippingAddress->postcode)
110
-                ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname)
110
+                ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname)
111 111
                 ->setCountryCode($this->language)
112 112
                 ->setCity($shippingAddress->city)
113
-                ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2)
113
+                ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2)
114 114
                 ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress))
115 115
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
116 116
             ;
117 117
 
118
-            $orderShippingAddress =  new \Pagantis\OrdersApiClient\Model\Order\User\Address();
118
+            $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
119 119
             $orderShippingAddress
120 120
                 ->setZipCode($shippingAddress->postcode)
121
-                ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname)
121
+                ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname)
122 122
                 ->setCountryCode($this->language)
123 123
                 ->setCity($shippingAddress->city)
124
-                ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2)
124
+                ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2)
125 125
                 ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress))
126 126
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
127 127
                 ->setFixPhone($shippingAddress->phone)
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
             $orderBillingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
132 132
             $orderBillingAddress
133 133
                 ->setZipCode($billingAddress->postcode)
134
-                ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname)
134
+                ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname)
135 135
                 ->setCountryCode($this->language)
136 136
                 ->setCity($billingAddress->city)
137
-                ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2)
137
+                ->setAddress($billingAddress->address1.' '.$billingAddress->address2)
138 138
                 ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress))
139 139
                 ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress))
140 140
                 ->setFixPhone($billingAddress->phone)
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
155 155
             ;
156 156
 
157
-            if ($customer->birthday!='0000-00-00') {
157
+            if ($customer->birthday != '0000-00-00') {
158 158
                 $orderUser->setDateOfBirth($customer->birthday);
159 159
             }
160 160
 
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
                     ->setQuantity($item['quantity'])
189 189
                     ->setDescription($item['name']);
190 190
                 if ($promotedProduct) {
191
-                    $promotedAmount+=$product->getAmount();
191
+                    $promotedAmount += $product->getAmount();
192 192
                     $productId = $item['id_product'];
193 193
                     $finalPrice = Product::getPriceStatic($productId);
194
-                    $promotedMessage = 'Promoted Item: ' . $product->getDescription() .
195
-                         ' Price: ' . $finalPrice .
196
-                         ' Qty: ' . $product->getQuantity() .
197
-                         ' Item ID: ' . $item['id_product'];
194
+                    $promotedMessage = 'Promoted Item: '.$product->getDescription().
195
+                         ' Price: '.$finalPrice.
196
+                         ' Qty: '.$product->getQuantity().
197
+                         ' Item ID: '.$item['id_product'];
198 198
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
199 199
                 }
200 200
                 $details->addProduct($product);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
             Tools::redirect($cancelUrl);
245 245
         }
246 246
 
247
-        $url ='';
247
+        $url = '';
248 248
         try {
249 249
             $orderClient = new \Pagantis\OrdersApiClient\Client(
250 250
                 $pagantisPublicKey,
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
             if ($order instanceof \Pagantis\OrdersApiClient\Model\Order) {
256 256
                 $url = $order->getActionUrls()->getForm();
257 257
                 $orderId = $order->getId();
258
-                $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`, `ps_order_id`)
258
+                $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`, `ps_order_id`)
259 259
                      VALUES ('$cart->id','$orderId', null) 
260 260
                      ON DUPLICATE KEY UPDATE `order_id` = '$orderId'";
261 261
                 $result = Db::getInstance()->execute($sql);
262 262
                 if (!$result) {
263
-                    throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql);
263
+                    throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql);
264 264
                 }
265 265
             } else {
266 266
                 throw new OrderNotFoundException();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
         if (count($langArray) != 2 && isset($lang['locale'])) {
360 360
             $langArray = explode("-", $lang['locale']);
361 361
         }
362
-        $this->language = Tools::strtoupper($langArray[count($langArray)-1]);
362
+        $this->language = Tools::strtoupper($langArray[count($langArray) - 1]);
363 363
         // Prevent null language detection
364 364
         $this->language = ($this->language) ? $this->language : 'ES';
365 365
     }
Please login to merge, or discard this patch.
controllers/front/notify.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     private function getPagantisOrderId()
208 208
     {
209 209
         try {
210
-            $this->pagantisOrderId= Db::getInstance()->getValue(
210
+            $this->pagantisOrderId = Db::getInstance()->getValue(
211 211
                 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId
212 212
             );
213 213
 
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
         $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0];
270 270
         if ($totalAmount != $merchantAmount) {
271 271
             try {
272
-                $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0);
272
+                $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0);
273 273
 
274 274
                 $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount();
275 275
                 $pgTotalAmount = substr_replace(
276 276
                     $pgTotalAmountInCents,
277 277
                     '.',
278
-                    (Tools::strlen($pgTotalAmountInCents) -2),
278
+                    (Tools::strlen($pgTotalAmountInCents) - 2),
279 279
                     0
280 280
                 );
281 281
 
282
-                $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId .
283
-                    ' compared with Pagantis Order: ' . $this->pagantisOrderId .
284
-                    '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' .
285
-                    $pgTotalAmount . ' PLEASE REVIEW THE ORDER';
282
+                $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId.
283
+                    ' compared with Pagantis Order: '.$this->pagantisOrderId.
284
+                    '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '.
285
+                    $pgTotalAmount.' PLEASE REVIEW THE ORDER';
286 286
                 $this->saveLog(array(
287 287
                     'message' => $this->amountMismatchError
288 288
                 ));
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
             }
306 306
 
307 307
             // Double check
308
-            $tableName = _DB_PREFIX_ . 'pagantis_order';
309
-            $sql = ('select ps_order_id from `' . $tableName . '` where `id` = ' . $this->merchantOrderId
310
-                . ' and `order_id` = \'' . $this->pagantisOrderId . '\''
308
+            $tableName = _DB_PREFIX_.'pagantis_order';
309
+            $sql = ('select ps_order_id from `'.$tableName.'` where `id` = '.$this->merchantOrderId
310
+                . ' and `order_id` = \''.$this->pagantisOrderId.'\''
311 311
                 . ' and `ps_order_id` is not null');
312 312
             $results = Db::getInstance()->ExecuteS($sql);
313 313
             if (is_array($results) && count($results) === 1) {
314
-                throw new WrongStatusException('PS->record found in ' . $tableName . ': already_processed');
314
+                throw new WrongStatusException('PS->record found in '.$tableName.': already_processed');
315 315
             }
316 316
         } catch (\Exception $exception) {
317 317
             throw new UnknownException($exception->getMessage());
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
                 Configuration::get('PS_OS_PAYMENT'),
341 341
                 $this->merchantOrder->getOrderTotal(true),
342 342
                 $this->module->displayName,
343
-                'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' .
344
-                'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() .
345
-                $this->amountMismatchError .
343
+                'pagantisOrderId: '.$this->pagantisOrder->getId().' '.
344
+                'pagantisOrderStatus: '.$this->pagantisOrder->getStatus().
345
+                $this->amountMismatchError.
346 346
                 $metadataInfo,
347 347
                 array('transaction_id' => $this->pagantisOrderId),
348 348
                 null,
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             Db::getInstance()->update(
357 357
                 'pagantis_order',
358 358
                 array('ps_order_id' => $this->module->currentOrder),
359
-                'id = \''. $this->merchantOrderId . '\' and order_id = \'' . $this->pagantisOrderId . '\''
359
+                'id = \''.$this->merchantOrderId.'\' and order_id = \''.$this->pagantisOrderId.'\''
360 360
             );
361 361
         } catch (\Exception $exception) {
362 362
             // Do nothing
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
             $this->orderClient->confirmOrder($this->pagantisOrderId);
375 375
             try {
376 376
                 $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION';
377
-                $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode .
378
-                    '. Pagantis OrderId=' . $this->pagantisOrderId .
379
-                    '. Prestashop OrderId=' . $this->module->currentOrder;
377
+                $message = 'Order CONFIRMED. The order was confirmed by a '.$mode.
378
+                    '. Pagantis OrderId='.$this->pagantisOrderId.
379
+                    '. Prestashop OrderId='.$this->module->currentOrder;
380 380
                 $this->saveLog(array(
381 381
                     'message' => $message
382 382
                 ));
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             );
424 424
             $resultSeconds = Db::getInstance()->getValue($query);
425 425
             $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0;
426
-            $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
426
+            $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
427 427
 
428 428
             $logMessage = sprintf(
429 429
                 "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
             $this->saveLog(array(
436 436
                 'message' => $logMessage
437 437
             ));
438
-            sleep($secondsToExpire+1);
438
+            sleep($secondsToExpire + 1);
439 439
             // After waiting...user continue the confirmation, hoping that previous call have finished.
440 440
             return true;
441 441
         }
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
             if (is_null($orderId)) {
453 453
                 Db::getInstance()->delete(
454 454
                     'pagantis_cart_process',
455
-                    'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT
455
+                    'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT
456 456
                     )
457 457
                 );
458 458
                 return;
459 459
             }
460
-            Db::getInstance()->delete('pagantis_cart_process', 'id = \'' . $orderId . '\'');
460
+            Db::getInstance()->delete('pagantis_cart_process', 'id = \''.$orderId.'\'');
461 461
         } catch (\Exception $exception) {
462 462
             throw new ConcurrencyException();
463 463
         }
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
         $data = array(
480 480
             'merchantOrderId' => $this->merchantOrderId,
481 481
             'pagantisOrderId' => $this->pagantisOrderId,
482
-            'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message',
483
-            'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode',
482
+            'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message',
483
+            'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode',
484 484
             'method' => $method,
485 485
             'file' => __FILE__,
486 486
             'line' => $line,
@@ -504,9 +504,9 @@  discard block
 block discarded – undo
504 504
             'id_cart' => $this->merchantOrderId,
505 505
             'key' => $this->config['secureKey'],
506 506
             'id_module' => $this->module->id,
507
-            'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null,
507
+            'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null,
508 508
         );
509
-        $url = ($error)? $this->config['urlKO'] : $this->config['urlOK'];
509
+        $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK'];
510 510
         return $this->redirect($url, $parameters);
511 511
     }
512 512
 }
513 513
\ No newline at end of file
Please login to merge, or discard this patch.