| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 |      { | 
| 35 | 35 | $parsedUrl = parse_url($url); | 
| 36 | 36 | $separator = ($parsedUrl['query'] == null) ? '?' : '&'; | 
| 37 | - $redirectUrl = $url. $separator . http_build_query($parameters); | |
| 37 | + $redirectUrl = $url.$separator.http_build_query($parameters); | |
| 38 | 38 | Tools::redirect($redirectUrl); | 
| 39 | 39 | } | 
| 40 | 40 | |
| @@ -76,8 +76,8 @@ discard block | ||
| 76 | 76 | $response = $exception->getMessage(); | 
| 77 | 77 |                  } else { | 
| 78 | 78 | $response = 'Unable to serialize log.'. | 
| 79 | - 'data: '. json_encode($data). | |
| 80 | - 'exception: '. json_encode($exception); | |
| 79 | + 'data: '.json_encode($data). | |
| 80 | + 'exception: '.json_encode($exception); | |
| 81 | 81 | } | 
| 82 | 82 | } | 
| 83 | 83 | |
| @@ -473,7 +473,7 @@ | ||
| 473 | 473 | * Get the form for editing the BackOffice options of the module | 
| 474 | 474 | * | 
| 475 | 475 | * @return array | 
| 476 | - */ | |
| 476 | + */ | |
| 477 | 477 | private function getConfigForm() | 
| 478 | 478 |      { | 
| 479 | 479 |          $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); | 
| @@ -11,7 +11,7 @@ discard block | ||
| 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 | |
| @@ -162,14 +162,14 @@ discard block | ||
| 162 | 162 |          foreach ($products as $product) { | 
| 163 | 163 |              $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); | 
| 164 | 164 |              if ($code === 'p4x') { | 
| 165 | - Configuration::updateValue($code . '_simulator_is_enabled', 1); | |
| 165 | + Configuration::updateValue($code.'_simulator_is_enabled', 1); | |
| 166 | 166 | } | 
| 167 | - Configuration::updateValue($code . '_is_enabled', 0); | |
| 168 | - Configuration::updateValue($code . '_public_key', ''); | |
| 169 | - Configuration::updateValue($code . '_private_key', ''); | |
| 167 | + Configuration::updateValue($code.'_is_enabled', 0); | |
| 168 | + Configuration::updateValue($code.'_public_key', ''); | |
| 169 | + Configuration::updateValue($code.'_private_key', ''); | |
| 170 | 170 | } | 
| 171 | 171 | |
| 172 | - $return = (parent::install() | |
| 172 | + $return = (parent::install() | |
| 173 | 173 |              && $this->registerHook('displayShoppingCart') | 
| 174 | 174 |              && $this->registerHook('paymentOptions') | 
| 175 | 175 |              && $this->registerHook('displayProductButtons') | 
| @@ -219,34 +219,34 @@ discard block | ||
| 219 | 219 | public function checkHooks() | 
| 220 | 220 |      { | 
| 221 | 221 |          try { | 
| 222 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where | |
| 223 | - id_module = \'' . Module::getModuleIdByName($this->name) . '\' and | |
| 224 | - id_shop = \'' . Shop::getContextShopID() . '\' and | |
| 225 | -            id_hook = \'' . Hook::getIdByName('header') . '\''; | |
| 222 | + $sql_content = 'select * from '._DB_PREFIX_.'hook_module where | |
| 223 | + id_module = \'' . Module::getModuleIdByName($this->name).'\' and | |
| 224 | + id_shop = \'' . Shop::getContextShopID().'\' and | |
| 225 | +            id_hook = \'' . Hook::getIdByName('header').'\''; | |
| 226 | 226 | $hook_exists = Db::getInstance()->ExecuteS($sql_content); | 
| 227 | 227 |              if (empty($hook_exists)) { | 
| 228 | - $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module | |
| 228 | + $sql_insert = 'insert into '._DB_PREFIX_.'hook_module | |
| 229 | 229 | (id_module, id_shop, id_hook, position) | 
| 230 | 230 | values | 
| 231 | - (\''. Module::getModuleIdByName($this->name) . '\', | |
| 232 | - \''. Shop::getContextShopID() . '\', | |
| 233 | -            \''. Hook::getIdByName('header') . '\', | |
| 231 | + (\''. Module::getModuleIdByName($this->name).'\', | |
| 232 | + \''. Shop::getContextShopID().'\', | |
| 233 | +            \''. Hook::getIdByName('header').'\', | |
| 234 | 234 | 150)'; | 
| 235 | 235 | Db::getInstance()->execute($sql_insert); | 
| 236 | 236 | } | 
| 237 | 237 | |
| 238 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where | |
| 239 | - id_module = \'' . Module::getModuleIdByName($this->name) . '\' and | |
| 240 | - id_shop = \'' . Shop::getContextShopID() . '\' and | |
| 241 | -            id_hook = \'' . Hook::getIdByName('displayProductPriceBlock') . '\''; | |
| 238 | + $sql_content = 'select * from '._DB_PREFIX_.'hook_module where | |
| 239 | + id_module = \'' . Module::getModuleIdByName($this->name).'\' and | |
| 240 | + id_shop = \'' . Shop::getContextShopID().'\' and | |
| 241 | +            id_hook = \'' . Hook::getIdByName('displayProductPriceBlock').'\''; | |
| 242 | 242 | $hook_exists = Db::getInstance()->ExecuteS($sql_content); | 
| 243 | 243 |              if (empty($hook_exists)) { | 
| 244 | - $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module | |
| 244 | + $sql_insert = 'insert into '._DB_PREFIX_.'hook_module | |
| 245 | 245 | (id_module, id_shop, id_hook, position) | 
| 246 | 246 | values | 
| 247 | - (\''. Module::getModuleIdByName($this->name) . '\', | |
| 248 | - \''. Shop::getContextShopID() . '\', | |
| 249 | -            \''. Hook::getIdByName('displayProductPriceBlock') . '\', | |
| 247 | + (\''. Module::getModuleIdByName($this->name).'\', | |
| 248 | + \''. Shop::getContextShopID().'\', | |
| 249 | +            \''. Hook::getIdByName('displayProductPriceBlock').'\', | |
| 250 | 250 | 160)'; | 
| 251 | 251 | Db::getInstance()->execute($sql_insert); | 
| 252 | 252 | } | 
| @@ -260,7 +260,7 @@ discard block | ||
| 260 | 260 | */ | 
| 261 | 261 | public function checkEnvVariables() | 
| 262 | 262 |      { | 
| 263 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; | |
| 263 | + $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; | |
| 264 | 264 | $dbConfigs = Db::getInstance()->executeS($sql_content); | 
| 265 | 265 | |
| 266 | 266 | // Convert a multimple dimension array for SQL insert statements into a simple key/value | 
| @@ -308,10 +308,10 @@ discard block | ||
| 308 | 308 |      { | 
| 309 | 309 |          try { | 
| 310 | 310 | $tableName = _DB_PREFIX_.'pagantis_order'; | 
| 311 | - $sql = "show tables like '" . $tableName . "'"; | |
| 311 | + $sql = "show tables like '".$tableName."'"; | |
| 312 | 312 | $data = Db::getInstance()->ExecuteS($sql); | 
| 313 | 313 |              if (count($data) > 0) { | 
| 314 | - $sql = "desc " . $tableName; | |
| 314 | + $sql = "desc ".$tableName; | |
| 315 | 315 | $data = Db::getInstance()->ExecuteS($sql); | 
| 316 | 316 |                  if (count($data) == 2) { | 
| 317 | 317 | $sql = "ALTER TABLE $tableName ADD COLUMN ps_order_id VARCHAR(60) AFTER order_id"; | 
| @@ -328,10 +328,10 @@ discard block | ||
| 328 | 328 | $this->loadSQLFile($sql_file); | 
| 329 | 329 | } | 
| 330 | 330 | $tableName = _DB_PREFIX_.'pagantis_config'; | 
| 331 | - $sql = "show tables like '" . $tableName . "'"; | |
| 331 | + $sql = "show tables like '".$tableName."'"; | |
| 332 | 332 | $data = Db::getInstance()->ExecuteS($sql); | 
| 333 | 333 |              if (count($data) > 0) { | 
| 334 | - $sql = "desc " . $tableName; | |
| 334 | + $sql = "desc ".$tableName; | |
| 335 | 335 | $data = Db::getInstance()->ExecuteS($sql); | 
| 336 | 336 |                  if (count($data) === 3 && $data[2]['Type'] !== 'varchar(5000)') { | 
| 337 | 337 | $sql = "ALTER TABLE $tableName MODIFY `value` VARCHAR(5000)"; | 
| @@ -360,8 +360,8 @@ discard block | ||
| 360 | 360 |          $availableCurrencies       = array('EUR'); | 
| 361 | 361 | $pagantisDisplayMinAmount = $configs['DISPLAY_MIN_AMOUNT']; | 
| 362 | 362 | $pagantisDisplayMaxAmount = $configs['DISPLAY_MAX_AMOUNT']; | 
| 363 | - $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key'); | |
| 364 | - $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key'); | |
| 363 | + $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key'); | |
| 364 | + $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key'); | |
| 365 | 365 |          $this->allowedCountries    = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); | 
| 366 | 366 | $this->getUserLanguage(); | 
| 367 | 367 | return ( | 
| @@ -440,42 +440,42 @@ discard block | ||
| 440 | 440 |              if ($this->isPaymentMethodAvailable($product)) { | 
| 441 | 441 | $productConfigs = Pagantis::getExtraConfig($product, null); | 
| 442 | 442 | $productConfigs = json_decode($productConfigs, true); | 
| 443 | - $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); | |
| 444 | - $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); | |
| 445 | - $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); | |
| 443 | + $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); | |
| 444 | + $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); | |
| 445 | + $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); | |
| 446 | 446 | |
| 447 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); | |
| 447 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); | |
| 448 | 448 | unset($productConfigs['TITLE']); | 
| 449 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal; | |
| 450 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount; | |
| 451 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; | |
| 452 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; | |
| 453 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; | |
| 454 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; | |
| 455 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; | |
| 456 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; | |
| 457 | -                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment') . '&product=' . $productConfigs['CODE']; | |
| 458 | -                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); | |
| 449 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal; | |
| 450 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount; | |
| 451 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; | |
| 452 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; | |
| 453 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; | |
| 454 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; | |
| 455 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; | |
| 456 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; | |
| 457 | +                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment').'&product='.$productConfigs['CODE']; | |
| 458 | +                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); | |
| 459 | 459 | |
| 460 | 460 |                  foreach ($productConfigs as $productConfigKey => $productConfigValue) { | 
| 461 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; | |
| 461 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; | |
| 462 | 462 | } | 
| 463 | 463 | $this->context->smarty->assign($templateConfigs); | 
| 464 | 464 | |
| 465 | 465 | $paymentOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); | 
| 466 | 466 |                  $uri = $link->getModuleLink('pagantis', 'payment'); | 
| 467 | 467 |                  if (strpos($uri, '?') !== false) { | 
| 468 | - $uri .= '&product=' . $productConfigs['CODE']; | |
| 468 | + $uri .= '&product='.$productConfigs['CODE']; | |
| 469 | 469 |                  } else { | 
| 470 | - $uri .= '?product=' . $productConfigs['CODE']; | |
| 470 | + $uri .= '?product='.$productConfigs['CODE']; | |
| 471 | 471 | } | 
| 472 | 472 | $paymentOption | 
| 473 | - ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE']) | |
| 473 | + ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE']) | |
| 474 | 474 | ->setAction($uri) | 
| 475 | - ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO']) | |
| 475 | + ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO']) | |
| 476 | 476 | ->setModuleName(__CLASS__) | 
| 477 | 477 | ->setAdditionalInformation( | 
| 478 | -                        $this->fetch('module:pagantis/views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl') | |
| 478 | +                        $this->fetch('module:pagantis/views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl') | |
| 479 | 479 | ) | 
| 480 | 480 | ; | 
| 481 | 481 | $return[] = $paymentOption; | 
| @@ -499,61 +499,61 @@ discard block | ||
| 499 | 499 |          foreach ($products as $product) { | 
| 500 | 500 |              $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); | 
| 501 | 501 | $inputs[] = array( | 
| 502 | - 'name' => $code .'_is_enabled', | |
| 503 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', | |
| 504 | -                'label' => $this->l('Module is enabled ' . $code), | |
| 502 | + 'name' => $code.'_is_enabled', | |
| 503 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', | |
| 504 | +                'label' => $this->l('Module is enabled '.$code), | |
| 505 | 505 | 'prefix' => '<i class="icon icon-key"></i>', | 
| 506 | 506 | 'class' => 't', | 
| 507 | 507 | 'required' => true, | 
| 508 | 508 | 'values'=> array( | 
| 509 | 509 | array( | 
| 510 | - 'id' => $code .'_is_enabled_true', | |
| 510 | + 'id' => $code.'_is_enabled_true', | |
| 511 | 511 | 'value' => 1, | 
| 512 | 512 |                          'label' => $this->l('Yes', get_class($this), null, false), | 
| 513 | 513 | ), | 
| 514 | 514 | array( | 
| 515 | - 'id' => $code . '_is_enabled_false', | |
| 515 | + 'id' => $code.'_is_enabled_false', | |
| 516 | 516 | 'value' => 0, | 
| 517 | 517 |                          'label' => $this->l('No', get_class($this), null, false), | 
| 518 | 518 | ), | 
| 519 | 519 | ) | 
| 520 | 520 | ); | 
| 521 | 521 | $inputs[] = array( | 
| 522 | - 'name' => $code . '_public_key', | |
| 522 | + 'name' => $code.'_public_key', | |
| 523 | 523 |                  'suffix' => $this->l('ex: pk_fd53cd467ba49022e4gf215e'), | 
| 524 | 524 | 'type' => 'text', | 
| 525 | 525 | 'size' => 60, | 
| 526 | -                'label' => $this->l('Public Key ' . $code), | |
| 526 | +                'label' => $this->l('Public Key '.$code), | |
| 527 | 527 | 'prefix' => '<i class="icon icon-key"></i>', | 
| 528 | 528 | 'col' => 6, | 
| 529 | 529 | 'required' => true, | 
| 530 | 530 | ); | 
| 531 | 531 | $inputs[] = array( | 
| 532 | - 'name' => $code . '_private_key', | |
| 532 | + 'name' => $code.'_private_key', | |
| 533 | 533 |                  'suffix' => $this->l('ex: 21e5723a97459f6a'), | 
| 534 | 534 | 'type' => 'text', | 
| 535 | 535 | 'size' => 60, | 
| 536 | -                'label' => $this->l('Private Key ' . $code), | |
| 536 | +                'label' => $this->l('Private Key '.$code), | |
| 537 | 537 | 'prefix' => '<i class="icon icon-key"></i>', | 
| 538 | 538 | 'col' => 6, | 
| 539 | 539 | 'required' => true, | 
| 540 | 540 | ); | 
| 541 | 541 |              if ($code !== "p4x") { | 
| 542 | 542 | $inputs[] = array( | 
| 543 | - 'name' => $code . '_simulator_is_enabled', | |
| 544 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', | |
| 545 | -                    'label' => $this->l('Simulator is enabled ' . $code), | |
| 543 | + 'name' => $code.'_simulator_is_enabled', | |
| 544 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', | |
| 545 | +                    'label' => $this->l('Simulator is enabled '.$code), | |
| 546 | 546 | 'prefix' => '<i class="icon icon-key"></i>', | 
| 547 | 547 | 'class' => 't', | 
| 548 | 548 | 'required' => true, | 
| 549 | 549 | 'values'=> array( | 
| 550 | 550 | array( | 
| 551 | - 'id' => $code . '_simulator_is_enabled_on', | |
| 551 | + 'id' => $code.'_simulator_is_enabled_on', | |
| 552 | 552 | 'value' => 1, | 
| 553 | 553 |                              'label' => $this->l('Yes'), | 
| 554 | 554 | ), | 
| 555 | 555 | array( | 
| 556 | - 'id' => $code . '_simulator_is_enabled_off', | |
| 556 | + 'id' => $code.'_simulator_is_enabled_off', | |
| 557 | 557 | 'value' => 0, | 
| 558 | 558 |                              'label' => $this->l('No'), | 
| 559 | 559 | ), | 
| @@ -621,17 +621,17 @@ discard block | ||
| 621 | 621 |          $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); | 
| 622 | 622 |          foreach ($products as $product) { | 
| 623 | 623 |              $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); | 
| 624 | - $settings[$code . '_public_key'] = Configuration::get($code . '_public_key'); | |
| 625 | - $settings[$code . '_private_key'] = Configuration::get($code . '_private_key'); | |
| 626 | - $settings[$code . '_is_enabled'] = Configuration::get($code . '_is_enabled'); | |
| 624 | + $settings[$code.'_public_key'] = Configuration::get($code.'_public_key'); | |
| 625 | + $settings[$code.'_private_key'] = Configuration::get($code.'_private_key'); | |
| 626 | + $settings[$code.'_is_enabled'] = Configuration::get($code.'_is_enabled'); | |
| 627 | 627 |              if ($code !== 'p4x') { | 
| 628 | - $settings[$code . '_simulator_is_enabled'] = Configuration::get($code . '_simulator_is_enabled'); | |
| 628 | + $settings[$code.'_simulator_is_enabled'] = Configuration::get($code.'_simulator_is_enabled'); | |
| 629 | 629 | } | 
| 630 | - $settingsKeys[] = $code . '_is_enabled'; | |
| 631 | - $settingsKeys[] = $code . '_public_key'; | |
| 632 | - $settingsKeys[] = $code . '_private_key'; | |
| 630 | + $settingsKeys[] = $code.'_is_enabled'; | |
| 631 | + $settingsKeys[] = $code.'_public_key'; | |
| 632 | + $settingsKeys[] = $code.'_private_key'; | |
| 633 | 633 |              if ($code !== 'p4x') { | 
| 634 | - $settingsKeys[] = $code . '_simulator_is_enabled'; | |
| 634 | + $settingsKeys[] = $code.'_simulator_is_enabled'; | |
| 635 | 635 | } | 
| 636 | 636 | } | 
| 637 | 637 | |
| @@ -702,43 +702,43 @@ discard block | ||
| 702 | 702 |              if ($this->isPaymentMethodAvailable($product)) { | 
| 703 | 703 | $productConfigs = Pagantis::getExtraConfig($product, null); | 
| 704 | 704 | $productConfigs = json_decode($productConfigs, true); | 
| 705 | - $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); | |
| 706 | - $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); | |
| 707 | - $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); | |
| 705 | + $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); | |
| 706 | + $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); | |
| 707 | + $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); | |
| 708 | 708 | |
| 709 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); | |
| 709 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); | |
| 710 | 710 | unset($productConfigs['TITLE']); | 
| 711 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal; | |
| 712 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount; | |
| 713 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; | |
| 714 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; | |
| 715 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; | |
| 716 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; | |
| 717 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; | |
| 718 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; | |
| 711 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal; | |
| 712 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount; | |
| 713 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; | |
| 714 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; | |
| 715 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; | |
| 716 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; | |
| 717 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; | |
| 718 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; | |
| 719 | 719 |                  $uri = $link->getModuleLink('pagantis', 'payment'); | 
| 720 | 720 |                  if (strpos($uri, '?') !== false) { | 
| 721 | - $uri .= '&product=' . $productConfigs['CODE']; | |
| 721 | + $uri .= '&product='.$productConfigs['CODE']; | |
| 722 | 722 |                  } else { | 
| 723 | - $uri .= '?product=' . $productConfigs['CODE']; | |
| 723 | + $uri .= '?product='.$productConfigs['CODE']; | |
| 724 | 724 | } | 
| 725 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $uri; | |
| 726 | -                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); | |
| 725 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $uri; | |
| 726 | +                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); | |
| 727 | 727 | |
| 728 | 728 |                  foreach ($productConfigs as $productConfigKey => $productConfigValue) { | 
| 729 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; | |
| 729 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; | |
| 730 | 730 | } | 
| 731 | 731 | $this->context->smarty->assign($templateConfigs); | 
| 732 | 732 |                  if ($supercheckout_enabled || $onepagecheckout_enabled || $onepagecheckoutps_enabled) { | 
| 733 | 733 | $this->checkLogoExists(); | 
| 734 | 734 | $return .= $this->display( | 
| 735 | 735 | __FILE__, | 
| 736 | - 'views/templates/hook/onepagecheckout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' | |
| 736 | + 'views/templates/hook/onepagecheckout-'.Tools::strtolower($productConfigs['CODE']).'.tpl' | |
| 737 | 737 | ); | 
| 738 | 738 |                  } elseif (_PS_VERSION_ < 1.7) { | 
| 739 | 739 | $return .= $this->display( | 
| 740 | 740 | __FILE__, | 
| 741 | - 'views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' | |
| 741 | + 'views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl' | |
| 742 | 742 | ); | 
| 743 | 743 | } | 
| 744 | 744 | } | 
| @@ -771,12 +771,12 @@ discard block | ||
| 771 | 771 | $productConfigs = Pagantis::getExtraConfig($product, null); | 
| 772 | 772 | $productConfigs = json_decode($productConfigs, true); | 
| 773 | 773 | |
| 774 | - $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); | |
| 775 | - $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); | |
| 774 | + $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); | |
| 775 | + $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); | |
| 776 | 776 |              if (Tools::strtolower($productConfigs['CODE']) === 'p4x') { | 
| 777 | 777 | $simulatorIsEnabled = true; | 
| 778 | 778 | } | 
| 779 | - $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); | |
| 779 | + $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); | |
| 780 | 780 | $availableSimulators = array( | 
| 781 | 781 | 'hookDisplayProductButtons' => array( | 
| 782 | 782 | 'sdk.simulator.types.SIMPLE', | 
| @@ -799,30 +799,30 @@ discard block | ||
| 799 | 799 | in_array(Tools::strtolower($this->language), $allowedCountries) && | 
| 800 | 800 | (in_array($productConfigs['SIMULATOR_DISPLAY_TYPE'], $availableSimulators[$hookName]) || _PS_VERSION_ < 1.6) | 
| 801 | 801 |              ) { | 
| 802 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); | |
| 803 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']); | |
| 804 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']); | |
| 802 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); | |
| 803 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']); | |
| 804 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']); | |
| 805 | 805 | unset($productConfigs['TITLE']); | 
| 806 | 806 | unset($productConfigs['SIMULATOR_TITLE']); | 
| 807 | 807 | unset($productConfigs['SIMULATOR_SUBTITLE']); | 
| 808 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $amount; | |
| 809 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT4X'] = number_format(($amount / 4), 2, '.', ''); | |
| 810 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_PROMOTED_PRODUCT'] = $isPromotedProduct; | |
| 811 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; | |
| 812 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; | |
| 813 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; | |
| 814 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; | |
| 815 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; | |
| 816 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; | |
| 817 | -                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); | |
| 808 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $amount; | |
| 809 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT4X'] = number_format(($amount / 4), 2, '.', ''); | |
| 810 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_PROMOTED_PRODUCT'] = $isPromotedProduct; | |
| 811 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; | |
| 812 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; | |
| 813 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; | |
| 814 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; | |
| 815 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; | |
| 816 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; | |
| 817 | +                $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); | |
| 818 | 818 |                  foreach ($productConfigs as $productConfigKey => $productConfigValue) { | 
| 819 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; | |
| 819 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; | |
| 820 | 820 | } | 
| 821 | 821 | |
| 822 | 822 | $this->context->smarty->assign($templateConfigs); | 
| 823 | 823 | $return .= $this->display( | 
| 824 | 824 | __FILE__, | 
| 825 | - 'views/templates/hook/product-simulator-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' | |
| 825 | + 'views/templates/hook/product-simulator-'.Tools::strtolower($productConfigs['CODE']).'.tpl' | |
| 826 | 826 | ); | 
| 827 | 827 | } | 
| 828 | 828 | } | 
| @@ -851,7 +851,7 @@ discard block | ||
| 851 | 851 | // $params['type'] = weight | price | after_price | 
| 852 | 852 | if (isset($params['type']) && $params['type'] === 'price' && | 
| 853 | 853 | isset($params['smarty']) && isset($params['smarty']->template_resource) && | 
| 854 | - (strpos($params['smarty']->template_resource, 'product.tpl') !== false || | |
| 854 | + (strpos($params['smarty']->template_resource, 'product.tpl') !== false || | |
| 855 | 855 | strpos($params['smarty']->template_resource, 'product-prices.tpl') !== false) | 
| 856 | 856 |          ) { | 
| 857 | 857 |              return $this->productPageSimulatorDisplay("hookDisplayProductPriceBlock"); | 
| @@ -884,16 +884,16 @@ discard block | ||
| 884 | 884 |          if (!in_array(PROMOTIONS_CATEGORY_NAME, $categories)) { | 
| 885 | 885 | /** @var CategoryCore $category */ | 
| 886 | 886 | $category = new Category(); | 
| 887 | -            $categoryArray = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY ); | |
| 887 | +            $categoryArray = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY); | |
| 888 | 888 | $category->is_root_category = false; | 
| 889 | 889 | $category->link_rewrite = $categoryArray; | 
| 890 | 890 | $category->meta_description = $categoryArray; | 
| 891 | 891 | $category->meta_keywords = $categoryArray; | 
| 892 | 892 | $category->meta_title = $categoryArray; | 
| 893 | -            $category->name = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); | |
| 893 | +            $category->name = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); | |
| 894 | 894 |              $category->id_parent = Configuration::get('PS_HOME_CATEGORY'); | 
| 895 | - $category->active=0; | |
| 896 | - $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' . | |
| 895 | + $category->active = 0; | |
| 896 | + $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '. | |
| 897 | 897 | 'Use it to promote your products or brands.'; | 
| 898 | 898 | $category->description = $this->l($description); | 
| 899 | 899 | $category->save(); | 
| @@ -913,7 +913,7 @@ discard block | ||
| 913 | 913 | } | 
| 914 | 914 | |
| 915 | 915 |          if (is_null($product)) { | 
| 916 | - $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1'; | |
| 916 | + $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1'; | |
| 917 | 917 |              if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) { | 
| 918 | 918 |                  if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { | 
| 919 | 919 | return $results[0]['value']; | 
| @@ -921,7 +921,7 @@ discard block | ||
| 921 | 921 | } | 
| 922 | 922 | } | 
| 923 | 923 | |
| 924 | - $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($product) . '\' limit 1'; | |
| 924 | + $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($product).'\' limit 1'; | |
| 925 | 925 |          if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) { | 
| 926 | 926 |              if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { | 
| 927 | 927 | $configs = json_decode($results[0]['value'], true); | 
| @@ -941,10 +941,10 @@ discard block | ||
| 941 | 941 | */ | 
| 942 | 942 | public function checkLogoExists() | 
| 943 | 943 |      { | 
| 944 | - $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png'; | |
| 945 | -        if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) { | |
| 944 | + $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png'; | |
| 945 | +        if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) { | |
| 946 | 946 | copy( | 
| 947 | - _PS_PAGANTIS_DIR . '/logo.png', | |
| 947 | + _PS_PAGANTIS_DIR.'/logo.png', | |
| 948 | 948 | $logoPg | 
| 949 | 949 | ); | 
| 950 | 950 | } | 
| @@ -960,7 +960,7 @@ discard block | ||
| 960 | 960 |          if (count($langArray) != 2 && isset($lang['locale'])) { | 
| 961 | 961 |              $langArray = explode("-", $lang['locale']); | 
| 962 | 962 | } | 
| 963 | - $this->language = Tools::strtoupper($langArray[count($langArray)-1]); | |
| 963 | + $this->language = Tools::strtoupper($langArray[count($langArray) - 1]); | |
| 964 | 964 | // Prevent null language detection | 
| 965 | 965 |          if (in_array(Tools::strtolower($this->language), $this->allowedCountries)) { | 
| 966 | 966 | return; | 
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 | |
| 71 | 71 |          header('HTTP/1.1 200 Ok', true, 200); | 
| 72 | 72 |          header('Content-Type: application/json', true); | 
| 73 | -        header('Content-Length: ' . Tools::strlen($result)); | |
| 73 | +        header('Content-Length: '.Tools::strlen($result)); | |
| 74 | 74 | |
| 75 | 75 | echo $result; | 
| 76 | 76 | exit(); | 
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 |      { | 
| 84 | 84 |          $productCode = Tools::getValue('product', false); | 
| 85 | 85 |          $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); | 
| 86 | - $privateKey = Configuration::get(Tools::strtolower($productCode) . '_private_key'); | |
| 86 | + $privateKey = Configuration::get(Tools::strtolower($productCode).'_private_key'); | |
| 87 | 87 |          $privateKeyGet = Tools::getValue('secret', false); | 
| 88 | 88 |          if (!empty($privateKeyGet) && $privateKeyGet === $privateKey && in_array(Tools::strtoupper($productCode), $products)) { | 
| 89 | 89 | return true; | 
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | |
| 97 | 97 |          header('HTTP/1.1 403 Forbidden', true, 403); | 
| 98 | 98 |          header('Content-Type: application/json', true); | 
| 99 | -        header('Content-Length: ' . Tools::strlen($result)); | |
| 99 | +        header('Content-Length: '.Tools::strlen($result)); | |
| 100 | 100 | |
| 101 | 101 | echo $result; | 
| 102 | 102 | exit(); | 
| @@ -36,9 +36,9 @@ discard block | ||
| 36 | 36 |              $limit = Tools::getValue('limit'); | 
| 37 | 37 | } | 
| 38 | 38 |          if (Tools::getValue('from', false)) { | 
| 39 | -            $where = 'WHERE createdAt >= \'' . Tools::getValue('from') . '\''; | |
| 39 | +            $where = 'WHERE createdAt >= \''.Tools::getValue('from').'\''; | |
| 40 | 40 | } | 
| 41 | - $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'pagantis_log ' . $where . ' ORDER BY id desc LIMIT ' . $limit; | |
| 41 | + $sql = 'SELECT * FROM '._DB_PREFIX_.'pagantis_log '.$where.' ORDER BY id desc LIMIT '.$limit; | |
| 42 | 42 |          if ($results = Db::getInstance()->ExecuteS($sql)) { | 
| 43 | 43 |              foreach ($results as $row) { | 
| 44 | 44 | $data = (is_null(json_decode($row['log']))) ? $row['log'] : json_decode($row['log']); | 
| @@ -65,7 +65,7 @@ discard block | ||
| 65 | 65 | |
| 66 | 66 |          header('HTTP/1.1 200 Ok', true, 200); | 
| 67 | 67 |          header('Content-Type: application/json', true); | 
| 68 | -        header('Content-Length: ' . Tools::strlen($result)); | |
| 68 | +        header('Content-Length: '.Tools::strlen($result)); | |
| 69 | 69 | |
| 70 | 70 | echo $result; | 
| 71 | 71 | exit(); | 
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 |      { | 
| 79 | 79 |          $productCode = Tools::getValue('product', false); | 
| 80 | 80 |          $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); | 
| 81 | - $privateKey = Configuration::get(Tools::strtolower($productCode) . '_private_key'); | |
| 81 | + $privateKey = Configuration::get(Tools::strtolower($productCode).'_private_key'); | |
| 82 | 82 |          $privateKeyGet = Tools::getValue('secret', false); | 
| 83 | 83 |          if (!empty($privateKeyGet) && $privateKeyGet === $privateKey && in_array(Tools::strtoupper($productCode), $products)) { | 
| 84 | 84 | return true; | 
| @@ -18,13 +18,13 @@ discard block | ||
| 18 | 18 | public function initContent() | 
| 19 | 19 |      { | 
| 20 | 20 | $this->authorize(); | 
| 21 | - $method = Tools::strtolower($_SERVER['REQUEST_METHOD']) . "Method"; | |
| 21 | + $method = Tools::strtolower($_SERVER['REQUEST_METHOD'])."Method"; | |
| 22 | 22 | $params = (_PS_VERSION_ < 1.6) ? $_POST + $_GET : Tools::getAllValues(); | 
| 23 | 23 |          if (method_exists($this, $method)) { | 
| 24 | 24 |              header('HTTP/1.1 200 Ok', true, 200); | 
| 25 | 25 |              header('Content-Type: application/json', true); | 
| 26 | 26 |              $result = json_encode($this->{$method}($params['product'])); | 
| 27 | -            header('Content-Length: ' . Tools::strlen($result)); | |
| 27 | +            header('Content-Length: '.Tools::strlen($result)); | |
| 28 | 28 | echo $result; | 
| 29 | 29 | exit(); | 
| 30 | 30 | } | 
| @@ -40,17 +40,17 @@ discard block | ||
| 40 | 40 | */ | 
| 41 | 41 | public function getExtraConfigs($product = null) | 
| 42 | 42 |      { | 
| 43 | - $availableProductsSQL = 'select * from ' . _DB_PREFIX_. 'pagantis_config where config = \'PRODUCTS\''; | |
| 43 | + $availableProductsSQL = 'select * from '._DB_PREFIX_.'pagantis_config where config = \'PRODUCTS\''; | |
| 44 | 44 | $dbProducts = Db::getInstance()->executeS($availableProductsSQL); | 
| 45 | 45 |          $availableProductsArray = explode(',', $dbProducts[0]['value']); | 
| 46 | 46 | $unrequestedProducts = array_diff($availableProductsArray, array($product)); | 
| 47 | 47 | $unrequestedProductSQL = ''; | 
| 48 | 48 |          foreach ($unrequestedProducts as $unrequestedProduct) { | 
| 49 | - $unrequestedProductSQL .= "'". $unrequestedProduct . "',"; | |
| 49 | + $unrequestedProductSQL .= "'".$unrequestedProduct."',"; | |
| 50 | 50 | } | 
| 51 | 51 | $unrequestedProductSQL = rtrim($unrequestedProductSQL, ","); | 
| 52 | - $sql_content = 'select * from ' . _DB_PREFIX_. | |
| 53 | -            'pagantis_config where config not in (' . $unrequestedProductSQL . ')  | |
| 52 | + $sql_content = 'select * from '._DB_PREFIX_. | |
| 53 | +            'pagantis_config where config not in ('.$unrequestedProductSQL.')  | |
| 54 | 54 | and config not like (\'PAGANTIS_%\') and config not like (\'PMT_%\') '; | 
| 55 | 55 | |
| 56 | 56 | $dbConfigs = Db::getInstance()->executeS($sql_content); | 
| @@ -81,8 +81,8 @@ discard block | ||
| 81 | 81 | unset($params['secret']); | 
| 82 | 82 | $product = $params['product']; | 
| 83 | 83 | unset($params['product']); | 
| 84 | - $productConfigsSQL = 'select * from ' . _DB_PREFIX_. | |
| 85 | - 'pagantis_config where config = \''. pSQL($product) . '\''; | |
| 84 | + $productConfigsSQL = 'select * from '._DB_PREFIX_. | |
| 85 | + 'pagantis_config where config = \''.pSQL($product).'\''; | |
| 86 | 86 | $productConfigs = Db::getInstance()->executeS($productConfigsSQL); | 
| 87 | 87 | $availableProductsArray = json_decode($productConfigs[0]['value'], true); | 
| 88 | 88 |          if (count($params) > 0) { | 
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | Db::getInstance()->update( | 
| 97 | 97 | 'pagantis_config', | 
| 98 | 98 |                                  array('value' => pSQL($value)), | 
| 99 | - 'config = \''. pSQL($config) .'\'' | |
| 99 | + 'config = \''.pSQL($config).'\'' | |
| 100 | 100 | ); | 
| 101 | 101 | } | 
| 102 | 102 |                      } else { | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | Db::getInstance()->update( | 
| 107 | 107 | 'pagantis_config', | 
| 108 | 108 |                      array('value' => json_encode($availableProductsArray)), | 
| 109 | - 'config = \''. pSQL($product) .'\'' | |
| 109 | + 'config = \''.pSQL($product).'\'' | |
| 110 | 110 | ); | 
| 111 | 111 | } | 
| 112 | 112 |          } else { | 
| @@ -138,7 +138,7 @@ discard block | ||
| 138 | 138 |      { | 
| 139 | 139 |          $productCode = Tools::getValue('product', false); | 
| 140 | 140 |          $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); | 
| 141 | - $privateKey = Configuration::get(Tools::strtolower($productCode) . '_private_key'); | |
| 141 | + $privateKey = Configuration::get(Tools::strtolower($productCode).'_private_key'); | |
| 142 | 142 |          $privateKeyGet = Tools::getValue('secret', false); | 
| 143 | 143 |          if (!empty($privateKeyGet) && $privateKeyGet === $privateKey && in_array(Tools::strtoupper($productCode), $products)) { | 
| 144 | 144 | return true; | 
| @@ -28,9 +28,9 @@ discard block | ||
| 28 | 28 |      { | 
| 29 | 29 |          if (_PS_VERSION_ < 1.6) { | 
| 30 | 30 | Logger::addLog( | 
| 31 | - 'Pagantis Exception For user ' . | |
| 32 | - $customer->email . | |
| 33 | - ' : ' . | |
| 31 | + 'Pagantis Exception For user '. | |
| 32 | + $customer->email. | |
| 33 | + ' : '. | |
| 34 | 34 | $exception->getMessage(), | 
| 35 | 35 | 3, | 
| 36 | 36 | $exception->getCode(), | 
| @@ -40,9 +40,9 @@ discard block | ||
| 40 | 40 | ); | 
| 41 | 41 |          } else { | 
| 42 | 42 | PrestaShopLogger::addLog( | 
| 43 | - 'Pagantis Exception For user ' . | |
| 44 | - $customer->email . | |
| 45 | - ' : ' . | |
| 43 | + 'Pagantis Exception For user '. | |
| 44 | + $customer->email. | |
| 45 | + ' : '. | |
| 46 | 46 | $exception->getMessage(), | 
| 47 | 47 | 3, | 
| 48 | 48 | $exception->getCode(), | 
| @@ -88,15 +88,15 @@ discard block | ||
| 88 | 88 | $configs = json_decode(Pagantis::getExtraConfig($product, null), true); | 
| 89 | 89 |          $iframe = Pagantis::getExtraConfig('FORM_DISPLAY_TYPE', $product); | 
| 90 | 90 | |
| 91 | - $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key'); | |
| 92 | - $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key'); | |
| 91 | + $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key'); | |
| 92 | + $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key'); | |
| 93 | 93 | |
| 94 | 94 | $okUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ | 
| 95 | - .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=redirect&product=' . Tools::strtolower($configs['CODE']) . '&' | |
| 95 | + .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=redirect&product='.Tools::strtolower($configs['CODE']).'&' | |
| 96 | 96 | .http_build_query($query) | 
| 97 | 97 | ; | 
| 98 | 98 | $notificationOkUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ | 
| 99 | - .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=notification&product=' . Tools::strtolower($configs['CODE']) . '&' | |
| 99 | + .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&token='.$urlToken.'&origin=notification&product='.Tools::strtolower($configs['CODE']).'&' | |
| 100 | 100 | .http_build_query($query) | 
| 101 | 101 | ; | 
| 102 | 102 | |
| @@ -111,27 +111,27 @@ discard block | ||
| 111 | 111 | |
| 112 | 112 |          try { | 
| 113 | 113 | $shippingCountry = Country::getIsoById($shippingAddress->id_country); | 
| 114 | - $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); | |
| 114 | + $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); | |
| 115 | 115 | $userAddress | 
| 116 | 116 | ->setZipCode($shippingAddress->postcode) | 
| 117 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) | |
| 117 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) | |
| 118 | 118 | ->setCountryCode($shippingCountry) | 
| 119 | 119 | ->setCity($shippingAddress->city) | 
| 120 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) | |
| 120 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) | |
| 121 | 121 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) | 
| 122 | 122 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) | 
| 123 | 123 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) | 
| 124 | 124 | ; | 
| 125 | 125 | |
| 126 | - $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); | |
| 126 | + $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); | |
| 127 | 127 | $shippingPhone = (empty($shippingAddress->phone_mobile)) ? | 
| 128 | 128 | $shippingAddress->phone : $shippingAddress->phone_mobile; | 
| 129 | 129 | $orderShippingAddress | 
| 130 | 130 | ->setZipCode($shippingAddress->postcode) | 
| 131 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) | |
| 131 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) | |
| 132 | 132 | ->setCountryCode($shippingCountry) | 
| 133 | 133 | ->setCity($shippingAddress->city) | 
| 134 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) | |
| 134 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) | |
| 135 | 135 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) | 
| 136 | 136 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) | 
| 137 | 137 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) | 
| @@ -145,10 +145,10 @@ discard block | ||
| 145 | 145 | $billingAddress->phone : $billingAddress->phone_mobile; | 
| 146 | 146 | $orderBillingAddress | 
| 147 | 147 | ->setZipCode($billingAddress->postcode) | 
| 148 | - ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname) | |
| 148 | + ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname) | |
| 149 | 149 | ->setCountryCode($billingCountry) | 
| 150 | 150 | ->setCity($billingAddress->city) | 
| 151 | - ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2) | |
| 151 | + ->setAddress($billingAddress->address1.' '.$billingAddress->address2) | |
| 152 | 152 | ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress)) | 
| 153 | 153 | ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress)) | 
| 154 | 154 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) | 
| @@ -171,7 +171,7 @@ discard block | ||
| 171 | 171 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) | 
| 172 | 172 | ; | 
| 173 | 173 | |
| 174 | -            if ($customer->birthday!='0000-00-00') { | |
| 174 | +            if ($customer->birthday != '0000-00-00') { | |
| 175 | 175 | $orderUser->setDateOfBirth($customer->birthday); | 
| 176 | 176 | } | 
| 177 | 177 | |
| @@ -205,13 +205,13 @@ discard block | ||
| 205 | 205 | ->setQuantity($item['quantity']) | 
| 206 | 206 | ->setDescription($item['name']); | 
| 207 | 207 |                  if ($promotedProduct) { | 
| 208 | - $promotedAmount+=$product->getAmount(); | |
| 208 | + $promotedAmount += $product->getAmount(); | |
| 209 | 209 | $productId = $item['id_product']; | 
| 210 | 210 | $finalPrice = Product::getPriceStatic($productId); | 
| 211 | - $promotedMessage = 'Promoted Item: ' . $product->getDescription() . | |
| 212 | - ' Price: ' . $finalPrice . | |
| 213 | - ' Qty: ' . $product->getQuantity() . | |
| 214 | - ' Item ID: ' . $item['id_product']; | |
| 211 | + $promotedMessage = 'Promoted Item: '.$product->getDescription(). | |
| 212 | + ' Price: '.$finalPrice. | |
| 213 | + ' Qty: '.$product->getQuantity(). | |
| 214 | + ' Item ID: '.$item['id_product']; | |
| 215 | 215 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
| 216 | 216 | } | 
| 217 | 217 | $details->addProduct($product); | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 | Tools::redirect($cancelUrl); | 
| 263 | 263 | } | 
| 264 | 264 | |
| 265 | - $url =''; | |
| 265 | + $url = ''; | |
| 266 | 266 |          try { | 
| 267 | 267 | $orderClient = new \Pagantis\OrdersApiClient\Client( | 
| 268 | 268 | trim($pagantisPublicKey), | 
| @@ -274,11 +274,11 @@ discard block | ||
| 274 | 274 | $url = $order->getActionUrls()->getForm(); | 
| 275 | 275 | /** @var string $orderId MD5 value */ | 
| 276 | 276 | $orderId = $order->getId(); | 
| 277 | - $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`, `token`) | |
| 277 | + $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`, `token`) | |
| 278 | 278 |                       VALUES ('$cart->id','$orderId', '$urlToken')"; | 
| 279 | 279 | $result = Db::getInstance()->execute($sql); | 
| 280 | 280 |                  if (!$result) { | 
| 281 | -                    throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql); | |
| 281 | +                    throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql); | |
| 282 | 282 | } | 
| 283 | 283 |              } else { | 
| 284 | 284 | throw new OrderNotFoundException(); | 
| @@ -410,13 +410,13 @@ discard block | ||
| 410 | 410 | */ | 
| 411 | 411 | private function getUserLanguage($shippingAddress = null, $billingAddress = null) | 
| 412 | 412 |      { | 
| 413 | -        $allowedCountries    = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); | |
| 413 | +        $allowedCountries = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); | |
| 414 | 414 | $lang = Language::getLanguage($this->context->language->id); | 
| 415 | 415 |          $langArray = explode("-", $lang['language_code']); | 
| 416 | 416 |          if (count($langArray) != 2 && isset($lang['locale'])) { | 
| 417 | 417 |              $langArray = explode("-", $lang['locale']); | 
| 418 | 418 | } | 
| 419 | - $language = Tools::strtoupper($langArray[count($langArray)-1]); | |
| 419 | + $language = Tools::strtoupper($langArray[count($langArray) - 1]); | |
| 420 | 420 | // Prevent null language detection | 
| 421 | 421 |          if (in_array(Tools::strtolower($language), $allowedCountries)) { | 
| 422 | 422 | return $language; | 
| @@ -144,7 +144,7 @@ discard block | ||
| 144 | 144 |          } catch (\Exception $exception) { | 
| 145 | 145 | $thrownException = true; | 
| 146 | 146 | $this->getMerchantOrderId(); | 
| 147 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; | |
| 147 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; | |
| 148 | 148 |              if ($this->isPost()) { | 
| 149 | 149 | $this->jsonResponse = new JsonExceptionResponse(); | 
| 150 | 150 | $this->jsonResponse->setMerchantOrderId($theId); | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 |              if (!$thrownException) { | 
| 160 | 160 | $this->jsonResponse = new JsonSuccessResponse(); | 
| 161 | 161 | $this->getMerchantOrderId(); | 
| 162 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; | |
| 162 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; | |
| 163 | 163 | $this->jsonResponse->setMerchantOrderId($theId); | 
| 164 | 164 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); | 
| 165 | 165 | $this->confirmPagantisOrder(); | 
| @@ -168,7 +168,7 @@ discard block | ||
| 168 | 168 | $this->rollbackMerchantOrder(); | 
| 169 | 169 |              if ($this->isNotification()) { | 
| 170 | 170 | $this->getMerchantOrderId(); | 
| 171 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; | |
| 171 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; | |
| 172 | 172 | $this->jsonResponse = new JsonExceptionResponse(); | 
| 173 | 173 | $this->jsonResponse->setMerchantOrderId($theId); | 
| 174 | 174 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); | 
| @@ -185,7 +185,7 @@ discard block | ||
| 185 | 185 |          } catch (\Exception $exception) { | 
| 186 | 186 | $thrownException = true; | 
| 187 | 187 | $this->getMerchantOrderId(); | 
| 188 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; | |
| 188 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; | |
| 189 | 189 |              if ($this->isPost()) { | 
| 190 | 190 | $this->jsonResponse = new JsonExceptionResponse(); | 
| 191 | 191 | $this->jsonResponse->setMerchantOrderId($theId); | 
| @@ -254,13 +254,13 @@ discard block | ||
| 254 | 254 |          $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); | 
| 255 | 255 |          if (!in_array(Tools::strtoupper($productCode), $products)) { | 
| 256 | 256 | throw new UnknownException( | 
| 257 | -                'No valid Pagantis product provided in the url: ' . Tools::getValue('product') | |
| 257 | +                'No valid Pagantis product provided in the url: '.Tools::getValue('product') | |
| 258 | 258 | ); | 
| 259 | 259 | } | 
| 260 | - $this->productName = "Pagantis " . Tools::strtolower($productCode); | |
| 260 | + $this->productName = "Pagantis ".Tools::strtolower($productCode); | |
| 261 | 261 | |
| 262 | - $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_public_key')); | |
| 263 | - $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_private_key')); | |
| 262 | + $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_public_key')); | |
| 263 | + $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_private_key')); | |
| 264 | 264 | |
| 265 | 265 |          $this->merchantCartId = Tools::getValue('id_cart'); | 
| 266 | 266 | |
| @@ -280,8 +280,8 @@ discard block | ||
| 280 | 280 | public function getMerchantOrderId() | 
| 281 | 281 |      { | 
| 282 | 282 |          try { | 
| 283 | - $sql = 'select ps_order_id from ' . _DB_PREFIX_ .self::ORDERS_TABLE .' where id = ' | |
| 284 | - .(int)$this->merchantCartId . ' and token = \'' . $this->token . '\''; | |
| 283 | + $sql = 'select ps_order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = ' | |
| 284 | + .(int) $this->merchantCartId.' and token = \''.$this->token.'\''; | |
| 285 | 285 | $this->merchantOrderId = Db::getInstance()->getValue($sql); | 
| 286 | 286 |          } catch (\Exception $exception) { | 
| 287 | 287 | $exceptionMessage = sprintf( | 
| @@ -325,9 +325,9 @@ discard block | ||
| 325 | 325 | private function getPagantisOrderId() | 
| 326 | 326 |      { | 
| 327 | 327 |          try { | 
| 328 | - $sql = 'select order_id from ' . _DB_PREFIX_.self::ORDERS_TABLE .' where id = ' | |
| 329 | - .(int)$this->merchantCartId . ' and token = \'' . $this->token . '\''; | |
| 330 | - $this->pagantisOrderId= Db::getInstance()->getValue($sql); | |
| 328 | + $sql = 'select order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = ' | |
| 329 | + .(int) $this->merchantCartId.' and token = \''.$this->token.'\''; | |
| 330 | + $this->pagantisOrderId = Db::getInstance()->getValue($sql); | |
| 331 | 331 | |
| 332 | 332 |              if (is_null($this->pagantisOrderId)) { | 
| 333 | 333 | throw new NoIdentificationException(); | 
| @@ -360,7 +360,7 @@ discard block | ||
| 360 | 360 |      { | 
| 361 | 361 |          if ($this->pagantisOrder->getStatus() === PagantisModelOrder::STATUS_CONFIRMED) { | 
| 362 | 362 | $this->getMerchantOrderId(); | 
| 363 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; | |
| 363 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; | |
| 364 | 364 | $this->jsonResponse = new JsonSuccessResponse(); | 
| 365 | 365 | $this->jsonResponse->setMerchantOrderId($theId); | 
| 366 | 366 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); | 
| @@ -391,7 +391,7 @@ discard block | ||
| 391 | 391 | $psTotalAmount = substr_replace( | 
| 392 | 392 | $merchantAmount, | 
| 393 | 393 | '.', | 
| 394 | - (Tools::strlen($merchantAmount) -2), | |
| 394 | + (Tools::strlen($merchantAmount) - 2), | |
| 395 | 395 | 0 | 
| 396 | 396 | ); | 
| 397 | 397 | |
| @@ -399,14 +399,14 @@ discard block | ||
| 399 | 399 | $pgTotalAmount = substr_replace( | 
| 400 | 400 | $pgTotalAmountInCents, | 
| 401 | 401 | '.', | 
| 402 | - (Tools::strlen($pgTotalAmountInCents) -2), | |
| 402 | + (Tools::strlen($pgTotalAmountInCents) - 2), | |
| 403 | 403 | 0 | 
| 404 | 404 | ); | 
| 405 | 405 | |
| 406 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'. $this->merchantCartId . | |
| 407 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . | |
| 408 | - '. The Cart in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . | |
| 409 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; | |
| 406 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'.$this->merchantCartId. | |
| 407 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. | |
| 408 | + '. The Cart in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. | |
| 409 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; | |
| 410 | 410 | |
| 411 | 411 | $this->saveLog(array( | 
| 412 | 412 | 'requestId' => $this->requestId, | 
| @@ -436,12 +436,12 @@ discard block | ||
| 436 | 436 | } | 
| 437 | 437 | |
| 438 | 438 | // Double check | 
| 439 | - $tableName = _DB_PREFIX_ . self::ORDERS_TABLE; | |
| 439 | + $tableName = _DB_PREFIX_.self::ORDERS_TABLE; | |
| 440 | 440 | $fieldName = 'ps_order_id'; | 
| 441 | -            $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . (int)$this->merchantCartId | |
| 442 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' | |
| 443 | - . ' and `token` = \'' . $this->token . '\'' | |
| 444 | - . ' and `' . $fieldName . '` is not null'); | |
| 441 | +            $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.(int) $this->merchantCartId | |
| 442 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' | |
| 443 | + . ' and `token` = \''.$this->token.'\'' | |
| 444 | + . ' and `'.$fieldName.'` is not null'); | |
| 445 | 445 | $results = Db::getInstance()->ExecuteS($sql); | 
| 446 | 446 |              if (is_array($results) && count($results) === 1) { | 
| 447 | 447 | $this->getMerchantOrderId(); | 
| @@ -481,9 +481,9 @@ discard block | ||
| 481 | 481 |                  Configuration::get('PS_OS_PAYMENT'), | 
| 482 | 482 | $this->merchantCart->getOrderTotal(true), | 
| 483 | 483 | $this->productName, | 
| 484 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . | |
| 485 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . | |
| 486 | - $this->amountMismatchError . | |
| 484 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. | |
| 485 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). | |
| 486 | + $this->amountMismatchError. | |
| 487 | 487 | $metadataInfo, | 
| 488 | 488 |                  array('transaction_id' => $this->pagantisOrderId), | 
| 489 | 489 | null, | 
| @@ -497,9 +497,9 @@ discard block | ||
| 497 | 497 | Db::getInstance()->update( | 
| 498 | 498 | self::ORDERS_TABLE, | 
| 499 | 499 |                  array('ps_order_id' => $this->module->currentOrder), | 
| 500 | - 'id = '. (int)$this->merchantCartId | |
| 501 | - . ' and order_id = \'' . $this->pagantisOrderId . '\'' | |
| 502 | - . ' and token = \'' . $this->token . '\'' | |
| 500 | + 'id = '.(int) $this->merchantCartId | |
| 501 | + . ' and order_id = \''.$this->pagantisOrderId.'\'' | |
| 502 | + . ' and token = \''.$this->token.'\'' | |
| 503 | 503 | ); | 
| 504 | 504 | |
| 505 | 505 |          } catch (\Exception $exception) { | 
| @@ -526,9 +526,9 @@ discard block | ||
| 526 | 526 | $this->orderClient->confirmOrder($this->pagantisOrderId); | 
| 527 | 527 |              try { | 
| 528 | 528 | $mode = ($this->isPost()) ? 'NOTIFICATION' : 'REDIRECTION'; | 
| 529 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . | |
| 530 | - '. Pagantis OrderId=' . $this->pagantisOrderId . | |
| 531 | - '. Prestashop OrderId=' . $this->module->currentOrder; | |
| 529 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. | |
| 530 | + '. Pagantis OrderId='.$this->pagantisOrderId. | |
| 531 | + '. Prestashop OrderId='.$this->module->currentOrder; | |
| 532 | 532 |                  $this->saveLog(array('requestId' => $this->requestId, 'message' => $message)); | 
| 533 | 533 |              } catch (\Exception $exception) { | 
| 534 | 534 | $exceptionMessage = sprintf( | 
| @@ -555,16 +555,16 @@ discard block | ||
| 555 | 555 |      { | 
| 556 | 556 |          try { | 
| 557 | 557 | $this->getMerchantOrderId(); | 
| 558 | - $message = 'Roolback method: ' . | |
| 559 | - '. Pagantis OrderId=' . $this->pagantisOrderId . | |
| 560 | - '. Prestashop CartId=' . $this->merchantCartId . | |
| 561 | - '. Prestashop OrderId=' . $this->merchantOrderId; | |
| 558 | + $message = 'Roolback method: '. | |
| 559 | + '. Pagantis OrderId='.$this->pagantisOrderId. | |
| 560 | + '. Prestashop CartId='.$this->merchantCartId. | |
| 561 | + '. Prestashop OrderId='.$this->merchantOrderId; | |
| 562 | 562 |              if ($this->module->currentOrder) { | 
| 563 | 563 | $objOrder = new Order($this->module->currentOrder); | 
| 564 | 564 | $history = new OrderHistory(); | 
| 565 | - $history->id_order = (int)$objOrder->id; | |
| 566 | - $history->changeIdOrderState(8, (int)($objOrder->id)); | |
| 567 | - $message .= ' Prestashop OrderId=' . $this->merchantCartId; | |
| 565 | + $history->id_order = (int) $objOrder->id; | |
| 566 | + $history->changeIdOrderState(8, (int) ($objOrder->id)); | |
| 567 | + $message .= ' Prestashop OrderId='.$this->merchantCartId; | |
| 568 | 568 | } | 
| 569 | 569 | $this->saveLog(array( | 
| 570 | 570 | 'requestId' => $this->requestId, | 
| @@ -589,7 +589,7 @@ discard block | ||
| 589 | 589 |      { | 
| 590 | 590 |          try { | 
| 591 | 591 | $table = self::CART_TABLE; | 
| 592 | -            $insertBlock = Db::getInstance()->insert($table, array('id' =>(int)$orderId, 'timestamp' =>(time()))); | |
| 592 | +            $insertBlock = Db::getInstance()->insert($table, array('id' =>(int) $orderId, 'timestamp' =>(time()))); | |
| 593 | 593 |              if ($insertBlock === false) { | 
| 594 | 594 |                  if ($this->isNotification()) { | 
| 595 | 595 | throw new ConcurrencyException(); | 
| @@ -599,11 +599,11 @@ discard block | ||
| 599 | 599 | as rest FROM %s WHERE %s", | 
| 600 | 600 | self::CONCURRENCY_TIMEOUT, | 
| 601 | 601 | _DB_PREFIX_.$table, | 
| 602 | - 'id='.(int)$orderId | |
| 602 | + 'id='.(int) $orderId | |
| 603 | 603 | ); | 
| 604 | 604 | $resultSeconds = Db::getInstance()->getValue($query); | 
| 605 | 605 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; | 
| 606 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? | |
| 606 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? | |
| 607 | 607 | self::CONCURRENCY_TIMEOUT : $restSeconds; | 
| 608 | 608 |                      if ($secondsToExpire > 0) { | 
| 609 | 609 | sleep($secondsToExpire + 1); | 
| @@ -612,7 +612,7 @@ discard block | ||
| 612 | 612 | $this->getMerchantOrderId(); | 
| 613 | 613 | $this->getPagantisOrderId(); | 
| 614 | 614 | |
| 615 | - $logMessage = sprintf( | |
| 615 | + $logMessage = sprintf( | |
| 616 | 616 | "User has waited %s seconds, default %s, bd time to expire %s [cartId=%s][origin=%s]", | 
| 617 | 617 | $secondsToExpire, | 
| 618 | 618 | self::CONCURRENCY_TIMEOUT, | 
| @@ -641,10 +641,10 @@ discard block | ||
| 641 | 641 |      { | 
| 642 | 642 |          try { | 
| 643 | 643 |              if (is_null($orderId)) { | 
| 644 | - Db::getInstance()->delete(self::CART_TABLE, 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT)); | |
| 644 | + Db::getInstance()->delete(self::CART_TABLE, 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT)); | |
| 645 | 645 | return; | 
| 646 | 646 | } | 
| 647 | - Db::getInstance()->delete(self::CART_TABLE, 'id = ' . (int)$orderId); | |
| 647 | + Db::getInstance()->delete(self::CART_TABLE, 'id = '.(int) $orderId); | |
| 648 | 648 |          } catch (\Exception $exception) { | 
| 649 | 649 | throw new ConcurrencyException(); | 
| 650 | 650 | } | 
| @@ -669,8 +669,8 @@ discard block | ||
| 669 | 669 | 'merchantCartId' => $this->merchantCartId, | 
| 670 | 670 | 'merchantOrderId' => $this->merchantOrderId, | 
| 671 | 671 | 'pagantisOrderId' => $this->pagantisOrderId, | 
| 672 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', | |
| 673 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', | |
| 672 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', | |
| 673 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', | |
| 674 | 674 | 'method' => $method, | 
| 675 | 675 | 'file' => __FILE__, | 
| 676 | 676 | 'line' => $line, | 
| @@ -706,7 +706,7 @@ discard block | ||
| 706 | 706 | 'id_module' => $this->module->id, | 
| 707 | 707 | 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, | 
| 708 | 708 | ); | 
| 709 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; | |
| 709 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; | |
| 710 | 710 | $returnMessage = sprintf( | 
| 711 | 711 | "[origin=%s][cartId=%s][prestashopOrderId=%s][pagantisOrderId=%s][returnUrl=%s]", | 
| 712 | 712 | $this->getOrigin(), |