Skip to content

Commit

Permalink
Merge pull request #3 from slawn/master
Browse files Browse the repository at this point in the history
Various fixed
  • Loading branch information
PaoloNardini authored Oct 15, 2018
2 parents 8e8d60f + 8747f45 commit 45a2509
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 36 deletions.
69 changes: 69 additions & 0 deletions Oara/Network/Publisher/AffiliNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,75 @@ public function getPaymentHistory()
return $paymentHistory;
}

public function paymentTransactions($paymentId) {

$payments = $this->getPaymentHistory();
$dEndDate = '';
$dStartDate = '';
foreach ($payments as $index => $payment) {
if ($payment['pid'] == $paymentId) {
$dEndDate = new \DateTime(date("Y-m-d H:i:s", strtotime($payment['date'])));
$dStartDate = new \DateTime(date("Y-m-d H:i:s", strtotime($payments[$index + 1]['date']) + 60 * 60 * 24));
break;
}
}

$totalTransactions = array();

$publisherStatisticsServiceUrl = 'https://api.affili.net/V2.0/PublisherStatistics.svc?wsdl';
$publisherStatisticsService = new \SoapClient($publisherStatisticsServiceUrl, array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE, 'soap_version' => SOAP_1_1));

$params = array(
'StartDate' => \strtotime($dStartDate->format("Y-m-d")),
'EndDate' => \strtotime($dEndDate->format("Y-m-d")),
'TransactionStatus' => 'Confirmed',
'SubId' => '',
'ProgramTypes' => 'All',
'ValuationType' => 'DateOfConfirmation',
'MaximumRecords' => '1000',
);

$currentPage = 1;
$transactionList = self::affilinetCall('transaction', $publisherStatisticsService, $params, 0, $currentPage);

while (isset($transactionList->TotalRecords) && $transactionList->TotalRecords > 0 && isset($transactionList->TransactionCollection->Transaction)) {
$transactionCollection = array();
if (!\is_array($transactionList->TransactionCollection->Transaction)) {
$transactionCollection[] = $transactionList->TransactionCollection->Transaction;
} else {
$transactionCollection = $transactionList->TransactionCollection->Transaction;
}

foreach ($transactionCollection as $transactionObject){

$transaction = array();
$transaction["status"] = $transactionObject->TransactionStatus;
$transaction["unique_id"] = $transactionObject->TransactionId;
$transaction["commission"] = $transactionObject->PublisherCommission;
$transaction["amount"] = $transactionObject->NetPrice;
$dateString = \explode (".", $transactionObject->RegistrationDate);
$transactionDate = \DateTime::createFromFormat("Y-m-d\TH:i:s", $dateString[0]);
$transaction["date"] = $transactionDate->format("Y-m-d H:i:s");
$transaction["merchantId"] = $transactionObject->ProgramId;
$transaction["custom_id"] = $transactionObject->SubId;
if ($transaction['status'] == 'Confirmed') {
$transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
} else
if ($transaction['status'] == 'Open') {
$transaction['status'] = \Oara\Utilities::STATUS_PENDING;
} else
if ($transaction['status'] == 'Cancelled') {
$transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
}
$totalTransactions[] = $transaction;
}
$currentPage++;
$transactionList = self::affilinetCall('transaction', $publisherStatisticsService, $params, 0, $currentPage);
}

return $totalTransactions;
}

/**
* Call to the API controlling the exception and Login
*/
Expand Down
4 changes: 2 additions & 2 deletions Oara/Network/Publisher/AutoEurope.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public function getTransactionList($merchantList = null, \DateTime $dStartDate =
public function readTransactions($htmlReport)
{
$pdfContent = '';
$dom = new \Zend_Dom_Query ($htmlReport);
$links = $dom->query('.text a');
$dom = new \Zend\Dom\Query($htmlReport);
$links = $dom->execute('.text a');
$pdfUrl = null;
foreach ($links as $link) {
$pdfUrl = $link->getAttribute('href');
Expand Down
6 changes: 3 additions & 3 deletions Oara/Network/Publisher/ImpactRadius.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function login($credentials)

$user = $this->_credentials['user'];
$password = $this->_credentials['password'];
$loginUrl = 'https://member.impactradius.co.uk/secure/login.user';
$loginUrl = 'https://app.impact.com/secure/login.user';

$valuesLogin = array(new \Oara\Curl\Parameter('j_username', $user),
new \Oara\Curl\Parameter('j_password', $password)
Expand All @@ -62,7 +62,7 @@ public function login($credentials)

// Open Technical Settings page
$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
$apiPageHTML = $this->_client->get($urls);

// Parse page content
Expand Down Expand Up @@ -341,7 +341,7 @@ public function getPaymentHistory()
$paymentHistory = array();

$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/nositemesh/accounting/getPayStubParamsCSV.csv', array());
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/nositemesh/accounting/getPayStubParamsCSV.csv', array());
$exportReport = $this->_client->get($urls);
$exportData = \str_getcsv($exportReport[0], "\n");

Expand Down
2 changes: 1 addition & 1 deletion Oara/Network/Publisher/LinkShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function getTransactionList($merchantList = null, \DateTime $dStartDate =
for ($j = 1; $j < $num; $j++) {
$transactionData = \str_getcsv($exportData [$j], ",");

if (count($transactionData) > 10 && (count($merchantIdList)==0 || isset($merchantIdList[$transactionData [1]]))) {
if (count($transactionData) > 10 && (count($merchantIdList)==0 || isset($merchantIdList[$transactionData [3]]))) {
$transaction = Array();
$transaction['merchantId'] = ( int )$transactionData[3];
$transaction['merchantName'] = $transactionData[4];
Expand Down
27 changes: 14 additions & 13 deletions Oara/Network/Publisher/Smg.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function login($credentials)

$user = $this->_credentials['user'];
$password = $this->_credentials['password'];
$loginUrl = 'https://member.impactradius.co.uk/secure/login.user';
$loginUrl = 'https://app.impact.com/secure/login.user';

$valuesLogin = array(new \Oara\Curl\Parameter('j_username', $user),
new \Oara\Curl\Parameter('j_password', $password)
Expand All @@ -61,23 +61,23 @@ public function login($credentials)


$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
$exportReport = $this->_client->get($urls);
$dom = new \Zend_Dom_Query($exportReport[0]);
$results = $dom->query('div .uitkFields');
$dom = new \Zend\Dom\Query($exportReport[0]);
$results = $dom->execute('div .uitkFields');
$count = \count($results);
if ($count == 0) {

$activeAPI = array(new \Oara\Curl\Parameter('_eventId', "activate"));
$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', $activeAPI);
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', $activeAPI);
$this->_client->post($urls);

$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
$exportReport = $this->_client->get($urls);
$dom = new \Zend_Dom_Query($exportReport[0]);
$results = $dom->query('div .uitkFields');
$dom = new \Zend\Dom\Query($exportReport[0]);
$results = $dom->execute('div .uitkFields');
$count = \count($results); // get number of matches: 4
if ($count == 0) {
throw new \Exception ("No API credentials");
Expand Down Expand Up @@ -126,7 +126,7 @@ public function checkConnection()

//Checking connection for the impact Radius website
$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/mediapartner/home/pview.ihtml', array());
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/mediapartner/home/pview.ihtml', array());
$exportReport = $this->_client->get($urls);
$newCheck = false;
if (\preg_match('/\/logOut\.user/', $exportReport[0], $match)) {
Expand Down Expand Up @@ -229,16 +229,17 @@ public function getTransactionList($merchantList = null, \DateTime $dStartDate =
$transaction['custom_id'] = (string)$action->SubId1;
}

$status = (string)$action->Status;
$status = (string)$action->State;
$statusArray[$status] = "";
if ($status == 'APPROVED' || $status == 'DEFAULT') {
$transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
} else
if ($status == 'REJECTED') {
} else {
if ($status == 'REVERSED' || $status == 'REJECTED') {
$transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
} else {
$transaction['status'] = \Oara\Utilities::STATUS_PENDING;
}
}

$transaction['amount'] = (double)$action->Amount;
$transaction['commission'] = (double)$action->Payout;
Expand All @@ -265,7 +266,7 @@ public function getPaymentHistory()
$paymentHistory = array();

$urls = array();
$urls[] = new \Oara\Curl\Request('https://member.impactradius.co.uk/secure/nositemesh/accounting/getPayStubParamsCSV.csv', array());
$urls[] = new \Oara\Curl\Request('https://app.impact.com/secure/nositemesh/accounting/getPayStubParamsCSV.csv', array());
$exportReport = $this->_client->get($urls);
$exportData = \str_getcsv($exportReport[0], "\n");

Expand Down
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
12 changes: 7 additions & 5 deletions Oara/Network/Publisher/WebGains.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ private function getCampaignMap($html)
$results = $xpath->query('//select[@name="campaignswitchid"]');
$merchantLines = $results->item(0)->childNodes;
for ($i = 0; $i < $merchantLines->length; $i++) {
$cid = $merchantLines->item($i)->attributes->getNamedItem("value")->nodeValue;
$name = $merchantLines->item($i)->nodeValue;
if (\count($this->_sitesAllowed) == 0 || \in_array($name, $this->_sitesAllowed)) {
if (\is_numeric($cid)) {
$campaingMap[$cid] = $merchantLines->item($i)->nodeValue;
if(count($merchantLines->item($i)->attributes) > 0){
$cid = $merchantLines->item($i)->attributes->getNamedItem("value")->nodeValue;
$name = $merchantLines->item($i)->nodeValue;
if (\count($this->_sitesAllowed) == 0 || \in_array($name, $this->_sitesAllowed)) {
if (\is_numeric($cid)) {
$campaingMap[$cid] = $merchantLines->item($i)->nodeValue;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"require": {
"php": ">=5.3.0",
"phpoffice/phpexcel": "1.8.*",
"ext-curl": "*"
"ext-curl": "*",
"zendframework/zend-dom": "*"
},

"autoload": {
Expand Down

0 comments on commit 45a2509

Please sign in to comment.