|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace bSecure\Payments\Helpers; |
|
4
|
|
|
|
|
5
|
|
|
class Http |
|
6
|
|
|
{ |
|
7
|
|
|
static $RequestHeaders = [ |
|
8
|
|
|
'locale' => 'x-locale', |
|
9
|
|
|
'currency' => 'x-currency', |
|
10
|
|
|
'deviceType' => 'x-device-type', |
|
11
|
|
|
'osVersion' => 'x-os-version', |
|
12
|
|
|
'appVersion' => 'x-app-version', |
|
13
|
|
|
'accessToken' => 'x-access-token' |
|
14
|
|
|
]; |
|
15
|
|
|
|
|
16
|
|
|
static $CurlContentTypes = [ |
|
17
|
|
|
'JSON' => 'Application/json', |
|
18
|
|
|
'MultiPartFormData' => 'Multipart/form-data' |
|
19
|
|
|
]; |
|
20
|
|
|
|
|
21
|
|
|
//in case of successful create, read, update, delete & any successful operation |
|
22
|
|
|
const SUCCESS = "success"; |
|
23
|
|
|
|
|
24
|
|
|
//in case of operational or process failure |
|
25
|
|
|
const BAD_REQUEST = "bad_request"; |
|
26
|
|
|
|
|
27
|
|
|
//in case of authentication failure, trying to access any protected route with expired or no API token |
|
28
|
|
|
const UNAUTHORISED = "unauthorised"; |
|
29
|
|
|
|
|
30
|
|
|
//in case of validation failure |
|
31
|
|
|
const INPROCESSABLE = "inprocessable"; |
|
32
|
|
|
|
|
33
|
|
|
static $Codes = [ |
|
34
|
|
|
self::SUCCESS => 200, |
|
35
|
|
|
self::BAD_REQUEST => 400, |
|
36
|
|
|
self::UNAUTHORISED => 401, |
|
37
|
|
|
self::INPROCESSABLE => 422 |
|
38
|
|
|
]; |
|
39
|
|
|
|
|
40
|
|
|
public static function getApiPossibleCodes() |
|
41
|
|
|
{ |
|
42
|
|
|
return array_values(self::$Codes); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public static function getIpDetails($ip) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
return [ |
|
48
|
|
|
'country_name' => 'Pakistan' |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
$accessKey = env('IPSTACK_API_KEY'); |
|
|
|
|
|
|
52
|
|
|
$url = env('IPSTACK_URL') . $ip . '?access_key=' . $accessKey; |
|
53
|
|
|
return Helper::apiRequest('GET', $url); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.