@@ -109,7 +109,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
109109 {
110110 $ this ->beforeExecute ();
111111
112- $ this ->apiRequest ->setClientId ("sdk-php- " . \net \authorize \api \constants \ANetEnvironment::VERSION );
112+ $ this ->apiRequest ->setClientId ("sdk-php- " . \net \authorize \api \constants \ANetEnvironment::VERSION );
113113
114114 $ this ->logger ->info ("Request Creation Begin " );
115115 $ this ->logger ->debug ($ this ->apiRequest );
@@ -122,7 +122,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
122122 $ requestRoot = $ mapper ->getXmlName ((new \ReflectionClass ($ this ->apiRequest ))->getName ());
123123
124124 $ requestArray = [$ requestRoot => $ this ->apiRequest ];
125-
125+
126126 $ this ->logger ->info ("Request Creation End " );
127127
128128 $ this ->httpClient ->setPostUrl ( $ endPoint );
@@ -138,7 +138,15 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
138138 $ jsonResponse = $ this ->httpClient ->_sendRequest (json_encode ($ requestArray ));
139139 if ($ jsonResponse != null ){
140140 //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+ }
142150 $ this ->apiResponse = new $ this ->apiResponseType ();
143151 $ this ->apiResponse ->set ($ response );
144152 }
0 commit comments