@@ -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; |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | private function getPagantisOrderId() |
225 | 225 | { |
226 | 226 | try { |
227 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
228 | - 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.(int)$this->merchantOrderId |
|
227 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
228 | + 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.(int) $this->merchantOrderId |
|
229 | 229 | ); |
230 | 230 | |
231 | 231 | if (is_null($this->pagantisOrderId)) { |
@@ -286,20 +286,20 @@ discard block |
||
286 | 286 | $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0]; |
287 | 287 | if ($totalAmount != $merchantAmount) { |
288 | 288 | try { |
289 | - $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0); |
|
289 | + $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0); |
|
290 | 290 | |
291 | 291 | $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
292 | 292 | $pgTotalAmount = substr_replace( |
293 | 293 | $pgTotalAmountInCents, |
294 | 294 | '.', |
295 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
295 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
296 | 296 | 0 |
297 | 297 | ); |
298 | 298 | |
299 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId . |
|
300 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
301 | - '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
302 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
299 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId. |
|
300 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
301 | + '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
302 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
303 | 303 | $this->saveLog(array( |
304 | 304 | 'message' => $this->amountMismatchError |
305 | 305 | )); |
@@ -319,21 +319,21 @@ discard block |
||
319 | 319 | try { |
320 | 320 | if ($this->merchantOrder->orderExists() !== false) { |
321 | 321 | throw new WrongStatusException('PS->orderExists() cart_id = ' |
322 | - . $this->merchantOrderId . ' pagantis_id = ' |
|
323 | - . $this->pagantisOrderId . '): already_processed'); |
|
322 | + . $this->merchantOrderId.' pagantis_id = ' |
|
323 | + . $this->pagantisOrderId.'): already_processed'); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | // Double check |
327 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
327 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
328 | 328 | $fieldName = 'ps_order_id'; |
329 | - $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . (int)$this->merchantOrderId |
|
330 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
331 | - . ' and `' . $fieldName . '` is not null'); |
|
329 | + $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.(int) $this->merchantOrderId |
|
330 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
331 | + . ' and `'.$fieldName.'` is not null'); |
|
332 | 332 | $results = Db::getInstance()->ExecuteS($sql); |
333 | 333 | if (is_array($results) && count($results) === 1) { |
334 | - throw new WrongStatusException('PS->record found in ' . $tableName |
|
335 | - . ' (cart_id = ' . $this->merchantOrderId . ' pagantis_id = ' |
|
336 | - . $this->pagantisOrderId . '): already_processed'); |
|
334 | + throw new WrongStatusException('PS->record found in '.$tableName |
|
335 | + . ' (cart_id = '.$this->merchantOrderId.' pagantis_id = ' |
|
336 | + . $this->pagantisOrderId.'): already_processed'); |
|
337 | 337 | } |
338 | 338 | } catch (\Exception $exception) { |
339 | 339 | throw new UnknownException($exception->getMessage()); |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | Configuration::get('PS_OS_PAYMENT'), |
363 | 363 | $this->merchantOrder->getOrderTotal(true), |
364 | 364 | $this->module->displayName, |
365 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
366 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
367 | - $this->amountMismatchError . |
|
365 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
366 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
367 | + $this->amountMismatchError. |
|
368 | 368 | $metadataInfo, |
369 | 369 | array('transaction_id' => $this->pagantisOrderId), |
370 | 370 | null, |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | Db::getInstance()->update( |
379 | 379 | 'pagantis_order', |
380 | 380 | array('ps_order_id' => $this->module->currentOrder), |
381 | - 'id = '. (int)$this->merchantOrderId . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
381 | + 'id = '.(int) $this->merchantOrderId.' and order_id = \''.$this->pagantisOrderId.'\'' |
|
382 | 382 | ); |
383 | 383 | } catch (\Exception $exception) { |
384 | 384 | // Do nothing |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
397 | 397 | try { |
398 | 398 | $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION'; |
399 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
400 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
401 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
399 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
400 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
401 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
402 | 402 | $this->saveLog(array('message' => $message)); |
403 | 403 | } catch (\Exception $exception) { |
404 | 404 | // Do nothing |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | public function rollbackMerchantOrder() |
417 | 417 | { |
418 | 418 | try { |
419 | - $message = 'Roolback method: ' . |
|
420 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
421 | - '. Prestashop CartId=' . $this->merchantOrderId; |
|
419 | + $message = 'Roolback method: '. |
|
420 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
421 | + '. Prestashop CartId='.$this->merchantOrderId; |
|
422 | 422 | if ($this->module->currentOrder) { |
423 | 423 | $objOrder = new Order($this->module->currentOrder); |
424 | 424 | $history = new OrderHistory(); |
425 | - $history->id_order = (int)$objOrder->id; |
|
426 | - $history->changeIdOrderState(8, (int)($objOrder->id)); |
|
427 | - $message .= ' Prestashop OrderId=' . $this->merchantOrderId; |
|
425 | + $history->id_order = (int) $objOrder->id; |
|
426 | + $history->changeIdOrderState(8, (int) ($objOrder->id)); |
|
427 | + $message .= ' Prestashop OrderId='.$this->merchantOrderId; |
|
428 | 428 | } |
429 | 429 | $this->saveLog(array('message' => $message)); |
430 | 430 | } catch (\Exception $exception) { |
@@ -440,17 +440,17 @@ discard block |
||
440 | 440 | { |
441 | 441 | if ($_SERVER['REQUEST_METHOD'] == 'GET') { |
442 | 442 | $this->getPagantisOrderId(); |
443 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
443 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
444 | 444 | $tries = Db::getInstance()->getValue( |
445 | - 'SELECT tries FROM ' . $tableName . ' WHERE id = ' . |
|
446 | - (int)$this->merchantOrderId . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
445 | + 'SELECT tries FROM '.$tableName.' WHERE id = '. |
|
446 | + (int) $this->merchantOrderId.' and order_id = \''.$this->pagantisOrderId.'\'' |
|
447 | 447 | ); |
448 | 448 | if ($tries < self::MAX_TRIES) { |
449 | 449 | try { |
450 | 450 | Db::getInstance()->update( |
451 | 451 | 'pagantis_order', |
452 | 452 | array('tries' => $tries + 1), |
453 | - 'id = ' . (int)$this->merchantOrderId . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
453 | + 'id = '.(int) $this->merchantOrderId.' and order_id = \''.$this->pagantisOrderId.'\'' |
|
454 | 454 | ); |
455 | 455 | } catch (\Exception $exception) { |
456 | 456 | // Do nothing |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | { |
474 | 474 | try { |
475 | 475 | $table = 'pagantis_cart_process'; |
476 | - if (Db::getInstance()->insert($table, array('id' => (int)$orderId, 'timestamp' => (time()))) === false) { |
|
476 | + if (Db::getInstance()->insert($table, array('id' => (int) $orderId, 'timestamp' => (time()))) === false) { |
|
477 | 477 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
478 | 478 | throw new ConcurrencyException(); |
479 | 479 | } |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | FROM %s WHERE %s", |
484 | 484 | self::CONCURRENCY_TIMEOUT, |
485 | 485 | _DB_PREFIX_.$table, |
486 | - 'id='.(int)$orderId |
|
486 | + 'id='.(int) $orderId |
|
487 | 487 | ); |
488 | 488 | $resultSeconds = Db::getInstance()->getValue($query); |
489 | 489 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
490 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
490 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
491 | 491 | |
492 | 492 | $logMessage = sprintf( |
493 | - "Redirect concurrency, User have to wait %s seconds, default seconds %s. CartId=" . $orderId, |
|
493 | + "Redirect concurrency, User have to wait %s seconds, default seconds %s. CartId=".$orderId, |
|
494 | 494 | $secondsToExpire, |
495 | 495 | self::CONCURRENCY_TIMEOUT, |
496 | 496 | $restSeconds |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $this->saveLog(array( |
500 | 500 | 'message' => $logMessage |
501 | 501 | )); |
502 | - sleep($secondsToExpire+1); |
|
502 | + sleep($secondsToExpire + 1); |
|
503 | 503 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
504 | 504 | return true; |
505 | 505 | } |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | if (is_null($orderId)) { |
520 | 520 | Db::getInstance()->delete( |
521 | 521 | 'pagantis_cart_process', |
522 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT) |
|
522 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT) |
|
523 | 523 | ); |
524 | 524 | return; |
525 | 525 | } |
526 | - Db::getInstance()->delete('pagantis_cart_process', 'id = ' . (int)$orderId); |
|
526 | + Db::getInstance()->delete('pagantis_cart_process', 'id = '.(int) $orderId); |
|
527 | 527 | } catch (\Exception $exception) { |
528 | 528 | throw new ConcurrencyException(); |
529 | 529 | } |
@@ -545,8 +545,8 @@ discard block |
||
545 | 545 | $data = array( |
546 | 546 | 'merchantOrderId' => $this->merchantOrderId, |
547 | 547 | 'pagantisOrderId' => $this->pagantisOrderId, |
548 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
549 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
548 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
549 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
550 | 550 | 'method' => $method, |
551 | 551 | 'file' => __FILE__, |
552 | 552 | 'line' => $line, |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | 'id_cart' => $this->merchantOrderId, |
577 | 577 | 'key' => $this->config['secureKey'], |
578 | 578 | 'id_module' => $this->module->id, |
579 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
579 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
580 | 580 | ); |
581 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
581 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
582 | 582 | return $this->redirect($url, $parameters); |
583 | 583 | } |
584 | 584 | } |