1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
4
|
|
|
|
5
|
|
|
use GuzzleHttp\Psr7; |
6
|
|
|
use Srmklive\PayPal\Services\VerifyDocuments; |
7
|
|
|
|
8
|
|
|
trait DisputesActions |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Acknowledge item has been returned. |
12
|
|
|
* |
13
|
|
|
* @param string $dispute_id |
14
|
|
|
* @param string $dispute_note |
15
|
|
|
* @param string $acknowledgement_type |
16
|
|
|
* |
17
|
|
|
* @throws \Throwable |
18
|
|
|
* |
19
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
20
|
|
|
* |
21
|
|
|
* @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes-actions_acknowledge-return-item |
22
|
|
|
*/ |
23
|
|
|
public function acknowledgeItemReturned(string $dispute_id, string $dispute_note, string $acknowledgement_type) |
24
|
|
|
{ |
25
|
|
|
$this->apiEndPoint = "v1/customer/disputes/{$dispute_id}/acknowledge-return-item"; |
26
|
|
|
|
27
|
|
|
$this->options['json'] = [ |
28
|
|
|
'note' => $dispute_note, |
29
|
|
|
'acknowledgement_type' => $acknowledgement_type, |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
$this->verb = 'post'; |
33
|
|
|
|
34
|
|
|
return $this->doPayPalRequest(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Providence evidence in support of a dispute. |
39
|
|
|
* |
40
|
|
|
* @param string $dispute_id |
41
|
|
|
* @param array $file_path |
42
|
|
|
* |
43
|
|
|
* @throws \Throwable |
44
|
|
|
* |
45
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
46
|
|
|
* |
47
|
|
|
* https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes_provide-evidence |
48
|
|
|
*/ |
49
|
|
|
public function provideDisputeEvidence(string $dispute_id, array $files) |
50
|
|
|
{ |
51
|
|
|
if (VerifyDocuments::isValidEvidenceFile($files) === false) { |
52
|
|
|
$this->throwInvalidEvidenceFileException(); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$this->apiEndPoint = "/v1/customer/disputes/{$dispute_id}/provide-evidence"; |
56
|
|
|
|
57
|
|
|
$this->setRequestHeader('Content-Type', 'multipart/form-data'); |
|
|
|
|
58
|
|
|
|
59
|
|
|
$this->options['multipart'] = []; |
60
|
|
|
|
61
|
|
|
foreach ($files as $file) { |
62
|
|
|
$this->options['multipart'][] = [ |
63
|
|
|
'name' => basename($file), |
64
|
|
|
'contents' => Psr7\Utils::tryFopen($file, 'r'), |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$this->verb = 'post'; |
69
|
|
|
|
70
|
|
|
return $this->doPayPalRequest(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Accept customer dispute claim. |
75
|
|
|
* |
76
|
|
|
* @param string $dispute_id |
77
|
|
|
* @param string $dispute_note |
78
|
|
|
* @param array $data |
79
|
|
|
* |
80
|
|
|
* @throws \Throwable |
81
|
|
|
* |
82
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
83
|
|
|
* |
84
|
|
|
* @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes-actions_accept-claim |
85
|
|
|
*/ |
86
|
|
|
public function acceptDisputeClaim(string $dispute_id, string $dispute_note, array $data = []) |
87
|
|
|
{ |
88
|
|
|
$this->apiEndPoint = "v1/customer/disputes/{$dispute_id}/accept-claim"; |
89
|
|
|
|
90
|
|
|
$data['note'] = $dispute_note; |
91
|
|
|
$data['accept_claim_type'] = 'REFUND'; |
92
|
|
|
|
93
|
|
|
$this->options['json'] = $data; |
94
|
|
|
|
95
|
|
|
$this->verb = 'post'; |
96
|
|
|
|
97
|
|
|
return $this->doPayPalRequest(); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Accept offer to resolve dispute. |
102
|
|
|
* |
103
|
|
|
* @param string $dispute_id |
104
|
|
|
* @param string $dispute_note |
105
|
|
|
* |
106
|
|
|
* @throws \Throwable |
107
|
|
|
* |
108
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
109
|
|
|
* |
110
|
|
|
* @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes-actions_accept-offer |
111
|
|
|
*/ |
112
|
|
|
public function acceptDisputeOfferResolution(string $dispute_id, string $dispute_note) |
113
|
|
|
{ |
114
|
|
|
$this->apiEndPoint = "v1/customer/disputes/{$dispute_id}/accept-offer"; |
115
|
|
|
|
116
|
|
|
$this->options['json'] = [ |
117
|
|
|
'note' => $dispute_note, |
118
|
|
|
]; |
119
|
|
|
|
120
|
|
|
$this->verb = 'post'; |
121
|
|
|
|
122
|
|
|
return $this->doPayPalRequest(); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|