Order   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 66
rs 10
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createMerchantOrder() 0 29 3
A getOrderStatus() 0 23 4
1
<?php
2
3
namespace bSecure\Payments\Models;
4
5
use bSecure\Payments\Models\Merchant;
6
use bSecure\Payments\Helpers\Helper;
7
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Model 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...
8
9
class Order extends Model
10
{
11
    /**
12
     * Author: Sara Hasan
13
     * Date: 10-November-2020
14
     */
15
    public static function createMerchantOrder($orderPayload)
16
    {
17
        try {
18
19
            $order_response = Helper::createPaymentPluginOrder($orderPayload);
20
            if ($order_response['error']) {
21
                return ['error' => true, 'message' => $order_response['body']['message'], 'exception' => $order_response['body']['exception']];
22
            } else {
23
                return $order_response;
24
            }
25
            /*
26
            $merchantToken = Merchant::getMerchantAccessToken();
27
28
            if ($merchantToken['error']) {
29
                return ['error' => true, 'message' => $merchantToken['message']];
30
            } else {
31
                $merchantAccessToken = $merchantToken['body'];
32
                // Call Create Order API
33
                $order_response = Helper::createOrder($merchantAccessToken, $orderPayload);
34
35
                if ($order_response['error']) {
36
                    return ['error' => true, 'message' => $order_response['body']['message'], 'exception' => $order_response['body']['exception']];
37
                } else {
38
                    return $order_response;
39
                }
40
            }
41
            */
42
        } catch (\Exception $e) {
43
            return ['error' => true, 'message' => trans('bSecurePayments::messages.order.failure'), 'exception' => $e->getTraceAsString()];
0 ignored issues
show
Bug introduced by
The function trans 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

43
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecurePayments::messages.order.failure'), 'exception' => $e->getTraceAsString()];
Loading history...
44
        }
45
    }
46
47
48
    /**
49
     * Author: Sara Hasan
50
     * Date: 10-November-2020
51
     */
52
    public static function getOrderStatus($order_ref)
53
    {
54
        try {
55
            $merchantToken = Merchant::getMerchantAccessToken();
56
57
            if ($merchantToken['error']) {
58
                return ['error' => true, 'message' => $merchantToken['message']];
59
            } else {
60
                $merchantAccessToken = $merchantToken['body'];
61
                // Call Order Status Update API
62
63
                $payload = ['order_ref' => $order_ref];
64
65
                $order_response = Helper::orderStatus($merchantAccessToken, $payload);
66
67
                if ($order_response['error']) {
68
                    return ['error' => true, 'message' => $order_response['body']['message']];
69
                } else {
70
                    return $order_response;
71
                }
72
            }
73
        } catch (\Exception $e) {
74
            return ['error' => true, 'message' => trans('bSecurePayments::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
0 ignored issues
show
Bug introduced by
The function trans 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

74
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecurePayments::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
Loading history...
75
        }
76
    }
77
}
78