Issues (13)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/ClubKonnect.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace HenryEjemuta\LaravelClubKonnect;
4
5
use HenryEjemuta\LaravelClubKonnect\Classes\ClubKonnectResponse;
6
use HenryEjemuta\LaravelClubKonnect\Enums\NetworkEnum;
7
use Illuminate\Support\Facades\Http;
8
9
class ClubKonnect
10
{
11
    /**
12
     * base url
13
     *
14
     * @var string
15
     */
16
    private $baseUrl;
17
18
    /**
19
     * the session key
20
     *
21
     * @var string
22
     */
23
    protected $instanceName;
24
25
    protected $config;
26
27
    public function __construct($baseUrl, $instanceName, $config)
28
    {
29
        $this->baseUrl = $baseUrl;
30
        $this->instanceName = $instanceName;
31
        $this->config = $config;
32
    }
33
34
    /**
35
     * get instance name of the cart
36
     *
37
     * @return string
38
     */
39
    public function getInstanceName()
40
    {
41
        return $this->instanceName;
42
    }
43
44
    /**
45
     * @param string $endpoint
46
     * @param array $params
47
     * @return ClubKonnectResponse
48
     */
49
    public function withAuth(string $endpoint, array $params = []): ClubKonnectResponse
50
    {
51
        $params['UserID'] = $this->config['user_id'];
52
        $params['APIKey'] = urldecode($this->config['api_key']);
53
        $response = Http::get("{$this->baseUrl}$endpoint", $params);
54
        $responseObject = json_decode($response->body());
55
56
        if ($response->getStatusCode() == 200)
0 ignored issues
show
The method getStatusCode() does not exist on Illuminate\Http\Client\Response. Did you maybe mean status()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
57
            return new ClubKonnectResponse($responseObject);
58
        return new ClubKonnectResponse();
59
    }
60
61
    /**
62
     * Check your Server IP
63
     * @return ClubKonnectResponse
64
     */
65
    public function checkYourServerIP(): ClubKonnectResponse
66
    {
67
        return $this->withAuth('APIServerIPV1.asp');
68
    }
69
70
    /**
71
     * Get Your wallet available balance, Wallet is identified by username set in clubkonnect config or environmental variable
72
     * @return ClubKonnectResponse
73
     */
74
    public function getWalletBalance(): ClubKonnectResponse
75
    {
76
        return $this->withAuth('APIWalletBalanceV1.asp');
77
    }
78
79
    /**
80
     * @param NetworkEnum $mobileNetwork
81
     * @param int $amount
82
     * @param $phoneNumber
83
     * @param $requestID
84
     * @param $callbackUrl
85
     * @return ClubKonnectResponse
86
     */
87 View Code Duplication
    public function purchaseAirtime(NetworkEnum $mobileNetwork, int $amount, $phoneNumber, $requestID, $callbackUrl): ClubKonnectResponse
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
88
    {
89
        return $this->withAuth('APIAirtimeV1.asp', [
90
            'MobileNetwork' => $mobileNetwork->getCode(),
91
            'Amount' => $amount,
92
            'MobileNumber' => $phoneNumber,
93
            'RequestID' => $requestID,
94
            'CallBackURL' => $callbackUrl
95
        ]);
96
    }
97
98
    private $transaction;
99
100
    /**
101
     * ClubKonnect API Transaction handler to access:
102
     * CableTv()->queryByOrderID(string $orderID);
103
     * CableTv()->queryByRequestID(string $requestID);
104
     * CableTv()->cancelTransaction(string $orderID);
105
     *
106
     * @return Transaction
107
     */
108
    public function Transaction(): Transaction
109
    {
110
        if (is_null($this->transaction))
111
            $this->transaction = new class($this) extends Transaction {
112
            };
113
        return $this->transaction;
114
    }
115
116
    private $smile;
117
118
    /**
119
     * Smile Bill handler to access:
120
     * CableTv()->getDataBundles();
121
     * CableTv()->verifySmileAccountID($phoneNumber);
122
     * CableTv()->purchaseBundle(string $plan, string $phoneNumber, $requestID, $callbackUrl = null);
123
     *
124
     * @return Smile
125
     */
126
    public function Smile(): Smile
127
    {
128
        if (is_null($this->smile))
129
            $this->smile = new class($this, $this->config) extends Smile {
130
            };
131
        return $this->smile;
132
    }
133
134
    private $cableTv;
135
136
    /**
137
     * Cable TV Bill handler to access:
138
     * CableTv()->getTvPackages();
139
     * CableTv()->verifyCustomerID(CableTvEnum $cableTv, $smartCardNo);
140
     * CableTv()->purchasePackage(CableTvEnum $cableTv, string $package, $smartCardNo, $requestID, $callbackUrl = null);
141
     *
142
     * @return CableTv
143
     */
144
    public function CableTv(): CableTv
145
    {
146
        if (is_null($this->cableTv))
147
            $this->cableTv = new class($this, $this->config) extends CableTv {
148
            };
149
        return $this->cableTv;
150
    }
151
152
    private $rechargeCardPrinting;
153
154
    /**
155
     * Recharge Card Printing handler to access:
156
     * RechargeCardPrinting()->getEPinNetworks();
157
     * RechargeCardPrinting()->buyEPins(NetworkEnum $network, $amount, int $quantity, $requestID, $callbackUrl = null);
158
     *
159
     * @return RechargeCardPrinting
160
     */
161
    public function RechargeCardPrinting(): RechargeCardPrinting
162
    {
163
        if (is_null($this->rechargeCardPrinting))
164
            $this->rechargeCardPrinting = new class($this, $this->config) extends RechargeCardPrinting {
165
            };
166
        return $this->rechargeCardPrinting;
167
    }
168
169
170
    /**
171
     * Get all Data Bundles
172
     * @return ClubKonnectResponse
173
     */
174
    public function getDataBundles(): ClubKonnectResponse
175
    {
176
        return $this->withAuth('APIDatabundlePlansV1.asp', []);
177
    }
178
179
180
    /**
181
     * @param NetworkEnum $network
182
     * @param string $plan
183
     * @param string $phoneNumber
184
     * @param $requestID
185
     * @param $callbackUrl
186
     * @return ClubKonnectResponse
187
     */
188 View Code Duplication
    public function purchaseDataBundle(NetworkEnum $network, string $plan, string $phoneNumber, $requestID, $callbackUrl): ClubKonnectResponse
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
189
    {
190
        return $this->withAuth('APIDatabundleV1.asp', [
191
            'MobileNetwork' => $network->getCode(),
192
            'DataPlan' => $plan,
193
            'MobileNumber' => $phoneNumber,
194
            'RequestID' => $requestID,
195
            'CallBackURL' => $callbackUrl
196
        ]);
197
    }
198
199
200
    private $electricity;
201
202
    /**
203
     * Electricity Bills payment handler to access:
204
     * Electricity()->getDiscosAndMinMax();
205
     * Electricity()->verifyMeterNumber(DiscoEnum $disco, $meterNumber): ClubKonnectResponse
206
     * Electricity()->buyElectricity(DiscoEnum $disco, $meterNumber, $amount, MeterTypeEnum $meterType, $requestID, $callbackUrl = null): ClubKonnectResponse
207
     *
208
     * @return Electricity
209
     */
210
    public function Electricity(): Electricity
211
    {
212
        if (is_null($this->electricity))
213
            $this->electricity = new class($this, $this->config) extends Electricity {
214
            };
215
        return $this->electricity;
216
    }
217
}
218