Skip to content

Commit 23de64e

Browse files
authored
Merge pull request #406 from AuthorizeNet/022021-hotfix
Hotfix for BOM character issue
2 parents cba5827 + 8cc56b4 commit 23de64e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ override the new secure-http default setting)*.
5656
{
5757
"require": {
5858
"php": ">=5.6",
59-
"authorizenet/authorizenet": "2.0.0"
59+
"authorizenet/authorizenet": "2.0.1"
6060
}
6161
}
6262
```

lib/net/authorize/api/constants/ANetEnvironment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ class ANetEnvironment
77
const SANDBOX = "https://apitest.authorize.net";
88
const PRODUCTION = "https://api2.authorize.net";
99

10-
const VERSION = "2.0.0";
10+
const VERSION = "2.0.1";
1111
}

lib/net/authorize/api/controller/base/ApiOperationBase.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)