1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
4
|
|
|
|
5
|
|
|
trait Payouts |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Create a Batch Payout. |
9
|
|
|
* |
10
|
|
|
* @param array $data |
11
|
|
|
* |
12
|
|
|
* @throws \Throwable |
13
|
|
|
* |
14
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
15
|
|
|
* |
16
|
|
|
* @see https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_post |
17
|
|
|
*/ |
18
|
|
|
public function createBatchPayout(array $data) |
19
|
|
|
{ |
20
|
|
|
$this->apiEndPoint = 'v1/payments/payouts'; |
21
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
22
|
|
|
|
23
|
|
|
$this->options['json'] = $data; |
24
|
|
|
|
25
|
|
|
$this->verb = 'post'; |
26
|
|
|
|
27
|
|
|
return $this->doPayPalRequest(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Show Batch Payout details by ID. |
32
|
|
|
* |
33
|
|
|
* @param string $payout_id |
34
|
|
|
* |
35
|
|
|
* @throws \Throwable |
36
|
|
|
* |
37
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
38
|
|
|
* |
39
|
|
|
* @see https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_get |
40
|
|
|
*/ |
41
|
|
|
public function showBatchPayoutDetails(string $payout_id) |
42
|
|
|
{ |
43
|
|
|
$this->apiEndPoint = "v1/payments/payouts/{$payout_id}"; |
44
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
45
|
|
|
|
46
|
|
|
$this->verb = 'get'; |
47
|
|
|
|
48
|
|
|
return $this->doPayPalRequest(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Show Payout Item details by ID. |
53
|
|
|
* |
54
|
|
|
* @param string $payout_item_id |
55
|
|
|
* |
56
|
|
|
* @throws \Throwable |
57
|
|
|
* |
58
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
59
|
|
|
* |
60
|
|
|
* @see https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_get |
61
|
|
|
*/ |
62
|
|
|
public function showPayoutItemDetails(string $payout_item_id) |
63
|
|
|
{ |
64
|
|
|
$this->apiEndPoint = "v1/payments/payouts-item/{$payout_item_id}"; |
65
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
66
|
|
|
|
67
|
|
|
$this->verb = 'get'; |
68
|
|
|
|
69
|
|
|
return $this->doPayPalRequest(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Show Payout Item details by ID. |
74
|
|
|
* |
75
|
|
|
* @param string $payout_item_id |
76
|
|
|
* |
77
|
|
|
* @throws \Throwable |
78
|
|
|
* |
79
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
80
|
|
|
* |
81
|
|
|
* @see https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_cancel |
82
|
|
|
*/ |
83
|
|
|
public function cancelUnclaimedPayoutItem(string $payout_item_id) |
84
|
|
|
{ |
85
|
|
|
$this->apiEndPoint = "v1/payments/payouts-item/{$payout_item_id}/cancel"; |
86
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
87
|
|
|
|
88
|
|
|
$this->verb = 'post'; |
89
|
|
|
|
90
|
|
|
return $this->doPayPalRequest(); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|