@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | header('HTTP/1.1 200 Ok', true, 200); |
| 68 | 68 | header('Content-Type: application/json', true); |
| 69 | - header('Content-Length: ' . Tools::strlen($result)); |
|
| 69 | + header('Content-Length: '.Tools::strlen($result)); |
|
| 70 | 70 | |
| 71 | 71 | echo $result; |
| 72 | 72 | exit(); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | header('HTTP/1.1 403 Forbidden', true, 403); |
| 92 | 92 | header('Content-Type: application/json', true); |
| 93 | - header('Content-Length: ' . Tools::strlen($result)); |
|
| 93 | + header('Content-Length: '.Tools::strlen($result)); |
|
| 94 | 94 | |
| 95 | 95 | echo $result; |
| 96 | 96 | exit(); |
@@ -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 | |
@@ -18,12 +18,12 @@ 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 | if (method_exists($this, $method)) { |
| 23 | 23 | header('HTTP/1.1 200 Ok', true, 200); |
| 24 | 24 | header('Content-Type: application/json', true); |
| 25 | 25 | $result = json_encode($this->{$method}()); |
| 26 | - header('Content-Length: ' . Tools::strlen($result)); |
|
| 26 | + header('Content-Length: '.Tools::strlen($result)); |
|
| 27 | 27 | echo $result; |
| 28 | 28 | exit(); |
| 29 | 29 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function getExtraConfigs() |
| 40 | 40 | { |
| 41 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; |
|
| 41 | + $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; |
|
| 42 | 42 | $dbConfigs = Db::getInstance()->executeS($sql_content); |
| 43 | 43 | |
| 44 | 44 | $simpleDbConfigs = array(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | Db::getInstance()->update( |
| 68 | 68 | 'pagantis_config', |
| 69 | 69 | array('value' => pSQL($value)), |
| 70 | - 'config = \''. pSQL($config) .'\'' |
|
| 70 | + 'config = \''.pSQL($config).'\'' |
|
| 71 | 71 | ); |
| 72 | 72 | } else { |
| 73 | 73 | $errors[$config] = $value; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function getMethod() |
| 93 | 93 | { |
| 94 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; |
|
| 94 | + $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; |
|
| 95 | 95 | $dbConfigs = Db::getInstance()->executeS($sql_content); |
| 96 | 96 | |
| 97 | 97 | $simpleDbConfigs = array(); |
@@ -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 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | Configuration::updateValue('pagantis_public_key', ''); |
| 134 | 134 | Configuration::updateValue('pagantis_private_key', ''); |
| 135 | 135 | |
| 136 | - $return = (parent::install() |
|
| 136 | + $return = (parent::install() |
|
| 137 | 137 | && $this->registerHook('displayShoppingCart') |
| 138 | 138 | && $this->registerHook('paymentOptions') |
| 139 | 139 | && $this->registerHook('displayRightColumn') |
@@ -215,18 +215,18 @@ 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 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function checkEnvVariables() |
| 242 | 242 | { |
| 243 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; |
|
| 243 | + $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; |
|
| 244 | 244 | $dbConfigs = Db::getInstance()->executeS($sql_content); |
| 245 | 245 | |
| 246 | 246 | // Convert a multimple dimension array for SQL insert statements into a simple key/value |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | } else { |
| 359 | 359 | $this->context->controller->addJS($url); |
| 360 | 360 | } |
| 361 | - $this->context->controller->addJS($this->getPathUri(). 'views/js/simulator.js'); |
|
| 361 | + $this->context->controller->addJS($this->getPathUri().'views/js/simulator.js'); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | 'input' => array( |
| 457 | 457 | array( |
| 458 | 458 | 'name' => 'pagantis_is_enabled', |
| 459 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
| 459 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
| 460 | 460 | 'label' => $this->l('Module is enabled'), |
| 461 | 461 | 'prefix' => '<i class="icon icon-key"></i>', |
| 462 | 462 | 'class' => 't', |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | ), |
| 497 | 497 | array( |
| 498 | 498 | 'name' => 'pagantis_simulator_is_enabled', |
| 499 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
| 499 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
| 500 | 500 | 'label' => $this->l('Simulator is enabled'), |
| 501 | 501 | 'prefix' => '<i class="icon icon-key"></i>', |
| 502 | 502 | 'class' => 't', |
@@ -850,16 +850,16 @@ discard block |
||
| 850 | 850 | if (!in_array(PROMOTIONS_CATEGORY_NAME, $categories)) { |
| 851 | 851 | /** @var CategoryCore $category */ |
| 852 | 852 | $category = new Category(); |
| 853 | - $categoryArray = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY ); |
|
| 853 | + $categoryArray = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY); |
|
| 854 | 854 | $category->is_root_category = false; |
| 855 | 855 | $category->link_rewrite = $categoryArray; |
| 856 | 856 | $category->meta_description = $categoryArray; |
| 857 | 857 | $category->meta_keywords = $categoryArray; |
| 858 | 858 | $category->meta_title = $categoryArray; |
| 859 | - $category->name = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
| 859 | + $category->name = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
| 860 | 860 | $category->id_parent = Configuration::get('PS_HOME_CATEGORY'); |
| 861 | - $category->active=0; |
|
| 862 | - $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' . |
|
| 861 | + $category->active = 0; |
|
| 862 | + $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '. |
|
| 863 | 863 | 'Use it to promote your products or brands.'; |
| 864 | 864 | $category->description = $this->l($description); |
| 865 | 865 | $category->save(); |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | return ''; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1'; |
|
| 876 | + $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1'; |
|
| 877 | 877 | if ($results = Db::getInstance()->ExecuteS($sql)) { |
| 878 | 878 | if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { |
| 879 | 879 | return $results[0]['value']; |
@@ -888,10 +888,10 @@ discard block |
||
| 888 | 888 | */ |
| 889 | 889 | public function checkLogoExists() |
| 890 | 890 | { |
| 891 | - $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
| 892 | - if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) { |
|
| 891 | + $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
| 892 | + if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) { |
|
| 893 | 893 | copy( |
| 894 | - _PS_PAGANTIS_DIR . '/logo.png', |
|
| 894 | + _PS_PAGANTIS_DIR.'/logo.png', |
|
| 895 | 895 | $logoPg |
| 896 | 896 | ); |
| 897 | 897 | } |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | if (count($langArray) != 2 && isset($lang['locale'])) { |
| 908 | 908 | $langArray = explode("-", $lang['locale']); |
| 909 | 909 | } |
| 910 | - $this->language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
| 910 | + $this->language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
| 911 | 911 | // Prevent null language detection |
| 912 | 912 | if (in_array(Tools::strtolower($this->language), $this->allowedCountries)) { |
| 913 | 913 | return; |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $pagantisPublicKey = Configuration::get('pagantis_public_key'); |
| 87 | 87 | $pagantisPrivateKey = Configuration::get('pagantis_private_key'); |
| 88 | 88 | $okUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ |
| 89 | - .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=redirect&' |
|
| 90 | - .http_build_query($query) |
|
| 89 | + .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=redirect&' |
|
| 90 | + .http_build_query($query) |
|
| 91 | 91 | ; |
| 92 | 92 | $notificationOkUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ |
| 93 | 93 | .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&origin=notification&' |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | $productId = $item['id_product']; |
| 195 | 195 | $finalPrice = Product::getPriceStatic($productId); |
| 196 | 196 | $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
| 197 | - ' Price: ' . $finalPrice . |
|
| 198 | - ' Qty: ' . $product->getQuantity() . |
|
| 199 | - ' Item ID: ' . $item['id_product']; |
|
| 197 | + ' Price: ' . $finalPrice . |
|
| 198 | + ' Qty: ' . $product->getQuantity() . |
|
| 199 | + ' Item ID: ' . $item['id_product']; |
|
| 200 | 200 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 201 | 201 | } |
| 202 | 202 | $details->addProduct($product); |
@@ -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(), |
@@ -107,24 +107,24 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | try { |
| 109 | 109 | $shippingCountry = Country::getIsoById($shippingAddress->id_country); |
| 110 | - $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 110 | + $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 111 | 111 | $userAddress |
| 112 | 112 | ->setZipCode($shippingAddress->postcode) |
| 113 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) |
|
| 113 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) |
|
| 114 | 114 | ->setCountryCode($shippingCountry) |
| 115 | 115 | ->setCity($shippingAddress->city) |
| 116 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) |
|
| 116 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) |
|
| 117 | 117 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) |
| 118 | 118 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 119 | 119 | ; |
| 120 | 120 | |
| 121 | - $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 121 | + $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
| 122 | 122 | $orderShippingAddress |
| 123 | 123 | ->setZipCode($shippingAddress->postcode) |
| 124 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) |
|
| 124 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) |
|
| 125 | 125 | ->setCountryCode($shippingCountry) |
| 126 | 126 | ->setCity($shippingAddress->city) |
| 127 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) |
|
| 127 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) |
|
| 128 | 128 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) |
| 129 | 129 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 130 | 130 | ->setFixPhone($shippingAddress->phone) |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | $orderBillingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
| 136 | 136 | $orderBillingAddress |
| 137 | 137 | ->setZipCode($billingAddress->postcode) |
| 138 | - ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname) |
|
| 138 | + ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname) |
|
| 139 | 139 | ->setCountryCode($billingCountry) |
| 140 | 140 | ->setCity($billingAddress->city) |
| 141 | - ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2) |
|
| 141 | + ->setAddress($billingAddress->address1.' '.$billingAddress->address2) |
|
| 142 | 142 | ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress)) |
| 143 | 143 | ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress)) |
| 144 | 144 | ->setFixPhone($billingAddress->phone) |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
| 159 | 159 | ; |
| 160 | 160 | |
| 161 | - if ($customer->birthday!='0000-00-00') { |
|
| 161 | + if ($customer->birthday != '0000-00-00') { |
|
| 162 | 162 | $orderUser->setDateOfBirth($customer->birthday); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | ->setQuantity($item['quantity']) |
| 193 | 193 | ->setDescription($item['name']); |
| 194 | 194 | if ($promotedProduct) { |
| 195 | - $promotedAmount+=$product->getAmount(); |
|
| 195 | + $promotedAmount += $product->getAmount(); |
|
| 196 | 196 | $productId = $item['id_product']; |
| 197 | 197 | $finalPrice = Product::getPriceStatic($productId); |
| 198 | - $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
|
| 199 | - ' Price: ' . $finalPrice . |
|
| 200 | - ' Qty: ' . $product->getQuantity() . |
|
| 201 | - ' Item ID: ' . $item['id_product']; |
|
| 198 | + $promotedMessage = 'Promoted Item: '.$product->getDescription(). |
|
| 199 | + ' Price: '.$finalPrice. |
|
| 200 | + ' Qty: '.$product->getQuantity(). |
|
| 201 | + ' Item ID: '.$item['id_product']; |
|
| 202 | 202 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 203 | 203 | } |
| 204 | 204 | $details->addProduct($product); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | Tools::redirect($cancelUrl); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $url =''; |
|
| 252 | + $url = ''; |
|
| 253 | 253 | try { |
| 254 | 254 | $orderClient = new \Pagantis\OrdersApiClient\Client( |
| 255 | 255 | $pagantisPublicKey, |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | * @var string $orderId Pagantis Order id |
| 264 | 264 | */ |
| 265 | 265 | $orderId = $order->getId(); |
| 266 | - $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`) |
|
| 266 | + $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`) |
|
| 267 | 267 | VALUES ('$cart->id','$orderId') |
| 268 | 268 | ON DUPLICATE KEY UPDATE `order_id` = '$orderId'"; |
| 269 | 269 | $result = Db::getInstance()->execute($sql); |
| 270 | 270 | if (!$result) { |
| 271 | - throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql); |
|
| 271 | + throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql); |
|
| 272 | 272 | } |
| 273 | 273 | } else { |
| 274 | 274 | throw new OrderNotFoundException(); |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | private function getUserLanguage($shippingAddress = null, $billingAddress = null) |
| 393 | 393 | { |
| 394 | - $allowedCountries = unserialize(Pagantis::getExtraConfig('PAGANTIS_ALLOWED_COUNTRIES')); |
|
| 394 | + $allowedCountries = unserialize(Pagantis::getExtraConfig('PAGANTIS_ALLOWED_COUNTRIES')); |
|
| 395 | 395 | $lang = Language::getLanguage($this->context->language->id); |
| 396 | 396 | $langArray = explode("-", $lang['language_code']); |
| 397 | 397 | if (count($langArray) != 2 && isset($lang['locale'])) { |
| 398 | 398 | $langArray = explode("-", $lang['locale']); |
| 399 | 399 | } |
| 400 | - $language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
| 400 | + $language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
| 401 | 401 | // Prevent null language detection |
| 402 | 402 | if (in_array(Tools::strtolower($language), $allowedCountries)) { |
| 403 | 403 | return $language; |
@@ -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']); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | header('HTTP/1.1 200 Ok', true, 200); |
| 64 | 64 | header('Content-Type: application/json', true); |
| 65 | - header('Content-Length: ' . Tools::strlen($result)); |
|
| 65 | + header('Content-Length: '.Tools::strlen($result)); |
|
| 66 | 66 | |
| 67 | 67 | echo $result; |
| 68 | 68 | exit(); |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | private function getPagantisOrderId() |
| 214 | 214 | { |
| 215 | 215 | try { |
| 216 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
| 217 | - 'select order_id from '._DB_PREFIX_.'pagantis_order where id = ' . intval($this->merchantOrderId) |
|
| 216 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
| 217 | + 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.intval($this->merchantOrderId) |
|
| 218 | 218 | ); |
| 219 | 219 | |
| 220 | 220 | if (is_null($this->pagantisOrderId)) { |
@@ -275,20 +275,20 @@ discard block |
||
| 275 | 275 | $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0]; |
| 276 | 276 | if ($totalAmount != $merchantAmount) { |
| 277 | 277 | try { |
| 278 | - $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0); |
|
| 278 | + $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0); |
|
| 279 | 279 | |
| 280 | 280 | $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 281 | 281 | $pgTotalAmount = substr_replace( |
| 282 | 282 | $pgTotalAmountInCents, |
| 283 | 283 | '.', |
| 284 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
| 284 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
| 285 | 285 | 0 |
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId . |
|
| 289 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
| 290 | - '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
| 291 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
| 288 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId. |
|
| 289 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
| 290 | + '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
| 291 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
| 292 | 292 | $this->saveLog(array( |
| 293 | 293 | 'message' => $this->amountMismatchError |
| 294 | 294 | )); |
@@ -308,21 +308,21 @@ discard block |
||
| 308 | 308 | try { |
| 309 | 309 | if ($this->merchantOrder->orderExists() !== false) { |
| 310 | 310 | throw new WrongStatusException('PS->orderExists() cart_id = ' |
| 311 | - . $this->merchantOrderId . ' pagantis_id = ' |
|
| 312 | - . $this->pagantisOrderId . '): already_processed'); |
|
| 311 | + . $this->merchantOrderId.' pagantis_id = ' |
|
| 312 | + . $this->pagantisOrderId.'): already_processed'); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Double check |
| 316 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
| 316 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
| 317 | 317 | $fieldName = 'ps_order_id'; |
| 318 | - $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . intval($this->merchantOrderId) |
|
| 319 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
| 320 | - . ' and `' . $fieldName . '` is not null'); |
|
| 318 | + $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.intval($this->merchantOrderId) |
|
| 319 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
| 320 | + . ' and `'.$fieldName.'` is not null'); |
|
| 321 | 321 | $results = Db::getInstance()->ExecuteS($sql); |
| 322 | 322 | if (is_array($results) && count($results) === 1) { |
| 323 | - throw new WrongStatusException('PS->record found in ' . $tableName |
|
| 324 | - . ' (cart_id = ' . $this->merchantOrderId . ' pagantis_id = ' |
|
| 325 | - . $this->pagantisOrderId . '): already_processed'); |
|
| 323 | + throw new WrongStatusException('PS->record found in '.$tableName |
|
| 324 | + . ' (cart_id = '.$this->merchantOrderId.' pagantis_id = ' |
|
| 325 | + . $this->pagantisOrderId.'): already_processed'); |
|
| 326 | 326 | } |
| 327 | 327 | } catch (\Exception $exception) { |
| 328 | 328 | throw new UnknownException($exception->getMessage()); |
@@ -351,9 +351,9 @@ discard block |
||
| 351 | 351 | Configuration::get('PS_OS_PAYMENT'), |
| 352 | 352 | $this->merchantOrder->getOrderTotal(true), |
| 353 | 353 | $this->module->displayName, |
| 354 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
| 355 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
| 356 | - $this->amountMismatchError . |
|
| 354 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
| 355 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
| 356 | + $this->amountMismatchError. |
|
| 357 | 357 | $metadataInfo, |
| 358 | 358 | array('transaction_id' => $this->pagantisOrderId), |
| 359 | 359 | null, |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | Db::getInstance()->update( |
| 368 | 368 | 'pagantis_order', |
| 369 | 369 | array('ps_order_id' => $this->module->currentOrder), |
| 370 | - 'id = '. intval($this->merchantOrderId) . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
| 370 | + 'id = '.intval($this->merchantOrderId).' and order_id = \''.$this->pagantisOrderId.'\'' |
|
| 371 | 371 | ); |
| 372 | 372 | } catch (\Exception $exception) { |
| 373 | 373 | // Do nothing |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 386 | 386 | try { |
| 387 | 387 | $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION'; |
| 388 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
| 389 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 390 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
| 388 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
| 389 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 390 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
| 391 | 391 | $this->saveLog(array('message' => $message)); |
| 392 | 392 | } catch (\Exception $exception) { |
| 393 | 393 | // Do nothing |
@@ -405,15 +405,15 @@ discard block |
||
| 405 | 405 | public function rollbackMerchantOrder() |
| 406 | 406 | { |
| 407 | 407 | try { |
| 408 | - $message = 'Roolback method: ' . |
|
| 409 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 410 | - '. Prestashop CartId=' . $this->merchantOrderId; |
|
| 408 | + $message = 'Roolback method: '. |
|
| 409 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 410 | + '. Prestashop CartId='.$this->merchantOrderId; |
|
| 411 | 411 | if ($this->module->currentOrder) { |
| 412 | 412 | $objOrder = new Order($this->module->currentOrder); |
| 413 | 413 | $history = new OrderHistory(); |
| 414 | - $history->id_order = (int)$objOrder->id; |
|
| 415 | - $history->changeIdOrderState(8, (int)($objOrder->id)); |
|
| 416 | - $message .= ' Prestashop OrderId=' . $this->merchantOrderId; |
|
| 414 | + $history->id_order = (int) $objOrder->id; |
|
| 415 | + $history->changeIdOrderState(8, (int) ($objOrder->id)); |
|
| 416 | + $message .= ' Prestashop OrderId='.$this->merchantOrderId; |
|
| 417 | 417 | } |
| 418 | 418 | $this->saveLog(array('message' => $message)); |
| 419 | 419 | } catch (\Exception $exception) { |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | FROM %s WHERE %s", |
| 443 | 443 | self::CONCURRENCY_TIMEOUT, |
| 444 | 444 | _DB_PREFIX_.$table, |
| 445 | - "id=" . intval($orderId) |
|
| 445 | + "id=".intval($orderId) |
|
| 446 | 446 | ); |
| 447 | 447 | $resultSeconds = Db::getInstance()->getValue($query); |
| 448 | 448 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
| 449 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 449 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 450 | 450 | |
| 451 | 451 | $logMessage = sprintf( |
| 452 | - "Redirect concurrency, User have to wait %s seconds, default seconds %s. CartId=" . $orderId, |
|
| 452 | + "Redirect concurrency, User have to wait %s seconds, default seconds %s. CartId=".$orderId, |
|
| 453 | 453 | $secondsToExpire, |
| 454 | 454 | self::CONCURRENCY_TIMEOUT, |
| 455 | 455 | $restSeconds |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $this->saveLog(array( |
| 459 | 459 | 'message' => $logMessage |
| 460 | 460 | )); |
| 461 | - sleep($secondsToExpire+1); |
|
| 461 | + sleep($secondsToExpire + 1); |
|
| 462 | 462 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
| 463 | 463 | return true; |
| 464 | 464 | } |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | if (is_null($orderId)) { |
| 479 | 479 | Db::getInstance()->delete( |
| 480 | 480 | 'pagantis_cart_process', |
| 481 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT) |
|
| 481 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT) |
|
| 482 | 482 | ); |
| 483 | 483 | return; |
| 484 | 484 | } |
| 485 | - Db::getInstance()->delete('pagantis_cart_process', 'id = ' . intval($orderId)); |
|
| 485 | + Db::getInstance()->delete('pagantis_cart_process', 'id = '.intval($orderId)); |
|
| 486 | 486 | } catch (\Exception $exception) { |
| 487 | 487 | throw new ConcurrencyException(); |
| 488 | 488 | } |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | $data = array( |
| 505 | 505 | 'merchantOrderId' => $this->merchantOrderId, |
| 506 | 506 | 'pagantisOrderId' => $this->pagantisOrderId, |
| 507 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
| 508 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 507 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
| 508 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 509 | 509 | 'method' => $method, |
| 510 | 510 | 'file' => __FILE__, |
| 511 | 511 | 'line' => $line, |
@@ -530,9 +530,9 @@ discard block |
||
| 530 | 530 | 'id_cart' => $this->merchantOrderId, |
| 531 | 531 | 'key' => $this->config['secureKey'], |
| 532 | 532 | 'id_module' => $this->module->id, |
| 533 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
| 533 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
| 534 | 534 | ); |
| 535 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 535 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 536 | 536 | return $this->redirect($url, $parameters); |
| 537 | 537 | } |
| 538 | 538 | } |