@@ -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('message' => $message)); |
| 385 | 385 | } catch (\Exception $exception) { |
| 386 | 386 | // Do nothing |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | { |
| 400 | 400 | // Do nothing because the order is created only when the purchase was successfully |
| 401 | 401 | try { |
| 402 | - $message = 'Roolback method: ' . |
|
| 403 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 404 | - '. Prestashop CartId=' . $this->merchantOrderId; |
|
| 402 | + $message = 'Roolback method: '. |
|
| 403 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 404 | + '. Prestashop CartId='.$this->merchantOrderId; |
|
| 405 | 405 | $this->saveLog(array('message' => $message)); |
| 406 | 406 | } catch (\Exception $exception) { |
| 407 | 407 | // Do nothing |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | ); |
| 433 | 433 | $resultSeconds = Db::getInstance()->getValue($query); |
| 434 | 434 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
| 435 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 435 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 436 | 436 | |
| 437 | 437 | $logMessage = sprintf( |
| 438 | 438 | "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | $this->saveLog(array( |
| 445 | 445 | 'message' => $logMessage |
| 446 | 446 | )); |
| 447 | - sleep($secondsToExpire+1); |
|
| 447 | + sleep($secondsToExpire + 1); |
|
| 448 | 448 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
| 449 | 449 | return true; |
| 450 | 450 | } |
@@ -464,11 +464,11 @@ discard block |
||
| 464 | 464 | if (is_null($orderId)) { |
| 465 | 465 | Db::getInstance()->delete( |
| 466 | 466 | 'pagantis_cart_process', |
| 467 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT) |
|
| 467 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT) |
|
| 468 | 468 | ); |
| 469 | 469 | return; |
| 470 | 470 | } |
| 471 | - Db::getInstance()->delete('pagantis_cart_process', 'id = \'' . $orderId . '\''); |
|
| 471 | + Db::getInstance()->delete('pagantis_cart_process', 'id = \''.$orderId.'\''); |
|
| 472 | 472 | } catch (\Exception $exception) { |
| 473 | 473 | throw new ConcurrencyException(); |
| 474 | 474 | } |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | $data = array( |
| 491 | 491 | 'merchantOrderId' => $this->merchantOrderId, |
| 492 | 492 | 'pagantisOrderId' => $this->pagantisOrderId, |
| 493 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
| 494 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 493 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
| 494 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 495 | 495 | 'method' => $method, |
| 496 | 496 | 'file' => __FILE__, |
| 497 | 497 | 'line' => $line, |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | 'id_cart' => $this->merchantOrderId, |
| 516 | 516 | 'key' => $this->config['secureKey'], |
| 517 | 517 | 'id_module' => $this->module->id, |
| 518 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
| 518 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
| 519 | 519 | ); |
| 520 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 520 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 521 | 521 | return $this->redirect($url, $parameters); |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | \ No newline at end of file |