diff --git a/src/Message/AIMAbstractRequest.php b/src/Message/AIMAbstractRequest.php index 8133b928..9a5bb5ae 100644 --- a/src/Message/AIMAbstractRequest.php +++ b/src/Message/AIMAbstractRequest.php @@ -276,8 +276,8 @@ protected function addReferenceId(\SimpleXMLElement $data) protected function addTransactionType(\SimpleXMLElement $data) { - if (!$this->action) { - // The extending class probably hasn't specified an "action" + if (! $this->action) { + // The extending class probably hasn't specified an "action". throw new InvalidRequestException(); } diff --git a/src/Message/Query/AIMAbstractQueryRequest.php b/src/Message/Query/AIMAbstractQueryRequest.php index 9f719070..e3ca2433 100644 --- a/src/Message/Query/AIMAbstractQueryRequest.php +++ b/src/Message/Query/AIMAbstractQueryRequest.php @@ -2,16 +2,26 @@ namespace Omnipay\AuthorizeNet\Message\Query; -use Omnipay\AuthorizeNet\Message\AIMAbstractRequest; - /** * Authorize.Net AIM Abstract Request */ + +use Omnipay\AuthorizeNet\Message\AIMAbstractRequest; +use SimpleXMLElement; + abstract class AIMAbstractQueryRequest extends AIMAbstractRequest { protected $limit = 1000; protected $offset = 1; + /** + * Disable validation check on the parent method. + */ + protected function addTransactionType(SimpleXMLElement $data) + { + // NOOP + } + /** * Get Limit. * diff --git a/src/Message/Query/QueryBatchRequest.php b/src/Message/Query/QueryBatchRequest.php index a15b64ae..d2a7e630 100644 --- a/src/Message/Query/QueryBatchRequest.php +++ b/src/Message/Query/QueryBatchRequest.php @@ -5,17 +5,26 @@ /** * Authorize.Net AIM Authorize Request */ + class QueryBatchRequest extends AIMAbstractQueryRequest { - protected $action = ''; protected $requestType = 'getSettledBatchListRequest'; public function sendData($data) { $headers = array('Content-Type' => 'text/xml; charset=utf-8'); $data = $data->saveXml(); - $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data); - return $this->response = new QueryBatchResponse($this, $httpResponse->getBody()->getContents()); + $httpResponse = $this->httpClient->request( + 'POST', + $this->getEndpoint(), + $headers, + $data + ); + + return $this->response = new QueryBatchResponse( + $this, + $httpResponse->getBody()->getContents() + ); } } diff --git a/src/Message/Query/QueryRequest.php b/src/Message/Query/QueryRequest.php index e0429563..1fe967bb 100644 --- a/src/Message/Query/QueryRequest.php +++ b/src/Message/Query/QueryRequest.php @@ -5,13 +5,16 @@ /** * Authorize.Net AIM Authorize Request */ + class QueryRequest extends QueryBatchRequest { + const DATE_TIME_FORMAT = 'Y-m-d\Th:i:s\Z'; + protected $startTimestamp; protected $endTimestamp; /** - * @return mixed + * @return int|null */ public function getStartTimestamp() { @@ -19,7 +22,7 @@ public function getStartTimestamp() } /** - * @param mixed $startTimestamp + * @param int|null $startTimestamp unix timestamp */ public function setStartTimestamp($startTimestamp) { @@ -27,7 +30,7 @@ public function setStartTimestamp($startTimestamp) } /** - * @return mixed + * @return int|null */ public function getEndTimestamp() { @@ -35,7 +38,7 @@ public function getEndTimestamp() } /** - * @param mixed $endTimestamp + * @param int|null $endTimestamp unix timestamp */ public function setEndTimestamp($endTimestamp) { @@ -48,13 +51,22 @@ public function setEndTimestamp($endTimestamp) public function getData() { $data = $this->getBaseData(); + if ($this->getStartTimestamp()) { - $data->firstSettlementDate = date('Y-m-d\Th:i:s\Z', $this->getStartTimestamp()); - $data->lastSettlementDate = date('Y-m-d\Th:i:s\Z'); + $data->firstSettlementDate = date( + static::DATE_TIME_FORMAT, + $this->getStartTimestamp() + ); + $data->lastSettlementDate = date(static::DATE_TIME_FORMAT); } + if ($this->getEndTimestamp()) { - $data->lastSettlementDate = date('Y-m-d\Th:i:s\Z', $this->getEndTimestamp()); + $data->lastSettlementDate = date( + static::DATE_TIME_FORMAT, + $this->getEndTimestamp() + ); } + return $data; } @@ -62,9 +74,19 @@ public function sendData($data) { $headers = array('Content-Type' => 'text/xml; charset=utf-8'); $data = $data->saveXml(); - $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data); - $this->response = new QueryResponse($this, $httpResponse->getBody()->getContents()); + $httpResponse = $this->httpClient->request( + 'POST', + $this->getEndpoint(), + $headers, + $data + ); + + $this->response = new QueryResponse( + $this, + $httpResponse->getBody()->getContents() + ); + return $this->response; } }