From 38399c352cdeb567157c003a3eeaa68350b962c7 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Tue, 2 Feb 2021 15:05:16 +0530 Subject: [PATCH 1/2] BOM character fix --- .../api/controller/base/ApiOperationBase.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/net/authorize/api/controller/base/ApiOperationBase.php b/lib/net/authorize/api/controller/base/ApiOperationBase.php index 6aa75588..bb62d688 100644 --- a/lib/net/authorize/api/controller/base/ApiOperationBase.php +++ b/lib/net/authorize/api/controller/base/ApiOperationBase.php @@ -109,7 +109,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment { $this->beforeExecute(); - $this->apiRequest->setClientId("sdk-php-" . \net\authorize\api\constants\ANetEnvironment::VERSION); + $this->apiRequest->setClientId("sdk-php-" . \net\authorize\api\constants\ANetEnvironment::VERSION); $this->logger->info("Request Creation Begin"); $this->logger->debug($this->apiRequest); @@ -122,7 +122,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment $requestRoot = $mapper->getXmlName((new \ReflectionClass($this->apiRequest))->getName()); $requestArray = [$requestRoot => $this->apiRequest]; - + $this->logger->info("Request Creation End"); $this->httpClient->setPostUrl( $endPoint); @@ -138,7 +138,15 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment $jsonResponse = $this->httpClient->_sendRequest(json_encode($requestArray)); if($jsonResponse != null){ //decoding json and removing bom - $response = json_decode( substr($jsonResponse,3), true); + $possibleBOM = substr($jsonResponse, 0, 3); + $utfBOM = pack("CCC", 0xef, 0xbb, 0xbf); + + if (0 === strncmp($possibleBOM, $utfBOM, 3)) { + $response = json_decode( substr($jsonResponse,3), true); + } + else { + $response = json_decode($jsonResponse, true); + } $this->apiResponse = new $this->apiResponseType(); $this->apiResponse->set($response); } From 8cc56b487ff0974ad61f19e16403478ba8fe7fc6 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Nongsiej Date: Thu, 4 Feb 2021 23:28:04 +0530 Subject: [PATCH 2/2] Upgrade to v2.0.1 --- README.md | 2 +- lib/net/authorize/api/constants/ANetEnvironment.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 304e7601..4160aaaa 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ override the new secure-http default setting)*. { "require": { "php": ">=5.6", - "authorizenet/authorizenet": "2.0.0" + "authorizenet/authorizenet": "2.0.1" } } ``` diff --git a/lib/net/authorize/api/constants/ANetEnvironment.php b/lib/net/authorize/api/constants/ANetEnvironment.php index 61d1aec0..4dcd85c8 100644 --- a/lib/net/authorize/api/constants/ANetEnvironment.php +++ b/lib/net/authorize/api/constants/ANetEnvironment.php @@ -7,5 +7,5 @@ class ANetEnvironment const SANDBOX = "https://apitest.authorize.net"; const PRODUCTION = "https://api2.authorize.net"; - const VERSION = "2.0.0"; + const VERSION = "2.0.1"; }