1 | <?php |
||
10 | class ExpressCheckout |
||
11 | { |
||
12 | // Integrate PayPal Request trait |
||
13 | use PayPalAPIRequest, PayPalTransactions, RecurringProfiles; |
||
14 | |||
15 | /** |
||
16 | * ExpressCheckout constructor. |
||
17 | * |
||
18 | * @param array $config |
||
19 | * |
||
20 | * @throws \Exception |
||
21 | */ |
||
22 | public function __construct(array $config = []) |
||
31 | |||
32 | /** |
||
33 | * Set ExpressCheckout API endpoints & options. |
||
34 | * |
||
35 | * @param array $credentials |
||
36 | * |
||
37 | * @return void |
||
38 | */ |
||
39 | public function setExpressCheckoutOptions($credentials) |
||
59 | |||
60 | /** |
||
61 | * Set cart item details for PayPal. |
||
62 | * |
||
63 | * @param array $items |
||
64 | * |
||
65 | * @return \Illuminate\Support\Collection |
||
66 | */ |
||
67 | protected function setCartItems($items) |
||
79 | |||
80 | /** |
||
81 | * Set Recurring payments details for SetExpressCheckout API call. |
||
82 | * |
||
83 | * @param array $data |
||
84 | * @param bool $subscription |
||
85 | */ |
||
86 | protected function setExpressCheckoutRecurringPaymentConfig($data, $subscription = false) |
||
94 | |||
95 | /** |
||
96 | * Set item subtotal if available. |
||
97 | * |
||
98 | * @param array $data |
||
99 | */ |
||
100 | protected function setItemSubTotal($data) |
||
104 | |||
105 | /** |
||
106 | * Set shipping amount if available. |
||
107 | * |
||
108 | * @param array $data |
||
109 | */ |
||
110 | protected function setShippingAmount($data) |
||
118 | |||
119 | /** |
||
120 | * Set shipping discount if available. |
||
121 | * |
||
122 | * @param array $data |
||
123 | */ |
||
124 | protected function setShippingDiscount($data) |
||
132 | |||
133 | /** |
||
134 | * Perform a SetExpressCheckout API call on PayPal. |
||
135 | * |
||
136 | * @param array $data |
||
137 | * @param bool $subscription |
||
138 | * |
||
139 | * @throws \Exception |
||
140 | * |
||
141 | * @return array|\Psr\Http\Message\StreamInterface |
||
142 | */ |
||
143 | public function setExpressCheckout($data, $subscription = false) |
||
172 | |||
173 | /** |
||
174 | * Perform a GetExpressCheckoutDetails API call on PayPal. |
||
175 | * |
||
176 | * @param string $token |
||
177 | * |
||
178 | * @throws \Exception |
||
179 | * |
||
180 | * @return array|\Psr\Http\Message\StreamInterface |
||
181 | */ |
||
182 | public function getExpressCheckoutDetails($token) |
||
190 | |||
191 | /** |
||
192 | * Perform DoExpressCheckoutPayment API call on PayPal. |
||
193 | * |
||
194 | * @param array $data |
||
195 | * @param string $token |
||
196 | * @param string $payerid |
||
197 | * |
||
198 | * @throws \Exception |
||
199 | * |
||
200 | * @return array|\Psr\Http\Message\StreamInterface |
||
201 | */ |
||
202 | public function doExpressCheckoutPayment($data, $token, $payerid) |
||
222 | |||
223 | /** |
||
224 | * Perform a DoAuthorization API call on PayPal. |
||
225 | * |
||
226 | * @param string $authorization_id Transaction ID |
||
227 | * @param float $amount Amount to capture |
||
228 | * @param array $data Optional request fields |
||
229 | * |
||
230 | * @throws \Exception |
||
231 | * |
||
232 | * @return array|\Psr\Http\Message\StreamInterface |
||
233 | */ |
||
234 | public function doAuthorization($authorization_id, $amount, $data = []) |
||
245 | |||
246 | /** |
||
247 | * Perform a DoCapture API call on PayPal. |
||
248 | * |
||
249 | * @param string $authorization_id Transaction ID |
||
250 | * @param float $amount Amount to capture |
||
251 | * @param string $complete Indicates whether or not this is the last capture. |
||
252 | * @param array $data Optional request fields |
||
253 | * |
||
254 | * @throws \Exception |
||
255 | * |
||
256 | * @return array|\Psr\Http\Message\StreamInterface |
||
257 | */ |
||
258 | public function doCapture($authorization_id, $amount, $complete = 'Complete', $data = []) |
||
271 | |||
272 | /** |
||
273 | * Perform a DoReauthorization API call on PayPal to reauthorize an existing authorization transaction. |
||
274 | * |
||
275 | * @param string $authorization_id |
||
276 | * @param float $amount |
||
277 | * @param array $data |
||
278 | * |
||
279 | * @throws \Exception |
||
280 | * |
||
281 | * @return array|\Psr\Http\Message\StreamInterface |
||
282 | */ |
||
283 | public function doReAuthorization($authorization_id, $amount, $data = []) |
||
294 | |||
295 | /** |
||
296 | * Perform a DoVoid API call on PayPal. |
||
297 | * |
||
298 | * @param string $authorization_id Transaction ID |
||
299 | * @param array $data Optional request fields |
||
300 | * |
||
301 | * @throws \Exception |
||
302 | * |
||
303 | * @return array|\Psr\Http\Message\StreamInterface |
||
304 | */ |
||
305 | public function doVoid($authorization_id, $data = []) |
||
315 | |||
316 | /** |
||
317 | * Perform a CreateBillingAgreement API call on PayPal. |
||
318 | * |
||
319 | * @param string $token |
||
320 | * |
||
321 | * @throws \Exception |
||
322 | * |
||
323 | * @return array|\Psr\Http\Message\StreamInterface |
||
324 | */ |
||
325 | public function createBillingAgreement($token) |
||
333 | |||
334 | /** |
||
335 | * Perform a CreateRecurringPaymentsProfile API call on PayPal. |
||
336 | * |
||
337 | * @param array $data |
||
338 | * @param string $token |
||
339 | * |
||
340 | * @throws \Exception |
||
341 | * |
||
342 | * @return array|\Psr\Http\Message\StreamInterface |
||
343 | */ |
||
344 | public function createRecurringPaymentsProfile($data, $token) |
||
352 | |||
353 | /** |
||
354 | * Perform a GetRecurringPaymentsProfileDetails API call on PayPal. |
||
355 | * |
||
356 | * @param string $id |
||
357 | * |
||
358 | * @throws \Exception |
||
359 | * |
||
360 | * @return array|\Psr\Http\Message\StreamInterface |
||
361 | */ |
||
362 | public function getRecurringPaymentsProfileDetails($id) |
||
370 | |||
371 | /** |
||
372 | * Perform a UpdateRecurringPaymentsProfile API call on PayPal. |
||
373 | * |
||
374 | * @param array $data |
||
375 | * @param string $id |
||
376 | * |
||
377 | * @throws \Exception |
||
378 | * |
||
379 | * @return array|\Psr\Http\Message\StreamInterface |
||
380 | */ |
||
381 | public function updateRecurringPaymentsProfile($data, $id) |
||
389 | |||
390 | /** |
||
391 | * Change Recurring payment profile status on PayPal. |
||
392 | * |
||
393 | * @param string $id |
||
394 | * @param string $status |
||
395 | * |
||
396 | * @throws \Exception |
||
397 | * |
||
398 | * @return array|\Psr\Http\Message\StreamInterface |
||
399 | */ |
||
400 | protected function manageRecurringPaymentsProfileStatus($id, $status) |
||
409 | |||
410 | /** |
||
411 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to cancel a RecurringPaymentsProfile. |
||
412 | * |
||
413 | * @param string $id |
||
414 | * |
||
415 | * @throws \Exception |
||
416 | * |
||
417 | * @return array|\Psr\Http\Message\StreamInterface |
||
418 | */ |
||
419 | public function cancelRecurringPaymentsProfile($id) |
||
423 | |||
424 | /** |
||
425 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to suspend a RecurringPaymentsProfile. |
||
426 | * |
||
427 | * @param string $id |
||
428 | * |
||
429 | * @throws \Exception |
||
430 | * |
||
431 | * @return array|\Psr\Http\Message\StreamInterface |
||
432 | */ |
||
433 | public function suspendRecurringPaymentsProfile($id) |
||
437 | |||
438 | /** |
||
439 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to reactivate a RecurringPaymentsProfile. |
||
440 | * |
||
441 | * @param string $id |
||
442 | * |
||
443 | * @throws \Exception |
||
444 | * |
||
445 | * @return array|\Psr\Http\Message\StreamInterface |
||
446 | */ |
||
447 | public function reactivateRecurringPaymentsProfile($id) |
||
451 | } |
||
452 |