Passed
Pull Request — master (#58)
by pablo
16:50 queued 11:45
created
Controller/Notify/IndexV2.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         $this->checkoutSession = $checkoutSession;
158 158
         $this->_request = $request;
159 159
         $this->origin = (
160
-            $this->_request->isPost() || $this->_request->getParam('origin')=='notification'
160
+            $this->_request->isPost() || $this->_request->getParam('origin') == 'notification'
161 161
                         ) ? 'Notification' : 'Order';
162 162
         $this->product = $this->_request->getParam('product');
163 163
         $this->token = $this->_request->getParam('token');
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
     private function getPagantisOrder()
314 314
     {
315 315
         try {
316
-            if ($this->getProduct()===ConfigProvider::CODE4X) {
316
+            if ($this->getProduct() === ConfigProvider::CODE4X) {
317 317
                 $this->orderClient = new Client(
318 318
                     $this->config['pagantis_public_key_4x'],
319 319
                     $this->config['pagantis_private_key_4x']
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             $this->checkPagantisStatus(array('AUTHORIZED'));
341 341
         } catch (\Exception $e) {
342 342
             $this->getMagentoOrderId();
343
-            if ($this->magentoOrderId!='') {
343
+            if ($this->magentoOrderId != '') {
344 344
                 throw new AlreadyProcessedException();
345 345
             } else {
346 346
                 throw new WrongStatusException($this->pagantisOrder->getStatus());
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
      */
354 354
     private function checkMerchantOrderStatus()
355 355
     {
356
-        if ($this->quote->getIsActive()=='0') {
356
+        if ($this->quote->getIsActive() == '0') {
357 357
             $this->getMagentoOrderId();
358 358
             throw new AlreadyProcessedException();
359 359
         }
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
             $tableName    = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);
486 486
             if ($mode == false) {
487 487
                 $dbConnection->delete($tableName, "timestamp<".(time() - 5));
488
-            } elseif ($this->quoteId!='') {
488
+            } elseif ($this->quoteId != '') {
489 489
                 $dbConnection->delete($tableName, "id=".$this->quoteId);
490 490
             }
491 491
         } catch (Exception $exception) {
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                 $this->getPagantisOrderId();
525 525
                 $this->getMagentoOrderId();
526 526
 
527
-                $logMessage  = sprintf(
527
+                $logMessage = sprintf(
528 528
                     "User waiting %s seconds, default seconds %s, bd time to expire %s seconds[quoteId=%s][origin=%s]",
529 529
                     $expirationSec,
530 530
                     self::CONCURRENCY_TIMEOUT,
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
                 $this->getPagantisOrderId();
577 577
             }
578 578
 
579
-            $pagantisOrderId   = $this->pagantisOrderId;
579
+            $pagantisOrderId = $this->pagantisOrderId;
580 580
             $query = sprintf(
581 581
                 "select mg_order_id from %s where id='%s' and order_id='%s' and token='%s'",
582 582
                 $tableName,
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
                 $pagantisOrderId,
585 585
                 $this->token
586 586
             );
587
-            $queryResult  = $dbConnection->fetchRow($query);
587
+            $queryResult = $dbConnection->fetchRow($query);
588 588
             $this->magentoOrderId = $queryResult['mg_order_id'];
589 589
         } catch (\Exception $e) {
590 590
             throw new UnknownException($e->getMessage());
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
             $metadataInfo = null;
608 608
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
609 609
                 if ($metadataKey == 'promotedProduct') {
610
-                    $metadataInfo.= "/Producto promocionado = $metadataValue";
610
+                    $metadataInfo .= "/Producto promocionado = $metadataValue";
611 611
                 }
612 612
             }
613 613
 
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
             /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
647 647
             $dbConnection = $this->dbObject->getConnection();
648 648
             $tableName    = $this->dbObject->getTableName(self::ORDERS_TABLE);
649
-            $pagantisOrderId   = $this->pagantisOrder->getId();
649
+            $pagantisOrderId = $this->pagantisOrder->getId();
650 650
             $dbConnection->update(
651 651
                 $tableName,
652 652
                 array('mg_order_id' => $this->magentoOrderId),
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
             $this->getMagentoOrderId();
722 722
         }
723 723
 
724
-        if ($this->magentoOrderId!='') {
724
+        if ($this->magentoOrderId != '') {
725 725
             /** @var Order $this->magentoOrder */
726 726
             $this->magentoOrder = $this->orderRepositoryInterface->get($this->magentoOrderId);
727 727
             if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
             $orderStatus    = strtolower($this->magentoOrder->getStatus());
747 747
             $acceptedStatus = array('processing', 'completed');
748 748
             if (in_array($orderStatus, $acceptedStatus)) {
749
-                if (isset($this->extraConfig['PAGANTIS_OK_URL']) &&  $this->extraConfig['PAGANTIS_OK_URL']!= '') {
749
+                if (isset($this->extraConfig['PAGANTIS_OK_URL']) && $this->extraConfig['PAGANTIS_OK_URL'] != '') {
750 750
                     $returnUrl = $this->extraConfig['PAGANTIS_OK_URL'];
751 751
                 } else {
752 752
                     $returnUrl = 'checkout/onepage/success';
Please login to merge, or discard this patch.
Controller/Notify/Index.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $this->checkoutSession = $checkoutSession;
156 156
         $this->_request = $request;
157 157
         $this->origin = (
158
-            $this->_request->isPost() || $this->_request->getParam('origin')=='notification'
158
+            $this->_request->isPost() || $this->_request->getParam('origin') == 'notification'
159 159
         ) ? 'Notification' : 'Order';
160 160
         $this->product = $this->_request->getParam('product');
161 161
         $this->token = $this->_request->getParam('token');
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
             $this->checkPagantisStatus(array('AUTHORIZED'));
322 322
         } catch (\Exception $e) {
323 323
             $this->getMagentoOrderId();
324
-            if ($this->magentoOrderId!='') {
324
+            if ($this->magentoOrderId != '') {
325 325
                 throw new AlreadyProcessedException();
326 326
             } else {
327 327
                 throw new WrongStatusException($this->pagantisOrder->getStatus());
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      */
335 335
     private function checkMerchantOrderStatus()
336 336
     {
337
-        if ($this->quote->getIsActive()=='0') {
337
+        if ($this->quote->getIsActive() == '0') {
338 338
             $this->getMagentoOrderId();
339 339
             throw new AlreadyProcessedException();
340 340
         }
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             $tableName    = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);
467 467
             if ($mode == false) {
468 468
                 $dbConnection->delete($tableName, "timestamp<".(time() - 5));
469
-            } elseif ($this->quoteId!='') {
469
+            } elseif ($this->quoteId != '') {
470 470
                 $dbConnection->delete($tableName, "id=".$this->quoteId);
471 471
             }
472 472
         } catch (Exception $exception) {
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
                 $this->getPagantisOrderId();
506 506
                 $this->getMagentoOrderId();
507 507
 
508
-                $logMessage  = sprintf(
508
+                $logMessage = sprintf(
509 509
                     "User waiting %s seconds, default seconds %s, bd time to expire %s seconds[quoteId=%s][origin=%s]",
510 510
                     $expirationSec,
511 511
                     self::CONCURRENCY_TIMEOUT,
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             if ($this->pagantisOrderId == '') {
557 557
                 $this->getPagantisOrderId();
558 558
             }
559
-            $pagantisOrderId   = $this->pagantisOrderId;
559
+            $pagantisOrderId = $this->pagantisOrderId;
560 560
 
561 561
             $query = sprintf(
562 562
                 "select mg_order_id from %s where id='%s' and order_id='%s' and token='%s'",
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
                 $pagantisOrderId,
566 566
                 $this->token
567 567
             );
568
-            $queryResult  = $dbConnection->fetchRow($query);
568
+            $queryResult = $dbConnection->fetchRow($query);
569 569
             $this->magentoOrderId = $queryResult['mg_order_id'];
570 570
         } catch (\Exception $e) {
571 571
             throw new UnknownException($e->getMessage());
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
             $metadataInfo = null;
590 590
             foreach ($metadataOrder as $metadataKey => $metadataValue) {
591 591
                 if ($metadataKey == 'promotedProduct') {
592
-                    $metadataInfo.= " Producto promocionado = $metadataValue //";
592
+                    $metadataInfo .= " Producto promocionado = $metadataValue //";
593 593
                 }
594 594
             }
595 595
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */
631 631
             $dbConnection = $this->dbObject->getConnection();
632 632
             $tableName    = $this->dbObject->getTableName(self::ORDERS_TABLE);
633
-            $pagantisOrderId   = $this->pagantisOrder->getId();
633
+            $pagantisOrderId = $this->pagantisOrder->getId();
634 634
             $dbConnection->update(
635 635
                 $tableName,
636 636
                 array('mg_order_id' => $this->magentoOrderId),
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
             $this->getMagentoOrderId();
707 707
         }
708 708
 
709
-        if ($this->magentoOrderId!='') {
709
+        if ($this->magentoOrderId != '') {
710 710
             /** @var Order $this->magentoOrder */
711 711
             $this->magentoOrder = $this->orderRepositoryInterface->get($this->magentoOrderId);
712 712
             if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
             $orderStatus    = strtolower($this->magentoOrder->getStatus());
733 733
             $acceptedStatus = array('processing', 'completed');
734 734
             if (in_array($orderStatus, $acceptedStatus)) {
735
-                if (isset($this->extraConfig['PAGANTIS_OK_URL']) &&  $this->extraConfig['PAGANTIS_OK_URL']!= '') {
735
+                if (isset($this->extraConfig['PAGANTIS_OK_URL']) && $this->extraConfig['PAGANTIS_OK_URL'] != '') {
736 736
                     $returnUrl = $this->extraConfig['PAGANTIS_OK_URL'];
737 737
                 } else {
738 738
                     $returnUrl = 'checkout/onepage/success';
Please login to merge, or discard this patch.
Controller/Payment/Index.php 1 patch
Spacing   +22 added lines, -25 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             /** @var Order $order */
124 124
             $lastOrder = $this->session->getLastRealOrder();
125 125
             $params = $this->getRequest()->getParams();
126
-            $pgProduct = (isset($params['product']) && $params['product']===ConfigProvider::CODE4X) ? ConfigProvider::CODE4X : ConfigProvider::CODE;
126
+            $pgProduct = (isset($params['product']) && $params['product'] === ConfigProvider::CODE4X) ? ConfigProvider::CODE4X : ConfigProvider::CODE;
127 127
 
128 128
             $urlToken = strtoupper(md5(uniqid(rand(), true)));
129 129
             $token = md5($urlToken);
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
             $customer = $quote->getCustomer();
132 132
             $shippingAddress = $quote->getShippingAddress();
133 133
 
134
-            if (isset($params['email']) && $params['email']!='') {
134
+            if (isset($params['email']) && $params['email'] != '') {
135 135
                 $this->session->setEmail($params['email']); //Get guest email after refresh page
136 136
                 $customer->setEmail($params['email']);
137 137
                 $quote->setCheckoutMethod('guest');
138 138
                 $quote->getBillingAddress()->setEmail($params['email']);
139
-            } elseif ($customer->getEmail()=='') {
139
+            } elseif ($customer->getEmail() == '') {
140 140
                 $customer->setEmail($this->session->getEmail());
141 141
                 $quote->setCheckoutMethod('guest');
142 142
                 $quote->getBillingAddress()->setEmail($this->session->getEmail());
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $currentQuote->setCustomerEmail($customer->getEmail());
148 148
             $this->quoteRepository->save($currentQuote);
149 149
 
150
-            $userAddress =  new Address();
150
+            $userAddress = new Address();
151 151
             $userAddress
152 152
                 ->setZipCode($shippingAddress->getPostcode())
153 153
                 ->setFullName($shippingAddress->getFirstname()." ".$shippingAddress->getLastname())
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
                 ->setTaxId($tax_id)
170 170
             ;
171 171
 
172
-            $orderBillingAddress =  new Address();
172
+            $orderBillingAddress = new Address();
173 173
             $billingAddress = $quote->getBillingAddress();
174 174
             $orderBillingAddress
175 175
                 ->setZipCode($billingAddress->getPostcode())
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
             if ($customer->getDob()) {
199 199
                 $orderUser->setDateOfBirth($customer->getDob());
200 200
             }
201
-            if ($customer->getTaxvat()!='') {
201
+            if ($customer->getTaxvat() != '') {
202 202
                 $orderUser->setDni($customer->getTaxvat());
203 203
                 $orderBillingAddress->setDni($customer->getTaxvat());
204 204
                 $orderShippingAddress->setDni($customer->getTaxvat());
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 
239 239
                 $promotedProduct = $this->isPromoted($item);
240 240
                 if ($promotedProduct == 'true') {
241
-                    $promotedAmount+=$product->getAmount()*$item->getQty();
242
-                    $promotedMessage = 'Promoted Item: ' . $item->getName() .
243
-                                       ' Price: ' . $item->getPrice() .
244
-                                       ' Qty: ' . $item->getQty() .
245
-                                       ' Item ID: ' . $item->getItemId();
241
+                    $promotedAmount += $product->getAmount() * $item->getQty();
242
+                    $promotedMessage = 'Promoted Item: '.$item->getName().
243
+                                       ' Price: '.$item->getPrice().
244
+                                       ' Qty: '.$item->getQty().
245
+                                       ' Item ID: '.$item->getItemId();
246 246
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
247 247
                 }
248 248
             }
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
                 $uriRoute = 'pagantis/notify/indexV2';
264 264
             }
265 265
 
266
-            $okUrlUser = $this->_url->getUrl($uriRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'redirect','product'=>$pgProduct, 'token'=>$token]]);
267
-            $okUrl     = $this->_url->getUrl($uriRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'redirect','product'=>$pgProduct, 'token'=>$token]]);
268
-            $okUrlNot  = $this->_url->getUrl($uriRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'notification','product'=>$pgProduct, 'token'=>$token]]);
266
+            $okUrlUser = $this->_url->getUrl($uriRoute, ['_query' => ['quoteId'=>$quoteId, 'origin'=>'redirect', 'product'=>$pgProduct, 'token'=>$token]]);
267
+            $okUrl     = $this->_url->getUrl($uriRoute, ['_query' => ['quoteId'=>$quoteId, 'origin'=>'redirect', 'product'=>$pgProduct, 'token'=>$token]]);
268
+            $okUrlNot  = $this->_url->getUrl($uriRoute, ['_query' => ['quoteId'=>$quoteId, 'origin'=>'notification', 'product'=>$pgProduct, 'token'=>$token]]);
269 269
 
270 270
             $orderConfigurationUrls
271 271
                 ->setCancel($cancelUrl)
@@ -280,15 +280,12 @@  discard block
 block discarded – undo
280 280
                 ->setType(Channel::ONLINE)
281 281
             ;
282 282
 
283
-            $haystack  = ($this->store->getLocale()!=null) ? $this->store->getLocale() : $this->getResolverCountry();
283
+            $haystack = ($this->store->getLocale() != null) ? $this->store->getLocale() : $this->getResolverCountry();
284 284
             $langCountry = strtolower(strstr($haystack, '_', true));
285 285
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
286 286
 
287 287
             $purchaseCountry =
288
-                in_array($langCountry, $allowedCountries) ? $langCountry :
289
-                in_array(strtolower($shippingAddress->getCountry()), $allowedCountries)? $shippingAddress->getCountry():
290
-                in_array(strtolower($billingAddress->getCountry()), $allowedCountries)? $billingAddress->getCountry() :
291
-                null;
288
+                in_array($langCountry, $allowedCountries) ? $langCountry : in_array(strtolower($shippingAddress->getCountry()), $allowedCountries) ? $shippingAddress->getCountry() : in_array(strtolower($billingAddress->getCountry()), $allowedCountries) ? $billingAddress->getCountry() : null;
292 289
 
293 290
             $orderConfiguration = new Configuration();
294 291
             $orderConfiguration
@@ -307,7 +304,7 @@  discard block
 block discarded – undo
307 304
             ;
308 305
 
309 306
             if ($pgProduct === ConfigProvider::CODE4X) {
310
-                if ($this->config['pagantis_public_key_4x']=='' || $this->config['pagantis_private_key_4x']=='') {
307
+                if ($this->config['pagantis_public_key_4x'] == '' || $this->config['pagantis_private_key_4x'] == '') {
311 308
                     throw new \Exception('Public and Secret Key not found');
312 309
                 } else {
313 310
                     $orderClient = new Client(
@@ -316,7 +313,7 @@  discard block
 block discarded – undo
316 313
                     );
317 314
                 }
318 315
             } else {
319
-                if ($this->config['pagantis_public_key']=='' || $this->config['pagantis_private_key']=='') {
316
+                if ($this->config['pagantis_public_key'] == '' || $this->config['pagantis_private_key'] == '') {
320 317
                     throw new \Exception('Public and Secret Key not found');
321 318
                 } else {
322 319
                     $orderClient = new Client(
@@ -343,7 +340,7 @@  discard block
 block discarded – undo
343 340
         }
344 341
 
345 342
         $displayMode = $this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE'];
346
-        if ($displayMode==='0') {
343
+        if ($displayMode === '0') {
347 344
             echo $url;
348 345
             exit;
349 346
         } else {
@@ -365,11 +362,11 @@  discard block
 block discarded – undo
365 362
     private function getOrders($customerId)
366 363
     {
367 364
         $orderCollection = array();
368
-        if ($customerId!='') {
365
+        if ($customerId != '') {
369 366
             $this->orderCollection->addAttributeToFilter('customer_id', $customerId)
370 367
                             ->addAttributeToFilter(
371 368
                                 'status',
372
-                                ['in' => ['processing','pending','complete']]
369
+                                ['in' => ['processing', 'pending', 'complete']]
373 370
                             )
374 371
                             ->load();
375 372
             $orderCollection = $this->orderCollection->getData();
@@ -414,7 +411,7 @@  discard block
 block discarded – undo
414 411
         $tableName = $this->dbObject->getTableName(self::ORDERS_TABLE);
415 412
         return $dbConnection->insert(
416 413
             $tableName,
417
-            array('id'=>$quoteId,'order_id'=>$pagantisOrderId,'token'=>$token),
414
+            array('id'=>$quoteId, 'order_id'=>$pagantisOrderId, 'token'=>$token),
418 415
             array('order_id')
419 416
         );
420 417
     }
Please login to merge, or discard this patch.
Setup/UpgradeData.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                 );
66 66
                 foreach ($newConfigs as $config => $value) {
67 67
                     $setup->getConnection()
68
-                          ->insert($prefixedTableName, array('config' => $config, 'value' => $value));
68
+                            ->insert($prefixedTableName, array('config' => $config, 'value' => $value));
69 69
                 }
70 70
             }
71 71
 
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
                 );
77 77
                 foreach ($newConfigs as $config => $value) {
78 78
                     $setup->getConnection()
79
-                          ->insert($prefixedTableName, array('config' => $config, 'value' => $value));
79
+                            ->insert($prefixedTableName, array('config' => $config, 'value' => $value));
80 80
                 }
81 81
                 $setup->getConnection()
82
-                      ->update(
83
-                          $prefixedTableName,
84
-                          array('value' => 'sdk.simulator.types.PRODUCT_PAGE'),
85
-                          "config='PAGANTIS_SIMULATOR_DISPLAY_TYPE'"
86
-                      );
82
+                        ->update(
83
+                            $prefixedTableName,
84
+                            array('value' => 'sdk.simulator.types.PRODUCT_PAGE'),
85
+                            "config='PAGANTIS_SIMULATOR_DISPLAY_TYPE'"
86
+                        );
87 87
 
88 88
             }
89 89
 
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
                 );
98 98
                 foreach ($newConfigs as $config => $value) {
99 99
                     $setup->getConnection()
100
-                          ->insert($prefixedTableName, array('config' => $config, 'value' => $value));
100
+                            ->insert($prefixedTableName, array('config' => $config, 'value' => $value));
101 101
                 }
102 102
                 $setup->getConnection()
103
-                      ->update(
104
-                          $prefixedTableName,
105
-                          array('value' => 'Instant financing'),
106
-                          "config='PAGANTIS_TITLE'"
107
-                      );
103
+                        ->update(
104
+                            $prefixedTableName,
105
+                            array('value' => 'Instant financing'),
106
+                            "config='PAGANTIS_TITLE'"
107
+                        );
108 108
             }
109 109
 
110 110
             if (version_compare($context->getVersion(), '8.6.1') < 0) {
Please login to merge, or discard this patch.