Skip to content

Commit

Permalink
Bit of formatting to aid readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Feb 6, 2019
1 parent aa43c8b commit 671c8de
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
13 changes: 11 additions & 2 deletions src/Message/Query/QueryBatchDetailRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/**
* Authorize.Net AIM Authorize Request
*/

class QueryBatchDetailRequest extends QueryBatchRequest
{
protected $action = '';
Expand All @@ -27,9 +28,17 @@ 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);
$httpResponse = $this->httpClient->request(
'POST',
$this->getEndpoint(),
$headers,
$data
);

return $this->response = new QueryBatchDetailResponse($this, $httpResponse->getBody()->getContents());
return $this->response = new QueryBatchDetailResponse(
$this,
$httpResponse->getBody()->getContents()
);
}

public function setBatchID($batchID)
Expand Down
8 changes: 6 additions & 2 deletions src/Message/Query/QueryBatchDetailResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
*/
class QueryBatchDetailResponse extends AbstractQueryResponse
{

public function __construct(AbstractRequest $request, $data)
{
// Strip out the xmlns junk so that PHP can parse the XML
$xml = preg_replace('/<getTransactionListRequest[^>]+>/', '<getTransactionListRequest>', (string)$data);
$xml = preg_replace(
'/<getTransactionListRequest[^>]+>/',
'<getTransactionListRequest>',
(string)$data
);

try {
$xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOWARNING);
} catch (\Exception $e) {
Expand Down
11 changes: 8 additions & 3 deletions src/Message/Query/QueryBatchResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
class QueryBatchResponse extends AbstractQueryResponse
{
/**
* For Error codes: @see https://developer.authorize.net/api/reference/responseCodes.html
* For Error codes: @see
* https://developer.authorize.net/api/reference/responseCodes.html
*/
const ERROR_RESPONSE_CODE_CANNOT_ISSUE_CREDIT = 54;

public function __construct(AbstractRequest $request, $data)
{
// Strip out the xmlns junk so that PHP can parse the XML
$xml = preg_replace('/<getSettledBatchListRequest[^>]+>/', '<getSettledBatchListRequest>', (string)$data);
// Strip out the xmlns junk so that PHP can parse the XML.
$xml = preg_replace(
'/<getSettledBatchListRequest[^>]+>/',
'<getSettledBatchListRequest>',
(string)$data
);

try {
$xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOWARNING);
Expand Down
14 changes: 12 additions & 2 deletions src/Message/Query/QueryResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,34 @@ public function getData()
{
$data = parent::getData();
$result = array();

/** @var \Omnipay\AuthorizeNet\AIMGateway $gateway */
$gateway = Omnipay::create('AuthorizeNet_AIM');

if (!empty($data)) {
foreach ($data as $batch) {
// CHECKME: can these settings be moved to outside the loop?
$gateway->setApiLoginId($this->request->getApiLoginId());
$gateway->setHashSecret($this->request->getHashSecret());
$gateway->setTransactionKey($this->request->getTransactionKey());
$gateway->setDeveloperMode($this->request->getDeveloperMode());

$data = array('batch_id' => $batch['batchId']);

$dataResponse = $gateway->queryBatchDetail($data)->send();
$transactions = $dataResponse->getData();

foreach ($transactions as $transaction) {
$detailResponse = $gateway->queryDetail(array('transactionReference' => $transaction['transId']))
->send();
$detailResponse = $gateway->queryDetail(array(
'transactionReference' => $transaction['transId']
))->send();

$result[] = $detailResponse;
}
}
}

return $result;
}
}

0 comments on commit 671c8de

Please sign in to comment.