Passed
Pull Request — master (#57)
by Raúl
05:01
created
controllers/front/payment.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
         $pagantisPublicKey = Configuration::get('pagantis_public_key');
89 89
         $pagantisPrivateKey = Configuration::get('pagantis_private_key');
90 90
         $okUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__
91
-                 .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&'
92
-                 .http_build_query($query)
91
+                    .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&'
92
+                    .http_build_query($query)
93 93
         ;
94 94
 
95 95
         $shippingAddress = new Address($cart->id_address_delivery);
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
                     $productId = $item['id_product'];
193 193
                     $finalPrice = Product::getPriceStatic($productId);
194 194
                     $promotedMessage = 'Promoted Item: ' . $product->getDescription() .
195
-                         ' Price: ' . $finalPrice .
196
-                         ' Qty: ' . $product->getQuantity() .
197
-                         ' Item ID: ' . $item['id_product'];
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);
Please login to merge, or discard this 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`)
258
+                $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`)
259 259
                      VALUES ('$cart->id','$orderId') 
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   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     private function getPagantisOrderId()
205 205
     {
206 206
         try {
207
-            $this->pagantisOrderId= Db::getInstance()->getValue(
207
+            $this->pagantisOrderId = Db::getInstance()->getValue(
208 208
                 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId
209 209
             );
210 210
 
@@ -277,20 +277,20 @@  discard block
 block discarded – undo
277 277
         $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0];
278 278
         if ($totalAmount != $merchantAmount) {
279 279
             try {
280
-                $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0);
280
+                $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0);
281 281
 
282 282
                 $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount();
283 283
                 $pgTotalAmount = substr_replace(
284 284
                     $pgTotalAmountInCents,
285 285
                     '.',
286
-                    (Tools::strlen($pgTotalAmountInCents) -2),
286
+                    (Tools::strlen($pgTotalAmountInCents) - 2),
287 287
                     0
288 288
                 );
289 289
 
290
-                $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId .
291
-                    ' compared with Pagantis Order: ' . $this->pagantisOrderId .
292
-                    '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' .
293
-                    $pgTotalAmount . ' PLEASE REVIEW THE ORDER';
290
+                $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId.
291
+                    ' compared with Pagantis Order: '.$this->pagantisOrderId.
292
+                    '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '.
293
+                    $pgTotalAmount.' PLEASE REVIEW THE ORDER';
294 294
                 $this->saveLog(array(
295 295
                     'message' => $this->amountMismatchError
296 296
                 ));
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
                 Configuration::get('PS_OS_PAYMENT'),
322 322
                 $this->merchantOrder->getOrderTotal(true),
323 323
                 $this->module->displayName,
324
-                'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' .
325
-                'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() .
326
-                $this->amountMismatchError .
324
+                'pagantisOrderId: '.$this->pagantisOrder->getId().' '.
325
+                'pagantisOrderStatus: '.$this->pagantisOrder->getStatus().
326
+                $this->amountMismatchError.
327 327
                 $metadataInfo,
328 328
                 array('transaction_id' => $this->pagantisOrderId),
329 329
                 null,
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
             $this->orderClient->confirmOrder($this->pagantisOrderId);
347 347
             try {
348 348
                 $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION';
349
-                $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode .
350
-                    '. Pagantis OrderId=' . $this->pagantisOrderId .
351
-                    '. Prestashop OrderId=' . $this->merchantOrderId;
349
+                $message = 'Order CONFIRMED. The order was confirmed by a '.$mode.
350
+                    '. Pagantis OrderId='.$this->pagantisOrderId.
351
+                    '. Prestashop OrderId='.$this->merchantOrderId;
352 352
                 $this->saveLog(array(
353 353
                     'message' => $message
354 354
                 ));
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             );
404 404
             $resultSeconds = Db::getInstance()->getValue($query);
405 405
             $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0;
406
-            $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
406
+            $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;
407 407
 
408 408
             $logMessage = sprintf(
409 409
                 "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds",
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
             $this->saveLog(array(
415 415
                 'message' => $logMessage
416 416
             ));
417
-            sleep($secondsToExpire+1);
417
+            sleep($secondsToExpire + 1);
418 418
             // After waiting...user continue the confirmation, hoping that previous call have finished.
419 419
             return true;
420 420
         }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     protected function unblockConcurrency()
429 429
     {
430 430
         try {
431
-            Db::getInstance()->delete('pagantis_cart_process', 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT));
431
+            Db::getInstance()->delete('pagantis_cart_process', 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT));
432 432
         } catch (\Exception $exception) {
433 433
             throw new ConcurrencyException();
434 434
         }
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
         $data = array(
451 451
             'merchantOrderId' => $this->merchantOrderId,
452 452
             'pagantisOrderId' => $this->pagantisOrderId,
453
-            'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message',
454
-            'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode',
453
+            'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message',
454
+            'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode',
455 455
             'method' => $method,
456 456
             'file' => __FILE__,
457 457
             'line' => $line,
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
             'id_cart' => $this->merchantOrderId,
476 476
             'key' => $this->config['secureKey'],
477 477
             'id_module' => $this->module->id,
478
-            'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null,
478
+            'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null,
479 479
         );
480
-        $url = ($error)? $this->config['urlKO'] : $this->config['urlOK'];
480
+        $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK'];
481 481
         return $this->redirect($url, $parameters);
482 482
     }
483 483
 }
484 484
\ No newline at end of file
Please login to merge, or discard this patch.