Passed
Pull Request — master (#4)
by Cesar
03:17
created

notifyController::getOrderStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
use Pagantis\OrdersApiClient\Client;
4
use Pagantis\ModuleUtils\Exception\AlreadyProcessedException;
5
use Pagantis\ModuleUtils\Exception\AmountMismatchException;
6
use Pagantis\ModuleUtils\Exception\MerchantOrderNotFoundException;
7
use Pagantis\ModuleUtils\Exception\NoIdentificationException;
8
use Pagantis\ModuleUtils\Exception\OrderNotFoundException;
9
use Pagantis\ModuleUtils\Exception\QuoteNotFoundException;
10
use Pagantis\ModuleUtils\Exception\UnknownException;
11
use Pagantis\ModuleUtils\Exception\WrongStatusException;
12
use Pagantis\ModuleUtils\Model\Response\JsonSuccessResponse;
13
use Pagantis\ModuleUtils\Model\Response\JsonExceptionResponse;
14
use Pagantis\ModuleUtils\Exception\ConcurrencyException;
15
use Pagantis\ModuleUtils\Model\Log\LogEntry;
16
17
18
define('TABLE_PAGANTIS_LOG', 'pagantis_log');
19
define('TABLE_PAGANTIS_CONFIG', 'pagantis_config');
20
define('TABLE_PAGANTIS_ORDERS', 'pagantis_order');
21
define('TABLE_PAGANTIS_CONCURRENCY', 'pagantis_concurrency');
22
23
class notifyController
24
{
25
    /** @var mixed $pagantisOrder */
26
    protected $pagantisOrder;
27
28
    /** @var $string $origin */
0 ignored issues
show
Documentation Bug introduced by
The doc comment $string at position 0 could not be parsed: Unknown type name '$string' at position 0 in $string.
Loading history...
29
    public $origin;
30
31
    /** @var $string */
0 ignored issues
show
Documentation Bug introduced by
The doc comment $string at position 0 could not be parsed: Unknown type name '$string' at position 0 in $string.
Loading history...
32
    public $order;
33
34
    /** @var mixed $oscommerceOrderId */
35
    protected $oscommerceOrderId = '';
36
37
    /** @var mixed $cfg */
38
    protected $cfg;
39
40
    /** @var Client $orderClient */
41
    protected $orderClient;
42
43
    /** @var Order $oscommerceOrder */
0 ignored issues
show
Bug introduced by
The type Order was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
44
    protected $oscommerceOrder;
45
46
    /** @var mixed $pagantisOrderId */
47
    protected $pagantisOrderId = '';
48
49
    /** @var array $extraConfig */
50
    protected $extraConfig;
51
52
    /**
53
     * notifyController constructor.
54
     */
55
    public function __construct()
56
    {
57
        $this->extraConfig = $this->getExtraConfig();
58
    }
59
60
    /**
61
     * Validation vs PagantisClient
62
     *
63
     * @return array|Array_
0 ignored issues
show
Bug introduced by
The type Array_ was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
64
     * @throws Exception
65
     */
66
    public function processInformation()
67
    {
68
        require_once('vendor/autoload.php');
69
        try {
70
            $this->checkConcurrency();
71
            $this->getMerchantOrder();
72
            $this->getPagantisOrderId();
73
            $this->getPagantisOrder();
74
            $this->checkOrderStatus();
75
            $this->checkMerchantOrderStatus();
76
            $this->validateAmount();
77
            //$this->processMerchantOrder(); //ESTE PASO SE HACE EN EL CHECKOUT_PROCESS
78
        } catch (\Exception $exception) {
79
            $this->unblockConcurrency($this->oscommerceOrderId);
80
            $jsonResponse = new JsonExceptionResponse();
81
            $jsonResponse->setMerchantOrderId($this->merchantOrderId);
82
            $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
83
            $jsonResponse->setException($exception);
84
            $this->insertLog($exception);
85
86
            if ($this->extraConfig['PAGANTIS_URL_KO'] =! '') {
87
                $koUrl = $this->extraConfig['PAGANTIS_URL_KO'];
88
            } else {
89
                $koUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false));
0 ignored issues
show
Bug introduced by
The constant FILENAME_CHECKOUT_SHIPPING was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The function tep_href_link was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

89
                $koUrl = trim(/** @scrutinizer ignore-call */ tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false));
Loading history...
90
            }
91
92
            if ($this->origin == 'notify') {
93
                $jsonResponse->printResponse();
94
            } else {
95
                if ($exception->getMessage() == AlreadyProcessedException::ERROR_MESSAGE) {
96
                    if ($this->extraConfig['PAGANTIS_URL_OK']!='') {
97
                        $confirmationUrl = $this->extraConfig['PAGANTIS_URL_OK'];
98
                        $confirmationUrl.="?order_id=$this->merchantOrderId";
99
                    } else {
100
                        $confirmationUrl = trim(tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, '', 'SSL', false));
0 ignored issues
show
Bug introduced by
The constant FILENAME_ACCOUNT_HISTORY_INFO was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
101
                        $confirmationUrl.="?order_id=$this->merchantOrderId";
102
                    }
103
104
                    header("Location: $confirmationUrl");
105
                    exit;
106
                }
107
108
                header("Location: $koUrl");
109
                exit;
110
            }
111
        }
112
    }
113
114
    public function confirmInformation()
115
    {
116
        try {
117
            $this->confirmPagantisOrder();
118
            $this->updateBdInfo();
119
            $jsonResponse = new JsonSuccessResponse();
120
            $jsonResponse->setMerchantOrderId($this->merchantOrderId);
121
            $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
122
            $this->unblockConcurrency($this->oscommerceOrderId);
123
        } catch (\Exception $exception) {
124
            $this->rollbackMerchantOrder();
125
            $this->unblockConcurrency($this->oscommerceOrderId);
126
            $jsonResponse = new JsonExceptionResponse();
127
            $jsonResponse->setMerchantOrderId($this->merchantOrderId);
128
            $jsonResponse->setPagantisOrderId($this->pagantisOrderId);
129
            $jsonResponse->setException($exception);
130
            $jsonResponse->toJson();
131
            $this->insertLog($exception);
132
        }
133
134
        if ($this->origin == 'notify') {
135
            $jsonResponse->printResponse();
136
        } else {
137
            return $jsonResponse;
138
        }
139
    }
140
141
    /**
142
     * COMMON FUNCTIONS
143
     */
144
145
    /**
146
     * @throws Exception
147
     */
148
    private function checkConcurrency()
149
    {
150
        $this->getQuoteId();
151
        $this->checkConcurrencyTable();
152
        $this->unblockConcurrency();
153
        $this->blockConcurrency();
154
    }
155
156
    /**
157
     * @throws MerchantOrderNotFoundException
158
     */
159
    private function getMerchantOrder()
160
    {
161
        global $order;
162
        $this->oscommerceOrder = $order;
163
        if (!isset($order->info)) {
164
            throw new MerchantOrderNotFoundException();
165
        }
166
    }
167
168
    /**
169
     * @throws NoIdentificationException
170
     */
171
    private function getPagantisOrderId()
172
    {
173
        $query = "select pagantis_order_id from ".TABLE_PAGANTIS_ORDERS." where os_order_reference='".$this->oscommerceOrderId."'";
174
        $resultsSelect = tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

174
        $resultsSelect = /** @scrutinizer ignore-call */ tep_db_query($query);
Loading history...
175
        while ($orderRow = tep_db_fetch_array($resultsSelect)) {
0 ignored issues
show
Bug introduced by
The function tep_db_fetch_array was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

175
        while ($orderRow = /** @scrutinizer ignore-call */ tep_db_fetch_array($resultsSelect)) {
Loading history...
176
            $this->pagantisOrderId = $orderRow['pagantis_order_id'];
177
        }
178
179
        if ($this->pagantisOrderId == '') {
180
            throw new NoIdentificationException();
181
        }
182
    }
183
184
    /**
185
     * @throws OrderNotFoundException
186
     */
187
    private function getPagantisOrder()
188
    {
189
        try {
190
            $publicKey     = trim(MODULE_PAYMENT_PAGANTIS_PK);
0 ignored issues
show
Bug introduced by
The constant MODULE_PAYMENT_PAGANTIS_PK was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
191
            $secretKey     = trim(MODULE_PAYMENT_PAGANTIS_SK);
0 ignored issues
show
Bug introduced by
The constant MODULE_PAYMENT_PAGANTIS_SK was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
192
            $this->orderClient   = new \Pagantis\OrdersApiClient\Client($publicKey, $secretKey);
193
            /** @var Pagantis\OrdersApiClient\Model\Order pagantisOrder */
194
            $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
195
        } catch (\Exception $e) {
196
            throw new OrderNotFoundException();
197
        }
198
    }
199
200
    /**
201
     * @throws AlreadyProcessedException
202
     * @throws WrongStatusException
203
     */
204
    private function checkOrderStatus()
205
    {
206
        try {
207
            $this->checkPagantisStatus(array('AUTHORIZED'));
208
        } catch (\Exception $e) {
209
            if ($this->findOscommerceOrderId()!='') {
210
                throw new AlreadyProcessedException();
211
            } else {
212
                if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
213
                    $status = $this->pagantisOrder->getStatus();
214
                } else {
215
                    $status = '-';
216
                }
217
                throw new WrongStatusException($status);
218
            }
219
        }
220
    }
221
222
    /**
223
     * @throws AlreadyProcessedException
224
     */
225
    private function checkMerchantOrderStatus()
226
    {
227
        global $order;
228
229
        if ($order->info['order_status']!=='1') {
230
            throw new AlreadyProcessedException();
231
        }
232
    }
233
234
    /**
235
     * @throws AmountMismatchException
236
     */
237
    private function validateAmount()
238
    {
239
        $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
240
        $ocAmount = intval($this->oscommerceOrder->info['total'] * 100);
241
242
        if ($pagantisAmount != $ocAmount) {
243
            throw new AmountMismatchException($pagantisAmount, $ocAmount);
244
        }
245
    }
246
247
    /**
248
     * @return false|string
249
     * @throws UnknownException
250
     */
251
    private function confirmPagantisOrder()
252
    {
253
        try {
254
            $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
255
        } catch (\Exception $e) {
256
            throw new UnknownException($e->getMessage());
257
        }
258
259
        $jsonResponse = new JsonSuccessResponse();
260
        return $jsonResponse->toJson();
261
    }
262
    /**
263
     * UTILS FUNCTIONS
264
     */
265
266
    /** STEP 1 CC - Check concurrency */
267
268
    /**
269
     * @throws QuoteNotFoundException
270
     */
271
    private function getQuoteId()
272
    {
273
        if ($this->oscommerceOrderId == "") {
274
            throw new QuoteNotFoundException();
275
        }
276
    }
277
278
    /**
279
     * Check if concurrency table exists
280
     */
281
    private function checkConcurrencyTable()
282
    {
283
        $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONCURRENCY."'");
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

283
        $checkTable = /** @scrutinizer ignore-call */ tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONCURRENCY."'");
Loading history...
284
        if (tep_db_num_rows($checkTable) == 0) {
0 ignored issues
show
Bug introduced by
The function tep_db_num_rows was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

284
        if (/** @scrutinizer ignore-call */ tep_db_num_rows($checkTable) == 0) {
Loading history...
285
            $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_CONCURRENCY." (
286
                            id int NOT NULL,
287
                            `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
288
                            UNIQUE KEY id(id))";
289
            tep_db_query($sql);
290
        }
291
        return;
292
    }
293
294
    /**
295
     * Unlock the concurrency
296
     *
297
     * @param null $orderId
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $orderId is correct as it would always require null to be passed?
Loading history...
298
     * @throws Exception
299
     */
300
    private function unblockConcurrency($orderId = null)
301
    {
302
        try {
303
            if ($orderId == null) {
0 ignored issues
show
introduced by
The condition $orderId == null is always true.
Loading history...
304
                $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where  timestamp<".(time() - 5);
305
                tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

305
                /** @scrutinizer ignore-call */ 
306
                tep_db_query($query);
Loading history...
306
            } elseif ($orderId!='') {
307
                $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where id='$orderId'";
308
                tep_db_query($query);
309
            }
310
        } catch (Exception $exception) {
311
            throw new ConcurrencyException();
312
        }
313
    }
314
315
    /**
316
     * @throws \Exception
317
     */
318
    private function blockConcurrency()
319
    {
320
        try {
321
            $query = "SELECT timestamp FROM ".TABLE_PAGANTIS_CONCURRENCY." where id='$this->oscommerceOrderId'";
322
            $resultsSelect = tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

322
            $resultsSelect = /** @scrutinizer ignore-call */ tep_db_query($query);
Loading history...
323
            $orderRow = tep_db_fetch_array($resultsSelect);
0 ignored issues
show
Bug introduced by
The function tep_db_fetch_array was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

323
            $orderRow = /** @scrutinizer ignore-call */ tep_db_fetch_array($resultsSelect);
Loading history...
324
325
            if (isset($orderRow['timestamp'])) {
326
                throw new ConcurrencyException();
327
            }
328
329
            $query = "INSERT INTO ".TABLE_PAGANTIS_CONCURRENCY." (id) VALUES ('$this->oscommerceOrderId')";
330
            tep_db_query($query);
331
332
        } catch (Exception $exception) {
333
            throw new ConcurrencyException();
334
        }
335
    }
336
337
    /** STEP 2 GMO - Get Merchant Order */
338
    /** STEP 3 GPOI - Get Pagantis OrderId */
339
    /** STEP 4 GPO - Get Pagantis Order */
340
    /** STEP 5 COS - Check Order Status */
341
    /**
342
     * @param $statusArray
343
     *
344
     * @throws \Exception
345
     */
346
    private function checkPagantisStatus($statusArray)
347
    {
348
        $pagantisStatus = array();
349
        foreach ($statusArray as $status) {
350
            $pagantisStatus[] = constant("\Pagantis\OrdersApiClient\Model\Order::STATUS_$status");
351
        }
352
353
        if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
354
            $payed = in_array($this->pagantisOrder->getStatus(), $pagantisStatus);
355
            if (!$payed) {
356
                if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
0 ignored issues
show
introduced by
$this->pagantisOrder is always a sub-type of Pagantis\OrdersApiClient\Model\Order.
Loading history...
357
                    $status = $this->pagantisOrder->getStatus();
358
                } else {
359
                    $status = '-';
360
                }
361
                throw new WrongStatusException($status);
362
            }
363
        } else {
364
            throw new OrderNotFoundException();
365
        }
366
    }
367
368
    /**
369
     * @return mixed
370
     */
371
    private function findOscommerceOrderId()
372
    {
373
        $query = "select os_order_id from ".TABLE_PAGANTIS_ORDERS." where os_order_reference='".$this->oscommerceOrderId."'";
374
        $resultsSelect = tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

374
        $resultsSelect = /** @scrutinizer ignore-call */ tep_db_query($query);
Loading history...
375
        $orderRow = tep_db_fetch_array($resultsSelect);
0 ignored issues
show
Bug introduced by
The function tep_db_fetch_array was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

375
        $orderRow = /** @scrutinizer ignore-call */ tep_db_fetch_array($resultsSelect);
Loading history...
376
        $this->merchantOrderId = $orderRow['os_order_id'];
0 ignored issues
show
Bug Best Practice introduced by
The property merchantOrderId does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
377
378
        return $orderRow['os_order_id'];
379
    }
380
381
    /** STEP 6 CMOS - Check Merchant Order Status */
382
    /** STEP 7 VA - Validate Amount */
383
    /** STEP 8 PMO - Process Merchant Order */
384
385
    /**
386
     * Save the order status with the related identification
387
     */
388
    private function updateBdInfo()
389
    {
390
        global $insert_id;
391
        $this->merchantOrderId = $insert_id;
0 ignored issues
show
Bug Best Practice introduced by
The property merchantOrderId does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
392
        $query = "update ".TABLE_PAGANTIS_ORDERS." set os_order_id='$insert_id' where os_order_reference='$this->oscommerceOrderId'";
393
        tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

393
        /** @scrutinizer ignore-call */ 
394
        tep_db_query($query);
Loading history...
394
395
        $metadataOrder = $this->pagantisOrder->getMetadata();
396
397
        $metadataInfo = '';
398
        foreach ($metadataOrder as $metadataKey => $metadataValue) {
399
            if ($metadataKey == 'promotedProduct') {
400
                $metadataInfo.= "/Producto promocionado = $metadataValue";
401
            }
402
        }
403
404
        $comment = "Pagantis id=$this->pagantisOrderId/Via=".ucfirst($this->origin)."/".$metadataInfo;
405
        $query = "insert into ".TABLE_ORDERS_STATUS_HISTORY ."(comments, orders_id, orders_status_id, customer_notified, date_added) values
0 ignored issues
show
Bug introduced by
The constant TABLE_ORDERS_STATUS_HISTORY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
406
            ('$comment', ".$insert_id.", '2', -1, now() )";
407
        tep_db_query($query);
408
409
        $query = "update ".TABLE_ORDERS." set orders_status='2' where orders_id='$insert_id'";
0 ignored issues
show
Bug introduced by
The constant TABLE_ORDERS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
410
        tep_db_query($query);
411
    }
412
413
    /** STEP 9 CPO - Confirmation Pagantis Order */
414
    private function rollbackMerchantOrder()
415
    {
416
        global $insert_id;
417
        $query = "update orders set orders_status='1' where orders_id='$insert_id' ";
418
        tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

418
        /** @scrutinizer ignore-call */ 
419
        tep_db_query($query);
Loading history...
419
420
        $query = "update ".TABLE_PAGANTIS_ORDERS." set os_order_id='' where os_order_reference='$this->oscommerceOrderId'";
421
        tep_db_query($query);
422
    }
423
424
    /**
425
     * @param $exception
426
     */
427
    private function insertLog($exception)
428
    {
429
        if ($exception instanceof \Exception) {
430
            $logEntry= new LogEntry();
431
            $logEntryJson = $logEntry->error($exception)->toJson();
432
433
            $query = "insert into ".TABLE_PAGANTIS_LOG."(log) values ('$logEntryJson')";
434
            tep_db_query($query);
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

434
            /** @scrutinizer ignore-call */ 
435
            tep_db_query($query);
Loading history...
435
        }
436
    }
437
438
    /**
439
     * @return array
440
     */
441
    private function getExtraConfig()
442
    {
443
        $checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'");
0 ignored issues
show
Bug introduced by
The function tep_db_query was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

443
        $checkTable = /** @scrutinizer ignore-call */ tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'");
Loading history...
444
        $response = array();
445
        if (tep_db_num_rows($checkTable) > 0) {
0 ignored issues
show
Bug introduced by
The function tep_db_num_rows was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

445
        if (/** @scrutinizer ignore-call */ tep_db_num_rows($checkTable) > 0) {
Loading history...
446
            $query       = "select * from ".TABLE_PAGANTIS_CONFIG;
447
            $result      = tep_db_query($query);
448
            $response    = array();
449
            while ($resultArray = tep_db_fetch_array($result)) {
0 ignored issues
show
Bug introduced by
The function tep_db_fetch_array was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

449
            while ($resultArray = /** @scrutinizer ignore-call */ tep_db_fetch_array($result)) {
Loading history...
450
                $response[$resultArray['config']] = $resultArray['value'];
451
            }
452
        }
453
454
        return $response;
455
    }
456
457
    /***
458
     * SETTERS Y GETTERS
459
     */
460
461
    /**
462
     * @return mixed
463
     */
464
    public function getOscommerceOrderId()
465
    {
466
        return $this->oscommerceOrderId;
467
    }
468
469
    /**
470
     * @param $oscommerceOrderId
471
     */
472
    public function setOscommerceOrderId($oscommerceOrderId)
473
    {
474
        $this->oscommerceOrderId = $oscommerceOrderId;
475
    }
476
477
    /**
478
     * @return mixed
479
     */
480
    public function getOrigin()
481
    {
482
        return $this->origin;
483
    }
484
485
    /**
486
     * @param mixed $origin
487
     */
488
    public function setOrigin($origin)
489
    {
490
        $this->origin = $origin;
491
    }
492
493
    /**
494
     * @return String
495
     */
496
    public function getOrderStatus()
497
    {
498
        return $this->orderStatus;
499
    }
500
501
    /**
502
     * @param String $orderStatus
503
     */
504
    public function setOrderStatus($orderStatus)
505
    {
506
        $this->orderStatus = $orderStatus;
0 ignored issues
show
Bug Best Practice introduced by
The property orderStatus does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
507
    }
508
}
509