Exemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $xmlLocation = "https://api.m4n.nl/restful/csv/affiliate/leads/clickTime/from/" . $dStartDate->toString("yyyyMMdd") . "/to/" . $dEndDate->toString("yyyyMMdd") . "";
     $transactionData = self::returnApiData($xmlLocation);
     $exportData = str_getcsv($transactionData, "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ";");
         if (in_array((int) $transactionExportArray[3], $merchantList)) {
             $transaction = array();
             $merchantId = (int) $transactionExportArray[3];
             $transaction['merchantId'] = $merchantId;
             $transaction['unique_id'] = $transactionExportArray[0];
             $date = $transactionExportArray[10];
             if ($transactionExportArray[10] == "null") {
                 $date = $transactionExportArray[9];
             }
             $transactionDate = new Zend_Date($date, 'yyyy-MM-dd HH:mm:ss');
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             if ($transactionExportArray[2] == 'ACCEPTED') {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[2] == 'ON_HOLD' || $transactionExportArray[2] == 'TO_BE_APPROVED' || $transactionExportArray[2] == 'BLOCKED') {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if ($transactionExportArray[2] == 'REJECTED') {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     } else {
                         throw new Exception("New status {$transactionExportArray['2']}");
                     }
                 }
             }
             $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[12]);
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[4]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 2
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($idMerchant, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $returnResult = self::makeCall("transactiondetail", "&dateStart=" . $dStartDate->toString("MM/dd/yyyy") . "&dateEnd=" . $dEndDate->toString("MM/dd/yyyy"));
     $exportData = str_getcsv($returnResult, "\r\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], "|");
         if (in_array((int) $transactionExportArray[1], $merchantList)) {
             $transaction = array();
             $merchantId = (int) $transactionExportArray[1];
             $transaction['merchantId'] = $merchantId;
             $transactionDate = new Zend_Date($transactionExportArray[2], 'MM-dd-yyyy HH:mm:ss');
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['unique_id'] = (int) $transactionExportArray[0];
             if ($transactionExportArray[27] != null) {
                 $transaction['custom_id'] = $transactionExportArray[27];
             }
             if ($transactionExportArray[8] != null) {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[9] != null) {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if ($transactionExportArray[7] != null) {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     } else {
                         $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                     }
                 }
             }
             $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[3]);
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[4]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 3
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory($currentPage = 1)
 {
     $paymentHistory = array();
     $pdfToTextPath = '';
     if (PHP_OS == "WIN32" || PHP_OS == "WINNT") {
         return $paymentHistory;
     } else {
         // some other platform
         $pdfToTextPath = 'pdftotext ';
     }
     $params = array();
     if ($currentPage != 1) {
         $urls = array();
         $urls[] = new Oara_Curl_Request($this->_serverUrl . '/Invoices/Default.aspx?', $params);
         $exportReport = $this->_client->post($urls);
         $doc = new DOMDocument();
         libxml_use_internal_errors(true);
         $doc->validateOnParse = true;
         $doc->loadHTML($exportReport[0]);
         $viewState = $doc->getElementById('__VIEWSTATE')->attributes->getNamedItem("value")->nodeValue;
         $params = array(new Oara_Curl_Parameter('__EVENTTARGET', 'ctl00$ContentPlaceHolder1$gvInvoices'), new Oara_Curl_Parameter('__EVENTARGUMENT', 'Page$' . $currentPage), new Oara_Curl_Parameter('__VIEWSTATE', $viewState));
     }
     $urls = array();
     $urls[] = new Oara_Curl_Request($this->_serverUrl . '/Invoices/Default.aspx?', $params);
     $exportReport = $this->_client->post($urls);
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $registerTable = $doc->getElementById('ctl00_ContentPlaceHolder1_gvInvoices');
     if ($registerTable !== null) {
         $registerLines = $registerTable->childNodes;
         $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
         $pagesNumber = 1;
         for ($i = 2; $i < $registerLines->length; $i++) {
             $registerLineClass = $registerLines->item($i)->attributes->getNamedItem("class")->nodeValue;
             if ($registerLineClass == 'pager') {
                 $lenght = $registerLines->item($i)->childNodes->item(0)->childNodes->item(0)->childNodes->item(0)->childNodes->length;
                 $pagesNumber = $registerLines->item($i)->childNodes->item(0)->childNodes->item(0)->childNodes->item(0)->childNodes->item($lenght - 2)->nodeValue;
             } else {
                 $registerLine = $registerLines->item($i)->childNodes;
                 $obj = array();
                 //get the pdf
                 $parameters = array();
                 $parameters[] = new Oara_Curl_Parameter('id', $registerLine->item(0)->nodeValue);
                 $urls = array();
                 $urls[] = new Oara_Curl_Request($this->_serverUrl . 'Invoices/ViewInvoice.aspx?', $parameters);
                 $exportReport = $this->_client->get($urls);
                 $exportReportUrl = $this->_client->get($urls, 'url');
                 $exportReportUrl = explode('/', $exportReportUrl[0]);
                 $exportReportUrl = $exportReportUrl[count($exportReportUrl) - 1];
                 $dir = realpath(dirname(__FILE__)) . '/../../data/pdf/';
                 //writing temp pdf
                 $fh = fopen($dir . $exportReportUrl, 'w') or die("can't open file");
                 fwrite($fh, $exportReport[0]);
                 fclose($fh);
                 //parsing the pdf
                 $pipes = null;
                 $pdfReader = proc_open($pdfToTextPath . $dir . $exportReportUrl . ' -', $descriptorspec, $pipes, null, null);
                 if (is_resource($pdfReader)) {
                     $pdfContent = '';
                     $error = '';
                     $stdin = $pipes[0];
                     $stdout = $pipes[1];
                     $stderr = $pipes[2];
                     while (!feof($stdout)) {
                         $pdfContent .= fgets($stdout);
                     }
                     while (!feof($stderr)) {
                         $error .= fgets($stderr);
                     }
                     fclose($stdin);
                     fclose($stdout);
                     fclose($stderr);
                     $exit_code = proc_close($pdfReader);
                 }
                 if (preg_match_all("/[0-9]*,?[0-9]*\\.[0-9]+/", $pdfContent, $matches)) {
                     $obj['value'] = Oara_Utilities::parseDouble($matches[0][count($matches[0]) - 1]);
                 } else {
                     throw new Exception('Problem getting value in payments');
                 }
                 unlink($dir . $exportReportUrl);
                 $date = new Zend_Date($registerLine->item(3)->nodeValue, "dd/MMM/yyyy", 'en_US');
                 $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                 $obj['pid'] = $registerLine->item(0)->nodeValue;
                 $obj['method'] = 'BACS';
                 $paymentHistory[] = $obj;
             }
         }
         if ($currentPage == 1) {
             for ($i = 2; $i <= $pagesNumber; $i++) {
                 $paymentHistory = array_merge($paymentHistory, self::getPaymentHistory($i));
             }
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 4
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2));
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://affiliates.wehkamp.nl/pan/reportSelection/Payment?', array());
     $exportReport = $this->_client->get($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $selectList = $doc->getElementsByTagName('select');
     $paymentSelect = null;
     if ($selectList->length > 0) {
         // looking for the payments select
         $it = 0;
         while ($it < $selectList->length) {
             $selectName = $selectList->item($it)->attributes->getNamedItem('name')->nodeValue;
             if ($selectName == 'payment_id') {
                 $paymentSelect = $selectList->item($it);
                 break;
             }
             $it++;
         }
         if ($paymentSelect != null) {
             $paymentLines = $paymentSelect->childNodes;
             for ($i = 0; $i < $paymentLines->length; $i++) {
                 $pid = $paymentLines->item($i)->attributes->getNamedItem("value")->nodeValue;
                 if (is_numeric($pid)) {
                     $obj = array();
                     $paymentLine = $paymentLines->item($i)->nodeValue;
                     $value = preg_replace("/[^0-9\\.,]/", "", substr($paymentLine, 10));
                     $date = self::toDate(substr($paymentLine, 0, 10));
                     $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                     $obj['pid'] = $pid;
                     $obj['method'] = 'BACS';
                     $obj['value'] = Oara_Utilities::parseDouble($value);
                     $paymentHistory[] = $obj;
                 }
             }
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 5
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $valuesFromExport = $this->_exportPaymentParameters;
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://admin.omgpm.com/v2/finance/affiliate/view_payments.aspx?', array());
     $exportReport = $this->_client->get($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $hiddenList = $doc->getElementsByTagName('input');
     for ($i = 0; $i < $hiddenList->length; $i++) {
         $attrs = $hiddenList->item($i)->attributes;
         if ($attrs->getNamedItem("type")->nodeValue == 'hidden') {
             //we are adding the hidden parameters
             $valuesFromExport[] = new Oara_Curl_Parameter($attrs->getNamedItem("name")->nodeValue, $attrs->getNamedItem("value")->nodeValue);
         }
     }
     $yearSelect = $doc->getElementById('ctl00_ContentPlaceHolder1_ddlYear')->childNodes;
     $yearStart = (int) $yearSelect->item($yearSelect->length - 1)->attributes->getNamedItem("value")->nodeValue;
     $nowDays = new Zend_Date();
     $yearEnd = (int) $nowDays->get(Zend_Date::YEAR);
     $urls = array();
     for ($i = $yearStart; $i <= $yearEnd; $i++) {
         $requestValuesFromExport = Oara_Utilities::cloneArray($valuesFromExport);
         $requestValuesFromExport[] = new Oara_Curl_Parameter('ctl00$ContentPlaceHolder1$ddlYear', (string) $i);
         $urls[] = new Oara_Curl_Request('https://admin.omgpm.com/v2/finance/affiliate/view_payments.aspx?', $requestValuesFromExport);
     }
     $exportReport = $this->_client->post($urls);
     for ($i = 0; $i < count($exportReport); $i++) {
         if (!preg_match("/No Results for this criteria/i", $exportReport[$i])) {
             $doc = new DOMDocument();
             libxml_use_internal_errors(true);
             $doc->validateOnParse = true;
             $doc->loadHTML($exportReport[$i]);
             $table = $doc->getElementById('ctl00_ContentPlaceHolder1_gvSummary');
             $paymentList = $table->childNodes;
             for ($j = 1; $j < $paymentList->length; $j++) {
                 $paymentData = $paymentList->item($j)->childNodes;
                 $obj = array();
                 $obj['value'] = Oara_Utilities::parseDouble($paymentData->item(5)->nodeValue);
                 if ($obj['value'] != null) {
                     $date = new Zend_date($paymentData->item(8)->nodeValue, "dd/MM/yyyy HH:mm:ss");
                     $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                     $obj['pid'] = $paymentData->item(2)->nodeValue;
                     $ass = $paymentData->item(5)->nodeValue;
                     $obj['method'] = 'BACS';
                     $paymentHistory[] = $obj;
                 }
             }
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 6
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://www.tradedoubler.com/pan/reportSelection/Payment?', array());
     $exportReport = $this->_client->get($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $selectList = $doc->getElementsByTagName('select');
     $paymentSelect = null;
     if ($selectList->length > 0) {
         // looking for the payments select
         $it = 0;
         while ($it < $selectList->length) {
             $selectName = $selectList->item($it)->attributes->getNamedItem('name')->nodeValue;
             if ($selectName == 'payment_id') {
                 $paymentSelect = $selectList->item($it);
                 break;
             }
             $it++;
         }
         if ($paymentSelect != null) {
             $paymentLines = $paymentSelect->childNodes;
             for ($i = 0; $i < $paymentLines->length; $i++) {
                 $pid = $paymentLines->item($i)->attributes->getNamedItem("value")->nodeValue;
                 if (is_numeric($pid)) {
                     $obj = array();
                     $paymentLine = $paymentLines->item($i)->nodeValue;
                     $paymentLine = htmlentities($paymentLine);
                     $paymentLine = str_replace("&Acirc;&nbsp;", "", $paymentLine);
                     $paymentLine = html_entity_decode($paymentLine);
                     if ($this->_dateFormat == 'dd/MM/yy') {
                         $date = new Zend_Date(substr($paymentLine, 0, 10), "dd/MM/yy");
                     } else {
                         if ($this->_dateFormat == 'M/d/yy') {
                             $date = new Zend_Date(substr($paymentLine, 0, 10), "M/d/yy");
                         } else {
                             if ($this->_dateFormat == 'd/MM/yy') {
                                 $date = new Zend_Date(substr($paymentLine, 0, 10), "d/MM/yy");
                             } else {
                                 if ($this->_dateFormat == 'tt.MM.uu') {
                                     $date = new Zend_Date(substr($paymentLine, 0, 10), "dd.MM.yy");
                                 } else {
                                     throw new Exception("\n Date Format not supported " . $this->_dateFormat . "\n");
                                 }
                             }
                         }
                     }
                     $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                     $obj['pid'] = $pid;
                     $obj['method'] = 'BACS';
                     if (preg_match("/[-+]?[0-9]*,?[0-9]*\\.?[0-9]+/", substr($paymentLine, 10), $matches)) {
                         $obj['value'] = Oara_Utilities::parseDouble($matches[0]);
                     } else {
                         throw new Exception("Problem reading payments");
                     }
                     $paymentHistory[] = $obj;
                 }
             }
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 7
0
 /**
  * @param null $merchantList
  * @param Zend_Date|null $dStartDate
  * @param Zend_Date|null $dEndDate
  * @param null $merchantMap
  * @return array
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFromExport = array(new Oara_Curl_Parameter('payment[from]', $dStartDate->toString("MM/dd/yyyy")), new Oara_Curl_Parameter('payment[to]', $dEndDate->toString("MM/dd/yyyy")));
     $rch = curl_init();
     $options = $this->_options;
     $arg = array();
     foreach ($valuesFromExport as $parameter) {
         $arg[] = $parameter->getKey() . '=' . urlencode($parameter->getValue());
     }
     $url = 'http://affiliates.shuttlefare.com/partners/payments/report.csv?' . implode('&', $arg);
     curl_setopt($rch, CURLOPT_URL, $url);
     curl_setopt_array($rch, $options);
     $html = curl_exec($rch);
     curl_close($rch);
     if (!preg_match("/No transaction in given date range/", $html) && $html) {
         $exportData = explode("\n", $html);
         $num = count($exportData);
         for ($i = 0; $i < $num - 1; $i++) {
             $transactionExportArray = explode(",", $exportData[$i]);
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transaction['unique_id'] = $transactionExportArray[0];
             $transactionDate = new Zend_Date($transactionExportArray[7], 'MM/dd/yyyy');
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $transactionExportArray[2]));
             $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $transactionExportArray[3]));
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 8
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $stringToFind = $dStartDate->toString("MMMM yyyy");
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/partner/my/payments', array());
     $exportReport = $this->_client->get($urls);
     /*** load the html into the object ***/
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('#navigation > table');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
     $num = count($exportData);
     for ($i = 1; $i < $num - 1; $i++) {
         $transactionArray = str_getcsv($exportData[$i], ";");
         if ($transactionArray[0] == $stringToFind) {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['date'] = $dEndDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionArray[2]));
             $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionArray[2]));
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 9
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://www.webgains.com/affiliates/payment.html', array());
     $exportReport = $this->_webClient->get($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $tableList = $doc->getElementsByTagName('table');
     $i = 0;
     $enc = false;
     while ($i < $tableList->length && !$enc) {
         $registerTable = $tableList->item($i);
         if ($registerTable->getAttribute('class') == 'withgrid') {
             $enc = true;
         }
         $i++;
     }
     if (!$enc) {
         throw new Exception('Fail getting the payment History');
     }
     $registerLines = $registerTable->childNodes;
     for ($i = 2; $i < $registerLines->length; $i++) {
         $obj = array();
         $linkList = $registerLines->item($i)->getElementsByTagName('a');
         $url = $linkList->item(1)->attributes->getNamedItem("href")->nodeValue;
         $parseUrl = parse_url(trim($url));
         $parameters = explode('&', $parseUrl['query']);
         foreach ($parameters as $parameter) {
             $parameterValue = explode('=', $parameter);
             if ($parameterValue[0] == 'payment') {
                 $obj['pid'] = $parameterValue[1];
             }
         }
         $registerLine = $registerLines->item($i)->childNodes;
         $date = new Zend_Date($registerLine->item(0)->nodeValue, "dd/MM/yy");
         $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
         $value = $registerLine->item(2)->nodeValue;
         preg_match('/[0-9]+(,[0-9]{3})*(\\.[0-9]{2})?$/', $value, $matches);
         $obj['value'] = Oara_Utilities::parseDouble($matches[0]);
         $obj['method'] = $registerLine->item(6)->nodeValue;
         $paymentHistory[] = $obj;
     }
     return $paymentHistory;
 }
Exemplo n.º 10
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $startDate = $dStartDate->toString('dd/MM/yyyy');
     $endDate = $dEndDate->toString('dd/MM/yyyy');
     $valueIndex = 9;
     $commissionIndex = 16;
     $statusIndex = 17;
     if ($this->_serverUrl == "https://mats.brandconversions.com/") {
         $valueIndex = 11;
         $commissionIndex = 17;
         $statusIndex = 18;
     }
     $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
     //$valuesFormExport[] = new Oara_Curl_Parameter('merchant', '0');
     $valuesFormExport[] = new Oara_Curl_Parameter('datefrom', $startDate);
     $valuesFormExport[] = new Oara_Curl_Parameter('dateto', $endDate);
     $urls = array();
     $urls[] = new Oara_Curl_Request($this->_serverUrl . 'reports/remote.aspx?', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $exportData = str_getcsv($exportReport[0], "\r\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (in_array((int) $transactionExportArray[4], $merchantList)) {
             $transaction = array();
             $transaction['unique_id'] = $transactionExportArray[0];
             $transaction['merchantId'] = $transactionExportArray[4];
             $transactionDate = new Zend_Date($transactionExportArray[2], "dd/MM/YY HH:mm:ss");
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             if ($transactionExportArray[7] != null) {
                 $transaction['custom_id'] = $transactionExportArray[7];
             }
             if (preg_match('/Unpaid Confirmed/', $transactionExportArray[$statusIndex]) || preg_match('/Paid Confirmed/', $transactionExportArray[$statusIndex])) {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if (preg_match('/Unpaid Unconfirmed/', $transactionExportArray[$statusIndex])) {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if (preg_match('/Unpaid Rejected/', $transactionExportArray[$statusIndex])) {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     } else {
                         throw new Exception("No Status supported " . $transactionExportArray[$statusIndex]);
                     }
                 }
             }
             $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[$valueIndex]);
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[$commissionIndex]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 11
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $today = new Zend_Date();
     $today->setHour(0);
     $today->setMinute(0);
     $urls = array();
     $exportParams = array(new Oara_Curl_Parameter('data[query][agent]', $this->_agent), new Oara_Curl_Parameter('data[query][date1]', $dStartDate->toString("yyyy-MM-dd")), new Oara_Curl_Parameter('data[query][date2]', $dEndDate->toString("yyyy-MM-dd")), new Oara_Curl_Parameter('data[query][api_key]', $this->_apiKey));
     $urls[] = new Oara_Curl_Request('http://www.skyparksecure.com/api/v4/jsonp/getSales?', $exportParams);
     $exportReport = $this->_client->get($urls);
     $report = substr($exportReport[0], 1, strlen($exportReport[0]) - 3);
     $exportData = json_decode($report);
     foreach ($exportData->result as $booking) {
         $transaction = array();
         $transaction['merchantId'] = 1;
         $transaction['unique_id'] = $booking->booking_ref;
         $transaction['metadata'] = $booking->product_name;
         $transaction['custom_id'] = $booking->custom_id;
         $transactionDate = new Zend_Date($booking->booking_date, 'yyyy.MMM.dd HH:mm:00', 'en');
         $pickupDate = new Zend_Date($booking->dateA, 'yyyy.MMM.dd HH:mm:00', 'en');
         $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
         $transaction['metadata'] = $booking->product_id;
         if ($booking->booking_mode == "Booked" || $booking->booking_mode == "Amended") {
             $transaction['status'] = Oara_Utilities::STATUS_PENDING;
             if ($today > $pickupDate) {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             }
         } else {
             if ($booking->booking_mode == "Cancelled") {
                 $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
             } else {
                 throw new Exception("New status found");
             }
         }
         $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $booking->sale_price)) / 1.2;
         $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $booking->commission_affiliate)) / 1.2;
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
Exemplo n.º 12
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $url = 'http://api.effiliation.com/apiv2/transaction.csv?key=' . $this->_credentials["apiPassword"] . '&start=' . $dStartDate->toString("dd/MM/yyyy") . '&end=' . $dEndDate->toString("dd/MM/yyyy") . '&type=date';
     $content = utf8_encode(file_get_contents($url));
     $exportData = str_getcsv($content, "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], "|");
         if (in_array((int) $transactionExportArray[2], $merchantList)) {
             /*
             $numFields = 0;
             foreach ($transactionExportArray as $fieldValue){
             	if ($fieldValue == "Valide" || $fieldValue == "Attente" || $fieldValue == "Refusé"){
             		break;
             	}
             	$numFields ++;
             }
             */
             $transaction = array();
             $merchantId = (int) $transactionExportArray[2];
             $transaction['merchantId'] = $merchantId;
             $transaction['date'] = $transactionExportArray[10];
             $transaction['unique_id'] = $transactionExportArray[0];
             if ($transactionExportArray[15] != null) {
                 $transaction['custom_id'] = $transactionExportArray[15];
             }
             if ($transactionExportArray[9] == 'Valide') {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[9] == 'Attente') {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if ($transactionExportArray[9] == 'Refusé') {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     }
                 }
             }
             $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[7]);
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[8]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 13
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate)
  */
 public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null)
 {
     $overviewArray = array();
     $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList);
     $mothOverviewUrls = array();
     $dateArray = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate);
     $dateArraySize = sizeof($dateArray);
     for ($i = 0; $i < $dateArraySize; $i++) {
         $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
         $valuesFormExport[] = new Oara_Curl_Parameter('datefrom', $dateArray[$i]->toString("yyyy-MM-dd"));
         $valuesFormExport[] = new Oara_Curl_Parameter('dateto', $dateArray[$i]->toString("yyyy-MM-dd"));
         $mothUrls[] = new Oara_Curl_Request('https://accounts.skimlinks.com/reports_export.php?', $valuesFormExport);
     }
     $exportReport = $this->_client->get($mothUrls);
     $exportReportNumber = count($exportReport);
     for ($i = 0; $i < $exportReportNumber; $i++) {
         $exportData = str_getcsv($exportReport[$i], "\n");
         $num = count($exportData);
         for ($j = 1; $j < $num - 5; $j++) {
             $overviewExportArray = str_getcsv($exportData[$j], ",");
             if (Oara_Utilities::parseDouble($overviewExportArray[2]) != 0 && isset($this->_merchantMap[$overviewExportArray[0]]) && in_array($this->_merchantMap[$overviewExportArray[0]], $merchantList)) {
                 $overview = array();
                 $overview['merchantId'] = $this->_merchantMap[$overviewExportArray[0]];
                 $overviewDate = new Zend_Date($mothUrls[$i]->getParameter(5)->getValue(), 'yyyy-MM-dd', 'en');
                 $overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss");
                 $overview['click_number'] = (int) $overviewExportArray[1];
                 $overview['impression_number'] = 0;
                 $overview['transaction_number'] = 0;
                 $overview['transaction_confirmed_value'] = 0;
                 $overview['transaction_confirmed_commission'] = 0;
                 $overview['transaction_pending_value'] = 0;
                 $overview['transaction_pending_commission'] = 0;
                 $overview['transaction_declined_value'] = 0;
                 $overview['transaction_declined_commission'] = 0;
                 $transactionDateArray = Oara_Utilities::getDayFromArray($overview['merchantId'], $transactionArray, $overviewDate);
                 foreach ($transactionDateArray as $transaction) {
                     $overview['transaction_number']++;
                     if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) {
                         $overview['transaction_confirmed_value'] += $transaction['amount'];
                         $overview['transaction_confirmed_commission'] += $transaction['commission'];
                     } else {
                         if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) {
                             $overview['transaction_pending_value'] += $transaction['amount'];
                             $overview['transaction_pending_commission'] += $transaction['commission'];
                         } else {
                             if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) {
                                 $overview['transaction_declined_value'] += $transaction['amount'];
                                 $overview['transaction_declined_commission'] += $transaction['commission'];
                             }
                         }
                     }
                 }
                 if (Oara_Utilities::checkRegister($overview)) {
                     $overviewArray[] = $overview;
                 }
             }
         }
     }
     return $overviewArray;
 }
Exemplo n.º 14
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request("https://publisher.ebaypartnernetwork.com/PublisherReportsTx?pt=2&start_date={$dStartDate->toSTring("M/d/yyyy")}&end_date={$dEndDate->toSTring("M/d/yyyy")}&user_name={$this->_credentials['user']}&user_password={$this->_credentials['password']}&advIdProgIdCombo=&tx_fmt=3&submit_tx=Download", array());
     $exportData = array();
     try {
         $exportReport = $this->_client->get($urls, 'content', 5);
         $exportData = str_getcsv($exportReport[0], "\n");
     } catch (Exception $e) {
     }
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], "\t");
         if ($transactionExportArray[2] == "Winning Bid (Revenue)" && (empty($this->_sitesAllowed) || in_array($transactionExportArray[5], $this->_sitesAllowed))) {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transactionDate = new Zend_Date($transactionExportArray[1], 'yyyy-MM-dd', 'en');
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             unset($transactionDate);
             if ($transactionExportArray[12] != null) {
                 $transaction['custom_id'] = $transactionExportArray[12];
             }
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[3]);
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[20]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 15
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $rch = curl_init();
     $options = $this->_options;
     curl_setopt($rch, CURLOPT_URL, 'https://www.sportscoverdirect.com/promoters/earn');
     curl_setopt_array($rch, $options);
     $html = curl_exec($rch);
     curl_close($rch);
     $dom = new Zend_Dom_Query($html);
     $results = $dom->query('.performance');
     if (count($results) > 0) {
         $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
         $num = count($exportData) - 1;
         //the last row is show-more show-less
         for ($i = 1; $i < $num; $i++) {
             $overviewExportArray = str_getcsv($exportData[$i], ";");
             $transaction = array();
             $transaction['merchantId'] = 1;
             $date = new Zend_Date($overviewExportArray[0], "dd/MM/yyyy");
             $transaction['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $overviewExportArray[1]));
             $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $overviewExportArray[1]));
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 16
0
 /**
  * (non-PHPdoc)
  *
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     //----------------------------------------------
     // get recordset of list of transactions
     $request = new Pap_Api_TransactionsGrid($this->_session);
     // set filter
     $request->addFilter('dateinserted', 'D>=', $dStartDate->toString("yyyy-MM-dd"));
     $request->addFilter('dateinserted', 'D<=', $dEndDate->toString("yyyy-MM-dd"));
     $request->setLimit(0, 100);
     $request->setSorting('orderid', false);
     $request->sendNow();
     $grid = $request->getGrid();
     $recordset = $grid->getRecordset();
     // iterate through the records
     foreach ($recordset as $rec) {
         $transaction = array();
         $transaction['merchantId'] = 1;
         $transaction['uniqueId'] = $rec->get('orderid');
         $transactionDate = new Zend_Date($rec->get('dateinserted'), 'yyyy-MM-dd HH:mm:ss', 'en');
         $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
         unset($transactionDate);
         $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         $transaction['amount'] = Oara_Utilities::parseDouble($rec->get('totalcost'));
         $transaction['commission'] = Oara_Utilities::parseDouble($rec->get('commission'));
         $totalTransactions[] = $transaction;
     }
     //----------------------------------------------
     // in case there are more than 30 records total
     // we should load and display the rest of the records
     // in the cycle
     $totalRecords = $grid->getTotalCount();
     $maxRecords = $recordset->getSize();
     if ($maxRecords > 0) {
         $cycles = ceil($totalRecords / $maxRecords);
         for ($i = 1; $i < $cycles; $i++) {
             // now get next 30 records
             $request->setLimit($i * $maxRecords, $maxRecords);
             $request->sendNow();
             $recordset = $request->getGrid()->getRecordset();
             // iterate through the records
             foreach ($recordset as $rec) {
                 $transaction = array();
                 $transaction['merchantId'] = 1;
                 $transaction['uniqueId'] = $rec->get('orderid');
                 $transactionDate = new Zend_Date($rec->get('dateinserted'), 'yyyy-MM-dd HH:mm:ss', 'en');
                 $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
                 unset($transactionDate);
                 if ($rec->get('rstatus') == 'D') {
                     $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                 } else {
                     if ($rec->get('rstatus') == 'P') {
                         $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                     } else {
                         if ($rec->get('rstatus') == 'A') {
                             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
                         }
                     }
                 }
                 $transaction['amount'] = Oara_Utilities::parseDouble($rec->get('totalcost'));
                 $transaction['commission'] = Oara_Utilities::parseDouble($rec->get('commission'));
                 $totalTransactions[] = $transaction;
             }
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 17
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://members.cj.com/member/cj/publisher/paymentStatus', array());
     $exportReport = $this->_client->get($urls);
     if (preg_match("/\\/publisher\\/getpublisherpaymenthistory\\.do/", $exportReport[0], $matches)) {
         $urls = array();
         $valuesFromExport = $this->_exportPaymentParameters;
         $urls[] = new Oara_Curl_Request('https://members.cj.com/member/' . $this->_memberId . '/publisher/getpublisherpaymenthistory.do?', $valuesFromExport);
         $exportReport = $this->_client->get($urls);
         $exportData = str_getcsv($exportReport[0], "\n");
         $num = count($exportData);
         for ($j = 1; $j < $num; $j++) {
             $paymentData = str_getcsv($exportData[$j], ",");
             $obj = array();
             $date = new Zend_Date($paymentData[0], "dd-MMM-yyyy HH:mm", 'en_US');
             $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
             $obj['value'] = Oara_Utilities::parseDouble($paymentData[1]);
             $obj['method'] = $paymentData[2];
             $obj['pid'] = $paymentData[6];
             $paymentHistory[] = $obj;
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 18
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $dirDestination = realpath(dirname(__FILE__)) . '/../../data/pdf';
     $now = new Zend_Date();
     if ($now->toString("yyyy-MM") != $dStartDate->toString("yyyy-MM")) {
         $fileName = "S_M_{$this->_apiPassword}_" . $dStartDate->toString("yyyyMM") . ".txt.gz";
         // Raising this value may increase performance
         $buffer_size = 4096;
         // read 4kb at a time
         $local_file = $dirDestination . "/" . $fileName;
         $url = "http://affjet.dc.fubra.net/tools/ItunesConnect/ic.php?user="******"&password="******"&apiPassword="******"&type=M&date=" . $dStartDate->toString("yyyyMM");
         $context = \stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode("{$this->_httpLogin}"))));
         \file_put_contents($local_file, \file_get_contents($url, false, $context));
         $out_file_name = \str_replace('.gz', '', $local_file);
         // Open our files (in binary mode)
         $file = \gzopen($local_file, 'rb');
         if ($file != null) {
             $out_file = \fopen($out_file_name, 'wb');
             // Keep repeating until the end of the input file
             while (!\gzeof($file)) {
                 // Read buffer-size bytes
                 // Both fwrite and gzread and binary-safe
                 \fwrite($out_file, \gzread($file, $buffer_size));
             }
             // Files are done, close files
             \fclose($out_file);
             \gzclose($file);
             unlink($local_file);
             $salesReport = file_get_contents($out_file_name);
             $salesReport = explode("\n", $salesReport);
             for ($i = 1; $i < count($salesReport) - 1; $i++) {
                 $row = str_getcsv($salesReport[$i], "\t");
                 if ($row[15] != 0) {
                     $sub = false;
                     if ($row[7] < 0) {
                         $sub = true;
                         $row[7] = abs($row[7]);
                     }
                     for ($j = 0; $j < $row[7]; $j++) {
                         $obj = array();
                         $obj['merchantId'] = "1";
                         $obj['date'] = $dEndDate->toString("yyyy-MM-dd") . " 00:00:00";
                         $obj['custom_id'] = $row[4];
                         $comission = 0.3;
                         if ($row[2] == "FUBRA1PETROLPRICES1" || $row[2] == "com.fubra.petrolpricespro.subscriptionYear") {
                             $value = 2.99;
                             $obj['amount'] = Oara_Utilities::parseDouble($value);
                             $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                         } else {
                             if ($row[2] == "FUBRA1WORLDAIRPORTCODES1") {
                                 if ($obj['date'] < "2013-04-23 00:00:00") {
                                     $value = 0.6899999999999999;
                                     $obj['amount'] = Oara_Utilities::parseDouble($value);
                                     $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                                 } else {
                                     $value = 1.49;
                                     $obj['amount'] = Oara_Utilities::parseDouble($value);
                                     $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                                 }
                             } else {
                                 throw new Exception("APP not found {$row[2]}");
                             }
                         }
                         if ($sub) {
                             $obj['amount'] = -$obj['amount'];
                             $obj['commission'] = -$obj['commission'];
                         }
                         $obj['status'] = Oara_Utilities::STATUS_CONFIRMED;
                         $totalTransactions[] = $obj;
                     }
                 }
             }
             unlink($out_file_name);
         }
     } else {
         $dateArray = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate);
         $dateArraySize = sizeof($dateArray);
         for ($z = 0; $z < $dateArraySize; $z++) {
             $transactionDate = $dateArray[$z];
             $fileName = "S_D_{$this->_apiPassword}_" . $transactionDate->toString("yyyyMMdd") . ".txt.gz";
             // Raising this value may increase performance
             $buffer_size = 4096;
             // read 4kb at a time
             $local_file = $dirDestination . "/" . $fileName;
             $url = "http://affjet.dc.fubra.net/tools/ItunesConnect/ic.php?user="******"&password="******"&apiPassword="******"&type=D&date=" . $transactionDate->toString("yyyyMMdd");
             $context = \stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode("{$this->_httpLogin}"))));
             \file_put_contents($local_file, \file_get_contents($url, false, $context));
             $out_file_name = \str_replace('.gz', '', $local_file);
             // Open our files (in binary mode)
             $file = \gzopen($local_file, 'rb');
             if ($file != null) {
                 $out_file = \fopen($out_file_name, 'wb');
                 // Keep repeating until the end of the input file
                 while (!\gzeof($file)) {
                     // Read buffer-size bytes
                     // Both fwrite and gzread and binary-safe
                     \fwrite($out_file, \gzread($file, $buffer_size));
                 }
                 // Files are done, close files
                 \fclose($out_file);
                 \gzclose($file);
                 unlink($local_file);
                 $salesReport = file_get_contents($out_file_name);
                 $salesReport = explode("\n", $salesReport);
                 for ($i = 1; $i < count($salesReport) - 1; $i++) {
                     $row = str_getcsv($salesReport[$i], "\t");
                     if ($row[15] != 0) {
                         $sub = false;
                         if ($row[7] < 0) {
                             $sub = true;
                             $row[7] = abs($row[7]);
                         }
                         for ($j = 0; $j < $row[7]; $j++) {
                             $obj = array();
                             $obj['merchantId'] = "1";
                             $obj['date'] = $transactionDate->toString("yyyy-MM-dd") . " 00:00:00";
                             $obj['custom_id'] = $row[4];
                             if ($row[2] == "FUBRA1PETROLPRICES1" || $row[2] == "com.fubra.petrolpricespro.subscriptionYear") {
                                 $value = 2.99;
                                 $comission = 0.3;
                                 $obj['amount'] = Oara_Utilities::parseDouble($value);
                                 $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                             } else {
                                 if ($row[2] == "FUBRA1WORLDAIRPORTCODES1") {
                                     $comission = 0.3;
                                     if ($obj['date'] < "2013-04-23 00:00:00") {
                                         $value = 0.6899999999999999;
                                         $obj['amount'] = Oara_Utilities::parseDouble($value);
                                         $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                                     } else {
                                         $value = 1.49;
                                         $obj['amount'] = Oara_Utilities::parseDouble($value);
                                         $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                                     }
                                 } else {
                                     throw new Exception("APP not found {$row[2]}");
                                 }
                             }
                             if ($sub) {
                                 $obj['amount'] = -$obj['amount'];
                                 $obj['commission'] = -$obj['commission'];
                             }
                             $obj['status'] = Oara_Utilities::STATUS_CONFIRMED;
                             $totalTransactions[] = $obj;
                         }
                     }
                 }
                 unlink($out_file_name);
             }
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 19
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request("{$this->_extension}/affiliate_invoice.html?", array());
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $tableList = $dom->query('.bluetable');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->current()));
     $num = count($exportData);
     for ($i = 4; $i < $num; $i++) {
         $paymentExportArray = str_getcsv($exportData[$i], ";");
         if (count($paymentExportArray) > 7) {
             $obj = array();
             $date = new Zend_Date($paymentExportArray[1], "dd/MM/yyyy");
             $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
             $obj['pid'] = preg_replace('/[^0-9\\.,]/', "", $paymentExportArray[0]);
             $obj['method'] = 'BACS';
             $value = preg_replace('/[^0-9\\.,]/', "", $paymentExportArray[8]);
             $obj['value'] = Oara_Utilities::parseDouble($value);
             $paymentHistory[] = $obj;
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 20
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     foreach ($this->_idBox as $id) {
         $urls = array();
         $paymentExport = array();
         $paymentExport[] = new Oara_Curl_Parameter('idbox_store_id', $id);
         $urls[] = new Oara_Curl_Request($this->_networkServer . "/gp/associates/network/your-account/payment-history.html?", $paymentExport);
         $exportReport = $this->_client->get($urls);
         $dom = new Zend_Dom_Query($exportReport[0]);
         $results = $dom->query('.paymenthistory');
         $count = count($results);
         $yearArray = array();
         if ($count == 1) {
             $paymentTable = $results->current();
             $paymentReport = self::htmlToCsv(self::DOMinnerHTML($paymentTable));
             for ($i = 2; $i < count($paymentReport) - 1; $i++) {
                 $paymentExportArray = str_getcsv($paymentReport[$i], ";");
                 $obj = array();
                 $paymentDate = new Zend_Date($paymentExportArray[0], "M d yyyy", "en");
                 $obj['date'] = $paymentDate->toString("yyyy-MM-dd HH:mm:ss");
                 $obj['pid'] = $paymentDate->toString("yyyyMMdd") . substr((string) base_convert(md5($id), 16, 10), 0, 5);
                 $obj['method'] = 'BACS';
                 if (preg_match("/[0-9]*,?[0-9]*\\.?[0-9]+/", $paymentExportArray[4], $matches)) {
                     $obj['value'] = Oara_Utilities::parseDouble($matches[0]);
                     $paymentHistory[] = $obj;
                 }
             }
         } else {
             //throw new Exception('Problem getting the payments');
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 21
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $urls = array();
     $url = "https://foxtransfer.eu/index.php?q=prices.en.html&page=affiliate_orders&language=1&basedir=theme2&what=record_time&what=record_time&fy={$dStartDate->toString("yyyy")}&fm={$dStartDate->toString("M")}&fd={$dStartDate->toString("d")}&ty={$dEndDate->toString("yyyy")}&tm={$dEndDate->toString("M")}&td={$dEndDate->toString("d")}";
     $urls[] = new Oara_Curl_Request($url, array());
     $exportReport = array();
     $exportReport = $this->_client->get($urls);
     $exportReport = str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "", $exportReport);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $tableList = $dom->query('#tartalom-hatter table[cellspacing="0"][cellpadding="3"][border="0"]');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->current()));
     $num = count($exportData);
     for ($i = 3; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ";");
         $transaction = array();
         $transaction['merchantId'] = 1;
         $transaction['unique_id'] = $transactionExportArray[0];
         $transaction['date'] = "{$dStartDate->toString("yyyy")}-{$dStartDate->toString("MM")}-01 00:00:00";
         if ($transactionExportArray[7] == "Confirmed") {
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         } else {
             if ($transactionExportArray[7] == "Cancelled") {
                 $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
             } else {
                 throw new Exception("New status found");
             }
         }
         $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $transactionExportArray[10]));
         $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $transactionExportArray[13]));
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
Exemplo n.º 22
0
 /**
  * (non-PHPdoc)
  * @see Oara_Network::getTransactionList()
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2));
     self::login();
     $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
     $valuesFormExport[] = new Oara_Curl_Parameter('startDate', self::formatDate($dStartDate));
     $valuesFormExport[] = new Oara_Curl_Parameter('endDate', self::formatDate($dEndDate));
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://publisher.tradedoubler.com/pan/aReport3Internal.action?', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $exportReport[0] = self::checkReportError($exportReport[0], $urls[0]);
     $exportData = str_getcsv($exportReport[0], "\r\n");
     $num = count($exportData);
     for ($i = 2; $i < $num - 1; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (!isset($transactionExportArray[2])) {
             throw new Exception('Problem getting transaction\\n\\n');
         }
         if ($transactionExportArray[0] !== '') {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transactionDate = self::toDate($transactionExportArray[4]);
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             if ($transactionExportArray[8] != '') {
                 $transaction['unique_id'] = $transactionExportArray[8];
             } else {
                 if ($transactionExportArray[7] != '') {
                     $transaction['unique_id'] = $transactionExportArray[7];
                 } 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[18] != '') {
                 $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[18]);
             } else {
                 $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[19]);
             }
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[19]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 23
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $paymentExport = array();
     $paymentExport[] = new Oara_Curl_Parameter('session', $this->_sessionId);
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://affiliate.paidonresults.com/cgi-bin/invoice-status.pl?', $paymentExport);
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('#tableID1 tr');
     foreach ($results as $result) {
         $childrenList = $result->childNodes;
         $numberChildren = $childrenList->length;
         if ($numberChildren == 18) {
             $value = $childrenList->item(14)->nodeValue;
             if (preg_match('/[0-9]+(,[0-9]{3})*(\\.[0-9]{2})?$/', $value, $matches)) {
                 $obj = array();
                 $obj['pid'] = $childrenList->item(4)->nodeValue;
                 $date = new Zend_Date($childrenList->item(0)->nodeValue, "dd/MMM/yyyy");
                 $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                 $obj['value'] = Oara_Utilities::parseDouble($matches[0]);
                 $obj['method'] = 'BACS';
                 $paymentHistory[] = $obj;
             }
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 24
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://publisher.ebaypartnernetwork.com/PublisherAccountPaymentHistory', array());
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('table .aruba_report_table');
     if (count($results) > 0) {
         $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
         for ($j = 1; $j < count($exportData); $j++) {
             $paymentExportArray = str_getcsv($exportData[$j], ";");
             $obj = array();
             $paymentDate = new Zend_Date($paymentExportArray[0], "dd/MM/yy", "en");
             $obj['date'] = $paymentDate->toString("yyyy-MM-dd HH:mm:ss");
             $obj['pid'] = $paymentDate->toString("yyyyMMdd");
             $obj['method'] = 'BACS';
             if (preg_match("/[-+]?[0-9]*,?[0-9]*\\.?[0-9]+/", $paymentExportArray[2], $matches)) {
                 $obj['value'] = Oara_Utilities::parseDouble($matches[0]);
             } else {
                 throw new Exception("Problem reading payments");
             }
             $paymentHistory[] = $obj;
         }
     }
     return $paymentHistory;
 }
Exemplo n.º 25
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($idMerchant, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $affiliate_id = $this->_id;
     $auth_key = $this->_apikey;
     $strUrl = 'https://www.avantlink.ca/api.php';
     $strUrl .= "?affiliate_id={$affiliate_id}";
     $strUrl .= "&auth_key={$auth_key}";
     $strUrl .= "&module=AffiliateReport";
     $strUrl .= "&output=" . urlencode('csv');
     $strUrl .= "&report_id=8";
     $strUrl .= "&date_begin=" . urlencode($dStartDate->toString("yyyy-MM-dd HH:mm:ss"));
     $strUrl .= "&date_end=" . urlencode($dEndDate->toString("yyyy-MM-dd HH:mm:ss"));
     $strUrl .= "&include_inactive_merchants=0";
     $strUrl .= "&search_results_include_cpc=0";
     $returnResult = self::makeCall($strUrl);
     $exportData = str_getcsv($returnResult, "\r\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (count($transactionExportArray) > 1 && in_array((int) $transactionExportArray[17], $merchantList)) {
             $transaction = array();
             $merchantId = (int) $transactionExportArray[17];
             $transaction['merchantId'] = $merchantId;
             $transactionDate = new Zend_Date($transactionExportArray[11], 'MM-dd-yyyy HH:mm:ss');
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['unique_id'] = (int) $transactionExportArray[5];
             if ($transactionExportArray[4] != null) {
                 $transaction['custom_id'] = $transactionExportArray[4];
             }
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionExportArray[6]));
             $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionExportArray[7]));
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 26
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $valuesFromExport = $this->_exportPaymentParameters;
     $urls[] = new Oara_Curl_Request('http://users.buy.at/ma/index.php/affiliatePayments/paymentsHistory?', $valuesFromExport);
     $exportReport = $this->_client->get($urls);
     $exportData = str_getcsv($exportReport[0], "\r\n");
     $num = count($exportData);
     for ($j = 1; $j < $num; $j++) {
         $paymentData = str_getcsv($exportData[$j], ",");
         $obj = array();
         $date = new Zend_Date($paymentData[0], "dd-MM-yyyy");
         $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
         $obj['method'] = $paymentData[1];
         $obj['value'] = Oara_Utilities::parseDouble($paymentData[2]);
         $obj['pid'] = $paymentData[4];
         $paymentHistory[] = $obj;
     }
     return $paymentHistory;
 }
Exemplo n.º 27
0
 /**
  * (non-PHPdoc)
  * 
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFormExport = array();
     if ($this->_transactionList == null) {
         $urls = array();
         $valuesExport = array(new Oara_Curl_Parameter('D', '{"C":"Pap_Affiliates_Reports_TransactionsGrid", "M":"getCSVFile", "S":"' . $this->_s . '", "FormResponse":"Y", "sort_col":"dateinserted", "sort_asc":false, "offset":0, "limit":30, "columns":[["id"],["id"],["commission"],["totalcost"],["fixedcost"],["t_orderid"],["productid"],["dateinserted"],["name"],["rtype"],["tier"],["commissionTypeName"],["rstatus"],["merchantnote"],["channel"]]}'));
         $urls[] = new Oara_Curl_Request('https://vpnaffiliates.com/affiliates/scripts/server.php?', $valuesExport);
         $exportReport = array();
         $exportReport = $this->_client->post($urls);
         $this->_transactionList = str_getcsv($exportReport[0], "\n");
     }
     $exportData = $this->_transactionList;
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         // print_r($transactionExportArray);
         $transaction = array();
         $transaction['merchantId'] = 1;
         $transaction['uniqueId'] = $transactionExportArray[3];
         $transactionDate = new Zend_Date($transactionExportArray[5], 'yyyy-MM-dd HH:mm:ss', 'en');
         $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
         unset($transactionDate);
         $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[1]);
         $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[0]);
         // print_r($transaction);
         if ($transaction['date'] >= $dStartDate->toString("yyyy-MM-dd HH:mm:ss") && $transaction['date'] <= $dEndDate->toString("yyyy-MM-dd HH:mm:ss")) {
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 28
0
 /**
  * (non-PHPdoc)
  *
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFromExport = array();
     $valuesFromExport[] = new Oara_Curl_Parameter('getExcel', '1');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_sSearchMode', 'custom');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_nType', 'sale');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_sPeriod', 'day');
     $valuesFromExport[] = new Oara_Curl_Parameter('export', 'csv');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_nStatus', '3');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_nNbRowsByPage', '50');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_nProgId', '');
     $valuesFromExport[] = new Oara_Curl_Parameter('p_sStartDate', $dStartDate->toString("dd/MM/yyyy"));
     $valuesFromExport[] = new Oara_Curl_Parameter('p_sEndDate', $dEndDate->toString("dd/MM/yyyy"));
     $valuesFromExport[] = new Oara_Curl_Parameter('p_nPage', '1');
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://v2.afilio.com.br/include/lib/aff_lib_manage_sale.php?', $valuesFromExport);
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $tableList = $dom->query('table');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->next()));
     $num = count($exportData);
     for ($i = 0; $i < $num; $i++) {
         $transactionExportArray = explode(";,", $exportData[$i]);
         if (isset($merchantMap[$transactionExportArray[0]]) && in_array($merchantMap[$transactionExportArray[0]], $merchantList)) {
             $transaction = array();
             $transaction['merchantId'] = $merchantMap[$transactionExportArray[0]];
             $transaction['unique_id'] = $transactionExportArray[4];
             $transactionDate = new Zend_Date($transactionExportArray[1], 'dd/MM/yy HH:mm:dd', 'en');
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['customId'] = $transactionExportArray[5];
             if ($transactionExportArray[7] == "Accepted" || $transactionExportArray[7] == "Accepté") {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[7] == "Pending" || $transactionExportArray[7] == "En attente") {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if ($transactionExportArray[7] == "Rejected" || $transactionExportArray[7] == "Refusé" || $transactionExportArray[7] == "Refused") {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     } else {
                         throw new Exception("New status found {$transactionExportArray[7]}");
                     }
                 }
             }
             $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $transactionExportArray[6]));
             $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $transactionExportArray[6]));
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 29
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $context = stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode("{$this->_user}:{$this->_pass}"))));
     $from = urlencode($dStartDate->toString("yyyy-MM-dd HH:mm:ss"));
     $data = file_get_contents("http://api.webepartners.pl/wydawca/Auctions?from={$from}", false, $context);
     $dataArray = json_decode($data, true);
     foreach ($dataArray as $transactionObject) {
         if (in_array($transactionObject["ProgramId"], $merchantList)) {
             $transaction = array();
             $transaction['merchantId'] = $transactionObject["ProgramId"];
             $transaction['date'] = $transactionObject["AuctionDate"];
             if (isset($transactionObject["AuctionId"]) && $transactionObject["AuctionId"] != '') {
                 $transaction['unique_id'] = $transactionObject["AuctionId"];
             }
             if (isset($transactionObject["subID"]) && $transactionObject["subID"] != '') {
                 $transaction['custom_id'] = $transactionObject["subID"];
             }
             if ($transactionObject["AuctionStatusId"] == 3 || $transactionObject["AuctionStatusId"] == 4 || $transactionObject["AuctionStatusId"] == 5) {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionObject["AuctionStatusId"] == 1) {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if ($transactionObject["AuctionStatusId"] == 2) {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     } else {
                         if ($transactionObject["AuctionStatusId"] == 6) {
                             $transaction['status'] = Oara_Utilities::STATUS_PAID;
                         }
                     }
                 }
             }
             $transaction['amount'] = Oara_Utilities::parseDouble($transactionObject["OrderCost"]);
             $transaction['commission'] = Oara_Utilities::parseDouble($transactionObject["Commission"]);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemplo n.º 30
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://affiliates.mypcbackup.com/paychecks', array());
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $tableList = $dom->query('.transtable');
     if ($tableList->current() != null) {
         $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->current()));
         $num = count($exportData);
         for ($i = 1; $i < $num; $i++) {
             $paymentExportArray = str_getcsv($exportData[$i], ";");
             try {
                 $obj = array();
                 $date = new Zend_Date($paymentExportArray[14], "MM/dd/yyyy");
                 $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                 $obj['pid'] = preg_replace("/[^0-9\\.,]/", "", $paymentExportArray[14]);
                 $obj['method'] = $paymentExportArray[16];
                 $value = preg_replace("/[^0-9\\.,]/", "", $paymentExportArray[12]);
                 $obj['value'] = Oara_Utilities::parseDouble($value);
                 $paymentHistory[] = $obj;
             } catch (Exception $e) {
                 echo "Payment failed\n";
             }
         }
     }
     return $paymentHistory;
 }