Skip to content

Commit 824a645

Browse files
committed
Handle no response scenario
1 parent c9cb4b2 commit 824a645

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
124124
$requestArray = [$requestRoot => $this->apiRequest];
125125

126126
$this->logger->info("Request Creation End");
127-
/*
128-
//$xmlRequest = '<?xml version="1.0" encoding="UTF-8"?> <ARBGetSubscriptionListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>4YJmeW7V77us</name> <transactionKey>4qHK9u63F753be4Z</transactionKey> </merchantAuthentication> <refId><![CDATA[ref1416999093]]></refId> <searchType><![CDATA[subscriptionActive]]></searchType> <sorting> <orderBy><![CDATA[firstName]]></orderBy> <orderDescending>false</orderDescending> </sorting> <paging> <limit>10</limit> <offset>1</offset> </paging> </ARBGetSubscriptionListRequest> ';
129-
*/
127+
130128
$this->httpClient->setPostUrl( $endPoint);
131129
/*$xmlResponse = $this->httpClient->_sendRequest($xmlRequest);
132130
if ( null == $xmlResponse)
@@ -138,11 +136,17 @@ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment
138136
$this->logger->info("Response De-Serialization End");*/
139137

140138
$jsonResponse = $this->httpClient->_sendRequest(json_encode($requestArray));
141-
//decoding json and removing bom
142-
$response = json_decode( substr($jsonResponse,3), true);
143-
$this->apiResponse = new $this->apiResponseType();
144-
$this->apiResponse->set($response);
145-
139+
if($jsonResponse != null){
140+
//decoding json and removing bom
141+
$response = json_decode( substr($jsonResponse,3), true);
142+
$this->apiResponse = new $this->apiResponseType();
143+
$this->apiResponse->set($response);
144+
}
145+
else {
146+
$this->logger->error("Error getting response from API");
147+
$this->apiResponse = null;
148+
}
149+
146150
$this->afterExecute();
147151
}
148152

0 commit comments

Comments
 (0)