@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | private function checkConcurrency() |
| 108 | 108 | {
|
| 109 | 109 | $this->woocommerceOrderId = $_GET['order-received']; |
| 110 | - if ($this->woocommerceOrderId == '') {
|
|
| 110 | + if ($this->woocommerceOrderId=='') {
|
|
| 111 | 111 | throw new QuoteNotFoundException(); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'");
|
| 140 | 140 | $this->pagantisOrderId = $queryResult->order_id; |
| 141 | 141 | |
| 142 | - if ($this->pagantisOrderId == '') {
|
|
| 142 | + if ($this->pagantisOrderId=='') {
|
|
| 143 | 143 | throw new NoIdentificationException(); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $status = '-'; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ($status === Order::STATUS_CONFIRMED) {
|
|
| 176 | + if ($status===Order::STATUS_CONFIRMED) {
|
|
| 177 | 177 | return true; |
| 178 | 178 | } |
| 179 | 179 | throw new WrongStatusException($status); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | 196 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM
|
| 197 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
| 197 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
| 198 | 198 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
| 199 | 199 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
| 200 | 200 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | {
|
| 217 | 217 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 218 | 218 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 219 | - if ($pagantisAmount != $wcAmount) {
|
|
| 219 | + if ($pagantisAmount!=$wcAmount) {
|
|
| 220 | 220 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
| 241 | 241 | } catch (\Exception $e) {
|
| 242 | 242 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
| 243 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) {
|
|
| 243 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) {
|
|
| 244 | 244 | throw new UnknownException($e->getMessage()); |
| 245 | 245 | } else {
|
| 246 | 246 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | global $wpdb; |
| 265 | 265 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 266 | 266 | |
| 267 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 267 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 268 | 268 | $charset_collate = $wpdb->get_charset_collate(); |
| 269 | 269 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
| 270 | 270 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | global $wpdb; |
| 283 | 283 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 284 | 284 | |
| 285 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 285 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 286 | 286 | $charset_collate = $wpdb->get_charset_collate(); |
| 287 | 287 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 288 | 288 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | $metadataOrder = $this->pagantisOrder->getMetadata(); |
| 340 | 340 | $metadataInfo = null; |
| 341 | 341 | foreach ($metadataOrder as $metadataKey => $metadataValue) {
|
| 342 | - if ($metadataKey == 'promotedProduct') {
|
|
| 343 | - $metadataInfo.= "/Producto promocionado = $metadataValue"; |
|
| 342 | + if ($metadataKey=='promotedProduct') {
|
|
| 343 | + $metadataInfo .= "/Producto promocionado = $metadataValue"; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if ($metadataInfo != null) {
|
|
| 347 | + if ($metadataInfo!=null) {
|
|
| 348 | 348 | $this->woocommerceOrder->add_order_note($metadataInfo); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -413,13 +413,13 @@ discard block |
||
| 413 | 413 | {
|
| 414 | 414 | global $wpdb; |
| 415 | 415 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 416 | - if ($orderId == null) {
|
|
| 416 | + if ($orderId==null) {
|
|
| 417 | 417 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
| 418 | 418 | } else {
|
| 419 | 419 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
| 420 | 420 | } |
| 421 | 421 | $resultDelete = $wpdb->query($query); |
| 422 | - if ($resultDelete === false) {
|
|
| 422 | + if ($resultDelete===false) {
|
|
| 423 | 423 | throw new ConcurrencyException(); |
| 424 | 424 | } |
| 425 | 425 | } |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | global $wpdb; |
| 435 | 435 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 436 | 436 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId));
|
| 437 | - if ($insertResult === false) {
|
|
| 438 | - if ($this->getOrigin() == 'Notify') {
|
|
| 437 | + if ($insertResult===false) {
|
|
| 438 | + if ($this->getOrigin()=='Notify') {
|
|
| 439 | 439 | throw new ConcurrencyException(); |
| 440 | 440 | } else {
|
| 441 | 441 | $query = sprintf( |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | ); |
| 447 | 447 | $resultSeconds = $wpdb->get_row($query); |
| 448 | 448 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
| 449 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 450 | - sleep($secondsToExpire+1); |
|
| 449 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
| 450 | + sleep($secondsToExpire + 1); |
|
| 451 | 451 | |
| 452 | 452 | $logMessage = sprintf( |
| 453 | 453 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | {
|
| 473 | 473 | $this->unblockConcurrency($this->woocommerceOrderId); |
| 474 | 474 | |
| 475 | - if ($exception == null) {
|
|
| 475 | + if ($exception==null) {
|
|
| 476 | 476 | $jsonResponse = new JsonSuccessResponse(); |
| 477 | 477 | } else {
|
| 478 | 478 | $jsonResponse = new JsonExceptionResponse(); |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
| 483 | 483 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
| 484 | 484 | |
| 485 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
| 485 | + if ($_SERVER['REQUEST_METHOD']=='POST') {
|
|
| 486 | 486 | $jsonResponse->printResponse(); |
| 487 | 487 | } else {
|
| 488 | 488 | return $jsonResponse; |