|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) Padosoft.com 2017. |
|
4
|
|
|
*/ |
|
5
|
|
|
namespace Padosoft\AffiliateNetwork; |
|
6
|
|
|
use Oara\Network\Publisher\Effiliation as EffiliationOara; |
|
7
|
|
|
|
|
8
|
|
|
class EffiliationEx extends EffiliationOara{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @param null $merchantList |
|
11
|
|
|
* @param \DateTime|null $dStartDate |
|
12
|
|
|
* @param \DateTime|null $dEndDate |
|
13
|
|
|
* @return array |
|
14
|
|
|
*/ |
|
15
|
|
|
public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null) |
|
16
|
|
|
{ |
|
17
|
|
|
$totalTransactions = array(); |
|
18
|
|
|
|
|
19
|
|
|
$merchantIdList = \Oara\Utilities::getMerchantIdMapFromMerchantList($merchantList); |
|
20
|
|
|
|
|
21
|
|
|
$url = 'http://api.effiliation.com/apiv2/transaction.csv?key=' . $this->_credentials["apiPassword"] . '&start=' . $dStartDate->format("d/m/Y") . '&end=' . $dEndDate->format("d/m/Y") . '&type=date&all=yes'; |
|
|
|
|
|
|
22
|
|
|
$content = \utf8_encode(\file_get_contents($url)); |
|
23
|
|
|
$exportData = \str_getcsv($content, "\n"); |
|
24
|
|
|
$num = \count($exportData); |
|
25
|
|
|
|
|
26
|
|
|
for ($i = 1; $i < $num; $i++) { |
|
27
|
|
|
$transactionExportArray = \str_getcsv($exportData[$i], "|"); |
|
28
|
|
|
if (isset($merchantIdList[(int)$transactionExportArray[2]])) { |
|
29
|
|
|
|
|
30
|
|
|
$transaction = Array(); |
|
31
|
|
|
$merchantId = (int)$transactionExportArray[2]; |
|
32
|
|
|
$transaction['merchantId'] = $merchantId; |
|
33
|
|
|
$transaction['date'] = $transactionExportArray[10]; |
|
34
|
|
|
$transaction['unique_id'] = $transactionExportArray[0]; |
|
35
|
|
|
$transaction['custom_id'] = ''; |
|
36
|
|
|
if ($transactionExportArray[4] != null) { |
|
37
|
|
|
$transaction['custom_id'] = $transactionExportArray[4]; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
if ($transactionExportArray[9] == 'Valide') { |
|
41
|
|
|
$transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED; |
|
42
|
|
View Code Duplication |
} else |
|
|
|
|
|
|
43
|
|
|
if ($transactionExportArray[9] == 'Attente') { |
|
44
|
|
|
$transaction['status'] = \Oara\Utilities::STATUS_PENDING; |
|
45
|
|
|
} else |
|
46
|
|
|
if ($transactionExportArray[9] == 'Refus�') { |
|
47
|
|
|
$transaction['status'] = \Oara\Utilities::STATUS_DECLINED; |
|
48
|
|
|
} |
|
49
|
|
|
$transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[7]); |
|
50
|
|
|
$transaction['commission'] = \Oara\Utilities::parseDouble($transactionExportArray[8]); |
|
51
|
|
|
$totalTransactions[] = $transaction; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
return $totalTransactions; |
|
55
|
|
|
} |
|
56
|
|
|
} |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.