@@ -111,7 +111,7 @@  | 
                                                    ||
| 111 | 111 | Table::TYPE_TIMESTAMP,  | 
                                                        
| 112 | 112 | null,  | 
                                                        
| 113 | 113 |                      array('nullable'=>false, | 
                                                        
| 114 | - 'default'=>Table::TIMESTAMP_INIT)  | 
                                                        |
| 114 | + 'default'=>Table::TIMESTAMP_INIT)  | 
                                                        |
| 115 | 115 | );  | 
                                                        
| 116 | 116 | return $dbConnection->createTable($table);  | 
                                                        
| 117 | 117 | }  | 
                                                        
@@ -44,7 +44,7 @@  | 
                                                    ||
| 44 | 44 |              $secretKey = $this->getRequest()->getParam('secret'); | 
                                                        
| 45 | 45 | $privateKey = isset($this->config['pagantis_private_key']) ? $this->config['pagantis_private_key'] : null;  | 
                                                        
| 46 | 46 | |
| 47 | -            if ($secretKey!='' && $privateKey!='') { | 
                                                        |
| 47 | +            if ($secretKey != '' && $privateKey != '') { | 
                                                        |
| 48 | 48 | $this->checkDbLogTable();  | 
                                                        
| 49 | 49 | /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */  | 
                                                        
| 50 | 50 | $dbConnection = $this->dbObject->getConnection();  | 
                                                        
@@ -72,7 +72,7 @@ discard block  | 
                                                    ||
| 72 | 72 |              } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { | 
                                                        
| 73 | 73 |                  if (count($_POST)) { | 
                                                        
| 74 | 74 |                      foreach ($_POST as $config => $value) { | 
                                                        
| 75 | -                        if (isset($this->defaultConfigs[$config]) && $response['status']==null) { | 
                                                        |
| 75 | +                        if (isset($this->defaultConfigs[$config]) && $response['status'] == null) { | 
                                                        |
| 76 | 76 | $dbConnection->update(  | 
                                                        
| 77 | 77 | $tableName,  | 
                                                        
| 78 | 78 |                                  array('value' => $value), | 
                                                        
@@ -90,7 +90,7 @@ discard block  | 
                                                    ||
| 90 | 90 | }  | 
                                                        
| 91 | 91 | |
| 92 | 92 | $formattedResult = array();  | 
                                                        
| 93 | -            if ($response['status']==null) { | 
                                                        |
| 93 | +            if ($response['status'] == null) { | 
                                                        |
| 94 | 94 |                  $dbResult = $dbConnection->fetchAll("select * from $tableName"); | 
                                                        
| 95 | 95 |                  foreach ($dbResult as $value) { | 
                                                        
| 96 | 96 | $formattedResult[$value['config']] = $value['value'];  | 
                                                        
@@ -24,21 +24,21 @@  | 
                                                    ||
| 24 | 24 | * @var array $defaultConfigs  | 
                                                        
| 25 | 25 | */  | 
                                                        
| 26 | 26 |      public $defaultConfigs = array('PAGANTIS_TITLE'=>'Paga en cuotas', | 
                                                        
| 27 | - 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE',  | 
                                                        |
| 28 | - 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE',  | 
                                                        |
| 29 | - 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',  | 
                                                        |
| 30 | - 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3,  | 
                                                        |
| 31 | - 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12,  | 
                                                        |
| 32 | - 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default',  | 
                                                        |
| 33 | - 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'pgSDK.simulator.positions.INNER',  | 
                                                        |
| 34 | - 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'default',  | 
                                                        |
| 35 | - 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'default',  | 
                                                        |
| 36 | - 'PAGANTIS_FORM_DISPLAY_TYPE'=>0,  | 
                                                        |
| 37 | - 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1,  | 
                                                        |
| 38 | - 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0,  | 
                                                        |
| 39 | - 'PAGANTIS_URL_OK'=>'',  | 
                                                        |
| 40 | - 'PAGANTIS_URL_KO'=>'',  | 
                                                        |
| 41 | - 'PAGANTIS_TITLE_EXTRA' => 'Pay up to 12 comfortable installments with Pagantis. Completely online and sympathetic request, and the answer is immediate!'  | 
                                                        |
| 27 | + 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE',  | 
                                                        |
| 28 | + 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE',  | 
                                                        |
| 29 | + 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',  | 
                                                        |
| 30 | + 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3,  | 
                                                        |
| 31 | + 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12,  | 
                                                        |
| 32 | + 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default',  | 
                                                        |
| 33 | + 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'pgSDK.simulator.positions.INNER',  | 
                                                        |
| 34 | + 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'default',  | 
                                                        |
| 35 | + 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'default',  | 
                                                        |
| 36 | + 'PAGANTIS_FORM_DISPLAY_TYPE'=>0,  | 
                                                        |
| 37 | + 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1,  | 
                                                        |
| 38 | + 'PAGANTIS_DISPLAY_MAX_AMOUNT'=>0,  | 
                                                        |
| 39 | + 'PAGANTIS_URL_OK'=>'',  | 
                                                        |
| 40 | + 'PAGANTIS_URL_KO'=>'',  | 
                                                        |
| 41 | + 'PAGANTIS_TITLE_EXTRA' => 'Pay up to 12 comfortable installments with Pagantis. Completely online and sympathetic request, and the answer is immediate!'  | 
                                                        |
| 42 | 42 | );  | 
                                                        
| 43 | 43 | |
| 44 | 44 | /**  | 
                                                        
@@ -111,7 +111,7 @@  | 
                                                    ||
| 111 | 111 | Table::TYPE_TIMESTAMP,  | 
                                                        
| 112 | 112 | null,  | 
                                                        
| 113 | 113 |                      array('nullable'=>false, | 
                                                        
| 114 | - 'default'=>Table::TIMESTAMP_INIT)  | 
                                                        |
| 114 | + 'default'=>Table::TIMESTAMP_INIT)  | 
                                                        |
| 115 | 115 | );  | 
                                                        
| 116 | 116 | return $dbConnection->createTable($table);  | 
                                                        
| 117 | 117 | }  | 
                                                        
@@ -44,7 +44,7 @@  | 
                                                    ||
| 44 | 44 |              $secretKey = $this->getRequest()->getParam('secret'); | 
                                                        
| 45 | 45 | $privateKey = isset($this->config['pagantis_private_key']) ? $this->config['pagantis_private_key'] : null;  | 
                                                        
| 46 | 46 | |
| 47 | -            if ($secretKey!='' && $privateKey!='') { | 
                                                        |
| 47 | +            if ($secretKey != '' && $privateKey != '') { | 
                                                        |
| 48 | 48 | $this->checkDbLogTable();  | 
                                                        
| 49 | 49 | /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */  | 
                                                        
| 50 | 50 | $dbConnection = $this->dbObject->getConnection();  | 
                                                        
@@ -24,22 +24,22 @@ discard block  | 
                                                    ||
| 24 | 24 | $installer->startSetup();  | 
                                                        
| 25 | 25 | |
| 26 | 26 | $table = $installer->getConnection()  | 
                                                        
| 27 | - ->newTable($installer->getTable(self::CONFIG_TABLE))  | 
                                                        |
| 28 | - ->addColumn(  | 
                                                        |
| 29 | - 'id',  | 
                                                        |
| 30 | - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,  | 
                                                        |
| 31 | - null,  | 
                                                        |
| 32 | - ['identity' => true, 'unsigned' => true, 'nullable' =>  | 
                                                        |
| 33 | - false, 'primary' => true],  | 
                                                        |
| 34 | - 'Entity ID'  | 
                                                        |
| 35 | - )  | 
                                                        |
| 36 | - ->addColumn(  | 
                                                        |
| 37 | - 'config',  | 
                                                        |
| 38 | - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,  | 
                                                        |
| 39 | - 60,  | 
                                                        |
| 40 | - ['nullable' => false],  | 
                                                        |
| 41 | - 'Config'  | 
                                                        |
| 42 | - )  | 
                                                        |
| 27 | + ->newTable($installer->getTable(self::CONFIG_TABLE))  | 
                                                        |
| 28 | + ->addColumn(  | 
                                                        |
| 29 | + 'id',  | 
                                                        |
| 30 | + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,  | 
                                                        |
| 31 | + null,  | 
                                                        |
| 32 | + ['identity' => true, 'unsigned' => true, 'nullable' =>  | 
                                                        |
| 33 | + false, 'primary' => true],  | 
                                                        |
| 34 | + 'Entity ID'  | 
                                                        |
| 35 | + )  | 
                                                        |
| 36 | + ->addColumn(  | 
                                                        |
| 37 | + 'config',  | 
                                                        |
| 38 | + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,  | 
                                                        |
| 39 | + 60,  | 
                                                        |
| 40 | + ['nullable' => false],  | 
                                                        |
| 41 | + 'Config'  | 
                                                        |
| 42 | + )  | 
                                                        |
| 43 | 43 | ->addColumn(  | 
                                                        
| 44 | 44 | 'value',  | 
                                                        
| 45 | 45 | \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,  | 
                                                        
@@ -47,7 +47,7 @@ discard block  | 
                                                    ||
| 47 | 47 | ['nullable' => false],  | 
                                                        
| 48 | 48 | 'Value'  | 
                                                        
| 49 | 49 | )  | 
                                                        
| 50 | -                           ->setComment('Pagantis config table'); | 
                                                        |
| 50 | +                            ->setComment('Pagantis config table'); | 
                                                        |
| 51 | 51 | |
| 52 | 52 | $installer->getConnection()->createTable($table);  | 
                                                        
| 53 | 53 | |
@@ -26,9 +26,9 @@  | 
                                                    ||
| 26 | 26 |      { | 
                                                        
| 27 | 27 | $originalData = $element->getOriginalData();  | 
                                                        
| 28 | 28 | $label = __($originalData['button_label']);  | 
                                                        
| 29 | - $url = $this->escapeHtml($originalData['button_url']);  | 
                                                        |
| 29 | + $url = $this->escapeHtml($originalData['button_url']);  | 
                                                        |
| 30 | 30 | $labelCredentials = __($originalData['button_credentials_label']);  | 
                                                        
| 31 | - $urlCredentials = $this->escapeHtml($originalData['button_credentials_url']);  | 
                                                        |
| 31 | + $urlCredentials = $this->escapeHtml($originalData['button_credentials_url']);  | 
                                                        |
| 32 | 32 | return <<<EOD  | 
                                                        
| 33 | 33 | <div class="pp-buttons-container">  | 
                                                        
| 34 | 34 |      <button onclick="javascript:window.open('$url')" class="scalable" type="button" id="bo_pagantis"> | 
                                                        
@@ -234,9 +234,9 @@ discard block  | 
                                                    ||
| 234 | 234 |                  if ($promotedProduct == 'true') { | 
                                                        
| 235 | 235 | $promotedAmount+=$product->getAmount()*$item->getQty();  | 
                                                        
| 236 | 236 | $promotedMessage = 'Promoted Item: ' . $item->getName() .  | 
                                                        
| 237 | - ' Price: ' . $item->getPrice() .  | 
                                                        |
| 238 | - ' Qty: ' . $item->getQty() .  | 
                                                        |
| 239 | - ' Item ID: ' . $item->getItemId();  | 
                                                        |
| 237 | + ' Price: ' . $item->getPrice() .  | 
                                                        |
| 238 | + ' Qty: ' . $item->getQty() .  | 
                                                        |
| 239 | + ' Item ID: ' . $item->getItemId();  | 
                                                        |
| 240 | 240 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
                                                        
| 241 | 241 | }  | 
                                                        
| 242 | 242 | }  | 
                                                        
@@ -401,9 +401,9 @@ discard block  | 
                                                    ||
| 401 | 401 | $magentoVersion = $this->productMetadataInterface->getVersion();  | 
                                                        
| 402 | 402 |          $moduleInfo = $this->moduleList->getOne('Pagantis_Pagantis'); | 
                                                        
| 403 | 403 | return array( 'magento' => $magentoVersion,  | 
                                                        
| 404 | - 'pagantis' => $moduleInfo['setup_version'],  | 
                                                        |
| 405 | - 'php' => phpversion(),  | 
                                                        |
| 406 | - 'curl' => $curlVersion);  | 
                                                        |
| 404 | + 'pagantis' => $moduleInfo['setup_version'],  | 
                                                        |
| 405 | + 'php' => phpversion(),  | 
                                                        |
| 406 | + 'curl' => $curlVersion);  | 
                                                        |
| 407 | 407 | }  | 
                                                        
| 408 | 408 | |
| 409 | 409 | /**  | 
                                                        
@@ -125,12 +125,12 @@ discard block  | 
                                                    ||
| 125 | 125 | $customer = $quote->getCustomer();  | 
                                                        
| 126 | 126 | $shippingAddress = $quote->getShippingAddress();  | 
                                                        
| 127 | 127 | |
| 128 | -            if (isset($params['email']) && $params['email']!='') { | 
                                                        |
| 128 | +            if (isset($params['email']) && $params['email'] != '') { | 
                                                        |
| 129 | 129 | $this->session->setEmail($params['email']); //Get guest email after refresh page  | 
                                                        
| 130 | 130 | $customer->setEmail($params['email']);  | 
                                                        
| 131 | 131 |                  $quote->setCheckoutMethod('guest'); | 
                                                        
| 132 | 132 | $quote->getBillingAddress()->setEmail($params['email']);  | 
                                                        
| 133 | -            } elseif ($customer->getEmail()=='') { | 
                                                        |
| 133 | +            } elseif ($customer->getEmail() == '') { | 
                                                        |
| 134 | 134 | $customer->setEmail($this->session->getEmail());  | 
                                                        
| 135 | 135 |                  $quote->setCheckoutMethod('guest'); | 
                                                        
| 136 | 136 | $quote->getBillingAddress()->setEmail($this->session->getEmail());  | 
                                                        
@@ -141,7 +141,7 @@ discard block  | 
                                                    ||
| 141 | 141 | $currentQuote->setCustomerEmail($customer->getEmail());  | 
                                                        
| 142 | 142 | $this->quoteRepository->save($currentQuote);  | 
                                                        
| 143 | 143 | |
| 144 | - $userAddress = new Address();  | 
                                                        |
| 144 | + $userAddress = new Address();  | 
                                                        |
| 145 | 145 | $userAddress  | 
                                                        
| 146 | 146 | ->setZipCode($shippingAddress->getPostcode())  | 
                                                        
| 147 | 147 | ->setFullName($shippingAddress->getFirstname()." ".$shippingAddress->getLastname())  | 
                                                        
@@ -163,7 +163,7 @@ discard block  | 
                                                    ||
| 163 | 163 | ->setTaxId($tax_id)  | 
                                                        
| 164 | 164 | ;  | 
                                                        
| 165 | 165 | |
| 166 | - $orderBillingAddress = new Address();  | 
                                                        |
| 166 | + $orderBillingAddress = new Address();  | 
                                                        |
| 167 | 167 | $billingAddress = $quote->getBillingAddress();  | 
                                                        
| 168 | 168 | $orderBillingAddress  | 
                                                        
| 169 | 169 | ->setZipCode($billingAddress->getPostcode())  | 
                                                        
@@ -192,7 +192,7 @@ discard block  | 
                                                    ||
| 192 | 192 |              if ($customer->getDob()) { | 
                                                        
| 193 | 193 | $orderUser->setDateOfBirth($customer->getDob());  | 
                                                        
| 194 | 194 | }  | 
                                                        
| 195 | -            if ($customer->getTaxvat()!='') { | 
                                                        |
| 195 | +            if ($customer->getTaxvat() != '') { | 
                                                        |
| 196 | 196 | $orderUser->setDni($customer->getTaxvat());  | 
                                                        
| 197 | 197 | $orderBillingAddress->setDni($customer->getTaxvat());  | 
                                                        
| 198 | 198 | $orderShippingAddress->setDni($customer->getTaxvat());  | 
                                                        
@@ -232,11 +232,11 @@ discard block  | 
                                                    ||
| 232 | 232 | |
| 233 | 233 | $promotedProduct = $this->isPromoted($item);  | 
                                                        
| 234 | 234 |                  if ($promotedProduct == 'true') { | 
                                                        
| 235 | - $promotedAmount+=$product->getAmount()*$item->getQty();  | 
                                                        |
| 236 | - $promotedMessage = 'Promoted Item: ' . $item->getName() .  | 
                                                        |
| 237 | - ' Price: ' . $item->getPrice() .  | 
                                                        |
| 238 | - ' Qty: ' . $item->getQty() .  | 
                                                        |
| 239 | - ' Item ID: ' . $item->getItemId();  | 
                                                        |
| 235 | + $promotedAmount += $product->getAmount() * $item->getQty();  | 
                                                        |
| 236 | + $promotedMessage = 'Promoted Item: '.$item->getName().  | 
                                                        |
| 237 | + ' Price: '.$item->getPrice().  | 
                                                        |
| 238 | + ' Qty: '.$item->getQty().  | 
                                                        |
| 239 | + ' Item ID: '.$item->getItemId();  | 
                                                        |
| 240 | 240 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
                                                        
| 241 | 241 | }  | 
                                                        
| 242 | 242 | }  | 
                                                        
@@ -261,8 +261,8 @@ discard block  | 
                                                    ||
| 261 | 261 | $okUrlRoute = 'pagantis/notify/indexV2';  | 
                                                        
| 262 | 262 | }  | 
                                                        
| 263 | 263 | |
| 264 | - $okUrlUser = $this->_url->getUrl($okUrlRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'redirect']]);  | 
                                                        |
| 265 | - $okUrlNot = $this->_url->getUrl($okUrlRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'notification']]);  | 
                                                        |
| 264 | + $okUrlUser = $this->_url->getUrl($okUrlRoute, ['_query' => ['quoteId'=>$quoteId, 'origin'=>'redirect']]);  | 
                                                        |
| 265 | + $okUrlNot = $this->_url->getUrl($okUrlRoute, ['_query' => ['quoteId'=>$quoteId, 'origin'=>'notification']]);  | 
                                                        |
| 266 | 266 | |
| 267 | 267 | $orderConfigurationUrls  | 
                                                        
| 268 | 268 | ->setCancel($cancelUrl)  | 
                                                        
@@ -277,15 +277,12 @@ discard block  | 
                                                    ||
| 277 | 277 | ->setType(Channel::ONLINE)  | 
                                                        
| 278 | 278 | ;  | 
                                                        
| 279 | 279 | |
| 280 | - $haystack = ($this->store->getLocale()!=null) ? $this->store->getLocale() : $this->getResolverCountry();  | 
                                                        |
| 280 | + $haystack = ($this->store->getLocale() != null) ? $this->store->getLocale() : $this->getResolverCountry();  | 
                                                        |
| 281 | 281 | $langCountry = strtolower(strstr($haystack, '_', true));  | 
                                                        
| 282 | 282 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);  | 
                                                        
| 283 | 283 | |
| 284 | 284 | $purchaseCountry =  | 
                                                        
| 285 | - in_array($langCountry, $allowedCountries) ? $langCountry :  | 
                                                        |
| 286 | - in_array(strtolower($shippingAddress->getCountry()), $allowedCountries)? $shippingAddress->getCountry():  | 
                                                        |
| 287 | - in_array(strtolower($billingAddress->getCountry()), $allowedCountries)? $billingAddress->getCountry() :  | 
                                                        |
| 288 | - null;  | 
                                                        |
| 285 | + in_array($langCountry, $allowedCountries) ? $langCountry : in_array(strtolower($shippingAddress->getCountry()), $allowedCountries) ? $shippingAddress->getCountry() : in_array(strtolower($billingAddress->getCountry()), $allowedCountries) ? $billingAddress->getCountry() : null;  | 
                                                        |
| 289 | 286 | |
| 290 | 287 | $orderConfiguration = new Configuration();  | 
                                                        
| 291 | 288 | $orderConfiguration  | 
                                                        
@@ -303,7 +300,7 @@ discard block  | 
                                                    ||
| 303 | 300 | ->setUser($orderUser)  | 
                                                        
| 304 | 301 | ;  | 
                                                        
| 305 | 302 | |
| 306 | -            if ($this->config['pagantis_public_key']=='' || $this->config['pagantis_private_key']=='') { | 
                                                        |
| 303 | +            if ($this->config['pagantis_public_key'] == '' || $this->config['pagantis_private_key'] == '') { | 
                                                        |
| 307 | 304 |                  throw new \Exception('Public and Secret Key not found'); | 
                                                        
| 308 | 305 | }  | 
                                                        
| 309 | 306 | |
@@ -329,7 +326,7 @@ discard block  | 
                                                    ||
| 329 | 326 | }  | 
                                                        
| 330 | 327 | |
| 331 | 328 | $displayMode = $this->extraConfig['PAGANTIS_FORM_DISPLAY_TYPE'];  | 
                                                        
| 332 | -        if ($displayMode==='0') { | 
                                                        |
| 329 | +        if ($displayMode === '0') { | 
                                                        |
| 333 | 330 | echo $url;  | 
                                                        
| 334 | 331 | exit;  | 
                                                        
| 335 | 332 |          } else { | 
                                                        
@@ -351,11 +348,11 @@ discard block  | 
                                                    ||
| 351 | 348 | private function getOrders($customerId)  | 
                                                        
| 352 | 349 |      { | 
                                                        
| 353 | 350 | $orderCollection = array();  | 
                                                        
| 354 | -        if ($customerId!='') { | 
                                                        |
| 351 | +        if ($customerId != '') { | 
                                                        |
| 355 | 352 |              $this->orderCollection->addAttributeToFilter('customer_id', $customerId) | 
                                                        
| 356 | 353 | ->addAttributeToFilter(  | 
                                                        
| 357 | 354 | 'status',  | 
                                                        
| 358 | - ['in' => ['processing','pending','complete']]  | 
                                                        |
| 355 | + ['in' => ['processing', 'pending', 'complete']]  | 
                                                        |
| 359 | 356 | )  | 
                                                        
| 360 | 357 | ->load();  | 
                                                        
| 361 | 358 | $orderCollection = $this->orderCollection->getData();  | 
                                                        
@@ -398,7 +395,7 @@ discard block  | 
                                                    ||
| 398 | 395 | $tableName = $this->dbObject->getTableName(self::ORDERS_TABLE);  | 
                                                        
| 399 | 396 | return $dbConnection->insertOnDuplicate(  | 
                                                        
| 400 | 397 | $tableName,  | 
                                                        
| 401 | -            array('id'=>$quoteId,'order_id'=>$pagantisOrderId), | 
                                                        |
| 398 | +            array('id'=>$quoteId, 'order_id'=>$pagantisOrderId), | 
                                                        |
| 402 | 399 |              array('order_id') | 
                                                        
| 403 | 400 | );  | 
                                                        
| 404 | 401 | }  | 
                                                        
@@ -412,7 +409,7 @@ discard block  | 
                                                    ||
| 412 | 409 | $curlVersion = $curlInfo['version'];  | 
                                                        
| 413 | 410 | $magentoVersion = $this->productMetadataInterface->getVersion();  | 
                                                        
| 414 | 411 |          $moduleInfo = $this->moduleList->getOne('Pagantis_Pagantis'); | 
                                                        
| 415 | - return array( 'magento' => $magentoVersion,  | 
                                                        |
| 412 | +        return array('magento' => $magentoVersion, | 
                                                        |
| 416 | 413 | 'pagantis' => $moduleInfo['setup_version'],  | 
                                                        
| 417 | 414 | 'php' => phpversion(),  | 
                                                        
| 418 | 415 | 'curl' => $curlVersion);  | 
                                                        
@@ -107,7 +107,7 @@  | 
                                                    ||
| 107 | 107 |          foreach ($items as $key => $item) { | 
                                                        
| 108 | 108 | $promotedProduct = $this->isPromoted($item);  | 
                                                        
| 109 | 109 |              if ($promotedProduct == 'true') { | 
                                                        
| 110 | - $promotedAmount+=$item->getPrice()*$item->getQty();  | 
                                                        |
| 110 | + $promotedAmount += $item->getPrice() * $item->getQty();  | 
                                                        |
| 111 | 111 | }  | 
                                                        
| 112 | 112 | }  | 
                                                        
| 113 | 113 | |
@@ -531,17 +531,17 @@  | 
                                                    ||
| 531 | 531 | }  | 
                                                        
| 532 | 532 | |
| 533 | 533 | $this->magentoOrder->addStatusHistoryComment($metadataInfo)  | 
                                                        
| 534 | - ->setIsCustomerNotified(false)  | 
                                                        |
| 535 | -                               ->setEntityName('order') | 
                                                        |
| 536 | - ->save();  | 
                                                        |
| 534 | + ->setIsCustomerNotified(false)  | 
                                                        |
| 535 | +                                ->setEntityName('order') | 
                                                        |
| 536 | + ->save();  | 
                                                        |
| 537 | 537 | |
| 538 | 538 | $comment = 'pagantisOrderId: '.$this->pagantisOrder->getId(). ' ' .  | 
                                                        
| 539 | - 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). ' ' .  | 
                                                        |
| 540 | - 'via: '.$this->origin;  | 
                                                        |
| 539 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). ' ' .  | 
                                                        |
| 540 | + 'via: '.$this->origin;  | 
                                                        |
| 541 | 541 | $this->magentoOrder->addStatusHistoryComment($comment)  | 
                                                        
| 542 | - ->setIsCustomerNotified(false)  | 
                                                        |
| 543 | -                               ->setEntityName('order') | 
                                                        |
| 544 | - ->save();  | 
                                                        |
| 542 | + ->setIsCustomerNotified(false)  | 
                                                        |
| 543 | +                                ->setEntityName('order') | 
                                                        |
| 544 | + ->save();  | 
                                                        |
| 545 | 545 | |
| 546 | 546 |              if ($this->magentoOrderId == '') { | 
                                                        
| 547 | 547 |                  throw new UnknownException('Order can not be saved'); | 
                                                        
@@ -273,7 +273,7 @@ discard block  | 
                                                    ||
| 273 | 273 |              $this->checkPagantisStatus(array('AUTHORIZED')); | 
                                                        
| 274 | 274 |          } catch (\Exception $e) { | 
                                                        
| 275 | 275 | $this->getMagentoOrderId();  | 
                                                        
| 276 | -            if ($this->magentoOrderId!='') { | 
                                                        |
| 276 | +            if ($this->magentoOrderId != '') { | 
                                                        |
| 277 | 277 | throw new AlreadyProcessedException();  | 
                                                        
| 278 | 278 |              } else { | 
                                                        
| 279 | 279 | throw new WrongStatusException($this->pagantisOrder->getStatus());  | 
                                                        
@@ -286,7 +286,7 @@ discard block  | 
                                                    ||
| 286 | 286 | */  | 
                                                        
| 287 | 287 | private function checkMerchantOrderStatus()  | 
                                                        
| 288 | 288 |      { | 
                                                        
| 289 | -        if ($this->quote->getIsActive()=='0') { | 
                                                        |
| 289 | +        if ($this->quote->getIsActive() == '0') { | 
                                                        |
| 290 | 290 | $this->getMagentoOrderId();  | 
                                                        
| 291 | 291 | throw new AlreadyProcessedException();  | 
                                                        
| 292 | 292 | }  | 
                                                        
@@ -418,7 +418,7 @@ discard block  | 
                                                    ||
| 418 | 418 | $tableName = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);  | 
                                                        
| 419 | 419 |              if ($mode == false) { | 
                                                        
| 420 | 420 | $dbConnection->delete($tableName, "timestamp<".(time() - 5));  | 
                                                        
| 421 | -            } elseif ($this->quoteId!='') { | 
                                                        |
| 421 | +            } elseif ($this->quoteId != '') { | 
                                                        |
| 422 | 422 | $dbConnection->delete($tableName, "id=".$this->quoteId);  | 
                                                        
| 423 | 423 | }  | 
                                                        
| 424 | 424 |          } catch (Exception $exception) { | 
                                                        
@@ -454,7 +454,7 @@ discard block  | 
                                                    ||
| 454 | 454 | sleep($expirationSec + 1);  | 
                                                        
| 455 | 455 | }  | 
                                                        
| 456 | 456 | |
| 457 | - $logMessage = sprintf(  | 
                                                        |
| 457 | + $logMessage = sprintf(  | 
                                                        |
| 458 | 458 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",  | 
                                                        
| 459 | 459 | $expirationSec,  | 
                                                        
| 460 | 460 | self::CONCURRENCY_TIMEOUT,  | 
                                                        
@@ -499,7 +499,7 @@ discard block  | 
                                                    ||
| 499 | 499 | /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */  | 
                                                        
| 500 | 500 | $dbConnection = $this->dbObject->getConnection();  | 
                                                        
| 501 | 501 | $tableName = $this->dbObject->getTableName(self::ORDERS_TABLE);  | 
                                                        
| 502 | - $pagantisOrderId = $this->pagantisOrderId;  | 
                                                        |
| 502 | + $pagantisOrderId = $this->pagantisOrderId;  | 
                                                        |
| 503 | 503 | |
| 504 | 504 | $query = "select mg_order_id from $tableName where id='$this->quoteId' and order_id='$pagantisOrderId'";  | 
                                                        
| 505 | 505 | $queryResult = $dbConnection->fetchRow($query);  | 
                                                        
@@ -526,7 +526,7 @@ discard block  | 
                                                    ||
| 526 | 526 | $metadataInfo = null;  | 
                                                        
| 527 | 527 |              foreach ($metadataOrder as $metadataKey => $metadataValue) { | 
                                                        
| 528 | 528 |                  if ($metadataKey == 'promotedProduct') { | 
                                                        
| 529 | - $metadataInfo.= " Producto promocionado = $metadataValue //";  | 
                                                        |
| 529 | + $metadataInfo .= " Producto promocionado = $metadataValue //";  | 
                                                        |
| 530 | 530 | }  | 
                                                        
| 531 | 531 | }  | 
                                                        
| 532 | 532 | |
@@ -535,8 +535,8 @@ discard block  | 
                                                    ||
| 535 | 535 |                                 ->setEntityName('order') | 
                                                        
| 536 | 536 | ->save();  | 
                                                        
| 537 | 537 | |
| 538 | - $comment = 'pagantisOrderId: '.$this->pagantisOrder->getId(). ' ' .  | 
                                                        |
| 539 | - 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). ' ' .  | 
                                                        |
| 538 | + $comment = 'pagantisOrderId: '.$this->pagantisOrder->getId().' '.  | 
                                                        |
| 539 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus().' '.  | 
                                                        |
| 540 | 540 | 'via: '.$this->origin;  | 
                                                        
| 541 | 541 | $this->magentoOrder->addStatusHistoryComment($comment)  | 
                                                        
| 542 | 542 | ->setIsCustomerNotified(false)  | 
                                                        
@@ -560,7 +560,7 @@ discard block  | 
                                                    ||
| 560 | 560 | /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */  | 
                                                        
| 561 | 561 | $dbConnection = $this->dbObject->getConnection();  | 
                                                        
| 562 | 562 | $tableName = $this->dbObject->getTableName(self::ORDERS_TABLE);  | 
                                                        
| 563 | - $pagantisOrderId = $this->pagantisOrder->getId();  | 
                                                        |
| 563 | + $pagantisOrderId = $this->pagantisOrder->getId();  | 
                                                        |
| 564 | 564 | $dbConnection->update(  | 
                                                        
| 565 | 565 | $tableName,  | 
                                                        
| 566 | 566 |                  array('mg_order_id' => $this->magentoOrderId), | 
                                                        
@@ -610,7 +610,7 @@ discard block  | 
                                                    ||
| 610 | 610 |      { | 
                                                        
| 611 | 611 | //$returnUrl = 'checkout/#payment';  | 
                                                        
| 612 | 612 |          $returnUrl = $this->_url->getUrl('checkout', ['_fragment' => 'payment']); | 
                                                        
| 613 | -        if ($this->magentoOrderId!='') { | 
                                                        |
| 613 | +        if ($this->magentoOrderId != '') { | 
                                                        |
| 614 | 614 | /** @var Order $this->magentoOrder */  | 
                                                        
| 615 | 615 | $this->magentoOrder = $this->orderRepositoryInterface->get($this->magentoOrderId);  | 
                                                        
| 616 | 616 |              if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) { | 
                                                        
@@ -627,7 +627,7 @@ discard block  | 
                                                    ||
| 627 | 627 | $orderStatus = strtolower($this->magentoOrder->getStatus());  | 
                                                        
| 628 | 628 |              $acceptedStatus = array('processing', 'completed'); | 
                                                        
| 629 | 629 |              if (in_array($orderStatus, $acceptedStatus)) { | 
                                                        
| 630 | -                if (isset($this->extraConfig['PAGANTIS_OK_URL']) &&  $this->extraConfig['PAGANTIS_OK_URL']!= '') { | 
                                                        |
| 630 | +                if (isset($this->extraConfig['PAGANTIS_OK_URL']) && $this->extraConfig['PAGANTIS_OK_URL'] != '') { | 
                                                        |
| 631 | 631 | $returnUrl = $this->extraConfig['PAGANTIS_OK_URL'];  | 
                                                        
| 632 | 632 |                  } else { | 
                                                        
| 633 | 633 | $returnUrl = 'checkout/onepage/success';  | 
                                                        
@@ -537,17 +537,17 @@  | 
                                                    ||
| 537 | 537 | }  | 
                                                        
| 538 | 538 | |
| 539 | 539 | $this->magentoOrder->addStatusHistoryComment($metadataInfo)  | 
                                                        
| 540 | - ->setIsCustomerNotified(false)  | 
                                                        |
| 541 | -                               ->setEntityName('order') | 
                                                        |
| 542 | - ->save();  | 
                                                        |
| 540 | + ->setIsCustomerNotified(false)  | 
                                                        |
| 541 | +                                ->setEntityName('order') | 
                                                        |
| 542 | + ->save();  | 
                                                        |
| 543 | 543 | |
| 544 | 544 | $comment = 'pagantisOrderId: ' . $this->pagantisOrder->getId(). ' ' .  | 
                                                        
| 545 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus(). ' ' .  | 
                                                        |
| 546 | - 'via: '. $this->origin;  | 
                                                        |
| 545 | + 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus(). ' ' .  | 
                                                        |
| 546 | + 'via: '. $this->origin;  | 
                                                        |
| 547 | 547 | $this->magentoOrder->addStatusHistoryComment($comment)  | 
                                                        
| 548 | - ->setIsCustomerNotified(false)  | 
                                                        |
| 549 | -                               ->setEntityName('order') | 
                                                        |
| 550 | - ->save();  | 
                                                        |
| 548 | + ->setIsCustomerNotified(false)  | 
                                                        |
| 549 | +                                ->setEntityName('order') | 
                                                        |
| 550 | + ->save();  | 
                                                        |
| 551 | 551 | |
| 552 | 552 |              if ($this->magentoOrderId == '') { | 
                                                        
| 553 | 553 |                  throw new UnknownException('Order can not be saved'); | 
                                                        
@@ -276,7 +276,7 @@ discard block  | 
                                                    ||
| 276 | 276 |              $this->checkPagantisStatus(array('AUTHORIZED')); | 
                                                        
| 277 | 277 |          } catch (\Exception $e) { | 
                                                        
| 278 | 278 | $this->getMagentoOrderId();  | 
                                                        
| 279 | -            if ($this->magentoOrderId!='') { | 
                                                        |
| 279 | +            if ($this->magentoOrderId != '') { | 
                                                        |
| 280 | 280 | throw new AlreadyProcessedException();  | 
                                                        
| 281 | 281 |              } else { | 
                                                        
| 282 | 282 | throw new WrongStatusException($this->pagantisOrder->getStatus());  | 
                                                        
@@ -289,7 +289,7 @@ discard block  | 
                                                    ||
| 289 | 289 | */  | 
                                                        
| 290 | 290 | private function checkMerchantOrderStatus()  | 
                                                        
| 291 | 291 |      { | 
                                                        
| 292 | -        if ($this->quote->getIsActive()=='0') { | 
                                                        |
| 292 | +        if ($this->quote->getIsActive() == '0') { | 
                                                        |
| 293 | 293 | $this->getMagentoOrderId();  | 
                                                        
| 294 | 294 | throw new AlreadyProcessedException();  | 
                                                        
| 295 | 295 | }  | 
                                                        
@@ -421,7 +421,7 @@ discard block  | 
                                                    ||
| 421 | 421 | $tableName = $this->dbObject->getTableName(self::CONCURRENCY_TABLE);  | 
                                                        
| 422 | 422 |              if ($mode == false) { | 
                                                        
| 423 | 423 | $dbConnection->delete($tableName, "timestamp<".(time() - 5));  | 
                                                        
| 424 | -            } elseif ($this->quoteId!='') { | 
                                                        |
| 424 | +            } elseif ($this->quoteId != '') { | 
                                                        |
| 425 | 425 | $dbConnection->delete($tableName, "id=".$this->quoteId);  | 
                                                        
| 426 | 426 | }  | 
                                                        
| 427 | 427 |          } catch (Exception $exception) { | 
                                                        
@@ -457,7 +457,7 @@ discard block  | 
                                                    ||
| 457 | 457 | sleep($expirationSec + 1);  | 
                                                        
| 458 | 458 | }  | 
                                                        
| 459 | 459 | |
| 460 | - $logMessage = sprintf(  | 
                                                        |
| 460 | + $logMessage = sprintf(  | 
                                                        |
| 461 | 461 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",  | 
                                                        
| 462 | 462 | $expirationSec,  | 
                                                        
| 463 | 463 | self::CONCURRENCY_TIMEOUT,  | 
                                                        
@@ -502,14 +502,14 @@ discard block  | 
                                                    ||
| 502 | 502 | /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */  | 
                                                        
| 503 | 503 | $dbConnection = $this->dbObject->getConnection();  | 
                                                        
| 504 | 504 | $tableName = $this->dbObject->getTableName(self::ORDERS_TABLE);  | 
                                                        
| 505 | - $pagantisOrderId = $this->pagantisOrderId;  | 
                                                        |
| 505 | + $pagantisOrderId = $this->pagantisOrderId;  | 
                                                        |
| 506 | 506 | $query = sprintf(  | 
                                                        
| 507 | 507 | "select mg_order_id from %s where id='%s' and order_id='%s'",  | 
                                                        
| 508 | 508 | $tableName,  | 
                                                        
| 509 | 509 | $this->quoteId,  | 
                                                        
| 510 | 510 | $pagantisOrderId  | 
                                                        
| 511 | 511 | );  | 
                                                        
| 512 | - $queryResult = $dbConnection->fetchRow($query);  | 
                                                        |
| 512 | + $queryResult = $dbConnection->fetchRow($query);  | 
                                                        |
| 513 | 513 | $this->magentoOrderId = $queryResult['mg_order_id'];  | 
                                                        
| 514 | 514 |          } catch (\Exception $e) { | 
                                                        
| 515 | 515 | throw new UnknownException($e->getMessage());  | 
                                                        
@@ -532,7 +532,7 @@ discard block  | 
                                                    ||
| 532 | 532 | $metadataInfo = null;  | 
                                                        
| 533 | 533 |              foreach ($metadataOrder as $metadataKey => $metadataValue) { | 
                                                        
| 534 | 534 |                  if ($metadataKey == 'promotedProduct') { | 
                                                        
| 535 | - $metadataInfo.= "/Producto promocionado = $metadataValue";  | 
                                                        |
| 535 | + $metadataInfo .= "/Producto promocionado = $metadataValue";  | 
                                                        |
| 536 | 536 | }  | 
                                                        
| 537 | 537 | }  | 
                                                        
| 538 | 538 | |
@@ -541,9 +541,9 @@ discard block  | 
                                                    ||
| 541 | 541 |                                 ->setEntityName('order') | 
                                                        
| 542 | 542 | ->save();  | 
                                                        
| 543 | 543 | |
| 544 | - $comment = 'pagantisOrderId: ' . $this->pagantisOrder->getId(). ' ' .  | 
                                                        |
| 545 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus(). ' ' .  | 
                                                        |
| 546 | - 'via: '. $this->origin;  | 
                                                        |
| 544 | + $comment = 'pagantisOrderId: '.$this->pagantisOrder->getId().' '.  | 
                                                        |
| 545 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus().' '.  | 
                                                        |
| 546 | + 'via: '.$this->origin;  | 
                                                        |
| 547 | 547 | $this->magentoOrder->addStatusHistoryComment($comment)  | 
                                                        
| 548 | 548 | ->setIsCustomerNotified(false)  | 
                                                        
| 549 | 549 |                                 ->setEntityName('order') | 
                                                        
@@ -566,7 +566,7 @@ discard block  | 
                                                    ||
| 566 | 566 | /** @var \Magento\Framework\DB\Adapter\AdapterInterface $dbConnection */  | 
                                                        
| 567 | 567 | $dbConnection = $this->dbObject->getConnection();  | 
                                                        
| 568 | 568 | $tableName = $this->dbObject->getTableName(self::ORDERS_TABLE);  | 
                                                        
| 569 | - $pagantisOrderId = $this->pagantisOrder->getId();  | 
                                                        |
| 569 | + $pagantisOrderId = $this->pagantisOrder->getId();  | 
                                                        |
| 570 | 570 | $dbConnection->update(  | 
                                                        
| 571 | 571 | $tableName,  | 
                                                        
| 572 | 572 |                  array('mg_order_id' => $this->magentoOrderId), | 
                                                        
@@ -599,7 +599,7 @@ discard block  | 
                                                    ||
| 599 | 599 |      { | 
                                                        
| 600 | 600 | //$returnUrl = 'checkout/#payment';  | 
                                                        
| 601 | 601 |          $returnUrl = $this->_url->getUrl('checkout', ['_fragment' => 'payment']); | 
                                                        
| 602 | -        if ($this->magentoOrderId!='') { | 
                                                        |
| 602 | +        if ($this->magentoOrderId != '') { | 
                                                        |
| 603 | 603 | /** @var Order $this->magentoOrder */  | 
                                                        
| 604 | 604 | $this->magentoOrder = $this->orderRepositoryInterface->get($this->magentoOrderId);  | 
                                                        
| 605 | 605 |              if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) { | 
                                                        
@@ -616,7 +616,7 @@ discard block  | 
                                                    ||
| 616 | 616 | $orderStatus = strtolower($this->magentoOrder->getStatus());  | 
                                                        
| 617 | 617 |              $acceptedStatus = array('processing', 'completed'); | 
                                                        
| 618 | 618 |              if (in_array($orderStatus, $acceptedStatus)) { | 
                                                        
| 619 | -                if (isset($this->extraConfig['PAGANTIS_OK_URL']) &&  $this->extraConfig['PAGANTIS_OK_URL']!= '') { | 
                                                        |
| 619 | +                if (isset($this->extraConfig['PAGANTIS_OK_URL']) && $this->extraConfig['PAGANTIS_OK_URL'] != '') { | 
                                                        |
| 620 | 620 | $returnUrl = $this->extraConfig['PAGANTIS_OK_URL'];  | 
                                                        
| 621 | 621 |                  } else { | 
                                                        
| 622 | 622 | $returnUrl = 'checkout/onepage/success';  |