Passed
Pull Request — master (#4)
by
unknown
08:12 queued 02:55
created

notifyController::getPagantisOrderId()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
nc 4
nop 0
dl 0
loc 10
rs 10
c 1
b 0
f 0
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_catalog_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...
Bug introduced by
The function tep_catalog_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

100
                        $confirmationUrl = trim(/** @scrutinizer ignore-call */ tep_catalog_href_link(FILENAME_ACCOUNT_HISTORY_INFO, '', 'SSL', false));
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
            $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);
194
        } catch (\Exception $e) {
195
            throw new OrderNotFoundException();
196
        }
197
    }
198
199
    /**
200
     * @throws AlreadyProcessedException
201
     * @throws WrongStatusException
202
     */
203
    private function checkOrderStatus()
204
    {
205
        try {
206
            $this->checkPagantisStatus(array('AUTHORIZED'));
207
        } catch (\Exception $e) {
208
            if ($this->findOscommerceOrderId()!='') {
209
                throw new AlreadyProcessedException();
210
            } else {
211
                if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
212
                    $status = $this->pagantisOrder->getStatus();
213
                } else {
214
                    $status = '-';
215
                }
216
                throw new WrongStatusException($status);
217
            }
218
        }
219
    }
220
221
    /**
222
     * @throws AlreadyProcessedException
223
     */
224
    private function checkMerchantOrderStatus()
225
    {
226
        global $order;
227
228
        if ($order->info['order_status']!=='1') {
229
            throw new AlreadyProcessedException();
230
        }
231
    }
232
233
    /**
234
     * @throws AmountMismatchException
235
     */
236
    private function validateAmount()
237
    {
238
        $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();
239
        $ocAmount = intval($this->oscommerceOrder->info['total'] * 100);
240
241
        if ($pagantisAmount != $ocAmount) {
242
            throw new AmountMismatchException($pagantisAmount, $ocAmount);
243
        }
244
    }
245
246
    /**
247
     * @return false|string
248
     * @throws UnknownException
249
     */
250
    private function confirmPagantisOrder()
251
    {
252
        try {
253
            $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);
254
        } catch (\Exception $e) {
255
            throw new UnknownException($e->getMessage());
256
        }
257
258
        $jsonResponse = new JsonSuccessResponse();
259
        return $jsonResponse->toJson();
260
    }
261
    /**
262
     * UTILS FUNCTIONS
263
     */
264
265
    /** STEP 1 CC - Check concurrency */
266
267
    /**
268
     * @throws QuoteNotFoundException
269
     */
270
    private function getQuoteId()
271
    {
272
        if ($this->oscommerceOrderId == "") {
273
            throw new QuoteNotFoundException();
274
        }
275
    }
276
277
    /**
278
     * Check if concurrency table exists
279
     */
280
    private function checkConcurrencyTable()
281
    {
282
        $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

282
        $checkTable = /** @scrutinizer ignore-call */ tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONCURRENCY."'");
Loading history...
283
        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

283
        if (/** @scrutinizer ignore-call */ tep_db_num_rows($checkTable) == 0) {
Loading history...
284
            $sql = "CREATE TABLE IF NOT EXISTS ".TABLE_PAGANTIS_CONCURRENCY." (
285
                            id int NOT NULL,
286
                            `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
287
                            UNIQUE KEY id(id))";
288
            tep_db_query($sql);
289
        }
290
        return;
291
    }
292
293
    /**
294
     * Unlock the concurrency
295
     *
296
     * @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...
297
     * @throws Exception
298
     */
299
    private function unblockConcurrency($orderId = null)
300
    {
301
        try {
302
            if ($orderId == null) {
0 ignored issues
show
introduced by
The condition $orderId == null is always true.
Loading history...
303
                $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where  timestamp<".(time() - 5);
304
                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

304
                /** @scrutinizer ignore-call */ 
305
                tep_db_query($query);
Loading history...
305
            } elseif ($orderId!='') {
306
                $query = "delete from ".TABLE_PAGANTIS_CONCURRENCY." where id='$orderId'";
307
                tep_db_query($query);
308
            }
309
        } catch (Exception $exception) {
310
            throw new ConcurrencyException();
311
        }
312
    }
313
314
    /**
315
     * @throws \Exception
316
     */
317
    private function blockConcurrency()
318
    {
319
        try {
320
            $query = "SELECT timestamp FROM ".TABLE_PAGANTIS_CONCURRENCY." where id='$this->oscommerceOrderId'";
321
            $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

321
            $resultsSelect = /** @scrutinizer ignore-call */ tep_db_query($query);
Loading history...
322
            $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

322
            $orderRow = /** @scrutinizer ignore-call */ tep_db_fetch_array($resultsSelect);
Loading history...
323
324
            if (isset($orderRow['timestamp'])) {
325
                throw new ConcurrencyException();
326
            }
327
328
            $query = "INSERT INTO ".TABLE_PAGANTIS_CONCURRENCY." (id) VALUES ('$this->oscommerceOrderId')";
329
            tep_db_query($query);
330
331
        } catch (Exception $exception) {
332
            throw new ConcurrencyException();
333
        }
334
    }
335
336
    /** STEP 2 GMO - Get Merchant Order */
337
    /** STEP 3 GPOI - Get Pagantis OrderId */
338
    /** STEP 4 GPO - Get Pagantis Order */
339
    /** STEP 5 COS - Check Order Status */
340
    /**
341
     * @param $statusArray
342
     *
343
     * @throws \Exception
344
     */
345
    private function checkPagantisStatus($statusArray)
346
    {
347
        $pagantisStatus = array();
348
        foreach ($statusArray as $status) {
349
            $pagantisStatus[] = constant("\Pagantis\OrdersApiClient\Model\Order::STATUS_$status");
350
        }
351
352
        if ($this->pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
353
            $payed = in_array($this->pagantisOrder->getStatus(), $pagantisStatus);
354
            if (!$payed) {
355
                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...
356
                    $status = $this->pagantisOrder->getStatus();
357
                } else {
358
                    $status = '-';
359
                }
360
                throw new WrongStatusException($status);
361
            }
362
        } else {
363
            throw new OrderNotFoundException();
364
        }
365
    }
366
367
    /**
368
     * @return mixed
369
     */
370
    private function findOscommerceOrderId()
371
    {
372
        $query = "select os_order_id from ".TABLE_PAGANTIS_ORDERS." where os_order_reference='".$this->oscommerceOrderId."'";
373
        $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

373
        $resultsSelect = /** @scrutinizer ignore-call */ tep_db_query($query);
Loading history...
374
        $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

374
        $orderRow = /** @scrutinizer ignore-call */ tep_db_fetch_array($resultsSelect);
Loading history...
375
        $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...
376
377
        return $orderRow['os_order_id'];
378
    }
379
380
    /** STEP 6 CMOS - Check Merchant Order Status */
381
    /** STEP 7 VA - Validate Amount */
382
    /** STEP 8 PMO - Process Merchant Order */
383
384
    /**
385
     * Save the order status with the related identification
386
     */
387
    private function updateBdInfo()
388
    {
389
        global $insert_id;
390
        $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...
391
        $query = "update ".TABLE_PAGANTIS_ORDERS." set os_order_id='$insert_id' where os_order_reference='$this->oscommerceOrderId'";
392
        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

392
        /** @scrutinizer ignore-call */ 
393
        tep_db_query($query);
Loading history...
393
394
        $comment = "Pagantis id=$this->pagantisOrderId/Via=".ucfirst($this->origin);
395
        $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...
396
            ('$comment', ".$insert_id.", '2', -1, now() )";
397
        tep_db_query($query);
398
399
        $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...
400
        tep_db_query($query);
401
    }
402
403
    /** STEP 9 CPO - Confirmation Pagantis Order */
404
    private function rollbackMerchantOrder()
405
    {
406
        global $insert_id;
407
        $query = "update orders set orders_status='1' where orders_id='$insert_id' ";
408
        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

408
        /** @scrutinizer ignore-call */ 
409
        tep_db_query($query);
Loading history...
409
410
        $query = "update ".TABLE_PAGANTIS_ORDERS." set os_order_id='' where os_order_reference='$this->oscommerceOrderId'";
411
        tep_db_query($query);
412
    }
413
414
    /**
415
     * @param $exception
416
     */
417
    private function insertLog($exception)
418
    {
419
        if ($exception instanceof \Exception) {
420
            $logEntry= new LogEntry();
421
            $logEntryJson = $logEntry->error($exception)->toJson();
422
423
            $query = "insert into ".TABLE_PAGANTIS_LOG."(log) values ('$logEntryJson')";
424
            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

424
            /** @scrutinizer ignore-call */ 
425
            tep_db_query($query);
Loading history...
425
        }
426
    }
427
428
    /***
429
     * SETTERS Y GETTERS
430
     */
431
432
    /**
433
     * @return mixed
434
     */
435
    public function getOscommerceOrderId()
436
    {
437
        return $this->oscommerceOrderId;
438
    }
439
440
    /**
441
     * @param $oscommerceOrderId
442
     */
443
    public function setOscommerceOrderId($oscommerceOrderId)
444
    {
445
        $this->oscommerceOrderId = $oscommerceOrderId;
446
    }
447
448
    /**
449
     * @return mixed
450
     */
451
    public function getOrigin()
452
    {
453
        return $this->origin;
454
    }
455
456
    /**
457
     * @param mixed $origin
458
     */
459
    public function setOrigin($origin)
460
    {
461
        $this->origin = $origin;
462
    }
463
464
    /**
465
     * @return String
466
     */
467
    public function getOrderStatus()
468
    {
469
        return $this->orderStatus;
470
    }
471
472
    /**
473
     * @param String $orderStatus
474
     */
475
    public function setOrderStatus($orderStatus)
476
    {
477
        $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...
478
    }
479
480
    /**
481
     * @return array
482
     */
483
    private function getExtraConfig()
484
    {
485
        $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

485
        $checkTable = /** @scrutinizer ignore-call */ tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'");
Loading history...
486
        $response = array();
487
        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

487
        if (/** @scrutinizer ignore-call */ tep_db_num_rows($checkTable) > 0) {
Loading history...
488
            $query       = "select * from ".TABLE_PAGANTIS_CONFIG;
489
            $result      = tep_db_query($query);
490
            $response    = array();
491
            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

491
            while ($resultArray = /** @scrutinizer ignore-call */ tep_db_fetch_array($result)) {
Loading history...
492
                $response[$resultArray['config']] = $resultArray['value'];
493
            }
494
        }
495
496
        return $response;
497
    }}
498