Skip to content

Commit

Permalink
TradeDoubler paymentTransactions()
Browse files Browse the repository at this point in the history
Update paymentTransactions to return full transactions not just IDs
  • Loading branch information
slaweknaczynski committed Oct 15, 2018
1 parent 7037861 commit 8747f45
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions Oara/Network/Publisher/TradeDoubler.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,8 @@ public function paymentTransactions($paymentId)
$exportReport = $this->_client->get($urls);


$doc = new \DOMDocument();
@$doc->loadHTML(\Oara\Utilities::DOMinnerHTML($exportReport[0]));
$xpath = new \DOMXPath($doc);
$results = $xpath->query('//a');
$dom = new \Zend\Dom\Query($exportReport[0]);
$results = $dom->execute('//a');

$urls = array();
foreach ($results as $result) {
Expand All @@ -656,15 +654,45 @@ public function paymentTransactions($paymentId)
$exportReportData = \str_getcsv($exportReport, "\r\n");
$num = \count($exportReportData);
for ($i = 2; $i < $num - 1; $i++) {
$transactionArray = \str_getcsv($exportReportData[$i], ";");
if ($transactionArray[8] != '') {
$transactionList[] = $transactionArray[8];
} else
if ($transactionArray[7] != '') {
$transactionList[] = $transactionArray[7];
$transactionExportArray = \str_getcsv($exportReportData[$i], ";");
if (\count($this->_sitesAllowed) == 0 || \in_array($transactionExportArray[2], $this->_sitesAllowed)) {
$transaction = Array();
$transaction['merchantId'] = $transactionExportArray[2];
$transactionDate = self::toDate($transactionExportArray[6]);
$transaction['date'] = $transactionDate->format("Y-m-d H:i:s");
if ($transactionExportArray[8] != '') {
$transaction['unique_id'] = \substr($transactionExportArray[8], 0, 200);
} else
if ($transactionExportArray[7] != '') {
$transaction['unique_id'] = \substr($transactionExportArray[7], 0, 200);
} else {
throw new \Exception("No Identifier");
}


if ($transactionExportArray[9] != '') {
$transaction['custom_id'] = $transactionExportArray[9];
}

if ($transactionExportArray[11] == 'A') {
$transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
} else
if ($transactionExportArray[11] == 'P') {
$transaction['status'] = \Oara\Utilities::STATUS_PENDING;
} else
if ($transactionExportArray[11] == 'D') {
$transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
}

if ($transactionExportArray[13] != '') {
$transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[13]);
} else {
throw new \Exception("No Identifier");
$transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[14]);
}

$transaction['commission'] = \Oara\Utilities::parseDouble($transactionExportArray[15]);
$transactionList[] = $transaction;
}
}
}

Expand Down

0 comments on commit 8747f45

Please sign in to comment.