1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalResourceModel;
6 use PayPal\Rest\ApiContext;
7 use PayPal\Transport\PayPalRestCall;
8 use PayPal\Validation\ArgumentValidator;
9
10 /**
11 * Class PayoutItem
12 *
13 * A sender-created definition of a payout to a single recipient.
14 *
15 * @package PayPal\Api
16 *
17 * @property string recipient_type
18 * @property \PayPal\Api\Currency amount
19 * @property string note
20 * @property string receiver
21 * @property string sender_item_id
22 */
23 class PayoutItem extends PayPalResourceModel
24 {
25 /**
26 * The type of ID that identifies the payment receiver. Value is:<ul><code>EMAIL</code>. Unencrypted email. Value is a string of up to 127 single-byte characters.</li><li><code>PHONE</code>. Unencrypted phone number.<blockquote><strong>Note:</strong> The PayPal sandbox does not support the <code>PHONE</code> recipient type.</blockquote></li><li><code>PAYPAL_ID</code>. Encrypted PayPal account number.</li></ul>If the <code>sender_batch_header</code> includes the <code>recipient_type</code> attribute, any payout item without its own <code>recipient_type</code> attribute uses the <code>recipient_type</code> value from <code>sender_batch_header</code>. If the <code>sender_batch_header</code> omits the <code>recipient_type</code> attribute, each payout item must include its own <code>recipient_type</code> value.
27 *
28 * @param string $recipient_type
29 *
30 * @return $this
31 */
32 public function setRecipientType($recipient_type)
33 {
34 $this->recipient_type = $recipient_type;
35 return $this;
36 }
37
38 /**
39 * The type of ID that identifies the payment receiver. Value is:<ul><code>EMAIL</code>. Unencrypted email. Value is a string of up to 127 single-byte characters.</li><li><code>PHONE</code>. Unencrypted phone number.<blockquote><strong>Note:</strong> The PayPal sandbox does not support the <code>PHONE</code> recipient type.</blockquote></li><li><code>PAYPAL_ID</code>. Encrypted PayPal account number.</li></ul>If the <code>sender_batch_header</code> includes the <code>recipient_type</code> attribute, any payout item without its own <code>recipient_type</code> attribute uses the <code>recipient_type</code> value from <code>sender_batch_header</code>. If the <code>sender_batch_header</code> omits the <code>recipient_type</code> attribute, each payout item must include its own <code>recipient_type</code> value.
40 *
41 * @return string
42 */
43 public function getRecipientType()
44 {
45 return $this->recipient_type;
46 }
47
48 /**
49 * The amount of money to pay the receiver.
50 *
51 * @param \PayPal\Api\Currency $amount
52 *
53 * @return $this
54 */
55 public function setAmount($amount)
56 {
57 $this->amount = $amount;
58 return $this;
59 }
60
61 /**
62 * The amount of money to pay the receiver.
63 *
64 * @return \PayPal\Api\Currency
65 */
66 public function getAmount()
67 {
68 return $this->amount;
69 }
70
71 /**
72 * Optional. A sender-specified note for notifications. Value is any string value.
73 *
74 * @param string $note
75 *
76 * @return $this
77 */
78 public function setNote($note)
79 {
80 $this->note = $note;
81 return $this;
82 }
83
84 /**
85 * Optional. A sender-specified note for notifications. Value is any string value.
86 *
87 * @return string
88 */
89 public function getNote()
90 {
91 return $this->note;
92 }
93
94 /**
95 * The receiver of the payment. Corresponds to the `recipient_type` value in the request.
96 *
97 * @param string $receiver
98 *
99 * @return $this
100 */
101 public function setReceiver($receiver)
102 {
103 $this->receiver = $receiver;
104 return $this;
105 }
106
107 /**
108 * The receiver of the payment. Corresponds to the `recipient_type` value in the request.
109 *
110 * @return string
111 */
112 public function getReceiver()
113 {
114 return $this->receiver;
115 }
116
117 /**
118 * A sender-specified ID number. Tracks the batch payout in an accounting system.
119 *
120 * @param string $sender_item_id
121 *
122 * @return $this
123 */
124 public function setSenderItemId($sender_item_id)
125 {
126 $this->sender_item_id = $sender_item_id;
127 return $this;
128 }
129
130 /**
131 * A sender-specified ID number. Tracks the batch payout in an accounting system.
132 *
133 * @return string
134 */
135 public function getSenderItemId()
136 {
137 return $this->sender_item_id;
138 }
139
140 /**
141 * Obtain the status of a payout item by passing the item ID to the request URI.
142 *
143 * @param string $payoutItemId
144 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
145 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
146 * @return PayoutItemDetails
147 */
148 public static function get($payoutItemId, $apiContext = null, $restCall = null)
149 {
150 ArgumentValidator::validate($payoutItemId, 'payoutItemId');
151 $payLoad = "";
152 $json = self::executeCall(
153 "/v1/payments/payouts-item/$payoutItemId",
154 "GET",
155 $payLoad,
156 null,
157 $apiContext,
158 $restCall
159 );
160 $ret = new PayoutItemDetails();
161 $ret->fromJson($json);
162 return $ret;
163 }
164
165 /**
166 * Cancels the unclaimed payment using the items id passed in the request URI. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return.
167 *
168 * @param string $payoutItemId
169 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
170 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
171 * @return PayoutItemDetails
172 */
173 public static function cancel($payoutItemId, $apiContext = null, $restCall = null)
174 {
175 ArgumentValidator::validate($payoutItemId, 'payoutItemId');
176 $payLoad = "";
177 $json = self::executeCall(
178 "/v1/payments/payouts-item/$payoutItemId/cancel",
179 "POST",
180 $payLoad,
181 null,
182 $apiContext,
183 $restCall
184 );
185 $ret = new PayoutItemDetails();
186 $ret->fromJson($json);
187 return $ret;
188 }
189 }
190