@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | private function getPagantisOrderId() |
| 211 | 211 | { |
| 212 | 212 | try { |
| 213 | - $this->pagantisOrderId= Db::getInstance()->getValue( |
|
| 213 | + $this->pagantisOrderId = Db::getInstance()->getValue( |
|
| 214 | 214 | 'select order_id from '._DB_PREFIX_.'pagantis_order where id = '.$this->merchantOrderId |
| 215 | 215 | ); |
| 216 | 216 | |
@@ -272,20 +272,20 @@ discard block |
||
| 272 | 272 | $merchantAmount = explode('.', explode(',', $merchantAmount)[0])[0]; |
| 273 | 273 | if ($totalAmount != $merchantAmount) { |
| 274 | 274 | try { |
| 275 | - $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) -2), 0); |
|
| 275 | + $psTotalAmount = substr_replace($merchantAmount, '.', (Tools::strlen($merchantAmount) - 2), 0); |
|
| 276 | 276 | |
| 277 | 277 | $pgTotalAmountInCents = (string) $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 278 | 278 | $pgTotalAmount = substr_replace( |
| 279 | 279 | $pgTotalAmountInCents, |
| 280 | 280 | '.', |
| 281 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
| 281 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
| 282 | 282 | 0 |
| 283 | 283 | ); |
| 284 | 284 | |
| 285 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'. $this->merchantOrderId . |
|
| 286 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
| 287 | - '. The order in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
| 288 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
| 285 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Order #'.$this->merchantOrderId. |
|
| 286 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
| 287 | + '. The order in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
| 288 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
| 289 | 289 | $this->saveLog(array( |
| 290 | 290 | 'message' => $this->amountMismatchError |
| 291 | 291 | )); |
@@ -305,20 +305,20 @@ discard block |
||
| 305 | 305 | try { |
| 306 | 306 | if ($this->merchantOrder->orderExists() !== false) { |
| 307 | 307 | throw new WrongStatusException('PS->orderExists() cart_id = ' |
| 308 | - . $this->merchantOrderId . ' pagantis_id = ' |
|
| 309 | - . $this->pagantisOrderId . '): already_processed'); |
|
| 308 | + . $this->merchantOrderId.' pagantis_id = ' |
|
| 309 | + . $this->pagantisOrderId.'): already_processed'); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Double check |
| 313 | - $tableName = _DB_PREFIX_ . 'pagantis_order'; |
|
| 314 | - $sql = ('select ps_order_id from `' . $tableName . '` where `id` = ' . $this->merchantOrderId |
|
| 315 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
| 313 | + $tableName = _DB_PREFIX_.'pagantis_order'; |
|
| 314 | + $sql = ('select ps_order_id from `'.$tableName.'` where `id` = '.$this->merchantOrderId |
|
| 315 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
| 316 | 316 | . ' and `ps_order_id` is not null'); |
| 317 | 317 | $results = Db::getInstance()->ExecuteS($sql); |
| 318 | 318 | if (is_array($results) && count($results) === 1) { |
| 319 | - throw new WrongStatusException('PS->record found in ' . $tableName |
|
| 320 | - . ' (cart_id = ' . $this->merchantOrderId . ' pagantis_id = ' |
|
| 321 | - . $this->pagantisOrderId . '): already_processed'); |
|
| 319 | + throw new WrongStatusException('PS->record found in '.$tableName |
|
| 320 | + . ' (cart_id = '.$this->merchantOrderId.' pagantis_id = ' |
|
| 321 | + . $this->pagantisOrderId.'): already_processed'); |
|
| 322 | 322 | } |
| 323 | 323 | } catch (\Exception $exception) { |
| 324 | 324 | throw new UnknownException($exception->getMessage()); |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | Configuration::get('PS_OS_PAYMENT'), |
| 348 | 348 | $this->merchantOrder->getOrderTotal(true), |
| 349 | 349 | $this->module->displayName, |
| 350 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
| 351 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
| 352 | - $this->amountMismatchError . |
|
| 350 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
| 351 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
| 352 | + $this->amountMismatchError. |
|
| 353 | 353 | $metadataInfo, |
| 354 | 354 | array('transaction_id' => $this->pagantisOrderId), |
| 355 | 355 | null, |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | Db::getInstance()->update( |
| 364 | 364 | 'pagantis_order', |
| 365 | 365 | array('ps_order_id' => $this->module->currentOrder), |
| 366 | - 'id = \''. $this->merchantOrderId . '\' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
| 366 | + 'id = \''.$this->merchantOrderId.'\' and order_id = \''.$this->pagantisOrderId.'\'' |
|
| 367 | 367 | ); |
| 368 | 368 | } catch (\Exception $exception) { |
| 369 | 369 | // Do nothing |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 382 | 382 | try { |
| 383 | 383 | $mode = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'NOTIFICATION' : 'REDIRECTION'; |
| 384 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
| 385 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 386 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
| 384 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
| 385 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 386 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
| 387 | 387 | $this->saveLog(array('message' => $message)); |
| 388 | 388 | } catch (\Exception $exception) { |
| 389 | 389 | // Do nothing |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | { |
| 403 | 403 | // Do nothing because the order is created only when the purchase was successfully |
| 404 | 404 | try { |
| 405 | - $message = 'Roolback method: ' . |
|
| 406 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
| 407 | - '. Prestashop CartId=' . $this->merchantOrderId; |
|
| 405 | + $message = 'Roolback method: '. |
|
| 406 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
| 407 | + '. Prestashop CartId='.$this->merchantOrderId; |
|
| 408 | 408 | $this->saveLog(array('message' => $message)); |
| 409 | 409 | } catch (\Exception $exception) { |
| 410 | 410 | // Do nothing |
@@ -435,10 +435,10 @@ discard block |
||
| 435 | 435 | ); |
| 436 | 436 | $resultSeconds = Db::getInstance()->getValue($query); |
| 437 | 437 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
| 438 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 438 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 439 | 439 | |
| 440 | 440 | $logMessage = sprintf( |
| 441 | - "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds. CartId=" . $orderId, |
|
| 441 | + "Redirect concurrency, User have to wait %s seconds, default seconds %s, bd time to expire %s seconds. CartId=".$orderId, |
|
| 442 | 442 | $secondsToExpire, |
| 443 | 443 | self::CONCURRENCY_TIMEOUT, |
| 444 | 444 | $restSeconds |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $this->saveLog(array( |
| 448 | 448 | 'message' => $logMessage |
| 449 | 449 | )); |
| 450 | - sleep($secondsToExpire+1); |
|
| 450 | + sleep($secondsToExpire + 1); |
|
| 451 | 451 | // After waiting...user continue the confirmation, hoping that previous call have finished. |
| 452 | 452 | return true; |
| 453 | 453 | } |
@@ -467,11 +467,11 @@ discard block |
||
| 467 | 467 | if (is_null($orderId)) { |
| 468 | 468 | Db::getInstance()->delete( |
| 469 | 469 | 'pagantis_cart_process', |
| 470 | - 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT) |
|
| 470 | + 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT) |
|
| 471 | 471 | ); |
| 472 | 472 | return; |
| 473 | 473 | } |
| 474 | - Db::getInstance()->delete('pagantis_cart_process', 'id = \'' . $orderId . '\''); |
|
| 474 | + Db::getInstance()->delete('pagantis_cart_process', 'id = \''.$orderId.'\''); |
|
| 475 | 475 | } catch (\Exception $exception) { |
| 476 | 476 | throw new ConcurrencyException(); |
| 477 | 477 | } |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | $data = array( |
| 494 | 494 | 'merchantOrderId' => $this->merchantOrderId, |
| 495 | 495 | 'pagantisOrderId' => $this->pagantisOrderId, |
| 496 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
| 497 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 496 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
| 497 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
| 498 | 498 | 'method' => $method, |
| 499 | 499 | 'file' => __FILE__, |
| 500 | 500 | 'line' => $line, |
@@ -518,9 +518,9 @@ discard block |
||
| 518 | 518 | 'id_cart' => $this->merchantOrderId, |
| 519 | 519 | 'key' => $this->config['secureKey'], |
| 520 | 520 | 'id_module' => $this->module->id, |
| 521 | - 'id_order' => ($this->pagantisOrder)?$this->pagantisOrder->getId(): null, |
|
| 521 | + 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
|
| 522 | 522 | ); |
| 523 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 523 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
| 524 | 524 | return $this->redirect($url, $parameters); |
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | \ No newline at end of file |