@@ -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; |
@@ -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(); |
@@ -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, |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | $url = $order->getActionUrls()->getForm(); |
262 | 262 | /** @var string $orderId MD5 value */ |
263 | 263 | $orderId = $order->getId(); |
264 | - $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`) |
|
264 | + $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`) |
|
265 | 265 | VALUES ('$cart->id','$orderId') |
266 | 266 | ON DUPLICATE KEY UPDATE `order_id` = '$orderId'"; |
267 | 267 | $result = Db::getInstance()->execute($sql); |
268 | 268 | if (!$result) { |
269 | - throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql); |
|
269 | + throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql); |
|
270 | 270 | } |
271 | 271 | } else { |
272 | 272 | throw new OrderNotFoundException(); |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | */ |
395 | 395 | private function getUserLanguage($shippingAddress = null, $billingAddress = null) |
396 | 396 | { |
397 | - $allowedCountries = unserialize(Pagantis::getExtraConfig('PAGANTIS_ALLOWED_COUNTRIES')); |
|
397 | + $allowedCountries = unserialize(Pagantis::getExtraConfig('PAGANTIS_ALLOWED_COUNTRIES')); |
|
398 | 398 | $lang = Language::getLanguage($this->context->language->id); |
399 | 399 | $langArray = explode("-", $lang['language_code']); |
400 | 400 | if (count($langArray) != 2 && isset($lang['locale'])) { |
401 | 401 | $langArray = explode("-", $lang['locale']); |
402 | 402 | } |
403 | - $language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
403 | + $language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
404 | 404 | // Prevent null language detection |
405 | 405 | if (in_array(Tools::strtolower($language), $allowedCountries)) { |
406 | 406 | return $language; |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | private function getPagantisOrderId() |
217 | 217 | { |
218 | 218 | try { |
219 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
220 | - 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.(int)$this->merchantOrderId |
|
219 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
220 | + 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.(int) $this->merchantOrderId |
|
221 | 221 | ); |
222 | 222 | |
223 | 223 | if (is_null($this->pagantisOrderId)) { |
@@ -278,20 +278,20 @@ discard block |
||
278 | 278 | $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0]; |
279 | 279 | if ($totalAmount != $merchantAmount) { |
280 | 280 | try { |
281 | - $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0); |
|
281 | + $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0); |
|
282 | 282 | |
283 | 283 | $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
284 | 284 | $pgTotalAmount = substr_replace( |
285 | 285 | $pgTotalAmountInCents, |
286 | 286 | '.', |
287 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
287 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
288 | 288 | 0 |
289 | 289 | ); |
290 | 290 | |
291 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId . |
|
292 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
293 | - '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
294 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
291 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId. |
|
292 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
293 | + '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
294 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
295 | 295 | $this->saveLog(array( |
296 | 296 | 'message' => $this->amountMismatchError |
297 | 297 | )); |
@@ -311,21 +311,21 @@ discard block |
||
311 | 311 | try { |
312 | 312 | if ($this->merchantOrder->orderExists() !== false) { |
313 | 313 | throw new WrongStatusException('PS->orderExists() cart_id = ' |
314 | - . $this->merchantOrderId . ' pagantis_id = ' |
|
315 | - . $this->pagantisOrderId . '): already_processed'); |
|
314 | + . $this->merchantOrderId.' pagantis_id = ' |
|
315 | + . $this->pagantisOrderId.'): already_processed'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | // Double check |
319 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
319 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
320 | 320 | $fieldName = 'ps_order_id'; |
321 | - $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . (int)$this->merchantOrderId |
|
322 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
323 | - . ' and `' . $fieldName . '` is not null'); |
|
321 | + $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.(int) $this->merchantOrderId |
|
322 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
323 | + . ' and `'.$fieldName.'` is not null'); |
|
324 | 324 | $results = Db::getInstance()->ExecuteS($sql); |
325 | 325 | if (is_array($results) && count($results) === 1) { |
326 | - throw new WrongStatusException('PS->record found in ' . $tableName |
|
327 | - . ' (cart_id = ' . $this->merchantOrderId . ' pagantis_id = ' |
|
328 | - . $this->pagantisOrderId . '): already_processed'); |
|
326 | + throw new WrongStatusException('PS->record found in '.$tableName |
|
327 | + . ' (cart_id = '.$this->merchantOrderId.' pagantis_id = ' |
|
328 | + . $this->pagantisOrderId.'): already_processed'); |
|
329 | 329 | } |
330 | 330 | } catch (\Exception $exception) { |
331 | 331 | throw new UnknownException($exception->getMessage()); |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | Configuration::get('PS_OS_PAYMENT'), |
355 | 355 | $this->merchantOrder->getOrderTotal(true), |
356 | 356 | $this->module->displayName, |
357 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
358 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
359 | - $this->amountMismatchError . |
|
357 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
358 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
359 | + $this->amountMismatchError. |
|
360 | 360 | $metadataInfo, |
361 | 361 | array('transaction_id' => $this->pagantisOrderId), |
362 | 362 | null, |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | Db::getInstance()->update( |
371 | 371 | 'pagantis_order', |
372 | 372 | array('ps_order_id' => $this->module->currentOrder), |
373 | - 'id = '. (int)$this->merchantOrderId . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
373 | + 'id = '.(int) $this->merchantOrderId.' and order_id = \''.$this->pagantisOrderId.'\'' |
|
374 | 374 | ); |
375 | 375 | } catch (\Exception $exception) { |
376 | 376 | // Do nothing |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
389 | 389 | try { |
390 | 390 | $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION'; |
391 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
392 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
393 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
391 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
392 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
393 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
394 | 394 | $this->saveLog(array('message' => $message)); |
395 | 395 | } catch (\Exception $exception) { |
396 | 396 | // Do nothing |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | public function rollbackMerchantOrder() |
409 | 409 | { |
410 | 410 | try { |
411 | - $message = 'Roolback method: ' . |
|
412 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
413 | - '. Prestashop CartId=' . $this->merchantOrderId; |
|
411 | + $message = 'Roolback method: '. |
|
412 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
413 | + '. Prestashop CartId='.$this->merchantOrderId; |
|
414 | 414 | if ($this->module->currentOrder) { |
415 | 415 | $objOrder = new Order($this->module->currentOrder); |
416 | 416 | $history = new OrderHistory(); |
417 | - $history->id_order = (int)$objOrder->id; |
|
418 | - $history->changeIdOrderState(8, (int)($objOrder->id)); |
|
419 | - $message .= ' Prestashop OrderId=' . $this->merchantOrderId; |
|
417 | + $history->id_order = (int) $objOrder->id; |
|
418 | + $history->changeIdOrderState(8, (int) ($objOrder->id)); |
|
419 | + $message .= ' Prestashop OrderId='.$this->merchantOrderId; |
|
420 | 420 | } |
421 | 421 | $this->saveLog(array('message' => $message)); |
422 | 422 | } catch (\Exception $exception) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | { |
436 | 436 | try { |
437 | 437 | $table = 'pagantis_cart_process'; |
438 | - if (Db::getInstance()->insert($table, array('id' => (int)$orderId, 'timestamp' => (time()))) === false) { |
|
438 | + if (Db::getInstance()->insert($table, array('id' => (int) $orderId, 'timestamp' => (time()))) === false) { |
|
439 | 439 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
440 | 440 | throw new ConcurrencyException(); |
441 | 441 | } |
@@ -445,14 +445,14 @@ discard block |
||
445 | 445 | FROM %s WHERE %s", |
446 | 446 | self::CONCURRENCY_TIMEOUT, |
447 | 447 | _DB_PREFIX_.$table, |
448 | - 'id='.(int)$orderId |
|
448 | + 'id='.(int) $orderId |
|
449 | 449 | ); |
450 | 450 | $resultSeconds = Db::getInstance()->getValue($query); |
451 | 451 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
452 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
452 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
453 | 453 | |
454 | 454 | $logMessage = sprintf( |
455 | - "Redirect concurrency, User have to wait %s seconds, default seconds %s. CartId=" . $orderId, |
|
455 | + "Redirect concurrency, User have to wait %s seconds, default seconds %s. CartId=".$orderId, |
|
456 | 456 | $secondsToExpire, |
457 | 457 | self::CONCURRENCY_TIMEOUT, |
458 | 458 | $restSeconds |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $this->saveLog(array( |
462 | 462 | 'message' => $logMessage |
463 | 463 | )); |
464 | - sleep($secondsToExpire+1); |
|
464 | + sleep($secondsToExpire + 1); |
|
465 | 465 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
466 | 466 | return true; |
467 | 467 | } |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | if (is_null($orderId)) { |
482 | 482 | Db::getInstance()->delete( |
483 | 483 | 'pagantis_cart_process', |
484 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT) |
|
484 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT) |
|
485 | 485 | ); |
486 | 486 | return; |
487 | 487 | } |
488 | - Db::getInstance()->delete('pagantis_cart_process', 'id = ' . (int)$orderId); |
|
488 | + Db::getInstance()->delete('pagantis_cart_process', 'id = '.(int) $orderId); |
|
489 | 489 | } catch (\Exception $exception) { |
490 | 490 | throw new ConcurrencyException(); |
491 | 491 | } |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | $data = array( |
508 | 508 | 'merchantOrderId' => $this->merchantOrderId, |
509 | 509 | 'pagantisOrderId' => $this->pagantisOrderId, |
510 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
511 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
510 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
511 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
512 | 512 | 'method' => $method, |
513 | 513 | 'file' => __FILE__, |
514 | 514 | 'line' => $line, |
@@ -533,9 +533,9 @@ discard block |
||
533 | 533 | 'id_cart' => $this->merchantOrderId, |
534 | 534 | 'key' => $this->config['secureKey'], |
535 | 535 | 'id_module' => $this->module->id, |
536 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
536 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
537 | 537 | ); |
538 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
538 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
539 | 539 | return $this->redirect($url, $parameters); |
540 | 540 | } |
541 | 541 | } |