Passed
Pull Request — master (#45)
by Raúl
02:36
created
controllers/front/payment.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
         $pagantisPublicKey = Configuration::get('pagantis_public_key');
90 90
         $pagantisPrivateKey = Configuration::get('pagantis_private_key');
91 91
         $okUrl = _PS_BASE_URL_.__PS_BASE_URI__
92
-                 .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&'
93
-                 .http_build_query($query)
92
+                    .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&'
93
+                    .http_build_query($query)
94 94
         ;
95 95
 
96 96
         $shippingAddress = new Address($cart->id_address_delivery);
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
                     $promotedAmount+=$product->getAmount();
193 193
                     $finalPrice = Product::getPriceStatic($item['id_product']);
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   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
     {
26 26
         if (_PS_VERSION_ < 1.6) {
27 27
             Logger::addLog(
28
-                'Pagantis Exception For user ' .
29
-                $customer->email .
30
-                ' : ' .
28
+                'Pagantis Exception For user '.
29
+                $customer->email.
30
+                ' : '.
31 31
                 $exception->getMessage(),
32 32
                 3,
33 33
                 $exception->getCode(),
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
             );
38 38
         } else {
39 39
             PrestaShopLogger::addLog(
40
-                'Pagantis Exception For user ' .
41
-                $customer->email .
42
-                ' : ' .
40
+                'Pagantis Exception For user '.
41
+                $customer->email.
42
+                ' : '.
43 43
                 $exception->getMessage(),
44 44
                 3,
45 45
                 $exception->getCode(),
@@ -105,24 +105,24 @@  discard block
 block discarded – undo
105 105
         );
106 106
 
107 107
         try {
108
-            $userAddress =  new \Pagantis\OrdersApiClient\Model\Order\User\Address();
108
+            $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
109 109
             $userAddress
110 110
                 ->setZipCode($shippingAddress->postcode)
111
-                ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname)
111
+                ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname)
112 112
                 ->setCountryCode($this->language)
113 113
                 ->setCity($shippingAddress->city)
114
-                ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2)
114
+                ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2)
115 115
                 ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress))
116 116
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
117 117
             ;
118 118
 
119
-            $orderShippingAddress =  new \Pagantis\OrdersApiClient\Model\Order\User\Address();
119
+            $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
120 120
             $orderShippingAddress
121 121
                 ->setZipCode($shippingAddress->postcode)
122
-                ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname)
122
+                ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname)
123 123
                 ->setCountryCode($this->language)
124 124
                 ->setCity($shippingAddress->city)
125
-                ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2)
125
+                ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2)
126 126
                 ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress))
127 127
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
128 128
                 ->setFixPhone($shippingAddress->phone)
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
             $orderBillingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address();
133 133
             $orderBillingAddress
134 134
                 ->setZipCode($billingAddress->postcode)
135
-                ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname)
135
+                ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname)
136 136
                 ->setCountryCode($this->language)
137 137
                 ->setCity($billingAddress->city)
138
-                ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2)
138
+                ->setAddress($billingAddress->address1.' '.$billingAddress->address2)
139 139
                 ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress))
140 140
                 ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress))
141 141
                 ->setFixPhone($billingAddress->phone)
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress))
156 156
             ;
157 157
 
158
-            if ($customer->birthday!='0000-00-00') {
158
+            if ($customer->birthday != '0000-00-00') {
159 159
                 $orderUser->setDateOfBirth($customer->birthday);
160 160
             }
161 161
 
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
                     ->setQuantity($item['quantity'])
190 190
                     ->setDescription($item['name']);
191 191
                 if ($promotedProduct) {
192
-                    $promotedAmount+=$product->getAmount();
192
+                    $promotedAmount += $product->getAmount();
193 193
                     $finalPrice = Product::getPriceStatic($item['id_product']);
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();
Please login to merge, or discard this patch.
controllers/front/notify.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     private function getPagantisOrderId()
196 196
     {
197 197
         try {
198
-            $this->pagantisOrderId= Db::getInstance()->getValue(
198
+            $this->pagantisOrderId = Db::getInstance()->getValue(
199 199
                 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId
200 200
             );
201 201
 
@@ -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
                 ));
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     protected function unblockConcurrency()
405 405
     {
406 406
         try {
407
-            Db::getInstance()->delete('pagantis_cart_process', 'timestamp < ' . (time() - 6));
407
+            Db::getInstance()->delete('pagantis_cart_process', 'timestamp < '.(time() - 6));
408 408
         } catch (\Exception $exception) {
409 409
             throw new ConcurrencyException();
410 410
         }
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
             'id_cart' => $this->merchantOrderId,
449 449
             'key' => $this->config['secureKey'],
450 450
             'id_module' => $this->module->id,
451
-            'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null,
451
+            'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null,
452 452
         );
453
-        $url = ($error)? $this->config['urlKO'] : $this->config['urlOK'];
453
+        $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK'];
454 454
         return $this->redirect($url, $parameters);
455 455
     }
456 456
 }
Please login to merge, or discard this patch.
pagantis.php 1 patch
Spacing   +32 added lines, -32 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
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         if (count($langArray) != 2 && isset($lang['locale'])) {
98 98
             $langArray = explode("-", $lang['locale']);
99 99
         }
100
-        $this->language = Tools::strtoupper($langArray[count($langArray)-1]);
100
+        $this->language = Tools::strtoupper($langArray[count($langArray) - 1]);
101 101
 
102 102
         // Prevent null language detection
103 103
         $this->language = ($this->language) ? $this->language : 'ES';
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         Configuration::updateValue('pagantis_public_key', '');
126 126
         Configuration::updateValue('pagantis_private_key', '');
127 127
 
128
-        $return =  (parent::install()
128
+        $return = (parent::install()
129 129
             && $this->registerHook('displayShoppingCart')
130 130
             && $this->registerHook('paymentOptions')
131 131
             && $this->registerHook('displayRightColumn')
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
     public function checkHooks()
208 208
     {
209 209
         try {
210
-            $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where 
211
-            id_module = \'' . Module::getModuleIdByName($this->name) . '\' and 
212
-            id_shop = \'' . Shop::getContextShopID() . '\' and 
213
-            id_hook = \'' . Hook::getIdByName('header') . '\'';
210
+            $sql_content = 'select * from '._DB_PREFIX_.'hook_module where 
211
+            id_module = \'' . Module::getModuleIdByName($this->name).'\' and 
212
+            id_shop = \'' . Shop::getContextShopID().'\' and 
213
+            id_hook = \'' . Hook::getIdByName('header').'\'';
214 214
             $hook_exists = Db::getInstance()->ExecuteS($sql_content);
215 215
             if (empty($hook_exists)) {
216
-                $sql_insert = 'insert into ' . _DB_PREFIX_.  'hook_module 
216
+                $sql_insert = 'insert into '._DB_PREFIX_.'hook_module 
217 217
             (id_module, id_shop, id_hook, position)
218 218
             values
219
-            (\''. Module::getModuleIdByName($this->name) . '\',
220
-            \''. Shop::getContextShopID() . '\',
221
-            \''. Hook::getIdByName('header') . '\',
219
+            (\''. Module::getModuleIdByName($this->name).'\',
220
+            \''. Shop::getContextShopID().'\',
221
+            \''. Hook::getIdByName('header').'\',
222 222
             150)';
223 223
                 Db::getInstance()->execute($sql_insert);
224 224
             }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function checkEnvVariables()
234 234
     {
235
-        $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config';
235
+        $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config';
236 236
         $dbConfigs = Db::getInstance()->executeS($sql_content);
237 237
 
238 238
         // Convert a multimple dimension array for SQL insert statements into a simple key/value
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         } else {
336 336
             $this->context->controller->addJS($url);
337 337
         }
338
-        $this->context->controller->addJS($this->getPathUri(). 'views/js/simulator.js');
338
+        $this->context->controller->addJS($this->getPathUri().'views/js/simulator.js');
339 339
     }
340 340
 
341 341
     /**
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         $paymentOption
400 400
             ->setCallToActionText($pagantisTitle)
401 401
             ->setAction($link->getModuleLink('pagantis', 'payment'))
402
-            ->setLogo($this->getPathUri(). 'views/img/' . $logo)
402
+            ->setLogo($this->getPathUri().'views/img/'.$logo)
403 403
             ->setModuleName(__CLASS__)
404 404
         ;
405 405
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
                 'input' => array(
427 427
                     array(
428 428
                         'name' => 'pagantis_is_enabled',
429
-                        'type' =>  (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch',
429
+                        'type' =>  (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch',
430 430
                         'label' => $this->l('Module is enabled'),
431 431
                         'prefix' => '<i class="icon icon-key"></i>',
432 432
                         'class' => 't',
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                     ),
467 467
                     array(
468 468
                         'name' => 'pagantis_simulator_is_enabled',
469
-                        'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch',
469
+                        'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch',
470 470
                         'label' => $this->l('Simulator is enabled'),
471 471
                         'prefix' => '<i class="icon icon-key"></i>',
472 472
                         'class' => 't',
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
             $message = $this->displayError($error);
583 583
         }
584 584
 
585
-        $logo = $this->getPathUri(). 'views/img/logo_pagantis.png';
585
+        $logo = $this->getPathUri().'views/img/logo_pagantis.png';
586 586
         if ($this->language == 'ES' || $this->language == null) {
587
-            $logo = $this->getPathUri(). 'views/img/logo_pagamastarde.png';
587
+            $logo = $this->getPathUri().'views/img/logo_pagamastarde.png';
588 588
         }
589 589
         $tpl = $this->local_path.'views/templates/admin/config-info.tpl';
590 590
         $this->context->smarty->assign(array(
@@ -808,17 +808,17 @@  discard block
 block discarded – undo
808 808
      */
809 809
     public function checkLogoExists()
810 810
     {
811
-        $logoPmt = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagamastarde.png';
812
-        $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png';
813
-        if (!file_exists($logoPmt) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) {
811
+        $logoPmt = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagamastarde.png';
812
+        $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png';
813
+        if (!file_exists($logoPmt) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) {
814 814
             copy(
815
-                _PS_PAGANTIS_DIR . '/views/img/logo_pagamastarde.png',
815
+                _PS_PAGANTIS_DIR.'/views/img/logo_pagamastarde.png',
816 816
                 $logoPmt
817 817
             );
818 818
         }
819
-        if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) {
819
+        if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) {
820 820
             copy(
821
-                _PS_PAGANTIS_DIR . '/views/img/logo_pagantis.png',
821
+                _PS_PAGANTIS_DIR.'/views/img/logo_pagantis.png',
822 822
                 $logoPg
823 823
             );
824 824
         }
@@ -834,14 +834,14 @@  discard block
 block discarded – undo
834 834
             /** @var CategoryCore $category */
835 835
             $category = new Category();
836 836
             $category->is_root_category = false;
837
-            $category->link_rewrite = array( 1=> PROMOTIONS_CATEGORY );
838
-            $category->meta_description = array( 1=> PROMOTIONS_CATEGORY );
839
-            $category->meta_keywords = array( 1=> PROMOTIONS_CATEGORY );
840
-            $category->meta_title = array( 1=> PROMOTIONS_CATEGORY );
841
-            $category->name = array( 1=> PROMOTIONS_CATEGORY_NAME );
837
+            $category->link_rewrite = array(1=> PROMOTIONS_CATEGORY);
838
+            $category->meta_description = array(1=> PROMOTIONS_CATEGORY);
839
+            $category->meta_keywords = array(1=> PROMOTIONS_CATEGORY);
840
+            $category->meta_title = array(1=> PROMOTIONS_CATEGORY);
841
+            $category->name = array(1=> PROMOTIONS_CATEGORY_NAME);
842 842
             $category->id_parent = Configuration::get('PS_HOME_CATEGORY');
843
-            $category->active=0;
844
-            $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' .
843
+            $category->active = 0;
844
+            $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '.
845 845
                 'Use it to promote your products or brands.';
846 846
             $category->description = $this->l($description);
847 847
             $category->save();
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             return '';
856 856
         }
857 857
 
858
-        $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1';
858
+        $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1';
859 859
         if ($results = Db::getInstance()->ExecuteS($sql)) {
860 860
             if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) {
861 861
                 return $results[0]['value'];
Please login to merge, or discard this patch.