1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
4
|
|
|
|
5
|
|
|
trait ReferencedPayouts |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Create a referenced Batch Payout. |
9
|
|
|
* |
10
|
|
|
* @param array $data |
11
|
|
|
* @param string $request_id |
12
|
|
|
* @param string $partner_attribution_id |
13
|
|
|
* |
14
|
|
|
* @throws \Throwable |
15
|
|
|
* |
16
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
17
|
|
|
* |
18
|
|
|
* @see https://developer.paypal.com/docs/api/referenced-payouts/v1/#referenced-payouts_create_batch |
19
|
|
|
*/ |
20
|
|
|
public function createReferencedBatchPayout(array $data, string $request_id, string $partner_attribution_id) |
21
|
|
|
{ |
22
|
|
|
$this->apiEndPoint = 'v1/payments/referenced-payouts'; |
23
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
24
|
|
|
|
25
|
|
|
$this->options['headers']['PayPal-Request-Id'] = $request_id; |
26
|
|
|
$this->options['headers']['PayPal-Partner-Attribution-Id'] = $partner_attribution_id; |
27
|
|
|
$this->options['json'] = $data; |
28
|
|
|
|
29
|
|
|
$this->verb = 'post'; |
30
|
|
|
|
31
|
|
|
return $this->doPayPalRequest(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Show Batch Payout details by ID. |
36
|
|
|
* |
37
|
|
|
* @param string $batch_payout_id |
38
|
|
|
* |
39
|
|
|
* @throws \Throwable |
40
|
|
|
* |
41
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
42
|
|
|
* |
43
|
|
|
* @see https://developer.paypal.com/docs/api/referenced-payouts/v1/#referenced-payouts_get_batch_details |
44
|
|
|
*/ |
45
|
|
|
public function listItemsReferencedInBatchPayout(string $batch_payout_id) |
46
|
|
|
{ |
47
|
|
|
$this->apiEndPoint = "v1/payments/referenced-payouts/{$batch_payout_id}"; |
48
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
49
|
|
|
|
50
|
|
|
$this->verb = 'get'; |
51
|
|
|
|
52
|
|
|
return $this->doPayPalRequest(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Create a referenced Batch Payout Item. |
57
|
|
|
* |
58
|
|
|
* @param array $data |
59
|
|
|
* @param string $request_id |
60
|
|
|
* @param string $partner_attribution_id |
61
|
|
|
* |
62
|
|
|
* @throws \Throwable |
63
|
|
|
* |
64
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
65
|
|
|
* |
66
|
|
|
* @see https://developer.paypal.com/docs/api/referenced-payouts/v1/#referenced-payouts-items_create |
67
|
|
|
*/ |
68
|
|
|
public function createReferencedBatchPayoutItem(array $data, string $request_id, string $partner_attribution_id) |
69
|
|
|
{ |
70
|
|
|
$this->apiEndPoint = 'v1/payments/referenced-payouts-items'; |
71
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
72
|
|
|
|
73
|
|
|
$this->options['headers']['PayPal-Request-Id'] = $request_id; |
74
|
|
|
$this->options['headers']['PayPal-Partner-Attribution-Id'] = $partner_attribution_id; |
75
|
|
|
$this->options['json'] = $data; |
76
|
|
|
|
77
|
|
|
$this->verb = 'post'; |
78
|
|
|
|
79
|
|
|
return $this->doPayPalRequest(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Show Payout Item details by ID. |
84
|
|
|
* |
85
|
|
|
* @param string $payout_item_id |
86
|
|
|
* @param string $partner_attribution_id |
87
|
|
|
* |
88
|
|
|
* @throws \Throwable |
89
|
|
|
* |
90
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
91
|
|
|
* |
92
|
|
|
* @see https://developer.paypal.com/docs/api/referenced-payouts/v1/#referenced-payouts-items_get |
93
|
|
|
*/ |
94
|
|
|
public function showReferencedPayoutItemDetails(string $payout_item_id, string $partner_attribution_id) |
95
|
|
|
{ |
96
|
|
|
$this->apiEndPoint = "v1/payments/referenced-payouts-items/{$payout_item_id}"; |
97
|
|
|
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/'); |
98
|
|
|
|
99
|
|
|
$this->options['headers']['PayPal-Partner-Attribution-Id'] = $partner_attribution_id; |
100
|
|
|
$this->verb = 'get'; |
101
|
|
|
|
102
|
|
|
return $this->doPayPalRequest(); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|