1
1
<?php
2
2
namespace SatispayOnline ;
3
3
4
+ define ('SDKVERSION ' , '1.3.0 ' );
5
+
4
6
class Api {
5
7
public static $ securityBearer ;
6
8
public static $ urlStaging = 'https://staging.authservices.satispay.com ' ;
7
9
public static $ url = 'https://authservices.satispay.com ' ;
8
10
public static $ staging = false ;
11
+ public static $ client = null ;
9
12
10
13
public static function setSecurityBearer ($ securityBearer ) {
11
14
self ::$ securityBearer = $ securityBearer ;
@@ -19,6 +22,10 @@ public static function setStaging($staging) {
19
22
self ::$ staging = $ staging ;
20
23
}
21
24
25
+ public static function setClient ($ client ) {
26
+ self ::$ client = $ client ;
27
+ }
28
+
22
29
public static function request ($ url , $ method = null , $ params = null ) {
23
30
$ opts = [];
24
31
$ curl = curl_init ();
@@ -34,10 +41,15 @@ public static function request($url, $method = null, $params = null) {
34
41
$ opts [CURLOPT_URL ] = $ api .$ url ;
35
42
$ opts [CURLOPT_RETURNTRANSFER ] = true ;
36
43
37
- $ headers = [
44
+ $ headers = array (
38
45
'Authorization: Bearer ' .self ::$ securityBearer ,
39
- 'Content-Type: application/json '
40
- ];
46
+ 'Content-Type: application/json ' ,
47
+ 'X-Satispay-Client: ' .join (' ' , array (
48
+ self ::$ client ,
49
+ 'PHP/ ' .phpversion ()
50
+ )),
51
+ 'User-Agent: SatispayOnlineApi-PHPSDK/ ' .SDKVERSION
52
+ );
41
53
$ opts [CURLOPT_HTTPHEADER ] = $ headers ;
42
54
43
55
if ($ method == 'post ' ) {
@@ -67,10 +79,10 @@ public static function request($url, $method = null, $params = null) {
67
79
curl_close ($ curl );
68
80
}
69
81
70
- return [
82
+ return array (
71
83
'body ' => json_decode ($ rbody ),
72
84
'code ' => $ rcode ,
73
85
'error ' => $ error
74
- ] ;
86
+ ) ;
75
87
}
76
88
}
0 commit comments