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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
namespace Braintree;
/**
* Creates an instance of Dispute as returned from a transaction
*
*
* @package Braintree
*
* @property-read string $amount
* @property-read string $currencyIsoCode
* @property-read date $receivedDate
* @property-read string $reason
* @property-read string $status
* @property-read string $disbursementDate
* @property-read object $transactionDetails
*/
class Dispute extends Base
{
protected $_attributes = [];
/* Dispute Status */
const ACCEPTED = 'accepted';
const DISPUTED = 'disputed';
const EXPIRED = 'expired';
const OPEN = 'open';
const WON = 'won';
const LOST = 'lost';
/* deprecated; for backwards compatibilty */
const Open = 'open';
/* Dispute Reason */
const CANCELLED_RECURRING_TRANSACTION = "cancelled_recurring_transaction";
const CREDIT_NOT_PROCESSED = "credit_not_processed";
const DUPLICATE = "duplicate";
const FRAUD = "fraud";
const GENERAL = "general";
const INVALID_ACCOUNT = "invalid_account";
const NOT_RECOGNIZED = "not_recognized";
const PRODUCT_NOT_RECEIVED = "product_not_received";
const PRODUCT_UNSATISFACTORY = "product_unsatisfactory";
const TRANSACTION_AMOUNT_DIFFERS = "transaction_amount_differs";
const RETRIEVAL = "retrieval";
/* Dispute Kind */
const CHARGEBACK = 'chargeback';
const PRE_ARBITRATION = 'pre_arbitration';
// RETRIEVAL for kind already defined under Dispute Reason
protected function _initialize($disputeAttribs)
{
$this->_attributes = $disputeAttribs;
if (isset($disputeAttribs['transaction'])) {
$transactionDetails = new Dispute\TransactionDetails($disputeAttribs['transaction']);
$this->_set('transactionDetails', $transactionDetails);
$this->_set('transaction', $transactionDetails);
}
if (isset($disputeAttribs['evidence'])) {
$evidenceArray = array_map(function($evidence) {
return new Dispute\EvidenceDetails($evidence);
}, $disputeAttribs['evidence']);
$this->_set('evidence', $evidenceArray);
}
if (isset($disputeAttribs['statusHistory'])) {
$statusHistoryArray = array_map(function($statusHistory) {
return new Dispute\StatusHistoryDetails($statusHistory);
}, $disputeAttribs['statusHistory']);
$this->_set('statusHistory', $statusHistoryArray);
}
if (isset($disputeAttribs['transaction'])) {
$this->_set('transaction',
new Dispute\TransactionDetails($disputeAttribs['transaction'])
);
}
}
public static function factory($attributes)
{
$instance = new self();
$instance->_initialize($attributes);
return $instance;
}
public function __toString()
{
$display = [
'amount', 'reason', 'status',
'replyByDate', 'receivedDate', 'currencyIsoCode'
];
$displayAttributes = [];
foreach ($display AS $attrib) {
$displayAttributes[$attrib] = $this->$attrib;
}
return __CLASS__ . '[' .
Util::attributesToString($displayAttributes) .']';
}
/**
* Accepts a dispute, given a dispute ID
*
* @param string $id
*/
public static function accept($id)
{
return Configuration::gateway()->dispute()->accept($id);
}
/**
* Adds file evidence to a dispute, given a dispute ID and a document ID
*
* @param string $disputeId
* @param string $documentIdOrRequest
*/
public static function addFileEvidence($disputeId, $documentIdOrRequest)
{
return Configuration::gateway()->dispute()->addFileEvidence($disputeId, $documentIdOrRequest);
}
/**
* Adds text evidence to a dispute, given a dispute ID and content
*
* @param string $id
* @param string $contentOrRequest
*/
public static function addTextEvidence($id, $contentOrRequest)
{
return Configuration::gateway()->dispute()->addTextEvidence($id, $contentOrRequest);
}
/**
* Finalize a dispute, given a dispute ID
*
* @param string $id
*/
public static function finalize($id)
{
return Configuration::gateway()->dispute()->finalize($id);
}
/**
* Find a dispute, given a dispute ID
*
* @param string $id
*/
public static function find($id)
{
return Configuration::gateway()->dispute()->find($id);
}
/**
* Remove evidence from a dispute, given a dispute ID and evidence ID
*
* @param string $disputeId
* @param string $evidenceId
*/
public static function removeEvidence($disputeId, $evidenceId)
{
return Configuration::gateway()->dispute()->removeEvidence($disputeId, $evidenceId);
}
/**
* Search for Disputes, given a DisputeSearch query
*
* @param DisputeSearch $query
*/
public static function search($query)
{
return Configuration::gateway()->dispute()->search($query);
}
}
class_alias('Braintree\Dispute', 'Braintree_Dispute');