Passed
Pull Request — master (#100)
by Raúl
02:39
created
controllers/front/payment.php 1 patch
Spacing   +29 added lines, -29 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(),
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
         $configs = json_decode(Pagantis::getExtraConfig($product, null), true);
89 89
         $iframe = Pagantis::getExtraConfig('FORM_DISPLAY_TYPE', $product);
90 90
 
91
-        $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key');
92
-        $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key');
91
+        $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key');
92
+        $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key');
93 93
 
94 94
         $okUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__
95
-            .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=redirect&product=' . Tools::strtolower($configs['CODE']) . '&'
95
+            .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=redirect&product='.Tools::strtolower($configs['CODE']).'&'
96 96
             .http_build_query($query)
97 97
         ;
98 98
         $notificationOkUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__
99
-            .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=notification&product=' . Tools::strtolower($configs['CODE']) . '&'
99
+            .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=notification&product='.Tools::strtolower($configs['CODE']).'&'
100 100
             .http_build_query($query)
101 101
         ;
102 102
 
@@ -111,27 +111,27 @@  discard block
 block discarded – undo
111 111
 
112 112
         try {
113 113
             $shippingCountry = Country::getIsoById($shippingAddress->id_country);
114
-            $userAddress =  new \Pagantis\OrdersApiClient\Model\Order\User\Address();
114
+            $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
115 115
             $userAddress
116 116
                 ->setZipCode($shippingAddress->postcode)
117
-                ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname)
117
+                ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname)
118 118
                 ->setCountryCode($shippingCountry)
119 119
                 ->setCity($shippingAddress->city)
120
-                ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2)
120
+                ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2)
121 121
                 ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress))
122 122
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
123 123
                 ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress))
124 124
             ;
125 125
 
126
-            $orderShippingAddress =  new \Pagantis\OrdersApiClient\Model\Order\User\Address();
126
+            $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
127 127
             $shippingPhone = (empty($shippingAddress->phone_mobile)) ?
128 128
                 $shippingAddress->phone : $shippingAddress->phone_mobile;
129 129
             $orderShippingAddress
130 130
                 ->setZipCode($shippingAddress->postcode)
131
-                ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname)
131
+                ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname)
132 132
                 ->setCountryCode($shippingCountry)
133 133
                 ->setCity($shippingAddress->city)
134
-                ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2)
134
+                ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2)
135 135
                 ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress))
136 136
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
137 137
                 ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress))
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
                 $billingAddress->phone : $billingAddress->phone_mobile;
146 146
             $orderBillingAddress
147 147
                 ->setZipCode($billingAddress->postcode)
148
-                ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname)
148
+                ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname)
149 149
                 ->setCountryCode($billingCountry)
150 150
                 ->setCity($billingAddress->city)
151
-                ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2)
151
+                ->setAddress($billingAddress->address1.' '.$billingAddress->address2)
152 152
                 ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress))
153 153
                 ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress))
154 154
                 ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress))
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress))
172 172
             ;
173 173
 
174
-            if ($customer->birthday!='0000-00-00') {
174
+            if ($customer->birthday != '0000-00-00') {
175 175
                 $orderUser->setDateOfBirth($customer->birthday);
176 176
             }
177 177
 
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
                     ->setQuantity($item['quantity'])
206 206
                     ->setDescription($item['name']);
207 207
                 if ($promotedProduct) {
208
-                    $promotedAmount+=$product->getAmount();
208
+                    $promotedAmount += $product->getAmount();
209 209
                     $productId = $item['id_product'];
210 210
                     $finalPrice = Product::getPriceStatic($productId);
211
-                    $promotedMessage = 'Promoted Item: ' . $product->getDescription() .
212
-                        ' Price: ' . $finalPrice .
213
-                        ' Qty: ' . $product->getQuantity() .
214
-                        ' Item ID: ' . $item['id_product'];
211
+                    $promotedMessage = 'Promoted Item: '.$product->getDescription().
212
+                        ' Price: '.$finalPrice.
213
+                        ' Qty: '.$product->getQuantity().
214
+                        ' Item ID: '.$item['id_product'];
215 215
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
216 216
                 }
217 217
                 $details->addProduct($product);
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             Tools::redirect($cancelUrl);
263 263
         }
264 264
 
265
-        $url ='';
265
+        $url = '';
266 266
         try {
267 267
             $orderClient = new \Pagantis\OrdersApiClient\Client(
268 268
                 trim($pagantisPublicKey),
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
                 $url = $order->getActionUrls()->getForm();
275 275
                 /** @var string $orderId MD5 value */
276 276
                 $orderId = $order->getId();
277
-                $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`, `token`)
277
+                $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`, `token`)
278 278
                      VALUES ('$cart->id','$orderId', '$urlToken')";
279 279
                 $result = Db::getInstance()->execute($sql);
280 280
                 if (!$result) {
281
-                    throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql);
281
+                    throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql);
282 282
                 }
283 283
             } else {
284 284
                 throw new OrderNotFoundException();
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
      */
411 411
     private function getUserLanguage($shippingAddress = null, $billingAddress = null)
412 412
     {
413
-        $allowedCountries    = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null));
413
+        $allowedCountries = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null));
414 414
         $lang = Language::getLanguage($this->context->language->id);
415 415
         $langArray = explode("-", $lang['language_code']);
416 416
         if (count($langArray) != 2 && isset($lang['locale'])) {
417 417
             $langArray = explode("-", $lang['locale']);
418 418
         }
419
-        $language = Tools::strtoupper($langArray[count($langArray)-1]);
419
+        $language = Tools::strtoupper($langArray[count($langArray) - 1]);
420 420
         // Prevent null language detection
421 421
         if (in_array(Tools::strtolower($language), $allowedCountries)) {
422 422
             return $language;
Please login to merge, or discard this patch.
controllers/front/notify.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         } catch (\Exception $exception) {
144 144
             $thrownException = true;
145 145
             $this->getMerchantOrderId();
146
-            $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId;
146
+            $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId;
147 147
             if ($this->isPost()) {
148 148
                 $this->jsonResponse = new JsonExceptionResponse();
149 149
                 $this->jsonResponse->setMerchantOrderId($theId);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             if (!$thrownException) {
159 159
                 $this->jsonResponse = new JsonSuccessResponse();
160 160
                 $this->getMerchantOrderId();
161
-                $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId;
161
+                $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId;
162 162
                 $this->jsonResponse->setMerchantOrderId($theId);
163 163
                 $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId);
164 164
                 $this->confirmPagantisOrder();
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             $this->rollbackMerchantOrder();
168 168
             if ($this->isNotification()) {
169 169
                 $this->getMerchantOrderId();
170
-                $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId;
170
+                $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId;
171 171
                 $this->jsonResponse = new JsonExceptionResponse();
172 172
                 $this->jsonResponse->setMerchantOrderId($theId);
173 173
                 $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         } catch (\Exception $exception) {
185 185
             $thrownException = true;
186 186
             $this->getMerchantOrderId();
187
-            $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId;
187
+            $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId;
188 188
             if ($this->isPost()) {
189 189
                 $this->jsonResponse = new JsonExceptionResponse();
190 190
                 $this->jsonResponse->setMerchantOrderId($theId);
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
         $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null));
254 254
         if (!in_array(Tools::strtoupper($productCode), $products)) {
255 255
             throw new UnknownException(
256
-                'No valid Pagantis product provided in the url: ' . Tools::getValue('product')
256
+                'No valid Pagantis product provided in the url: '.Tools::getValue('product')
257 257
             );
258 258
         }
259
-        $this->productName = "Pagantis " . Tools::strtolower($productCode);
259
+        $this->productName = "Pagantis ".Tools::strtolower($productCode);
260 260
 
261
-        $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_public_key'));
262
-        $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_private_key'));
261
+        $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_public_key'));
262
+        $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_private_key'));
263 263
 
264 264
         $this->merchantCartId = Tools::getValue('id_cart');
265 265
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
     public function getMerchantOrderId()
280 280
     {
281 281
         try {
282
-            $sql = 'select ps_order_id from ' . _DB_PREFIX_ .self::ORDERS_TABLE .' where id = '
283
-                .(int)$this->merchantCartId . ' and token = \'' . $this->token . '\'';
282
+            $sql = 'select ps_order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = '
283
+                .(int) $this->merchantCartId.' and token = \''.$this->token.'\'';
284 284
             $this->merchantOrderId = Db::getInstance()->getValue($sql);
285 285
         } catch (\Exception $exception) {
286 286
             $exceptionMessage = sprintf(
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
     private function getPagantisOrderId()
325 325
     {
326 326
         try {
327
-            $sql = 'select order_id from ' . _DB_PREFIX_.self::ORDERS_TABLE .' where id = '
328
-                .(int)$this->merchantCartId . ' and token = \'' . $this->token . '\'';
329
-            $this->pagantisOrderId= Db::getInstance()->getValue($sql);
327
+            $sql = 'select order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = '
328
+                .(int) $this->merchantCartId.' and token = \''.$this->token.'\'';
329
+            $this->pagantisOrderId = Db::getInstance()->getValue($sql);
330 330
 
331 331
             if (is_null($this->pagantisOrderId)) {
332 332
                 throw new NoIdentificationException();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     {
360 360
         if ($this->pagantisOrder->getStatus() === PagantisModelOrder::STATUS_CONFIRMED) {
361 361
             $this->getMerchantOrderId();
362
-            $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId;
362
+            $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId;
363 363
             $this->jsonResponse = new JsonSuccessResponse();
364 364
             $this->jsonResponse->setMerchantOrderId($theId);
365 365
             $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId);
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
                 $psTotalAmount = substr_replace(
392 392
                     $merchantAmount,
393 393
                     '.',
394
-                    (Tools::strlen($merchantAmount) -2),
394
+                    (Tools::strlen($merchantAmount) - 2),
395 395
                     0
396 396
                 );
397 397
 
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
                 $pgTotalAmount = substr_replace(
400 400
                     $pgTotalAmountInCents,
401 401
                     '.',
402
-                    (Tools::strlen($pgTotalAmountInCents) -2),
402
+                    (Tools::strlen($pgTotalAmountInCents) - 2),
403 403
                     0
404 404
                 );
405 405
 
406
-                $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'. $this->merchantCartId .
407
-                    ' compared with Pagantis Order: ' . $this->pagantisOrderId .
408
-                    '. The Cart in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' .
409
-                    $pgTotalAmount . ' PLEASE REVIEW THE ORDER';
406
+                $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'.$this->merchantCartId.
407
+                    ' compared with Pagantis Order: '.$this->pagantisOrderId.
408
+                    '. The Cart in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '.
409
+                    $pgTotalAmount.' PLEASE REVIEW THE ORDER';
410 410
 
411 411
                 $this->saveLog(array(
412 412
                     'requestId' => $this->requestId,
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
             }
447 447
 
448 448
             // Double check
449
-            $tableName = _DB_PREFIX_ . self::ORDERS_TABLE;
449
+            $tableName = _DB_PREFIX_.self::ORDERS_TABLE;
450 450
             $fieldName = 'ps_order_id';
451
-            $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . (int)$this->merchantCartId
452
-                . ' and `order_id` = \'' . $this->pagantisOrderId . '\''
453
-                . ' and `token` = \'' . $this->token . '\''
454
-                . ' and `' . $fieldName . '` is not null');
451
+            $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.(int) $this->merchantCartId
452
+                . ' and `order_id` = \''.$this->pagantisOrderId.'\''
453
+                . ' and `token` = \''.$this->token.'\''
454
+                . ' and `'.$fieldName.'` is not null');
455 455
             $results = Db::getInstance()->ExecuteS($sql);
456 456
             if (is_array($results) && count($results) === 1) {
457 457
                 $this->getMerchantOrderId();
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
                 Configuration::get('PS_OS_PAYMENT'),
492 492
                 $this->merchantCart->getOrderTotal(true),
493 493
                 $this->productName,
494
-                'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' .
495
-                'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() .
496
-                $this->amountMismatchError .
494
+                'pagantisOrderId: '.$this->pagantisOrder->getId().' '.
495
+                'pagantisOrderStatus: '.$this->pagantisOrder->getStatus().
496
+                $this->amountMismatchError.
497 497
                 $metadataInfo,
498 498
                 array('transaction_id' => $this->pagantisOrderId),
499 499
                 null,
@@ -507,9 +507,9 @@  discard block
 block discarded – undo
507 507
             Db::getInstance()->update(
508 508
                 self::ORDERS_TABLE,
509 509
                 array('ps_order_id' => $this->module->currentOrder),
510
-                'id = '. (int)$this->merchantCartId
511
-                    . ' and order_id = \'' . $this->pagantisOrderId . '\''
512
-                    . ' and token = \'' . $this->token . '\''
510
+                'id = '.(int) $this->merchantCartId
511
+                    . ' and order_id = \''.$this->pagantisOrderId.'\''
512
+                    . ' and token = \''.$this->token.'\''
513 513
             );
514 514
 
515 515
         } catch (\Exception $exception) {
@@ -536,9 +536,9 @@  discard block
 block discarded – undo
536 536
             $this->orderClient->confirmOrder($this->pagantisOrderId);
537 537
             try {
538 538
                 $mode = ($this->isPost()) ? 'NOTIFICATION' : 'REDIRECTION';
539
-                $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode .
540
-                    '. Pagantis OrderId=' . $this->pagantisOrderId .
541
-                    '. Prestashop OrderId=' . $this->module->currentOrder;
539
+                $message = 'Order CONFIRMED. The order was confirmed by a '.$mode.
540
+                    '. Pagantis OrderId='.$this->pagantisOrderId.
541
+                    '. Prestashop OrderId='.$this->module->currentOrder;
542 542
                 $this->saveLog(array('requestId' => $this->requestId, 'message' => $message));
543 543
             } catch (\Exception $exception) {
544 544
                 $exceptionMessage = sprintf(
@@ -565,16 +565,16 @@  discard block
 block discarded – undo
565 565
     {
566 566
         try {
567 567
             $this->getMerchantOrderId();
568
-            $message = 'Roolback method: ' .
569
-                '. Pagantis OrderId=' . $this->pagantisOrderId .
570
-                '. Prestashop CartId=' . $this->merchantCartId .
571
-                '. Prestashop OrderId=' . $this->merchantOrderId;
568
+            $message = 'Roolback method: '.
569
+                '. Pagantis OrderId='.$this->pagantisOrderId.
570
+                '. Prestashop CartId='.$this->merchantCartId.
571
+                '. Prestashop OrderId='.$this->merchantOrderId;
572 572
             if ($this->module->currentOrder) {
573 573
                 $objOrder = new Order($this->module->currentOrder);
574 574
                 $history = new OrderHistory();
575
-                $history->id_order = (int)$objOrder->id;
576
-                $history->changeIdOrderState(8, (int)($objOrder->id));
577
-                $message .= ' Prestashop OrderId=' . $this->merchantCartId;
575
+                $history->id_order = (int) $objOrder->id;
576
+                $history->changeIdOrderState(8, (int) ($objOrder->id));
577
+                $message .= ' Prestashop OrderId='.$this->merchantCartId;
578 578
             }
579 579
             $this->saveLog(array(
580 580
                 'requestId' => $this->requestId,
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
     {
600 600
         try {
601 601
             $table = self::CART_TABLE;
602
-            $insertBlock = Db::getInstance()->insert($table, array('id' =>(int)$orderId, 'timestamp' =>(time())));
602
+            $insertBlock = Db::getInstance()->insert($table, array('id' =>(int) $orderId, 'timestamp' =>(time())));
603 603
             if ($insertBlock === false) {
604 604
                 if ($this->isNotification()) {
605 605
                     throw new ConcurrencyException();
@@ -609,11 +609,11 @@  discard block
 block discarded – undo
609 609
                               as rest FROM %s WHERE %s",
610 610
                         self::CONCURRENCY_TIMEOUT,
611 611
                         _DB_PREFIX_.$table,
612
-                        'id='.(int)$orderId
612
+                        'id='.(int) $orderId
613 613
                     );
614 614
                     $resultSeconds = Db::getInstance()->getValue($query);
615 615
                     $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0;
616
-                    $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ?
616
+                    $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ?
617 617
                         self::CONCURRENCY_TIMEOUT : $restSeconds;
618 618
                     if ($secondsToExpire > 0) {
619 619
                         sleep($secondsToExpire + 1);
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
                     $this->getMerchantOrderId();
623 623
                     $this->getPagantisOrderId();
624 624
 
625
-                    $logMessage  = sprintf(
625
+                    $logMessage = sprintf(
626 626
                         "User has waited %s seconds, default %s, bd time to expire %s [cartId=%s][origin=%s]",
627 627
                         $secondsToExpire,
628 628
                         self::CONCURRENCY_TIMEOUT,
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
     {
652 652
         try {
653 653
             if (is_null($orderId)) {
654
-                Db::getInstance()->delete(self::CART_TABLE, 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT));
654
+                Db::getInstance()->delete(self::CART_TABLE, 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT));
655 655
                 return;
656 656
             }
657
-            Db::getInstance()->delete(self::CART_TABLE, 'id = ' . (int)$orderId);
657
+            Db::getInstance()->delete(self::CART_TABLE, 'id = '.(int) $orderId);
658 658
         } catch (\Exception $exception) {
659 659
             throw new ConcurrencyException();
660 660
         }
@@ -679,8 +679,8 @@  discard block
 block discarded – undo
679 679
             'merchantCartId' => $this->merchantCartId,
680 680
             'merchantOrderId' => $this->merchantOrderId,
681 681
             'pagantisOrderId' => $this->pagantisOrderId,
682
-            'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message',
683
-            'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode',
682
+            'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message',
683
+            'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode',
684 684
             'method' => $method,
685 685
             'file' => __FILE__,
686 686
             'line' => $line,
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
                 'id_module' => $this->module->id,
717 717
                 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null,
718 718
             );
719
-            $url = ($error)? $this->config['urlKO'] : $this->config['urlOK'];
719
+            $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK'];
720 720
             $returnMessage = sprintf(
721 721
                 "[origin=%s][cartId=%s][prestashopOrderId=%s][pagantisOrderId=%s][returnUrl=%s]",
722 722
                 $this->getOrigin(),
Please login to merge, or discard this patch.
pagantis.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     exit;
12 12
 }
13 13
 
14
-define('_PS_PAGANTIS_DIR', _PS_MODULE_DIR_. '/pagantis');
14
+define('_PS_PAGANTIS_DIR', _PS_MODULE_DIR_.'/pagantis');
15 15
 define('PROMOTIONS_CATEGORY', 'pagantis-promotion-product');
16 16
 define('PROMOTIONS_CATEGORY_NAME', 'Pagantis Promoted Product');
17 17
 
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
         foreach ($products as $product) {
162 162
             $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product));
163 163
             if ($code === 'p4x') {
164
-                Configuration::updateValue($code . '_simulator_is_enabled', 1);
164
+                Configuration::updateValue($code.'_simulator_is_enabled', 1);
165 165
             }
166
-            Configuration::updateValue($code . '_is_enabled', 0);
167
-            Configuration::updateValue($code . '_public_key', '');
168
-            Configuration::updateValue($code . '_private_key', '');
166
+            Configuration::updateValue($code.'_is_enabled', 0);
167
+            Configuration::updateValue($code.'_public_key', '');
168
+            Configuration::updateValue($code.'_private_key', '');
169 169
         }
170 170
 
171
-        $return =  (parent::install()
171
+        $return = (parent::install()
172 172
             && $this->registerHook('displayShoppingCart')
173 173
             && $this->registerHook('paymentOptions')
174 174
             && $this->registerHook('displayProductButtons')
@@ -214,34 +214,34 @@  discard block
 block discarded – undo
214 214
     public function checkHooks()
215 215
     {
216 216
         try {
217
-            $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where 
218
-            id_module = \'' . Module::getModuleIdByName($this->name) . '\' and 
219
-            id_shop = \'' . Shop::getContextShopID() . '\' and 
220
-            id_hook = \'' . Hook::getIdByName('header') . '\'';
217
+            $sql_content = 'select * from '._DB_PREFIX_.'hook_module where 
218
+            id_module = \'' . Module::getModuleIdByName($this->name).'\' and 
219
+            id_shop = \'' . Shop::getContextShopID().'\' and 
220
+            id_hook = \'' . Hook::getIdByName('header').'\'';
221 221
             $hook_exists = Db::getInstance()->ExecuteS($sql_content);
222 222
             if (empty($hook_exists)) {
223
-                $sql_insert = 'insert into ' . _DB_PREFIX_.  'hook_module 
223
+                $sql_insert = 'insert into '._DB_PREFIX_.'hook_module 
224 224
             (id_module, id_shop, id_hook, position)
225 225
             values
226
-            (\''. Module::getModuleIdByName($this->name) . '\',
227
-            \''. Shop::getContextShopID() . '\',
228
-            \''. Hook::getIdByName('header') . '\',
226
+            (\''. Module::getModuleIdByName($this->name).'\',
227
+            \''. Shop::getContextShopID().'\',
228
+            \''. Hook::getIdByName('header').'\',
229 229
             150)';
230 230
                 Db::getInstance()->execute($sql_insert);
231 231
             }
232 232
 
233
-            $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where 
234
-            id_module = \'' . Module::getModuleIdByName($this->name) . '\' and 
235
-            id_shop = \'' . Shop::getContextShopID() . '\' and 
236
-            id_hook = \'' . Hook::getIdByName('displayProductPriceBlock') . '\'';
233
+            $sql_content = 'select * from '._DB_PREFIX_.'hook_module where 
234
+            id_module = \'' . Module::getModuleIdByName($this->name).'\' and 
235
+            id_shop = \'' . Shop::getContextShopID().'\' and 
236
+            id_hook = \'' . Hook::getIdByName('displayProductPriceBlock').'\'';
237 237
             $hook_exists = Db::getInstance()->ExecuteS($sql_content);
238 238
             if (empty($hook_exists)) {
239
-                $sql_insert = 'insert into ' . _DB_PREFIX_.  'hook_module 
239
+                $sql_insert = 'insert into '._DB_PREFIX_.'hook_module 
240 240
             (id_module, id_shop, id_hook, position)
241 241
             values
242
-            (\''. Module::getModuleIdByName($this->name) . '\',
243
-            \''. Shop::getContextShopID() . '\',
244
-            \''. Hook::getIdByName('displayProductPriceBlock') . '\',
242
+            (\''. Module::getModuleIdByName($this->name).'\',
243
+            \''. Shop::getContextShopID().'\',
244
+            \''. Hook::getIdByName('displayProductPriceBlock').'\',
245 245
             160)';
246 246
                 Db::getInstance()->execute($sql_insert);
247 247
             }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      */
256 256
     public function checkEnvVariables()
257 257
     {
258
-        $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config';
258
+        $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config';
259 259
         $dbConfigs = Db::getInstance()->executeS($sql_content);
260 260
 
261 261
         // Convert a multimple dimension array for SQL insert statements into a simple key/value
@@ -284,27 +284,27 @@  discard block
 block discarded – undo
284 284
     {
285 285
         try {
286 286
             $tableName = _DB_PREFIX_.'pagantis_order';
287
-            $sql = "show tables like '"   . $tableName . "'";
287
+            $sql = "show tables like '".$tableName."'";
288 288
             $data = Db::getInstance()->ExecuteS($sql);
289 289
             if (count($data) > 0) {
290
-                $sql = "desc "   . $tableName;
290
+                $sql = "desc ".$tableName;
291 291
                 $data = Db::getInstance()->ExecuteS($sql);
292 292
                 if (count($data) == 2) {
293 293
                     $sql = "ALTER TABLE $tableName ADD COLUMN ps_order_id VARCHAR(60) AFTER order_id";
294 294
                     Db::getInstance()->Execute($sql);
295 295
                 }
296 296
                 if (count($data) == 3) {
297
-                    $sql = "ALTER TABLE " . $tableName ." ADD COLUMN  token VARCHAR(32) NOT NULL AFTER order_id";
297
+                    $sql = "ALTER TABLE ".$tableName." ADD COLUMN  token VARCHAR(32) NOT NULL AFTER order_id";
298 298
                     Db::getInstance()->Execute($sql);
299 299
                     $sql = "ALTER TABLE ps_pagantis_order DROP PRIMARY KEY, ADD PRIMARY KEY(id, order_id);";
300 300
                     Db::getInstance()->Execute($sql);
301 301
                 }
302 302
 
303 303
             $tableName = _DB_PREFIX_.'pagantis_config';
304
-            $sql = "show tables like '"   . $tableName . "'";
304
+            $sql = "show tables like '".$tableName."'";
305 305
             $data = Db::getInstance()->ExecuteS($sql);
306 306
             if (count($data) > 0) {
307
-                $sql = "desc "   . $tableName;
307
+                $sql = "desc ".$tableName;
308 308
                 $data = Db::getInstance()->ExecuteS($sql);
309 309
                 if (count($data) === 3 && $data[2]['Type'] !== 'varchar(5000)') {
310 310
                     $sql = "ALTER TABLE $tableName MODIFY `value` VARCHAR(5000)";
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
         $availableCurrencies       = array('EUR');
348 348
         $pagantisDisplayMinAmount  = $configs['DISPLAY_MIN_AMOUNT'];
349 349
         $pagantisDisplayMaxAmount  = $configs['DISPLAY_MAX_AMOUNT'];
350
-        $pagantisPublicKey         = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key');
351
-        $pagantisPrivateKey        = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key');
350
+        $pagantisPublicKey         = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key');
351
+        $pagantisPrivateKey        = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key');
352 352
         $this->allowedCountries    = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null));
353 353
         $this->getUserLanguage();
354 354
         return (
@@ -427,42 +427,42 @@  discard block
 block discarded – undo
427 427
             if ($this->isPaymentMethodAvailable($product)) {
428 428
                 $productConfigs = Pagantis::getExtraConfig($product, null);
429 429
                 $productConfigs = json_decode($productConfigs, true);
430
-                $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key');
431
-                $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled');
432
-                $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled');
430
+                $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key');
431
+                $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled');
432
+                $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled');
433 433
 
434
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']);
434
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']);
435 435
                 unset($productConfigs['TITLE']);
436
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal;
437
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount;
438
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language;
439
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language;
440
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey;
441
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled;
442
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled;
443
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png';
444
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment') . '&product=' . $productConfigs['CODE'];
445
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3));
436
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal;
437
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount;
438
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language;
439
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language;
440
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey;
441
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled;
442
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled;
443
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png';
444
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment').'&product='.$productConfigs['CODE'];
445
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3));
446 446
 
447 447
                 foreach ($productConfigs as $productConfigKey => $productConfigValue) {
448
-                    $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue;
448
+                    $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue;
449 449
                 }
450 450
                 $this->context->smarty->assign($templateConfigs);
451 451
 
452 452
                 $paymentOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption();
453 453
                 $uri = $link->getModuleLink('pagantis', 'payment');
454 454
                 if (strpos($uri, '?') !== false) {
455
-                    $uri .= '&product=' . $productConfigs['CODE'];
455
+                    $uri .= '&product='.$productConfigs['CODE'];
456 456
                 } else {
457
-                    $uri .= '?product=' . $productConfigs['CODE'];
457
+                    $uri .= '?product='.$productConfigs['CODE'];
458 458
                 }
459 459
                 $paymentOption
460
-                    ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'])
460
+                    ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'])
461 461
                     ->setAction($uri)
462
-                    ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'])
462
+                    ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'])
463 463
                     ->setModuleName(__CLASS__)
464 464
                     ->setAdditionalInformation(
465
-                        $this->fetch('module:pagantis/views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl')
465
+                        $this->fetch('module:pagantis/views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl')
466 466
                     )
467 467
                 ;
468 468
                 $return[] = $paymentOption;
@@ -486,61 +486,61 @@  discard block
 block discarded – undo
486 486
         foreach ($products as $product) {
487 487
             $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product));
488 488
             $inputs[] = array(
489
-                'name' => $code .'_is_enabled',
490
-                'type' =>  (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch',
491
-                'label' => $this->l('Module is enabled ' . $code),
489
+                'name' => $code.'_is_enabled',
490
+                'type' =>  (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch',
491
+                'label' => $this->l('Module is enabled '.$code),
492 492
                 'prefix' => '<i class="icon icon-key"></i>',
493 493
                 'class' => 't',
494 494
                 'required' => true,
495 495
                 'values'=> array(
496 496
                     array(
497
-                        'id' => $code .'_is_enabled_true',
497
+                        'id' => $code.'_is_enabled_true',
498 498
                         'value' => 1,
499 499
                         'label' => $this->l('Yes', get_class($this), null, false),
500 500
                     ),
501 501
                     array(
502
-                        'id' => $code . '_is_enabled_false',
502
+                        'id' => $code.'_is_enabled_false',
503 503
                         'value' => 0,
504 504
                         'label' => $this->l('No', get_class($this), null, false),
505 505
                     ),
506 506
                 )
507 507
             );
508 508
             $inputs[] = array(
509
-                'name' => $code . '_public_key',
509
+                'name' => $code.'_public_key',
510 510
                 'suffix' => $this->l('ex: pk_fd53cd467ba49022e4gf215e'),
511 511
                 'type' => 'text',
512 512
                 'size' => 60,
513
-                'label' => $this->l('Public Key ' . $code),
513
+                'label' => $this->l('Public Key '.$code),
514 514
                 'prefix' => '<i class="icon icon-key"></i>',
515 515
                 'col' => 6,
516 516
                 'required' => true,
517 517
             );
518 518
             $inputs[] = array(
519
-                'name' => $code . '_private_key',
519
+                'name' => $code.'_private_key',
520 520
                 'suffix' => $this->l('ex: 21e5723a97459f6a'),
521 521
                 'type' => 'text',
522 522
                 'size' => 60,
523
-                'label' => $this->l('Private Key ' . $code),
523
+                'label' => $this->l('Private Key '.$code),
524 524
                 'prefix' => '<i class="icon icon-key"></i>',
525 525
                 'col' => 6,
526 526
                 'required' => true,
527 527
             );
528 528
             if ($code !== "p4x") {
529 529
                 $inputs[] = array(
530
-                    'name' => $code . '_simulator_is_enabled',
531
-                    'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch',
532
-                    'label' => $this->l('Simulator is enabled ' . $code),
530
+                    'name' => $code.'_simulator_is_enabled',
531
+                    'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch',
532
+                    'label' => $this->l('Simulator is enabled '.$code),
533 533
                     'prefix' => '<i class="icon icon-key"></i>',
534 534
                     'class' => 't',
535 535
                     'required' => true,
536 536
                     'values'=> array(
537 537
                         array(
538
-                            'id' => $code . '_simulator_is_enabled_on',
538
+                            'id' => $code.'_simulator_is_enabled_on',
539 539
                             'value' => 1,
540 540
                             'label' => $this->l('Yes'),
541 541
                         ),
542 542
                         array(
543
-                            'id' => $code . '_simulator_is_enabled_off',
543
+                            'id' => $code.'_simulator_is_enabled_off',
544 544
                             'value' => 0,
545 545
                             'label' => $this->l('No'),
546 546
                         ),
@@ -608,17 +608,17 @@  discard block
 block discarded – undo
608 608
         $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null));
609 609
         foreach ($products as $product) {
610 610
             $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product));
611
-            $settings[$code . '_public_key'] = Configuration::get($code . '_public_key');
612
-            $settings[$code . '_private_key'] = Configuration::get($code . '_private_key');
613
-            $settings[$code . '_is_enabled'] = Configuration::get($code . '_is_enabled');
611
+            $settings[$code.'_public_key'] = Configuration::get($code.'_public_key');
612
+            $settings[$code.'_private_key'] = Configuration::get($code.'_private_key');
613
+            $settings[$code.'_is_enabled'] = Configuration::get($code.'_is_enabled');
614 614
             if ($code !== 'p4x') {
615
-                $settings[$code . '_simulator_is_enabled'] = Configuration::get($code . '_simulator_is_enabled');
615
+                $settings[$code.'_simulator_is_enabled'] = Configuration::get($code.'_simulator_is_enabled');
616 616
             }
617
-            $settingsKeys[] = $code . '_is_enabled';
618
-            $settingsKeys[] = $code . '_public_key';
619
-            $settingsKeys[] = $code . '_private_key';
617
+            $settingsKeys[] = $code.'_is_enabled';
618
+            $settingsKeys[] = $code.'_public_key';
619
+            $settingsKeys[] = $code.'_private_key';
620 620
             if ($code !== 'p4x') {
621
-                $settingsKeys[] = $code . '_simulator_is_enabled';
621
+                $settingsKeys[] = $code.'_simulator_is_enabled';
622 622
             }
623 623
         }
624 624
 
@@ -689,43 +689,43 @@  discard block
 block discarded – undo
689 689
             if ($this->isPaymentMethodAvailable($product)) {
690 690
                 $productConfigs = Pagantis::getExtraConfig($product, null);
691 691
                 $productConfigs = json_decode($productConfigs, true);
692
-                $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key');
693
-                $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled');
694
-                $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled');
692
+                $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key');
693
+                $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled');
694
+                $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled');
695 695
 
696
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']);
696
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']);
697 697
                 unset($productConfigs['TITLE']);
698
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal;
699
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount;
700
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language;
701
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language;
702
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey;
703
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled;
704
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled;
705
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png';
698
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal;
699
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount;
700
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language;
701
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language;
702
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey;
703
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled;
704
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled;
705
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png';
706 706
                 $uri = $link->getModuleLink('pagantis', 'payment');
707 707
                 if (strpos($uri, '?') !== false) {
708
-                    $uri .= '&product=' . $productConfigs['CODE'];
708
+                    $uri .= '&product='.$productConfigs['CODE'];
709 709
                 } else {
710
-                    $uri .= '?product=' . $productConfigs['CODE'];
710
+                    $uri .= '?product='.$productConfigs['CODE'];
711 711
                 }
712
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $uri;
713
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3));
712
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $uri;
713
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3));
714 714
 
715 715
                 foreach ($productConfigs as $productConfigKey => $productConfigValue) {
716
-                    $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue;
716
+                    $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue;
717 717
                 }
718 718
                 $this->context->smarty->assign($templateConfigs);
719 719
                 if ($supercheckout_enabled || $onepagecheckout_enabled || $onepagecheckoutps_enabled) {
720 720
                     $this->checkLogoExists();
721 721
                     $return .= $this->display(
722 722
                         __FILE__,
723
-                        'views/templates/hook/onepagecheckout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl'
723
+                        'views/templates/hook/onepagecheckout-'.Tools::strtolower($productConfigs['CODE']).'.tpl'
724 724
                     );
725 725
                 } elseif (_PS_VERSION_ < 1.7) {
726 726
                     $return .= $this->display(
727 727
                         __FILE__,
728
-                        'views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl'
728
+                        'views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl'
729 729
                     );
730 730
                 }
731 731
             }
@@ -758,12 +758,12 @@  discard block
 block discarded – undo
758 758
             $productConfigs = Pagantis::getExtraConfig($product, null);
759 759
             $productConfigs = json_decode($productConfigs, true);
760 760
 
761
-            $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key');
762
-            $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled');
761
+            $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key');
762
+            $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled');
763 763
             if (Tools::strtolower($productConfigs['CODE']) === 'p4x') {
764 764
                 $simulatorIsEnabled = true;
765 765
             }
766
-            $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled');
766
+            $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled');
767 767
             $availableSimulators = array(
768 768
                 'hookDisplayProductButtons' => array(
769 769
                     'sdk.simulator.types.SIMPLE',
@@ -786,30 +786,30 @@  discard block
 block discarded – undo
786 786
                 in_array(Tools::strtolower($this->language), $allowedCountries) &&
787 787
                 (in_array($productConfigs['SIMULATOR_DISPLAY_TYPE'], $availableSimulators[$hookName]) || _PS_VERSION_ < 1.6)
788 788
             ) {
789
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']);
790
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']);
791
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']);
789
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']);
790
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']);
791
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']);
792 792
                 unset($productConfigs['TITLE']);
793 793
                 unset($productConfigs['SIMULATOR_TITLE']);
794 794
                 unset($productConfigs['SIMULATOR_SUBTITLE']);
795
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $amount;
796
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT4X'] = number_format(($amount / 4), 2, '.', '');
797
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_PROMOTED_PRODUCT'] = $isPromotedProduct;
798
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language;
799
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language;
800
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey;
801
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled;
802
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled;
803
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png';
804
-                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3));
795
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $amount;
796
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT4X'] = number_format(($amount / 4), 2, '.', '');
797
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_PROMOTED_PRODUCT'] = $isPromotedProduct;
798
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language;
799
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language;
800
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey;
801
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled;
802
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled;
803
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png';
804
+                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3));
805 805
                 foreach ($productConfigs as $productConfigKey => $productConfigValue) {
806
-                    $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue;
806
+                    $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue;
807 807
                 }
808 808
 
809 809
                 $this->context->smarty->assign($templateConfigs);
810 810
                 $return .= $this->display(
811 811
                     __FILE__,
812
-                    'views/templates/hook/product-simulator-' . Tools::strtolower($productConfigs['CODE']) . '.tpl'
812
+                    'views/templates/hook/product-simulator-'.Tools::strtolower($productConfigs['CODE']).'.tpl'
813 813
                 );
814 814
             }
815 815
         }
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
         // $params['type'] = weight | price | after_price
839 839
         if (isset($params['type']) && $params['type'] === 'price' &&
840 840
             isset($params['smarty']) && isset($params['smarty']->template_resource) &&
841
-            (strpos($params['smarty']->template_resource, 'product.tpl') !== false  ||
841
+            (strpos($params['smarty']->template_resource, 'product.tpl') !== false ||
842 842
             strpos($params['smarty']->template_resource, 'product-prices.tpl') !== false)
843 843
         ) {
844 844
             return $this->productPageSimulatorDisplay("hookDisplayProductPriceBlock");
@@ -871,16 +871,16 @@  discard block
 block discarded – undo
871 871
         if (!in_array(PROMOTIONS_CATEGORY_NAME, $categories)) {
872 872
             /** @var CategoryCore $category */
873 873
             $category = new Category();
874
-            $categoryArray = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY );
874
+            $categoryArray = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY);
875 875
             $category->is_root_category = false;
876 876
             $category->link_rewrite = $categoryArray;
877 877
             $category->meta_description = $categoryArray;
878 878
             $category->meta_keywords = $categoryArray;
879 879
             $category->meta_title = $categoryArray;
880
-            $category->name = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME);
880
+            $category->name = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME);
881 881
             $category->id_parent = Configuration::get('PS_HOME_CATEGORY');
882
-            $category->active=0;
883
-            $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' .
882
+            $category->active = 0;
883
+            $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '.
884 884
                 'Use it to promote your products or brands.';
885 885
             $category->description = $this->l($description);
886 886
             $category->save();
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
         }
901 901
 
902 902
         if (is_null($product)) {
903
-            $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1';
903
+            $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1';
904 904
             if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) {
905 905
                 if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) {
906 906
                     return $results[0]['value'];
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
             }
909 909
         }
910 910
 
911
-        $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($product) . '\' limit 1';
911
+        $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($product).'\' limit 1';
912 912
         if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) {
913 913
             if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) {
914 914
                 $configs = json_decode($results[0]['value'], true);
@@ -928,10 +928,10 @@  discard block
 block discarded – undo
928 928
      */
929 929
     public function checkLogoExists()
930 930
     {
931
-        $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png';
932
-        if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) {
931
+        $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png';
932
+        if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) {
933 933
             copy(
934
-                _PS_PAGANTIS_DIR . '/logo.png',
934
+                _PS_PAGANTIS_DIR.'/logo.png',
935 935
                 $logoPg
936 936
             );
937 937
         }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
         if (count($langArray) != 2 && isset($lang['locale'])) {
948 948
             $langArray = explode("-", $lang['locale']);
949 949
         }
950
-        $this->language = Tools::strtoupper($langArray[count($langArray)-1]);
950
+        $this->language = Tools::strtoupper($langArray[count($langArray) - 1]);
951 951
         // Prevent null language detection
952 952
         if (in_array(Tools::strtolower($this->language), $this->allowedCountries)) {
953 953
             return;
Please login to merge, or discard this patch.