@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } catch (\Exception $exception) { |
145 | 145 | $thrownException = true; |
146 | 146 | $this->getMerchantOrderId(); |
147 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
147 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
148 | 148 | if ($this->isPost()) { |
149 | 149 | $this->jsonResponse = new JsonExceptionResponse(); |
150 | 150 | $this->jsonResponse->setMerchantOrderId($theId); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | if (!$thrownException) { |
160 | 160 | $this->jsonResponse = new JsonSuccessResponse(); |
161 | 161 | $this->getMerchantOrderId(); |
162 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
162 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
163 | 163 | $this->jsonResponse->setMerchantOrderId($theId); |
164 | 164 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
165 | 165 | $this->confirmPagantisOrder(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $this->rollbackMerchantOrder(); |
169 | 169 | if ($this->isNotification()) { |
170 | 170 | $this->getMerchantOrderId(); |
171 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
171 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
172 | 172 | $this->jsonResponse = new JsonExceptionResponse(); |
173 | 173 | $this->jsonResponse->setMerchantOrderId($theId); |
174 | 174 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } catch (\Exception $exception) { |
186 | 186 | $thrownException = true; |
187 | 187 | $this->getMerchantOrderId(); |
188 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
188 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
189 | 189 | if ($this->isPost()) { |
190 | 190 | $this->jsonResponse = new JsonExceptionResponse(); |
191 | 191 | $this->jsonResponse->setMerchantOrderId($theId); |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | $products = explode(',', Pagantis::getExtraConfig('PRODUCTS', null)); |
255 | 255 | if (!in_array(Tools::strtoupper($productCode), $products)) { |
256 | 256 | throw new UnknownException( |
257 | - 'No valid Pagantis product provided in the url: ' . Tools::getValue('product') |
|
257 | + 'No valid Pagantis product provided in the url: '.Tools::getValue('product') |
|
258 | 258 | ); |
259 | 259 | } |
260 | - $this->productName = "Pagantis " . Tools::strtolower($productCode); |
|
260 | + $this->productName = "Pagantis ".Tools::strtolower($productCode); |
|
261 | 261 | |
262 | - $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_public_key')); |
|
263 | - $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode) . '_private_key')); |
|
262 | + $this->config['publicKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_public_key')); |
|
263 | + $this->config['privateKey'] = trim(Configuration::get(Tools::strtolower($productCode).'_private_key')); |
|
264 | 264 | |
265 | 265 | $this->merchantCartId = Tools::getValue('id_cart'); |
266 | 266 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | public function getMerchantOrderId() |
281 | 281 | { |
282 | 282 | try { |
283 | - $sql = 'select ps_order_id from ' . _DB_PREFIX_ .self::ORDERS_TABLE .' where id = ' |
|
284 | - .(int)$this->merchantCartId . ' and token = \'' . $this->token . '\''; |
|
283 | + $sql = 'select ps_order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = ' |
|
284 | + .(int) $this->merchantCartId.' and token = \''.$this->token.'\''; |
|
285 | 285 | $this->merchantOrderId = Db::getInstance()->getValue($sql); |
286 | 286 | } catch (\Exception $exception) { |
287 | 287 | $exceptionMessage = sprintf( |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | private function getPagantisOrderId() |
326 | 326 | { |
327 | 327 | try { |
328 | - $sql = 'select order_id from ' . _DB_PREFIX_.self::ORDERS_TABLE .' where id = ' |
|
329 | - .(int)$this->merchantCartId . ' and token = \'' . $this->token . '\''; |
|
330 | - $this->pagantisOrderId= Db::getInstance()->getValue($sql); |
|
328 | + $sql = 'select order_id from '._DB_PREFIX_.self::ORDERS_TABLE.' where id = ' |
|
329 | + .(int) $this->merchantCartId.' and token = \''.$this->token.'\''; |
|
330 | + $this->pagantisOrderId = Db::getInstance()->getValue($sql); |
|
331 | 331 | |
332 | 332 | if (is_null($this->pagantisOrderId)) { |
333 | 333 | throw new NoIdentificationException(); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | { |
361 | 361 | if ($this->pagantisOrder->getStatus() === PagantisModelOrder::STATUS_CONFIRMED) { |
362 | 362 | $this->getMerchantOrderId(); |
363 | - $theId = ($this->merchantOrderId)? $this->merchantOrderId : $this->merchantCartId; |
|
363 | + $theId = ($this->merchantOrderId) ? $this->merchantOrderId : $this->merchantCartId; |
|
364 | 364 | $this->jsonResponse = new JsonSuccessResponse(); |
365 | 365 | $this->jsonResponse->setMerchantOrderId($theId); |
366 | 366 | $this->jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $psTotalAmount = substr_replace( |
392 | 392 | $merchantAmount, |
393 | 393 | '.', |
394 | - (Tools::strlen($merchantAmount) -2), |
|
394 | + (Tools::strlen($merchantAmount) - 2), |
|
395 | 395 | 0 |
396 | 396 | ); |
397 | 397 | |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | $pgTotalAmount = substr_replace( |
400 | 400 | $pgTotalAmountInCents, |
401 | 401 | '.', |
402 | - (Tools::strlen($pgTotalAmountInCents) -2), |
|
402 | + (Tools::strlen($pgTotalAmountInCents) - 2), |
|
403 | 403 | 0 |
404 | 404 | ); |
405 | 405 | |
406 | - $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'. $this->merchantCartId . |
|
407 | - ' compared with Pagantis Order: ' . $this->pagantisOrderId . |
|
408 | - '. The Cart in PrestaShop has an amount of ' . $psTotalAmount . ' and in Pagantis ' . |
|
409 | - $pgTotalAmount . ' PLEASE REVIEW THE ORDER'; |
|
406 | + $this->amountMismatchError = '. Amount mismatch in PrestaShop Cart #'.$this->merchantCartId. |
|
407 | + ' compared with Pagantis Order: '.$this->pagantisOrderId. |
|
408 | + '. The Cart in PrestaShop has an amount of '.$psTotalAmount.' and in Pagantis '. |
|
409 | + $pgTotalAmount.' PLEASE REVIEW THE ORDER'; |
|
410 | 410 | |
411 | 411 | $this->saveLog(array( |
412 | 412 | 'requestId' => $this->requestId, |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | // Double check |
439 | - $tableName = _DB_PREFIX_ . self::ORDERS_TABLE; |
|
439 | + $tableName = _DB_PREFIX_.self::ORDERS_TABLE; |
|
440 | 440 | $fieldName = 'ps_order_id'; |
441 | - $sql = ('select ' . $fieldName . ' from `' . $tableName . '` where `id` = ' . (int)$this->merchantCartId |
|
442 | - . ' and `order_id` = \'' . $this->pagantisOrderId . '\'' |
|
443 | - . ' and `token` = \'' . $this->token . '\'' |
|
444 | - . ' and `' . $fieldName . '` is not null'); |
|
441 | + $sql = ('select '.$fieldName.' from `'.$tableName.'` where `id` = '.(int) $this->merchantCartId |
|
442 | + . ' and `order_id` = \''.$this->pagantisOrderId.'\'' |
|
443 | + . ' and `token` = \''.$this->token.'\'' |
|
444 | + . ' and `'.$fieldName.'` is not null'); |
|
445 | 445 | $results = Db::getInstance()->ExecuteS($sql); |
446 | 446 | if (is_array($results) && count($results) === 1) { |
447 | 447 | $this->getMerchantOrderId(); |
@@ -481,9 +481,9 @@ discard block |
||
481 | 481 | Configuration::get('PS_OS_PAYMENT'), |
482 | 482 | $this->merchantCart->getOrderTotal(true), |
483 | 483 | $this->productName, |
484 | - 'pagantisOrderId: ' . $this->pagantisOrder->getId() . ' ' . |
|
485 | - 'pagantisOrderStatus: '. $this->pagantisOrder->getStatus() . |
|
486 | - $this->amountMismatchError . |
|
484 | + 'pagantisOrderId: '.$this->pagantisOrder->getId().' '. |
|
485 | + 'pagantisOrderStatus: '.$this->pagantisOrder->getStatus(). |
|
486 | + $this->amountMismatchError. |
|
487 | 487 | $metadataInfo, |
488 | 488 | array('transaction_id' => $this->pagantisOrderId), |
489 | 489 | null, |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | Db::getInstance()->update( |
498 | 498 | self::ORDERS_TABLE, |
499 | 499 | array('ps_order_id' => $this->module->currentOrder), |
500 | - 'id = '. (int)$this->merchantCartId |
|
501 | - . ' and order_id = \'' . $this->pagantisOrderId . '\'' |
|
502 | - . ' and token = \'' . $this->token . '\'' |
|
500 | + 'id = '.(int) $this->merchantCartId |
|
501 | + . ' and order_id = \''.$this->pagantisOrderId.'\'' |
|
502 | + . ' and token = \''.$this->token.'\'' |
|
503 | 503 | ); |
504 | 504 | |
505 | 505 | } catch (\Exception $exception) { |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | $this->orderClient->confirmOrder($this->pagantisOrderId); |
527 | 527 | try { |
528 | 528 | $mode = ($this->isPost()) ? 'NOTIFICATION' : 'REDIRECTION'; |
529 | - $message = 'Order CONFIRMED. The order was confirmed by a ' . $mode . |
|
530 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
531 | - '. Prestashop OrderId=' . $this->module->currentOrder; |
|
529 | + $message = 'Order CONFIRMED. The order was confirmed by a '.$mode. |
|
530 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
531 | + '. Prestashop OrderId='.$this->module->currentOrder; |
|
532 | 532 | $this->saveLog(array('requestId' => $this->requestId, 'message' => $message)); |
533 | 533 | } catch (\Exception $exception) { |
534 | 534 | $exceptionMessage = sprintf( |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | { |
556 | 556 | try { |
557 | 557 | $this->getMerchantOrderId(); |
558 | - $message = 'Roolback method: ' . |
|
559 | - '. Pagantis OrderId=' . $this->pagantisOrderId . |
|
560 | - '. Prestashop CartId=' . $this->merchantCartId . |
|
561 | - '. Prestashop OrderId=' . $this->merchantOrderId; |
|
558 | + $message = 'Roolback method: '. |
|
559 | + '. Pagantis OrderId='.$this->pagantisOrderId. |
|
560 | + '. Prestashop CartId='.$this->merchantCartId. |
|
561 | + '. Prestashop OrderId='.$this->merchantOrderId; |
|
562 | 562 | if ($this->module->currentOrder) { |
563 | 563 | $objOrder = new Order($this->module->currentOrder); |
564 | 564 | $history = new OrderHistory(); |
565 | - $history->id_order = (int)$objOrder->id; |
|
566 | - $history->changeIdOrderState(8, (int)($objOrder->id)); |
|
567 | - $message .= ' Prestashop OrderId=' . $this->merchantCartId; |
|
565 | + $history->id_order = (int) $objOrder->id; |
|
566 | + $history->changeIdOrderState(8, (int) ($objOrder->id)); |
|
567 | + $message .= ' Prestashop OrderId='.$this->merchantCartId; |
|
568 | 568 | } |
569 | 569 | $this->saveLog(array( |
570 | 570 | 'requestId' => $this->requestId, |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | { |
590 | 590 | try { |
591 | 591 | $table = self::CART_TABLE; |
592 | - $insertBlock = Db::getInstance()->insert($table, array('id' =>(int)$orderId, 'timestamp' =>(time()))); |
|
592 | + $insertBlock = Db::getInstance()->insert($table, array('id' =>(int) $orderId, 'timestamp' =>(time()))); |
|
593 | 593 | if ($insertBlock === false) { |
594 | 594 | if ($this->isNotification()) { |
595 | 595 | throw new ConcurrencyException(); |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | as rest FROM %s WHERE %s", |
600 | 600 | self::CONCURRENCY_TIMEOUT, |
601 | 601 | _DB_PREFIX_.$table, |
602 | - 'id='.(int)$orderId |
|
602 | + 'id='.(int) $orderId |
|
603 | 603 | ); |
604 | 604 | $resultSeconds = Db::getInstance()->getValue($query); |
605 | 605 | $restSeconds = isset($resultSeconds) ? ($resultSeconds) : 0; |
606 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? |
|
606 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? |
|
607 | 607 | self::CONCURRENCY_TIMEOUT : $restSeconds; |
608 | 608 | if ($secondsToExpire > 0) { |
609 | 609 | sleep($secondsToExpire + 1); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | $this->getMerchantOrderId(); |
613 | 613 | $this->getPagantisOrderId(); |
614 | 614 | |
615 | - $logMessage = sprintf( |
|
615 | + $logMessage = sprintf( |
|
616 | 616 | "User has waited %s seconds, default %s, bd time to expire %s [cartId=%s][origin=%s]", |
617 | 617 | $secondsToExpire, |
618 | 618 | self::CONCURRENCY_TIMEOUT, |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | { |
642 | 642 | try { |
643 | 643 | if (is_null($orderId)) { |
644 | - Db::getInstance()->delete(self::CART_TABLE, 'timestamp < ' . (time() - self::CONCURRENCY_TIMEOUT)); |
|
644 | + Db::getInstance()->delete(self::CART_TABLE, 'timestamp < '.(time() - self::CONCURRENCY_TIMEOUT)); |
|
645 | 645 | return; |
646 | 646 | } |
647 | - Db::getInstance()->delete(self::CART_TABLE, 'id = ' . (int)$orderId); |
|
647 | + Db::getInstance()->delete(self::CART_TABLE, 'id = '.(int) $orderId); |
|
648 | 648 | } catch (\Exception $exception) { |
649 | 649 | throw new ConcurrencyException(); |
650 | 650 | } |
@@ -669,8 +669,8 @@ discard block |
||
669 | 669 | 'merchantCartId' => $this->merchantCartId, |
670 | 670 | 'merchantOrderId' => $this->merchantOrderId, |
671 | 671 | 'pagantisOrderId' => $this->pagantisOrderId, |
672 | - 'message' => ($exception)? $exception->getMessage() : 'Unable to get Exception message', |
|
673 | - 'statusCode' => ($exception)? $exception->getCode() : 'Unable to get Exception statusCode', |
|
672 | + 'message' => ($exception) ? $exception->getMessage() : 'Unable to get Exception message', |
|
673 | + 'statusCode' => ($exception) ? $exception->getCode() : 'Unable to get Exception statusCode', |
|
674 | 674 | 'method' => $method, |
675 | 675 | 'file' => __FILE__, |
676 | 676 | 'line' => $line, |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | 'id_module' => $this->module->id, |
707 | 707 | 'id_order' => ($this->pagantisOrder) ? $this->pagantisOrder->getId() : null, |
708 | 708 | ); |
709 | - $url = ($error)? $this->config['urlKO'] : $this->config['urlOK']; |
|
709 | + $url = ($error) ? $this->config['urlKO'] : $this->config['urlOK']; |
|
710 | 710 | $returnMessage = sprintf( |
711 | 711 | "[origin=%s][cartId=%s][prestashopOrderId=%s][pagantisOrderId=%s][returnUrl=%s]", |
712 | 712 | $this->getOrigin(), |