diff --git a/Oara/Network/Publisher/AffiliNet.php b/Oara/Network/Publisher/AffiliNet.php index 18c2092b..ed289028 100755 --- a/Oara/Network/Publisher/AffiliNet.php +++ b/Oara/Network/Publisher/AffiliNet.php @@ -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 */ diff --git a/Oara/Network/Publisher/AutoEurope.php b/Oara/Network/Publisher/AutoEurope.php index 308fe091..f8628e6a 100755 --- a/Oara/Network/Publisher/AutoEurope.php +++ b/Oara/Network/Publisher/AutoEurope.php @@ -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'); diff --git a/Oara/Network/Publisher/ImpactRadius.php b/Oara/Network/Publisher/ImpactRadius.php index 47c4eeb2..c207838d 100644 --- a/Oara/Network/Publisher/ImpactRadius.php +++ b/Oara/Network/Publisher/ImpactRadius.php @@ -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) @@ -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 @@ -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"); diff --git a/Oara/Network/Publisher/LinkShare.php b/Oara/Network/Publisher/LinkShare.php index 8ae0df15..9dcdc6ff 100755 --- a/Oara/Network/Publisher/LinkShare.php +++ b/Oara/Network/Publisher/LinkShare.php @@ -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]; diff --git a/Oara/Network/Publisher/Smg.php b/Oara/Network/Publisher/Smg.php index 2450f196..e46563b9 100755 --- a/Oara/Network/Publisher/Smg.php +++ b/Oara/Network/Publisher/Smg.php @@ -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) @@ -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"); @@ -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)) { @@ -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; @@ -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"); diff --git a/Oara/Network/Publisher/TradeDoubler.php b/Oara/Network/Publisher/TradeDoubler.php index 1dc9e40b..83f70a55 100755 --- a/Oara/Network/Publisher/TradeDoubler.php +++ b/Oara/Network/Publisher/TradeDoubler.php @@ -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) { @@ -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; + } } } diff --git a/Oara/Network/Publisher/WebGains.php b/Oara/Network/Publisher/WebGains.php index 5bd9fb39..f149fae4 100755 --- a/Oara/Network/Publisher/WebGains.php +++ b/Oara/Network/Publisher/WebGains.php @@ -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; + } } } } diff --git a/composer.json b/composer.json index caef1626..3b403348 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "require": { "php": ">=5.3.0", "phpoffice/phpexcel": "1.8.*", - "ext-curl": "*" + "ext-curl": "*", + "zendframework/zend-dom": "*" }, "autoload": {