@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | header('HTTP/1.1 200 Ok', true, 200); |
46 | 46 | header('Content-Type: application/json', true); |
47 | - header('Content-Length: ' . Tools::strlen($result)); |
|
47 | + header('Content-Length: '.Tools::strlen($result)); |
|
48 | 48 | |
49 | 49 | echo $result; |
50 | 50 | exit(); |
@@ -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 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | Configuration::updateValue('pagantis_public_key', ''); |
121 | 121 | Configuration::updateValue('pagantis_private_key', ''); |
122 | 122 | |
123 | - $return = (parent::install() |
|
123 | + $return = (parent::install() |
|
124 | 124 | && $this->registerHook('displayShoppingCart') |
125 | 125 | && $this->registerHook('paymentOptions') |
126 | 126 | && $this->registerHook('displayRightColumn') |
@@ -202,18 +202,18 @@ discard block |
||
202 | 202 | public function checkHooks() |
203 | 203 | { |
204 | 204 | try { |
205 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'hook_module where |
|
206 | - id_module = \'' . Module::getModuleIdByName($this->name) . '\' and |
|
207 | - id_shop = \'' . Shop::getContextShopID() . '\' and |
|
208 | - id_hook = \'' . Hook::getIdByName('header') . '\''; |
|
205 | + $sql_content = 'select * from '._DB_PREFIX_.'hook_module where |
|
206 | + id_module = \'' . Module::getModuleIdByName($this->name).'\' and |
|
207 | + id_shop = \'' . Shop::getContextShopID().'\' and |
|
208 | + id_hook = \'' . Hook::getIdByName('header').'\''; |
|
209 | 209 | $hook_exists = Db::getInstance()->ExecuteS($sql_content); |
210 | 210 | if (empty($hook_exists)) { |
211 | - $sql_insert = 'insert into ' . _DB_PREFIX_. 'hook_module |
|
211 | + $sql_insert = 'insert into '._DB_PREFIX_.'hook_module |
|
212 | 212 | (id_module, id_shop, id_hook, position) |
213 | 213 | values |
214 | - (\''. Module::getModuleIdByName($this->name) . '\', |
|
215 | - \''. Shop::getContextShopID() . '\', |
|
216 | - \''. Hook::getIdByName('header') . '\', |
|
214 | + (\''. Module::getModuleIdByName($this->name).'\', |
|
215 | + \''. Shop::getContextShopID().'\', |
|
216 | + \''. Hook::getIdByName('header').'\', |
|
217 | 217 | 150)'; |
218 | 218 | Db::getInstance()->execute($sql_insert); |
219 | 219 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function checkEnvVariables() |
229 | 229 | { |
230 | - $sql_content = 'select * from ' . _DB_PREFIX_. 'pagantis_config'; |
|
230 | + $sql_content = 'select * from '._DB_PREFIX_.'pagantis_config'; |
|
231 | 231 | $dbConfigs = Db::getInstance()->executeS($sql_content); |
232 | 232 | |
233 | 233 | // Convert a multimple dimension array for SQL insert statements into a simple key/value |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | } else { |
331 | 331 | $this->context->controller->addJS($url); |
332 | 332 | } |
333 | - $this->context->controller->addJS($this->getPathUri(). 'views/js/simulator.js'); |
|
333 | + $this->context->controller->addJS($this->getPathUri().'views/js/simulator.js'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $paymentOption |
395 | 395 | ->setCallToActionText($pagantisTitle) |
396 | 396 | ->setAction($link->getModuleLink('pagantis', 'payment')) |
397 | - ->setLogo($this->getPathUri(). 'views/img/' . $logo) |
|
397 | + ->setLogo($this->getPathUri().'views/img/'.$logo) |
|
398 | 398 | ->setModuleName(__CLASS__) |
399 | 399 | ; |
400 | 400 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | 'input' => array( |
422 | 422 | array( |
423 | 423 | 'name' => 'pagantis_is_enabled', |
424 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
424 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
425 | 425 | 'label' => $this->l('Module is enabled'), |
426 | 426 | 'prefix' => '<i class="icon icon-key"></i>', |
427 | 427 | 'class' => 't', |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | ), |
462 | 462 | array( |
463 | 463 | 'name' => 'pagantis_simulator_is_enabled', |
464 | - 'type' => (version_compare(_PS_VERSION_, '1.6')<0) ?'radio' :'switch', |
|
464 | + 'type' => (version_compare(_PS_VERSION_, '1.6') < 0) ? 'radio' : 'switch', |
|
465 | 465 | 'label' => $this->l('Simulator is enabled'), |
466 | 466 | 'prefix' => '<i class="icon icon-key"></i>', |
467 | 467 | 'class' => 't', |
@@ -577,9 +577,9 @@ discard block |
||
577 | 577 | $message = $this->displayError($error); |
578 | 578 | } |
579 | 579 | |
580 | - $logo = $this->getPathUri(). 'views/img/logo_pagantis.png'; |
|
580 | + $logo = $this->getPathUri().'views/img/logo_pagantis.png'; |
|
581 | 581 | if ($this->language == 'ES' || $this->language == null) { |
582 | - $logo = $this->getPathUri(). 'views/img/logo_pagamastarde.png'; |
|
582 | + $logo = $this->getPathUri().'views/img/logo_pagamastarde.png'; |
|
583 | 583 | } |
584 | 584 | $tpl = $this->local_path.'views/templates/admin/config-info.tpl'; |
585 | 585 | $this->context->smarty->assign(array( |
@@ -803,17 +803,17 @@ discard block |
||
803 | 803 | */ |
804 | 804 | public function checkLogoExists() |
805 | 805 | { |
806 | - $logoPmt = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagamastarde.png'; |
|
807 | - $logoPg = _PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
808 | - if (!file_exists($logoPmt) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) { |
|
806 | + $logoPmt = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagamastarde.png'; |
|
807 | + $logoPg = _PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments/pagantis.png'; |
|
808 | + if (!file_exists($logoPmt) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) { |
|
809 | 809 | copy( |
810 | - _PS_PAGANTIS_DIR . '/views/img/logo_pagamastarde.png', |
|
810 | + _PS_PAGANTIS_DIR.'/views/img/logo_pagamastarde.png', |
|
811 | 811 | $logoPmt |
812 | 812 | ); |
813 | 813 | } |
814 | - if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_ . '/onepagecheckoutps/views/img/payments')) { |
|
814 | + if (!file_exists($logoPg) && is_dir(_PS_MODULE_DIR_.'/onepagecheckoutps/views/img/payments')) { |
|
815 | 815 | copy( |
816 | - _PS_PAGANTIS_DIR . '/views/img/logo_pagantis.png', |
|
816 | + _PS_PAGANTIS_DIR.'/views/img/logo_pagantis.png', |
|
817 | 817 | $logoPg |
818 | 818 | ); |
819 | 819 | } |
@@ -828,16 +828,16 @@ discard block |
||
828 | 828 | if (!in_array(PROMOTIONS_CATEGORY_NAME, $categories)) { |
829 | 829 | /** @var CategoryCore $category */ |
830 | 830 | $category = new Category(); |
831 | - $categoryArray = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY ); |
|
831 | + $categoryArray = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY); |
|
832 | 832 | $category->is_root_category = false; |
833 | 833 | $category->link_rewrite = $categoryArray; |
834 | 834 | $category->meta_description = $categoryArray; |
835 | 835 | $category->meta_keywords = $categoryArray; |
836 | 836 | $category->meta_title = $categoryArray; |
837 | - $category->name = array((int)Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
837 | + $category->name = array((int) Configuration::get('PS_LANG_DEFAULT')=> PROMOTIONS_CATEGORY_NAME); |
|
838 | 838 | $category->id_parent = Configuration::get('PS_HOME_CATEGORY'); |
839 | - $category->active=0; |
|
840 | - $description = 'Pagantis: Products with this category have free financing assumed by the merchant. ' . |
|
839 | + $category->active = 0; |
|
840 | + $description = 'Pagantis: Products with this category have free financing assumed by the merchant. '. |
|
841 | 841 | 'Use it to promote your products or brands.'; |
842 | 842 | $category->description = $this->l($description); |
843 | 843 | $category->save(); |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | return ''; |
852 | 852 | } |
853 | 853 | |
854 | - $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \'' . pSQL($config) . '\' limit 1'; |
|
854 | + $sql = 'SELECT value FROM '._DB_PREFIX_.'pagantis_config where config = \''.pSQL($config).'\' limit 1'; |
|
855 | 855 | if ($results = Db::getInstance()->ExecuteS($sql)) { |
856 | 856 | if (is_array($results) && count($results) === 1 && isset($results[0]['value'])) { |
857 | 857 | return $results[0]['value']; |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | if (count($langArray) != 2 && isset($lang['locale'])) { |
872 | 872 | $langArray = explode("-", $lang['locale']); |
873 | 873 | } |
874 | - $this->language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
874 | + $this->language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
875 | 875 | // Prevent null language detection |
876 | 876 | $this->language = ($this->language) ? $this->language : 'ES'; |
877 | 877 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $pagantisPublicKey = Configuration::get('pagantis_public_key'); |
89 | 89 | $pagantisPrivateKey = Configuration::get('pagantis_private_key'); |
90 | 90 | $okUrl = _PS_BASE_URL_SSL_.__PS_BASE_URI__ |
91 | - .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&' |
|
92 | - .http_build_query($query) |
|
91 | + .'index.php?canonical=true&fc=module&module=pagantis&controller=notify&' |
|
92 | + .http_build_query($query) |
|
93 | 93 | ; |
94 | 94 | |
95 | 95 | $shippingAddress = new Address($cart->id_address_delivery); |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | $productId = $item['id_product']; |
193 | 193 | $finalPrice = Product::getPriceStatic($productId); |
194 | 194 | $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
195 | - ' Price: ' . $finalPrice . |
|
196 | - ' Qty: ' . $product->getQuantity() . |
|
197 | - ' Item ID: ' . $item['id_product']; |
|
195 | + ' Price: ' . $finalPrice . |
|
196 | + ' Qty: ' . $product->getQuantity() . |
|
197 | + ' Item ID: ' . $item['id_product']; |
|
198 | 198 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
199 | 199 | } |
200 | 200 | $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(), |
@@ -104,24 +104,24 @@ discard block |
||
104 | 104 | ); |
105 | 105 | |
106 | 106 | try { |
107 | - $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
107 | + $userAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
108 | 108 | $userAddress |
109 | 109 | ->setZipCode($shippingAddress->postcode) |
110 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) |
|
110 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) |
|
111 | 111 | ->setCountryCode($this->language) |
112 | 112 | ->setCity($shippingAddress->city) |
113 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) |
|
113 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) |
|
114 | 114 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) |
115 | 115 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
116 | 116 | ; |
117 | 117 | |
118 | - $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
118 | + $orderShippingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
|
119 | 119 | $orderShippingAddress |
120 | 120 | ->setZipCode($shippingAddress->postcode) |
121 | - ->setFullName($shippingAddress->firstname . ' ' . $shippingAddress->lastname) |
|
121 | + ->setFullName($shippingAddress->firstname.' '.$shippingAddress->lastname) |
|
122 | 122 | ->setCountryCode($this->language) |
123 | 123 | ->setCity($shippingAddress->city) |
124 | - ->setAddress($shippingAddress->address1 . ' ' . $shippingAddress->address2) |
|
124 | + ->setAddress($shippingAddress->address1.' '.$shippingAddress->address2) |
|
125 | 125 | ->setTaxId($this->getTaxId($customer, $shippingAddress, $billingAddress)) |
126 | 126 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
127 | 127 | ->setFixPhone($shippingAddress->phone) |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | $orderBillingAddress = new \Pagantis\OrdersApiClient\Model\Order\User\Address(); |
132 | 132 | $orderBillingAddress |
133 | 133 | ->setZipCode($billingAddress->postcode) |
134 | - ->setFullName($billingAddress->firstname . ' ' . $billingAddress->lastname) |
|
134 | + ->setFullName($billingAddress->firstname.' '.$billingAddress->lastname) |
|
135 | 135 | ->setCountryCode($this->language) |
136 | 136 | ->setCity($billingAddress->city) |
137 | - ->setAddress($billingAddress->address1 . ' ' . $billingAddress->address2) |
|
137 | + ->setAddress($billingAddress->address1.' '.$billingAddress->address2) |
|
138 | 138 | ->setTaxId($this->getTaxId($customer, $billingAddress, $shippingAddress)) |
139 | 139 | ->setNationalId($this->getNationalId($customer, $billingAddress, $shippingAddress)) |
140 | 140 | ->setFixPhone($billingAddress->phone) |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | ->setNationalId($this->getNationalId($customer, $shippingAddress, $billingAddress)) |
155 | 155 | ; |
156 | 156 | |
157 | - if ($customer->birthday!='0000-00-00') { |
|
157 | + if ($customer->birthday != '0000-00-00') { |
|
158 | 158 | $orderUser->setDateOfBirth($customer->birthday); |
159 | 159 | } |
160 | 160 | |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | ->setQuantity($item['quantity']) |
189 | 189 | ->setDescription($item['name']); |
190 | 190 | if ($promotedProduct) { |
191 | - $promotedAmount+=$product->getAmount(); |
|
191 | + $promotedAmount += $product->getAmount(); |
|
192 | 192 | $productId = $item['id_product']; |
193 | 193 | $finalPrice = Product::getPriceStatic($productId); |
194 | - $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
|
195 | - ' Price: ' . $finalPrice . |
|
196 | - ' Qty: ' . $product->getQuantity() . |
|
197 | - ' Item ID: ' . $item['id_product']; |
|
194 | + $promotedMessage = 'Promoted Item: '.$product->getDescription(). |
|
195 | + ' Price: '.$finalPrice. |
|
196 | + ' Qty: '.$product->getQuantity(). |
|
197 | + ' Item ID: '.$item['id_product']; |
|
198 | 198 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
199 | 199 | } |
200 | 200 | $details->addProduct($product); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | Tools::redirect($cancelUrl); |
245 | 245 | } |
246 | 246 | |
247 | - $url =''; |
|
247 | + $url = ''; |
|
248 | 248 | try { |
249 | 249 | $orderClient = new \Pagantis\OrdersApiClient\Client( |
250 | 250 | $pagantisPublicKey, |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | if ($order instanceof \Pagantis\OrdersApiClient\Model\Order) { |
256 | 256 | $url = $order->getActionUrls()->getForm(); |
257 | 257 | $orderId = $order->getId(); |
258 | - $sql = "INSERT INTO `" . _DB_PREFIX_ . "pagantis_order` (`id`, `order_id`) |
|
258 | + $sql = "INSERT INTO `"._DB_PREFIX_."pagantis_order` (`id`, `order_id`) |
|
259 | 259 | VALUES ('$cart->id','$orderId') |
260 | 260 | ON DUPLICATE KEY UPDATE `order_id` = '$orderId'"; |
261 | 261 | $result = Db::getInstance()->execute($sql); |
262 | 262 | if (!$result) { |
263 | - throw new UnknownException('Unable to save pagantis-order-id in database: '. $sql); |
|
263 | + throw new UnknownException('Unable to save pagantis-order-id in database: '.$sql); |
|
264 | 264 | } |
265 | 265 | } else { |
266 | 266 | throw new OrderNotFoundException(); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | if (count($langArray) != 2 && isset($lang['locale'])) { |
360 | 360 | $langArray = explode("-", $lang['locale']); |
361 | 361 | } |
362 | - $this->language = Tools::strtoupper($langArray[count($langArray)-1]); |
|
362 | + $this->language = Tools::strtoupper($langArray[count($langArray) - 1]); |
|
363 | 363 | // Prevent null language detection |
364 | 364 | $this->language = ($this->language) ? $this->language : 'ES'; |
365 | 365 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | private function getPagantisOrderId() |
208 | 208 | { |
209 | 209 | try { |
210 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
210 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
211 | 211 | 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId |
212 | 212 | ); |
213 | 213 | |
@@ -269,20 +269,20 @@ discard block |
||
269 | 269 | $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0]; |
270 | 270 | if ($totalAmount != $merchantAmount) { |
271 | 271 | try { |
272 | - $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0); |
|
272 | + $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0); |
|
273 | 273 | |
274 | 274 | $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
275 | 275 | $pgTotalAmount = substr_replace( |
276 | 276 | $pgTotalAmountInCents, |
277 | 277 | '.', |
278 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
278 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
279 | 279 | 0 |
280 | 280 | ); |
281 | 281 | |
282 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId . |
|
283 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
284 | - '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
285 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
282 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId. |
|
283 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
284 | + '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
285 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
286 | 286 | $this->saveLog(array( |
287 | 287 | 'message' => $this->amountMismatchError |
288 | 288 | )); |
@@ -302,20 +302,20 @@ discard block |
||
302 | 302 | try { |
303 | 303 | if ($this->merchantOrder->orderExists() !== false) { |
304 | 304 | throw new WrongStatusException('PS->orderExists() cart_id = ' |
305 | - . $this->merchantOrderId . ' pagantis_id = ' |
|
306 | - . $this->pagantisOrderId . '): already_processed'); |
|
305 | + . $this->merchantOrderId.' pagantis_id = ' |
|
306 | + . $this->pagantisOrderId.'): already_processed'); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | // Double check |
310 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
311 | - $sql = ('select ps_order_id from `' . $tableName . '` where `id` = ' . $this->merchantOrderId |
|
312 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
310 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
311 | + $sql = ('select ps_order_id from `'.$tableName.'` where `id` = '.$this->merchantOrderId |
|
312 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
313 | 313 | . ' and `ps_order_id` is not null'); |
314 | 314 | $results = Db::getInstance()->ExecuteS($sql); |
315 | 315 | if (is_array($results) && count($results) === 1) { |
316 | - throw new WrongStatusException('PS->record found in ' . $tableName |
|
317 | - . ' (cart_id = ' . $this->merchantOrderId . ' pagantis_id = ' |
|
318 | - . $this->pagantisOrderId . '): already_processed'); |
|
316 | + throw new WrongStatusException('PS->record found in '.$tableName |
|
317 | + . ' (cart_id = '.$this->merchantOrderId.' pagantis_id = ' |
|
318 | + . $this->pagantisOrderId.'): already_processed'); |
|
319 | 319 | } |
320 | 320 | } catch (\Exception $exception) { |
321 | 321 | throw new UnknownException($exception->getMessage()); |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | Configuration::get('PS_OS_PAYMENT'), |
345 | 345 | $this->merchantOrder->getOrderTotal(true), |
346 | 346 | $this->module->displayName, |
347 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
348 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
349 | - $this->amountMismatchError . |
|
347 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
348 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
349 | + $this->amountMismatchError. |
|
350 | 350 | $metadataInfo, |
351 | 351 | array('transaction_id' => $this->pagantisOrderId), |
352 | 352 | null, |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | Db::getInstance()->update( |
361 | 361 | 'pagantis_order', |
362 | 362 | array('ps_order_id' => $this->module->currentOrder), |
363 | - 'id = \''. $this->merchantOrderId . '\' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
363 | + 'id = \''.$this->merchantOrderId.'\' and order_id = \''.$this->pagantisOrderId.'\'' |
|
364 | 364 | ); |
365 | 365 | } catch (\Exception $exception) { |
366 | 366 | // Do nothing |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
379 | 379 | try { |
380 | 380 | $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION'; |
381 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
382 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
383 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
381 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
382 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
383 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
384 | 384 | $this->saveLog(array( |
385 | 385 | 'message' => $message |
386 | 386 | )); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | ); |
428 | 428 | $resultSeconds = Db::getInstance()->getValue($query); |
429 | 429 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
430 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
430 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
431 | 431 | |
432 | 432 | $logMessage = sprintf( |
433 | 433 | "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $this->saveLog(array( |
440 | 440 | 'message' => $logMessage |
441 | 441 | )); |
442 | - sleep($secondsToExpire+1); |
|
442 | + sleep($secondsToExpire + 1); |
|
443 | 443 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
444 | 444 | return true; |
445 | 445 | } |
@@ -456,12 +456,12 @@ discard block |
||
456 | 456 | if (is_null($orderId)) { |
457 | 457 | Db::getInstance()->delete( |
458 | 458 | 'pagantis_cart_process', |
459 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT |
|
459 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT |
|
460 | 460 | ) |
461 | 461 | ); |
462 | 462 | return; |
463 | 463 | } |
464 | - Db::getInstance()->delete('pagantis_cart_process', 'id = \'' . $orderId . '\''); |
|
464 | + Db::getInstance()->delete('pagantis_cart_process', 'id = \''.$orderId.'\''); |
|
465 | 465 | } catch (\Exception $exception) { |
466 | 466 | throw new ConcurrencyException(); |
467 | 467 | } |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | $data = array( |
484 | 484 | 'merchantOrderId' => $this->merchantOrderId, |
485 | 485 | 'pagantisOrderId' => $this->pagantisOrderId, |
486 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
487 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
486 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
487 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
488 | 488 | 'method' => $method, |
489 | 489 | 'file' => __FILE__, |
490 | 490 | 'line' => $line, |
@@ -508,9 +508,9 @@ discard block |
||
508 | 508 | 'id_cart' => $this->merchantOrderId, |
509 | 509 | 'key' => $this->config['secureKey'], |
510 | 510 | 'id_module' => $this->module->id, |
511 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
511 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
512 | 512 | ); |
513 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
513 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
514 | 514 | return $this->redirect($url, $parameters); |
515 | 515 | } |
516 | 516 | } |
517 | 517 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require(__DIR__ . '/src/Httpful/Bootstrap.php'); |
|
3 | +require(__DIR__.'/src/Httpful/Bootstrap.php'); |
|
4 | 4 | \Httpful\Bootstrap::init(); |
@@ -64,30 +64,30 @@ discard block |
||
64 | 64 | |
65 | 65 | function testInit() |
66 | 66 | { |
67 | - $r = Request::init(); |
|
68 | - // Did we get a 'Request' object? |
|
69 | - $this->assertEquals('Httpful\Request', get_class($r)); |
|
67 | + $r = Request::init(); |
|
68 | + // Did we get a 'Request' object? |
|
69 | + $this->assertEquals('Httpful\Request', get_class($r)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function testDetermineLength() |
73 | 73 | { |
74 | - $r = Request::init(); |
|
75 | - $this->assertEquals(1, $r->_determineLength('A')); |
|
76 | - $this->assertEquals(2, $r->_determineLength('À')); |
|
77 | - $this->assertEquals(2, $r->_determineLength('Ab')); |
|
78 | - $this->assertEquals(3, $r->_determineLength('Àb')); |
|
79 | - $this->assertEquals(6, $r->_determineLength('世界')); |
|
74 | + $r = Request::init(); |
|
75 | + $this->assertEquals(1, $r->_determineLength('A')); |
|
76 | + $this->assertEquals(2, $r->_determineLength('À')); |
|
77 | + $this->assertEquals(2, $r->_determineLength('Ab')); |
|
78 | + $this->assertEquals(3, $r->_determineLength('Àb')); |
|
79 | + $this->assertEquals(6, $r->_determineLength('世界')); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | function testMethods() |
83 | 83 | { |
84 | - $valid_methods = array('get', 'post', 'delete', 'put', 'options', 'head'); |
|
85 | - $url = 'http://example.com/'; |
|
86 | - foreach ($valid_methods as $method) { |
|
84 | + $valid_methods = array('get', 'post', 'delete', 'put', 'options', 'head'); |
|
85 | + $url = 'http://example.com/'; |
|
86 | + foreach ($valid_methods as $method) { |
|
87 | 87 | $r = call_user_func(array('Httpful\Request', $method), $url); |
88 | 88 | $this->assertEquals('Httpful\Request', get_class($r)); |
89 | 89 | $this->assertEquals(strtoupper($method), $r->method); |
90 | - } |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | function testDefaults() |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | function testSettingStrictSsl() |
125 | 125 | { |
126 | 126 | $r = Request::init() |
127 | - ->withStrictSsl(); |
|
127 | + ->withStrictSsl(); |
|
128 | 128 | |
129 | 129 | $this->assertTrue($r->strict_ssl); |
130 | 130 | |
131 | 131 | $r = Request::init() |
132 | - ->withoutStrictSsl(); |
|
132 | + ->withoutStrictSsl(); |
|
133 | 133 | |
134 | 134 | $this->assertFalse($r->strict_ssl); |
135 | 135 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | namespace Httpful\Test; |
11 | 11 | |
12 | -require(dirname(dirname(dirname(__FILE__))) . '/bootstrap.php'); |
|
12 | +require(dirname(dirname(dirname(__FILE__))).'/bootstrap.php'); |
|
13 | 13 | \Httpful\Bootstrap::init(); |
14 | 14 | |
15 | 15 | use Httpful\Httpful; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use Httpful\Response; |
20 | 20 | use Httpful\Handlers\JsonHandler; |
21 | 21 | |
22 | -define('TEST_SERVER', WEB_SERVER_HOST . ':' . WEB_SERVER_PORT); |
|
22 | +define('TEST_SERVER', WEB_SERVER_HOST.':'.WEB_SERVER_PORT); |
|
23 | 23 | |
24 | 24 | class HttpfulTest extends \PHPUnit_Framework_TestCase |
25 | 25 | { |
@@ -101,21 +101,21 @@ discard block |
||
101 | 101 | function testShortMime() |
102 | 102 | { |
103 | 103 | // Valid short ones |
104 | - $this->assertEquals(Mime::JSON, Mime::getFullMime('json')); |
|
105 | - $this->assertEquals(Mime::XML, Mime::getFullMime('xml')); |
|
106 | - $this->assertEquals(Mime::HTML, Mime::getFullMime('html')); |
|
107 | - $this->assertEquals(Mime::CSV, Mime::getFullMime('csv')); |
|
108 | - $this->assertEquals(Mime::UPLOAD, Mime::getFullMime('upload')); |
|
104 | + $this->assertEquals(Mime::JSON, Mime::getFullMime('json')); |
|
105 | + $this->assertEquals(Mime::XML, Mime::getFullMime('xml')); |
|
106 | + $this->assertEquals(Mime::HTML, Mime::getFullMime('html')); |
|
107 | + $this->assertEquals(Mime::CSV, Mime::getFullMime('csv')); |
|
108 | + $this->assertEquals(Mime::UPLOAD, Mime::getFullMime('upload')); |
|
109 | 109 | |
110 | 110 | // Valid long ones |
111 | 111 | $this->assertEquals(Mime::JSON, Mime::getFullMime(Mime::JSON)); |
112 | - $this->assertEquals(Mime::XML, Mime::getFullMime(Mime::XML)); |
|
112 | + $this->assertEquals(Mime::XML, Mime::getFullMime(Mime::XML)); |
|
113 | 113 | $this->assertEquals(Mime::HTML, Mime::getFullMime(Mime::HTML)); |
114 | 114 | $this->assertEquals(Mime::CSV, Mime::getFullMime(Mime::CSV)); |
115 | 115 | $this->assertEquals(Mime::UPLOAD, Mime::getFullMime(Mime::UPLOAD)); |
116 | 116 | |
117 | 117 | // No false positives |
118 | - $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::HTML)); |
|
118 | + $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::HTML)); |
|
119 | 119 | $this->assertNotEquals(Mime::JSON, Mime::getFullMime(Mime::XML)); |
120 | 120 | $this->assertNotEquals(Mime::HTML, Mime::getFullMime(Mime::JSON)); |
121 | 121 | $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::CSV)); |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | $this->assertEquals("object", gettype($sxe)); |
277 | 277 | $this->assertEquals("SimpleXMLElement", get_class($sxe)); |
278 | 278 | $bools = $sxe->xpath('/stdClass/boolProp'); |
279 | - list( , $bool ) = each($bools); |
|
279 | + list(, $bool) = each($bools); |
|
280 | 280 | $this->assertEquals("TRUE", (string) $bool); |
281 | 281 | $ints = $sxe->xpath('/stdClass/arrayProp/array/k1/myClass/intProp'); |
282 | - list( , $int ) = each($ints); |
|
282 | + list(, $int) = each($ints); |
|
283 | 283 | $this->assertEquals("2", (string) $int); |
284 | 284 | $strings = $sxe->xpath('/stdClass/stringProp'); |
285 | - list( , $string ) = each($strings); |
|
285 | + list(, $string) = each($strings); |
|
286 | 286 | $this->assertEquals("a string", (string) $string); |
287 | 287 | } |
288 | 288 | |
@@ -322,14 +322,14 @@ discard block |
||
322 | 322 | |
323 | 323 | function testAttach() { |
324 | 324 | $req = Request::init(); |
325 | - $testsPath = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'); |
|
326 | - $filename = $testsPath . DIRECTORY_SEPARATOR . 'test_image.jpg'; |
|
325 | + $testsPath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'); |
|
326 | + $filename = $testsPath.DIRECTORY_SEPARATOR.'test_image.jpg'; |
|
327 | 327 | $req->attach(array('index' => $filename)); |
328 | 328 | $payload = $req->payload['index']; |
329 | 329 | // PHP 5.5 + will take advantage of CURLFile while previous |
330 | 330 | // versions just use the string syntax |
331 | 331 | if (is_string($payload)) { |
332 | - $this->assertEquals($payload, '@' . $filename . ';type=image/jpeg'); |
|
332 | + $this->assertEquals($payload, '@'.$filename.';type=image/jpeg'); |
|
333 | 333 | } else { |
334 | 334 | $this->assertInstanceOf('CURLFile', $payload); |
335 | 335 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | |
419 | 419 | try { |
420 | 420 | Request::get('malformed://url') |
421 | - ->beforeSend(function($request) use(&$invoked,$self) { |
|
421 | + ->beforeSend(function($request) use(&$invoked, $self) { |
|
422 | 422 | $self->assertEquals('malformed://url', $request->uri); |
423 | 423 | $self->assertEquals('A payload', $request->serialized_payload); |
424 | 424 | $request->uri('malformed2://url'); |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | { |
449 | 449 | $req = Request::init()->sendsAndExpects(Mime::JSON); |
450 | 450 | $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req); |
451 | - $this->assertEquals(self::SAMPLE_JSON_RESPONSE, (string)$response); |
|
451 | + $this->assertEquals(self::SAMPLE_JSON_RESPONSE, (string) $response); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | function test_parseHeaders() |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | try { |
572 | 572 | $result = $handler->parse('invalid{json'); |
573 | - } catch(\Exception $e) { |
|
573 | + } catch (\Exception $e) { |
|
574 | 574 | $this->assertEquals('Unable to parse response as JSON', $e->getMessage()); |
575 | 575 | return; |
576 | 576 | } |