@@ -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; |
@@ -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(), |