@@ -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') |
@@ -215,34 +215,34 @@ discard block |
||
| 215 | 215 | public function checkHooks() |
| 216 | 216 | { |
| 217 | 217 | try { |
| 218 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where |
|
| 219 | - id_module = \'' . Module::getModuleIdByName($this->name) . '\' and |
|
| 220 | - id_shop = \'' . Shop::getContextShopID() . '\' and |
|
| 221 | - id_hook = \'' . Hook::getIdByName('header') . '\''; |
|
| 218 | + $sql_content = 'select * from '._DB_PREFIX_.'hook_module where |
|
| 219 | + id_module = \'' . Module::getModuleIdByName($this->name).'\' and |
|
| 220 | + id_shop = \'' . Shop::getContextShopID().'\' and |
|
| 221 | + id_hook = \'' . Hook::getIdByName('header').'\''; |
|
| 222 | 222 | $hook_exists = Db::getInstance()->ExecuteS($sql_content); |
| 223 | 223 | if (empty($hook_exists)) { |
| 224 | - $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module |
|
| 224 | + $sql_insert = 'insert into '._DB_PREFIX_.'hook_module |
|
| 225 | 225 | (id_module, id_shop, id_hook, position) |
| 226 | 226 | values |
| 227 | - (\''. Module::getModuleIdByName($this->name) . '\', |
|
| 228 | - \''. Shop::getContextShopID() . '\', |
|
| 229 | - \''. Hook::getIdByName('header') . '\', |
|
| 227 | + (\''. Module::getModuleIdByName($this->name).'\', |
|
| 228 | + \''. Shop::getContextShopID().'\', |
|
| 229 | + \''. Hook::getIdByName('header').'\', |
|
| 230 | 230 | 150)'; |
| 231 | 231 | Db::getInstance()->execute($sql_insert); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where |
|
| 235 | - id_module = \'' . Module::getModuleIdByName($this->name) . '\' and |
|
| 236 | - id_shop = \'' . Shop::getContextShopID() . '\' and |
|
| 237 | - id_hook = \'' . Hook::getIdByName('displayProductPriceBlock') . '\''; |
|
| 234 | + $sql_content = 'select * from '._DB_PREFIX_.'hook_module where |
|
| 235 | + id_module = \'' . Module::getModuleIdByName($this->name).'\' and |
|
| 236 | + id_shop = \'' . Shop::getContextShopID().'\' and |
|
| 237 | + id_hook = \'' . Hook::getIdByName('displayProductPriceBlock').'\''; |
|
| 238 | 238 | $hook_exists = Db::getInstance()->ExecuteS($sql_content); |
| 239 | 239 | if (empty($hook_exists)) { |
| 240 | - $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module |
|
| 240 | + $sql_insert = 'insert into '._DB_PREFIX_.'hook_module |
|
| 241 | 241 | (id_module, id_shop, id_hook, position) |
| 242 | 242 | values |
| 243 | - (\''. Module::getModuleIdByName($this->name) . '\', |
|
| 244 | - \''. Shop::getContextShopID() . '\', |
|
| 245 | - \''. Hook::getIdByName('displayProductPriceBlock') . '\', |
|
| 243 | + (\''. Module::getModuleIdByName($this->name).'\', |
|
| 244 | + \''. Shop::getContextShopID().'\', |
|
| 245 | + \''. Hook::getIdByName('displayProductPriceBlock').'\', |
|
| 246 | 246 | 160)'; |
| 247 | 247 | Db::getInstance()->execute($sql_insert); |
| 248 | 248 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function checkEnvVariables() |
| 258 | 258 | { |
| 259 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; |
|
| 259 | + $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; |
|
| 260 | 260 | $dbConfigs = Db::getInstance()->executeS($sql_content); |
| 261 | 261 | |
| 262 | 262 | // Convert a multimple dimension array for SQL insert statements into a simple key/value |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | { |
| 286 | 286 | try { |
| 287 | 287 | $tableName = _DB_PREFIX_.'pagantis_order'; |
| 288 | - $sql = "show tables like '" . $tableName . "'"; |
|
| 288 | + $sql = "show tables like '".$tableName."'"; |
|
| 289 | 289 | $data = Db::getInstance()->ExecuteS($sql); |
| 290 | 290 | if (count($data) > 0) { |
| 291 | - $sql = "desc " . $tableName; |
|
| 291 | + $sql = "desc ".$tableName; |
|
| 292 | 292 | $data = Db::getInstance()->ExecuteS($sql); |
| 293 | 293 | if (count($data) == 2) { |
| 294 | 294 | $sql = "ALTER TABLE $tableName ADD COLUMN ps_order_id VARCHAR(60) AFTER order_id"; |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | $tableName = _DB_PREFIX_.'pagantis_config'; |
| 299 | - $sql = "show tables like '" . $tableName . "'"; |
|
| 299 | + $sql = "show tables like '".$tableName."'"; |
|
| 300 | 300 | $data = Db::getInstance()->ExecuteS($sql); |
| 301 | 301 | if (count($data) > 0) { |
| 302 | - $sql = "desc " . $tableName; |
|
| 302 | + $sql = "desc ".$tableName; |
|
| 303 | 303 | $data = Db::getInstance()->ExecuteS($sql); |
| 304 | 304 | if (count($data) === 3 && $data[2]['Type'] !== 'varchar(5000)') { |
| 305 | 305 | $sql = "ALTER TABLE $tableName MODIFY `value` VARCHAR(5000)"; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | $availableCurrencies = array('EUR'); |
| 343 | 343 | $pagantisDisplayMinAmount = $configs['DISPLAY_MIN_AMOUNT']; |
| 344 | 344 | $pagantisDisplayMaxAmount = $configs['DISPLAY_MAX_AMOUNT']; |
| 345 | - $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key'); |
|
| 346 | - $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key'); |
|
| 345 | + $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key'); |
|
| 346 | + $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key'); |
|
| 347 | 347 | $this->allowedCountries = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); |
| 348 | 348 | $this->getUserLanguage(); |
| 349 | 349 | return ( |
@@ -422,42 +422,42 @@ discard block |
||
| 422 | 422 | if ($this->isPaymentMethodAvailable($product)) { |
| 423 | 423 | $productConfigs = Pagantis::getExtraConfig($product, null); |
| 424 | 424 | $productConfigs = json_decode($productConfigs, true); |
| 425 | - $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); |
|
| 426 | - $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); |
|
| 427 | - $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); |
|
| 425 | + $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); |
|
| 426 | + $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); |
|
| 427 | + $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); |
|
| 428 | 428 | |
| 429 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); |
|
| 429 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); |
|
| 430 | 430 | unset($productConfigs['TITLE']); |
| 431 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal; |
|
| 432 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount; |
|
| 433 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; |
|
| 434 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; |
|
| 435 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; |
|
| 436 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
| 437 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; |
|
| 438 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
| 439 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment') . '&product=' . $productConfigs['CODE']; |
|
| 440 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
| 431 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal; |
|
| 432 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount; |
|
| 433 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; |
|
| 434 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; |
|
| 435 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; |
|
| 436 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
| 437 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; |
|
| 438 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
| 439 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $link->getModuleLink('pagantis', 'payment').'&product='.$productConfigs['CODE']; |
|
| 440 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
| 441 | 441 | |
| 442 | 442 | foreach ($productConfigs as $productConfigKey => $productConfigValue) { |
| 443 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; |
|
| 443 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; |
|
| 444 | 444 | } |
| 445 | 445 | $this->context->smarty->assign($templateConfigs); |
| 446 | 446 | |
| 447 | 447 | $paymentOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); |
| 448 | 448 | $uri = $link->getModuleLink('pagantis', 'payment'); |
| 449 | 449 | if (strpos($uri, '?') !== false) { |
| 450 | - $uri .= '&product=' . $productConfigs['CODE']; |
|
| 450 | + $uri .= '&product='.$productConfigs['CODE']; |
|
| 451 | 451 | } else { |
| 452 | - $uri .= '?product=' . $productConfigs['CODE']; |
|
| 452 | + $uri .= '?product='.$productConfigs['CODE']; |
|
| 453 | 453 | } |
| 454 | 454 | $paymentOption |
| 455 | - ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE']) |
|
| 455 | + ->setCallToActionText($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE']) |
|
| 456 | 456 | ->setAction($uri) |
| 457 | - ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO']) |
|
| 457 | + ->setLogo($templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO']) |
|
| 458 | 458 | ->setModuleName(__CLASS__) |
| 459 | 459 | ->setAdditionalInformation( |
| 460 | - $this->fetch('module:pagantis/views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl') |
|
| 460 | + $this->fetch('module:pagantis/views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl') |
|
| 461 | 461 | ) |
| 462 | 462 | ; |
| 463 | 463 | $return[] = $paymentOption; |
@@ -481,61 +481,61 @@ discard block |
||
| 481 | 481 | foreach ($products as $product) { |
| 482 | 482 | $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); |
| 483 | 483 | $inputs[] = array( |
| 484 | - 'name' => $code .'_is_enabled', |
|
| 485 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
| 486 | - 'label' => $this->l('Module is enabled ' . $code), |
|
| 484 | + 'name' => $code.'_is_enabled', |
|
| 485 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
| 486 | + 'label' => $this->l('Module is enabled '.$code), |
|
| 487 | 487 | 'prefix' => '<i class="icon icon-key"></i>', |
| 488 | 488 | 'class' => 't', |
| 489 | 489 | 'required' => true, |
| 490 | 490 | 'values'=> array( |
| 491 | 491 | array( |
| 492 | - 'id' => $code .'_is_enabled_true', |
|
| 492 | + 'id' => $code.'_is_enabled_true', |
|
| 493 | 493 | 'value' => 1, |
| 494 | 494 | 'label' => $this->l('Yes', get_class($this), null, false), |
| 495 | 495 | ), |
| 496 | 496 | array( |
| 497 | - 'id' => $code . '_is_enabled_false', |
|
| 497 | + 'id' => $code.'_is_enabled_false', |
|
| 498 | 498 | 'value' => 0, |
| 499 | 499 | 'label' => $this->l('No', get_class($this), null, false), |
| 500 | 500 | ), |
| 501 | 501 | ) |
| 502 | 502 | ); |
| 503 | 503 | $inputs[] = array( |
| 504 | - 'name' => $code . '_public_key', |
|
| 504 | + 'name' => $code.'_public_key', |
|
| 505 | 505 | 'suffix' => $this->l('ex: pk_fd53cd467ba49022e4gf215e'), |
| 506 | 506 | 'type' => 'text', |
| 507 | 507 | 'size' => 60, |
| 508 | - 'label' => $this->l('Public Key ' . $code), |
|
| 508 | + 'label' => $this->l('Public Key '.$code), |
|
| 509 | 509 | 'prefix' => '<i class="icon icon-key"></i>', |
| 510 | 510 | 'col' => 6, |
| 511 | 511 | 'required' => true, |
| 512 | 512 | ); |
| 513 | 513 | $inputs[] = array( |
| 514 | - 'name' => $code . '_private_key', |
|
| 514 | + 'name' => $code.'_private_key', |
|
| 515 | 515 | 'suffix' => $this->l('ex: 21e5723a97459f6a'), |
| 516 | 516 | 'type' => 'text', |
| 517 | 517 | 'size' => 60, |
| 518 | - 'label' => $this->l('Private Key ' . $code), |
|
| 518 | + 'label' => $this->l('Private Key '.$code), |
|
| 519 | 519 | 'prefix' => '<i class="icon icon-key"></i>', |
| 520 | 520 | 'col' => 6, |
| 521 | 521 | 'required' => true, |
| 522 | 522 | ); |
| 523 | 523 | if ($code !== "p4x") { |
| 524 | 524 | $inputs[] = array( |
| 525 | - 'name' => $code . '_simulator_is_enabled', |
|
| 526 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
| 527 | - 'label' => $this->l('Simulator is enabled ' . $code), |
|
| 525 | + 'name' => $code.'_simulator_is_enabled', |
|
| 526 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
| 527 | + 'label' => $this->l('Simulator is enabled '.$code), |
|
| 528 | 528 | 'prefix' => '<i class="icon icon-key"></i>', |
| 529 | 529 | 'class' => 't', |
| 530 | 530 | 'required' => true, |
| 531 | 531 | 'values'=> array( |
| 532 | 532 | array( |
| 533 | - 'id' => $code . '_simulator_is_enabled_on', |
|
| 533 | + 'id' => $code.'_simulator_is_enabled_on', |
|
| 534 | 534 | 'value' => 1, |
| 535 | 535 | 'label' => $this->l('Yes'), |
| 536 | 536 | ), |
| 537 | 537 | array( |
| 538 | - 'id' => $code . '_simulator_is_enabled_off', |
|
| 538 | + 'id' => $code.'_simulator_is_enabled_off', |
|
| 539 | 539 | 'value' => 0, |
| 540 | 540 | 'label' => $this->l('No'), |
| 541 | 541 | ), |
@@ -603,17 +603,17 @@ discard block |
||
| 603 | 603 | $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); |
| 604 | 604 | foreach ($products as $product) { |
| 605 | 605 | $code = Tools::strtolower(Pagantis::getExtraConfig('CODE', $product)); |
| 606 | - $settings[$code . '_public_key'] = Configuration::get($code . '_public_key'); |
|
| 607 | - $settings[$code . '_private_key'] = Configuration::get($code . '_private_key'); |
|
| 608 | - $settings[$code . '_is_enabled'] = Configuration::get($code . '_is_enabled'); |
|
| 606 | + $settings[$code.'_public_key'] = Configuration::get($code.'_public_key'); |
|
| 607 | + $settings[$code.'_private_key'] = Configuration::get($code.'_private_key'); |
|
| 608 | + $settings[$code.'_is_enabled'] = Configuration::get($code.'_is_enabled'); |
|
| 609 | 609 | if ($code !== 'p4x') { |
| 610 | - $settings[$code . '_simulator_is_enabled'] = Configuration::get($code . '_simulator_is_enabled'); |
|
| 610 | + $settings[$code.'_simulator_is_enabled'] = Configuration::get($code.'_simulator_is_enabled'); |
|
| 611 | 611 | } |
| 612 | - $settingsKeys[] = $code . '_is_enabled'; |
|
| 613 | - $settingsKeys[] = $code . '_public_key'; |
|
| 614 | - $settingsKeys[] = $code . '_private_key'; |
|
| 612 | + $settingsKeys[] = $code.'_is_enabled'; |
|
| 613 | + $settingsKeys[] = $code.'_public_key'; |
|
| 614 | + $settingsKeys[] = $code.'_private_key'; |
|
| 615 | 615 | if ($code !== 'p4x') { |
| 616 | - $settingsKeys[] = $code . '_simulator_is_enabled'; |
|
| 616 | + $settingsKeys[] = $code.'_simulator_is_enabled'; |
|
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
@@ -684,43 +684,43 @@ discard block |
||
| 684 | 684 | if ($this->isPaymentMethodAvailable($product)) { |
| 685 | 685 | $productConfigs = Pagantis::getExtraConfig($product, null); |
| 686 | 686 | $productConfigs = json_decode($productConfigs, true); |
| 687 | - $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); |
|
| 688 | - $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); |
|
| 689 | - $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); |
|
| 687 | + $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); |
|
| 688 | + $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); |
|
| 689 | + $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); |
|
| 690 | 690 | |
| 691 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); |
|
| 691 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); |
|
| 692 | 692 | unset($productConfigs['TITLE']); |
| 693 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $orderTotal; |
|
| 694 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PROMOTED_AMOUNT'] = $promotedAmount; |
|
| 695 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; |
|
| 696 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; |
|
| 697 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; |
|
| 698 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
| 699 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; |
|
| 700 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
| 693 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $orderTotal; |
|
| 694 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PROMOTED_AMOUNT'] = $promotedAmount; |
|
| 695 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; |
|
| 696 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; |
|
| 697 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; |
|
| 698 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
| 699 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; |
|
| 700 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
| 701 | 701 | $uri = $link->getModuleLink('pagantis', 'payment'); |
| 702 | 702 | if (strpos($uri, '?') !== false) { |
| 703 | - $uri .= '&product=' . $productConfigs['CODE']; |
|
| 703 | + $uri .= '&product='.$productConfigs['CODE']; |
|
| 704 | 704 | } else { |
| 705 | - $uri .= '?product=' . $productConfigs['CODE']; |
|
| 705 | + $uri .= '?product='.$productConfigs['CODE']; |
|
| 706 | 706 | } |
| 707 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PAYMENT_URL'] = $uri; |
|
| 708 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
| 707 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PAYMENT_URL'] = $uri; |
|
| 708 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
| 709 | 709 | |
| 710 | 710 | foreach ($productConfigs as $productConfigKey => $productConfigValue) { |
| 711 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; |
|
| 711 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; |
|
| 712 | 712 | } |
| 713 | 713 | $this->context->smarty->assign($templateConfigs); |
| 714 | 714 | if ($supercheckout_enabled || $onepagecheckout_enabled || $onepagecheckoutps_enabled) { |
| 715 | 715 | $this->checkLogoExists(); |
| 716 | 716 | $return .= $this->display( |
| 717 | 717 | __FILE__, |
| 718 | - 'views/templates/hook/onepagecheckout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' |
|
| 718 | + 'views/templates/hook/onepagecheckout-'.Tools::strtolower($productConfigs['CODE']).'.tpl' |
|
| 719 | 719 | ); |
| 720 | 720 | } elseif (_PS_VERSION_ < 1.7) { |
| 721 | 721 | $return .= $this->display( |
| 722 | 722 | __FILE__, |
| 723 | - 'views/templates/hook/checkout-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' |
|
| 723 | + 'views/templates/hook/checkout-'.Tools::strtolower($productConfigs['CODE']).'.tpl' |
|
| 724 | 724 | ); |
| 725 | 725 | } |
| 726 | 726 | } |
@@ -753,12 +753,12 @@ discard block |
||
| 753 | 753 | $productConfigs = Pagantis::getExtraConfig($product, null); |
| 754 | 754 | $productConfigs = json_decode($productConfigs, true); |
| 755 | 755 | |
| 756 | - $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_public_key'); |
|
| 757 | - $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_simulator_is_enabled'); |
|
| 756 | + $publicKey = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_public_key'); |
|
| 757 | + $simulatorIsEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_simulator_is_enabled'); |
|
| 758 | 758 | if (Tools::strtolower($productConfigs['CODE']) === 'p4x') { |
| 759 | 759 | $simulatorIsEnabled = true; |
| 760 | 760 | } |
| 761 | - $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']) . '_is_enabled'); |
|
| 761 | + $isEnabled = Configuration::get(Tools::strtolower($productConfigs['CODE']).'_is_enabled'); |
|
| 762 | 762 | $availableSimulators = array( |
| 763 | 763 | 'hookDisplayProductButtons' => array( |
| 764 | 764 | 'sdk.simulator.types.SIMPLE', |
@@ -781,30 +781,30 @@ discard block |
||
| 781 | 781 | in_array(Tools::strtolower($this->language), $allowedCountries) && |
| 782 | 782 | (in_array($productConfigs['SIMULATOR_DISPLAY_TYPE'], $availableSimulators[$hookName]) || _PS_VERSION_ < 1.6) |
| 783 | 783 | ) { |
| 784 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_TITLE'] = $this->l($productConfigs['TITLE']); |
|
| 785 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']); |
|
| 786 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']); |
|
| 784 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_TITLE'] = $this->l($productConfigs['TITLE']); |
|
| 785 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_TITLE'] = $this->l($productConfigs['SIMULATOR_TITLE']); |
|
| 786 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_SUBTITLE'] = $this->l($productConfigs['SIMULATOR_SUBTITLE']); |
|
| 787 | 787 | unset($productConfigs['TITLE']); |
| 788 | 788 | unset($productConfigs['SIMULATOR_TITLE']); |
| 789 | 789 | unset($productConfigs['SIMULATOR_SUBTITLE']); |
| 790 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT'] = $amount; |
|
| 791 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_AMOUNT4X'] = number_format(($amount / 4), 2, '.', ''); |
|
| 792 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_PROMOTED_PRODUCT'] = $isPromotedProduct; |
|
| 793 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOCALE'] = $this->language; |
|
| 794 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_COUNTRY'] = $this->language; |
|
| 795 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PUBLIC_KEY'] = $publicKey; |
|
| 796 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
| 797 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_IS_ENABLED'] = $isEnabled; |
|
| 798 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
| 799 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . '_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
| 790 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT'] = $amount; |
|
| 791 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_AMOUNT4X'] = number_format(($amount / 4), 2, '.', ''); |
|
| 792 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_PROMOTED_PRODUCT'] = $isPromotedProduct; |
|
| 793 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOCALE'] = $this->language; |
|
| 794 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_COUNTRY'] = $this->language; |
|
| 795 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PUBLIC_KEY'] = $publicKey; |
|
| 796 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_SIMULATOR_IS_ENABLED'] = $simulatorIsEnabled; |
|
| 797 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_IS_ENABLED'] = $isEnabled; |
|
| 798 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_LOGO'] = 'https://cdn.digitalorigin.com/assets/master/logos/pg-favicon.png'; |
|
| 799 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])).'_PS_VERSION'] = str_replace('.', '-', Tools::substr(_PS_VERSION_, 0, 3)); |
|
| 800 | 800 | foreach ($productConfigs as $productConfigKey => $productConfigValue) { |
| 801 | - $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE'])) . "_" . $productConfigKey] = $productConfigValue; |
|
| 801 | + $templateConfigs[Tools::strtoupper(Tools::strtolower($productConfigs['CODE']))."_".$productConfigKey] = $productConfigValue; |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | $this->context->smarty->assign($templateConfigs); |
| 805 | 805 | $return .= $this->display( |
| 806 | 806 | __FILE__, |
| 807 | - 'views/templates/hook/product-simulator-' . Tools::strtolower($productConfigs['CODE']) . '.tpl' |
|
| 807 | + 'views/templates/hook/product-simulator-'.Tools::strtolower($productConfigs['CODE']).'.tpl' |
|
| 808 | 808 | ); |
| 809 | 809 | } |
| 810 | 810 | } |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | // $params['type'] = weight | price | after_price |
| 834 | 834 | if (isset($params['type']) && $params['type'] === 'price' && |
| 835 | 835 | isset($params['smarty']) && isset($params['smarty']->template_resource) && |
| 836 | - (strpos($params['smarty']->template_resource, 'product.tpl') !== false || |
|
| 836 | + (strpos($params['smarty']->template_resource, 'product.tpl') !== false || |
|
| 837 | 837 | strpos($params['smarty']->template_resource, 'product-prices.tpl') !== false) |
| 838 | 838 | ) { |
| 839 | 839 | return $this->productPageSimulatorDisplay("hookDisplayProductPriceBlock"); |
@@ -866,16 +866,16 @@ discard block |
||
| 866 | 866 | if (!in_array(PROMOTIONS_CATEGORY_NAME, $categories)) { |
| 867 | 867 | /** @var CategoryCore $category */ |
| 868 | 868 | $category = new Category(); |
| 869 | - $categoryArray = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY ); |
|
| 869 | + $categoryArray = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY); |
|
| 870 | 870 | $category->is_root_category = false; |
| 871 | 871 | $category->link_rewrite = $categoryArray; |
| 872 | 872 | $category->meta_description = $categoryArray; |
| 873 | 873 | $category->meta_keywords = $categoryArray; |
| 874 | 874 | $category->meta_title = $categoryArray; |
| 875 | - $category->name = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
| 875 | + $category->name = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
| 876 | 876 | $category->id_parent = Configuration::get('PS_HOME_CATEGORY'); |
| 877 | - $category->active=0; |
|
| 878 | - $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' . |
|
| 877 | + $category->active = 0; |
|
| 878 | + $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '. |
|
| 879 | 879 | 'Use it to promote your products or brands.'; |
| 880 | 880 | $category->description = $this->l($description); |
| 881 | 881 | $category->save(); |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | if (is_null($product)) { |
| 898 | - $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1'; |
|
| 898 | + $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1'; |
|
| 899 | 899 | if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) { |
| 900 | 900 | if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { |
| 901 | 901 | return $results[0]['value']; |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | } |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | - $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($product) . '\' limit 1'; |
|
| 906 | + $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($product).'\' limit 1'; |
|
| 907 | 907 | if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) { |
| 908 | 908 | if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { |
| 909 | 909 | $configs = json_decode($results[0]['value'], true); |
@@ -923,10 +923,10 @@ discard block |
||
| 923 | 923 | */ |
| 924 | 924 | public function checkLogoExists() |
| 925 | 925 | { |
| 926 | - $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
| 927 | - if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) { |
|
| 926 | + $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
| 927 | + if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) { |
|
| 928 | 928 | copy( |
| 929 | - _PS_PAGANTIS_DIR . '/logo.png', |
|
| 929 | + _PS_PAGANTIS_DIR.'/logo.png', |
|
| 930 | 930 | $logoPg |
| 931 | 931 | ); |
| 932 | 932 | } |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | if (count($langArray) != 2 && isset($lang['locale'])) { |
| 943 | 943 | $langArray = explode("-", $lang['locale']); |
| 944 | 944 | } |
| 945 | - $this->language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
| 945 | + $this->language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
| 946 | 946 | // Prevent null language detection |
| 947 | 947 | if (in_array(Tools::strtolower($this->language), $this->allowedCountries)) { |
| 948 | 948 | 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; |
@@ -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(), |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | $configs = json_decode(Pagantis::getExtraConfig($product, null), true); |
| 87 | 87 | $iframe = Pagantis::getExtraConfig('FORM_DISPLAY_TYPE', $product); |
| 88 | 88 | |
| 89 | - $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_public_key'); |
|
| 90 | - $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']) . '_private_key'); |
|
| 89 | + $pagantisPublicKey = Configuration::get(Tools::strtolower($configs['CODE']).'_public_key'); |
|
| 90 | + $pagantisPrivateKey = Configuration::get(Tools::strtolower($configs['CODE']).'_private_key'); |
|
| 91 | 91 | |
| 92 | 92 | $okUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ |
| 93 | - .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=redirect&product=' . Tools::strtolower($configs['CODE']) . '&' |
|
| 93 | + .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=redirect&product='.Tools::strtolower($configs['CODE']).'&' |
|
| 94 | 94 | .http_build_query($query) |
| 95 | 95 | ; |
| 96 | 96 | $notificationOkUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ |
| 97 | - .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=notification&product=' . Tools::strtolower($configs['CODE']) . '&' |
|
| 97 | + .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=notification&product='.Tools::strtolower($configs['CODE']).'&' |
|
| 98 | 98 | .http_build_query($query) |
| 99 | 99 | ; |
| 100 | 100 | |
@@ -109,27 +109,27 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | try { |
| 111 | 111 | $shippingCountry = Country::getIsoById($shippingAddress->id_country); |
| 112 | - $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 112 | + $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 113 | 113 | $userAddress |
| 114 | 114 | ->setZipCode($shippingAddress->postcode) |
| 115 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) |
|
| 115 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) |
|
| 116 | 116 | ->setCountryCode($shippingCountry) |
| 117 | 117 | ->setCity($shippingAddress->city) |
| 118 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) |
|
| 118 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) |
|
| 119 | 119 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) |
| 120 | 120 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 121 | 121 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 122 | 122 | ; |
| 123 | 123 | |
| 124 | - $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 124 | + $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 125 | 125 | $shippingPhone = (empty($shippingAddress->phone_mobile)) ? |
| 126 | 126 | $shippingAddress->phone : $shippingAddress->phone_mobile; |
| 127 | 127 | $orderShippingAddress |
| 128 | 128 | ->setZipCode($shippingAddress->postcode) |
| 129 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) |
|
| 129 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) |
|
| 130 | 130 | ->setCountryCode($shippingCountry) |
| 131 | 131 | ->setCity($shippingAddress->city) |
| 132 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) |
|
| 132 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) |
|
| 133 | 133 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) |
| 134 | 134 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 135 | 135 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $billingAddress->phone : $billingAddress->phone_mobile; |
| 144 | 144 | $orderBillingAddress |
| 145 | 145 | ->setZipCode($billingAddress->postcode) |
| 146 | - ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname) |
|
| 146 | + ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname) |
|
| 147 | 147 | ->setCountryCode($billingCountry) |
| 148 | 148 | ->setCity($billingAddress->city) |
| 149 | - ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2) |
|
| 149 | + ->setAddress($billingAddress->address1.' '.$billingAddress->address2) |
|
| 150 | 150 | ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress)) |
| 151 | 151 | ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress)) |
| 152 | 152 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | ->setDni($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 170 | 170 | ; |
| 171 | 171 | |
| 172 | - if ($customer->birthday!='0000-00-00') { |
|
| 172 | + if ($customer->birthday != '0000-00-00') { |
|
| 173 | 173 | $orderUser->setDateOfBirth($customer->birthday); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | ->setQuantity($item['quantity']) |
| 204 | 204 | ->setDescription($item['name']); |
| 205 | 205 | if ($promotedProduct) { |
| 206 | - $promotedAmount+=$product->getAmount(); |
|
| 206 | + $promotedAmount += $product->getAmount(); |
|
| 207 | 207 | $productId = $item['id_product']; |
| 208 | 208 | $finalPrice = Product::getPriceStatic($productId); |
| 209 | - $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
|
| 210 | - ' Price: ' . $finalPrice . |
|
| 211 | - ' Qty: ' . $product->getQuantity() . |
|
| 212 | - ' Item ID: ' . $item['id_product']; |
|
| 209 | + $promotedMessage = 'Promoted Item: '.$product->getDescription(). |
|
| 210 | + ' Price: '.$finalPrice. |
|
| 211 | + ' Qty: '.$product->getQuantity(). |
|
| 212 | + ' Item ID: '.$item['id_product']; |
|
| 213 | 213 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 214 | 214 | } |
| 215 | 215 | $details->addProduct($product); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | Tools::redirect($cancelUrl); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $url =''; |
|
| 263 | + $url = ''; |
|
| 264 | 264 | try { |
| 265 | 265 | $orderClient = new \Pagantis\OrdersApiClient\Client( |
| 266 | 266 | trim($pagantisPublicKey), |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | $url = $order->getActionUrls()->getForm(); |
| 273 | 273 | /** @var string $orderId MD5 value */ |
| 274 | 274 | $orderId = $order->getId(); |
| 275 | - $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`) |
|
| 275 | + $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`) |
|
| 276 | 276 | VALUES ('$cart->id','$orderId') |
| 277 | 277 | ON DUPLICATE KEY UPDATE `order_id` = '$orderId'"; |
| 278 | 278 | $result = Db::getInstance()->execute($sql); |
| 279 | 279 | if (!$result) { |
| 280 | - throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql); |
|
| 280 | + throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql); |
|
| 281 | 281 | } |
| 282 | 282 | } else { |
| 283 | 283 | throw new OrderNotFoundException(); |
@@ -409,13 +409,13 @@ discard block |
||
| 409 | 409 | */ |
| 410 | 410 | private function getUserLanguage($shippingAddress = null, $billingAddress = null) |
| 411 | 411 | { |
| 412 | - $allowedCountries = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); |
|
| 412 | + $allowedCountries = unserialize(Pagantis::getExtraConfig('ALLOWED_COUNTRIES', null)); |
|
| 413 | 413 | $lang = Language::getLanguage($this->context->language->id); |
| 414 | 414 | $langArray = explode("-", $lang['language_code']); |
| 415 | 415 | if (count($langArray) != 2 && isset($lang['locale'])) { |
| 416 | 416 | $langArray = explode("-", $lang['locale']); |
| 417 | 417 | } |
| 418 | - $language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
| 418 | + $language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
| 419 | 419 | // Prevent null language detection |
| 420 | 420 | if (in_array(Tools::strtolower($language), $allowedCountries)) { |
| 421 | 421 | return $language; |
@@ -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; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } catch (\Exception $exception) { |
| 139 | 139 | $thrownException = true; |
| 140 | 140 | $this->getMerchantOrderId(); |
| 141 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
| 141 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
| 142 | 142 | if ($this->isPost()) { |
| 143 | 143 | $this->jsonResponse = new JsonExceptionResponse(); |
| 144 | 144 | $this->jsonResponse->setMerchantOrderId($theId); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | if (!$thrownException) { |
| 154 | 154 | $this->jsonResponse = new JsonSuccessResponse(); |
| 155 | 155 | $this->getMerchantOrderId(); |
| 156 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
| 156 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
| 157 | 157 | $this->jsonResponse->setMerchantOrderId($theId); |
| 158 | 158 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 159 | 159 | $this->confirmPagantisOrder(); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->rollbackMerchantOrder(); |
| 163 | 163 | if ($this->isNotification()) { |
| 164 | 164 | $this->getMerchantOrderId(); |
| 165 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
| 165 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
| 166 | 166 | $this->jsonResponse = new JsonExceptionResponse(); |
| 167 | 167 | $this->jsonResponse->setMerchantOrderId($theId); |
| 168 | 168 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } catch (\Exception $exception) { |
| 180 | 180 | $thrownException = true; |
| 181 | 181 | $this->getMerchantOrderId(); |
| 182 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
| 182 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
| 183 | 183 | if ($this->isPost()) { |
| 184 | 184 | $this->jsonResponse = new JsonExceptionResponse(); |
| 185 | 185 | $this->jsonResponse->setMerchantOrderId($theId); |
@@ -247,13 +247,13 @@ discard block |
||
| 247 | 247 | $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); |
| 248 | 248 | if (!in_array(Tools::strtoupper($productCode), $products)) { |
| 249 | 249 | throw new UnknownException( |
| 250 | - 'No valid Pagantis product provided in the url: ' . Tools::getValue('product') |
|
| 250 | + 'No valid Pagantis product provided in the url: '.Tools::getValue('product') |
|
| 251 | 251 | ); |
| 252 | 252 | } |
| 253 | - $this->productName = "Pagantis " . Tools::strtolower($productCode); |
|
| 253 | + $this->productName = "Pagantis ".Tools::strtolower($productCode); |
|
| 254 | 254 | |
| 255 | - $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_public_key')); |
|
| 256 | - $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_private_key')); |
|
| 255 | + $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_public_key')); |
|
| 256 | + $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_private_key')); |
|
| 257 | 257 | |
| 258 | 258 | $this->merchantCartId = Tools::getValue('id_cart'); |
| 259 | 259 | |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | public function getMerchantOrderId() |
| 274 | 274 | { |
| 275 | 275 | try { |
| 276 | - $table = _DB_PREFIX_ .self::ORDERS_TABLE; |
|
| 277 | - $sql = 'select ps_order_id from ' . $table .' where id = ' .(int)$this->merchantCartId; |
|
| 276 | + $table = _DB_PREFIX_.self::ORDERS_TABLE; |
|
| 277 | + $sql = 'select ps_order_id from '.$table.' where id = '.(int) $this->merchantCartId; |
|
| 278 | 278 | $this->merchantOrderId = Db::getInstance()->getValue($sql); |
| 279 | 279 | } catch (\Exception $exception) { |
| 280 | 280 | $exceptionMessage = sprintf( |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | private function getPagantisOrderId() |
| 319 | 319 | { |
| 320 | 320 | try { |
| 321 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
| 322 | - 'select order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = '.(int)$this->merchantCartId |
|
| 321 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
| 322 | + 'select order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = '.(int) $this->merchantCartId |
|
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | 325 | if (is_null($this->pagantisOrderId)) { |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | { |
| 354 | 354 | if ($this->pagantisOrder->getStatus() === PagantisModelOrder::STATUS_CONFIRMED) { |
| 355 | 355 | $this->getMerchantOrderId(); |
| 356 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
| 356 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
| 357 | 357 | $this->jsonResponse = new JsonSuccessResponse(); |
| 358 | 358 | $this->jsonResponse->setMerchantOrderId($theId); |
| 359 | 359 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $psTotalAmount = substr_replace( |
| 386 | 386 | $merchantAmount, |
| 387 | 387 | '.', |
| 388 | - (Tools::strlen($merchantAmount) -2), |
|
| 388 | + (Tools::strlen($merchantAmount) - 2), |
|
| 389 | 389 | 0 |
| 390 | 390 | ); |
| 391 | 391 | |
@@ -393,14 +393,14 @@ discard block |
||
| 393 | 393 | $pgTotalAmount = substr_replace( |
| 394 | 394 | $pgTotalAmountInCents, |
| 395 | 395 | '.', |
| 396 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
| 396 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
| 397 | 397 | 0 |
| 398 | 398 | ); |
| 399 | 399 | |
| 400 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'. $this->merchantCartId . |
|
| 401 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
| 402 | - '. The Cart in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
| 403 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
| 400 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'.$this->merchantCartId. |
|
| 401 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
| 402 | + '. The Cart in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
| 403 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
| 404 | 404 | |
| 405 | 405 | $this->saveLog(array( |
| 406 | 406 | 'requestId' => $this->requestId, |
@@ -440,11 +440,11 @@ discard block |
||
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Double check |
| 443 | - $tableName = _DB_PREFIX_ . self::ORDERS_TABLE; |
|
| 443 | + $tableName = _DB_PREFIX_.self::ORDERS_TABLE; |
|
| 444 | 444 | $fieldName = 'ps_order_id'; |
| 445 | - $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . (int)$this->merchantCartId |
|
| 446 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
| 447 | - . ' and `' . $fieldName . '` is not null'); |
|
| 445 | + $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.(int) $this->merchantCartId |
|
| 446 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
| 447 | + . ' and `'.$fieldName.'` is not null'); |
|
| 448 | 448 | $results = Db::getInstance()->ExecuteS($sql); |
| 449 | 449 | if (is_array($results) && count($results) === 1) { |
| 450 | 450 | $this->getMerchantOrderId(); |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | Configuration::get('PS_OS_PAYMENT'), |
| 485 | 485 | $this->merchantCart->getOrderTotal(true), |
| 486 | 486 | $this->productName, |
| 487 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
| 488 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
| 489 | - $this->amountMismatchError . |
|
| 487 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
| 488 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
| 489 | + $this->amountMismatchError. |
|
| 490 | 490 | $metadataInfo, |
| 491 | 491 | array('transaction_id' => $this->pagantisOrderId), |
| 492 | 492 | null, |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | Db::getInstance()->update( |
| 501 | 501 | self::ORDERS_TABLE, |
| 502 | 502 | array('ps_order_id' => $this->module->currentOrder), |
| 503 | - 'id = '. (int)$this->merchantCartId . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
| 503 | + 'id = '.(int) $this->merchantCartId.' and order_id = \''.$this->pagantisOrderId.'\'' |
|
| 504 | 504 | ); |
| 505 | 505 | |
| 506 | 506 | } catch (\Exception $exception) { |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 528 | 528 | try { |
| 529 | 529 | $mode = ($this->isPost()) ? 'NOTIFICATION' : 'REDIRECTION'; |
| 530 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
| 531 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 532 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
| 530 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
| 531 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 532 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
| 533 | 533 | $this->saveLog(array('requestId' => $this->requestId, 'message' => $message)); |
| 534 | 534 | } catch (\Exception $exception) { |
| 535 | 535 | $exceptionMessage = sprintf( |
@@ -556,16 +556,16 @@ discard block |
||
| 556 | 556 | { |
| 557 | 557 | try { |
| 558 | 558 | $this->getMerchantOrderId(); |
| 559 | - $message = 'Roolback method: ' . |
|
| 560 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 561 | - '. Prestashop CartId=' . $this->merchantCartId . |
|
| 562 | - '. Prestashop OrderId=' . $this->merchantOrderId; |
|
| 559 | + $message = 'Roolback method: '. |
|
| 560 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 561 | + '. Prestashop CartId='.$this->merchantCartId. |
|
| 562 | + '. Prestashop OrderId='.$this->merchantOrderId; |
|
| 563 | 563 | if ($this->module->currentOrder) { |
| 564 | 564 | $objOrder = new Order($this->module->currentOrder); |
| 565 | 565 | $history = new OrderHistory(); |
| 566 | - $history->id_order = (int)$objOrder->id; |
|
| 567 | - $history->changeIdOrderState(8, (int)($objOrder->id)); |
|
| 568 | - $message .= ' Prestashop OrderId=' . $this->merchantCartId; |
|
| 566 | + $history->id_order = (int) $objOrder->id; |
|
| 567 | + $history->changeIdOrderState(8, (int) ($objOrder->id)); |
|
| 568 | + $message .= ' Prestashop OrderId='.$this->merchantCartId; |
|
| 569 | 569 | } |
| 570 | 570 | $this->saveLog(array( |
| 571 | 571 | 'requestId' => $this->requestId, |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | { |
| 591 | 591 | try { |
| 592 | 592 | $table = self::CART_TABLE; |
| 593 | - $insertBlock = Db::getInstance()->insert($table, array('id' =>(int)$orderId, 'timestamp' =>(time()))); |
|
| 593 | + $insertBlock = Db::getInstance()->insert($table, array('id' =>(int) $orderId, 'timestamp' =>(time()))); |
|
| 594 | 594 | if ($insertBlock === false) { |
| 595 | 595 | if ($this->isNotification()) { |
| 596 | 596 | throw new ConcurrencyException(); |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | as rest FROM %s WHERE %s", |
| 601 | 601 | self::CONCURRENCY_TIMEOUT, |
| 602 | 602 | _DB_PREFIX_.$table, |
| 603 | - 'id='.(int)$orderId |
|
| 603 | + 'id='.(int) $orderId |
|
| 604 | 604 | ); |
| 605 | 605 | $resultSeconds = Db::getInstance()->getValue($query); |
| 606 | 606 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
| 607 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? |
|
| 607 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? |
|
| 608 | 608 | self::CONCURRENCY_TIMEOUT : $restSeconds; |
| 609 | 609 | if ($secondsToExpire > 0) { |
| 610 | 610 | sleep($secondsToExpire + 1); |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | $this->getMerchantOrderId(); |
| 614 | 614 | $this->getPagantisOrderId(); |
| 615 | 615 | |
| 616 | - $logMessage = sprintf( |
|
| 616 | + $logMessage = sprintf( |
|
| 617 | 617 | "User has waited %s seconds, default %s, bd time to expire %s [cartId=%s][origin=%s]", |
| 618 | 618 | $secondsToExpire, |
| 619 | 619 | self::CONCURRENCY_TIMEOUT, |
@@ -642,10 +642,10 @@ discard block |
||
| 642 | 642 | { |
| 643 | 643 | try { |
| 644 | 644 | if (is_null($orderId)) { |
| 645 | - Db::getInstance()->delete(self::CART_TABLE, 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT)); |
|
| 645 | + Db::getInstance()->delete(self::CART_TABLE, 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT)); |
|
| 646 | 646 | return; |
| 647 | 647 | } |
| 648 | - Db::getInstance()->delete(self::CART_TABLE, 'id = ' . (int)$orderId); |
|
| 648 | + Db::getInstance()->delete(self::CART_TABLE, 'id = '.(int) $orderId); |
|
| 649 | 649 | } catch (\Exception $exception) { |
| 650 | 650 | throw new ConcurrencyException(); |
| 651 | 651 | } |
@@ -670,8 +670,8 @@ discard block |
||
| 670 | 670 | 'merchantCartId' => $this->merchantCartId, |
| 671 | 671 | 'merchantOrderId' => $this->merchantOrderId, |
| 672 | 672 | 'pagantisOrderId' => $this->pagantisOrderId, |
| 673 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
| 674 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 673 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
| 674 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 675 | 675 | 'method' => $method, |
| 676 | 676 | 'file' => __FILE__, |
| 677 | 677 | 'line' => $line, |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | 'id_module' => $this->module->id, |
| 708 | 708 | 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
| 709 | 709 | ); |
| 710 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 710 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 711 | 711 | $returnMessage = sprintf( |
| 712 | 712 | "[origin=%s][cartId=%s][prestashopOrderId=%s][pagantisOrderId=%s][returnUrl=%s]", |
| 713 | 713 | $this->getOrigin(), |