Disbursement.php
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Braintree;
class Disbursement extends Base
{
const TYPE_CREDIT = "credit";
const TYPE_DEBIT = "debit";
private $_merchantAccount;
protected function _initialize($disbursementAttribs)
{
$this->_attributes = $disbursementAttribs;
$this->merchantAccountDetails = $disbursementAttribs['merchantAccount'];
if (isset($disbursementAttribs['merchantAccount'])) {
$this->_set('merchantAccount',
MerchantAccount::factory($disbursementAttribs['merchantAccount'])
);
}
}
public function transactions()
{
$collection = Transaction::search([
TransactionSearch::ids()->in($this->transactionIds),
]);
return $collection;
}
public static function factory($attributes)
{
$instance = new self();
$instance->_initialize($attributes);
return $instance;
}
public function __toString()
{
$display = [
'id', 'merchantAccountDetails', 'exceptionMessage', 'amount',
'disbursementDate', 'followUpAction', 'retry', 'success',
'transactionIds', 'disbursementType'
];
$displayAttributes = [];
foreach ($display AS $attrib) {
$displayAttributes[$attrib] = $this->$attrib;
}
return __CLASS__ . '[' .
Util::attributesToString($displayAttributes) .']';
}
public function isDebit()
{
return $this->disbursementType == Disbursement::TYPE_DEBIT;
}
public function isCredit()
{
return $this->disbursementType == Disbursement::TYPE_CREDIT;
}
}
class_alias('Braintree\Disbursement', 'Braintree_Disbursement');