@@ -109,7 +109,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
109
109
{
110
110
$ this ->beforeExecute ();
111
111
112
- $ this ->apiRequest ->setClientId ("sdk-php- " . \net \authorize \api \constants \ANetEnvironment::VERSION );
112
+ $ this ->apiRequest ->setClientId ("sdk-php- " . \net \authorize \api \constants \ANetEnvironment::VERSION );
113
113
114
114
$ this ->logger ->info ("Request Creation Begin " );
115
115
$ this ->logger ->debug ($ this ->apiRequest );
@@ -122,7 +122,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
122
122
$ requestRoot = $ mapper ->getXmlName ((new \ReflectionClass ($ this ->apiRequest ))->getName ());
123
123
124
124
$ requestArray = [$ requestRoot => $ this ->apiRequest ];
125
-
125
+
126
126
$ this ->logger ->info ("Request Creation End " );
127
127
128
128
$ this ->httpClient ->setPostUrl ( $ endPoint );
@@ -138,7 +138,15 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
138
138
$ jsonResponse = $ this ->httpClient ->_sendRequest (json_encode ($ requestArray ));
139
139
if ($ jsonResponse != null ){
140
140
//decoding json and removing bom
141
- $ response = json_decode ( substr ($ jsonResponse ,3 ), true );
141
+ $ possibleBOM = substr ($ jsonResponse , 0 , 3 );
142
+ $ utfBOM = pack ("CCC " , 0xef , 0xbb , 0xbf );
143
+
144
+ if (0 === strncmp ($ possibleBOM , $ utfBOM , 3 )) {
145
+ $ response = json_decode ( substr ($ jsonResponse ,3 ), true );
146
+ }
147
+ else {
148
+ $ response = json_decode ($ jsonResponse , true );
149
+ }
142
150
$ this ->apiResponse = new $ this ->apiResponseType ();
143
151
$ this ->apiResponse ->set ($ response );
144
152
}
0 commit comments