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) |
||
171 | |||
172 | /** |
||
173 | * Perform a GetExpressCheckoutDetails API call on PayPal. |
||
174 | * |
||
175 | * @param string $token |
||
176 | * |
||
177 | * @throws \Exception |
||
178 | * |
||
179 | * @return array|\Psr\Http\Message\StreamInterface |
||
180 | */ |
||
181 | public function getExpressCheckoutDetails($token) |
||
189 | |||
190 | /** |
||
191 | * Perform DoExpressCheckoutPayment API call on PayPal. |
||
192 | * |
||
193 | * @param array $data |
||
194 | * @param string $token |
||
195 | * @param string $payerid |
||
196 | * |
||
197 | * @throws \Exception |
||
198 | * |
||
199 | * @return array|\Psr\Http\Message\StreamInterface |
||
200 | */ |
||
201 | public function doExpressCheckoutPayment($data, $token, $payerid) |
||
221 | |||
222 | /** |
||
223 | * Perform a DoAuthorization API call on PayPal. |
||
224 | * |
||
225 | * @param string $authorization_id Transaction ID |
||
226 | * @param float $amount Amount to capture |
||
227 | * @param array $data Optional request fields |
||
228 | * |
||
229 | * @throws \Exception |
||
230 | * |
||
231 | * @return array|\Psr\Http\Message\StreamInterface |
||
232 | */ |
||
233 | public function doAuthorization($authorization_id, $amount, $data = []) |
||
244 | |||
245 | /** |
||
246 | * Perform a DoCapture API call on PayPal. |
||
247 | * |
||
248 | * @param string $authorization_id Transaction ID |
||
249 | * @param float $amount Amount to capture |
||
250 | * @param string $complete Indicates whether or not this is the last capture. |
||
251 | * @param array $data Optional request fields |
||
252 | * |
||
253 | * @throws \Exception |
||
254 | * |
||
255 | * @return array|\Psr\Http\Message\StreamInterface |
||
256 | */ |
||
257 | public function doCapture($authorization_id, $amount, $complete = 'Complete', $data = []) |
||
270 | |||
271 | /** |
||
272 | * Perform a DoReauthorization API call on PayPal to reauthorize an existing authorization transaction. |
||
273 | * |
||
274 | * @param string $authorization_id |
||
275 | * @param float $amount |
||
276 | * @param array $data |
||
277 | * |
||
278 | * @throws \Exception |
||
279 | * |
||
280 | * @return array|\Psr\Http\Message\StreamInterface |
||
281 | */ |
||
282 | public function doReAuthorization($authorization_id, $amount, $data = []) |
||
293 | |||
294 | /** |
||
295 | * Perform a DoVoid API call on PayPal. |
||
296 | * |
||
297 | * @param string $authorization_id Transaction ID |
||
298 | * @param array $data Optional request fields |
||
299 | * |
||
300 | * @throws \Exception |
||
301 | * |
||
302 | * @return array|\Psr\Http\Message\StreamInterface |
||
303 | */ |
||
304 | public function doVoid($authorization_id, $data = []) |
||
314 | |||
315 | /** |
||
316 | * Perform a CreateBillingAgreement API call on PayPal. |
||
317 | * |
||
318 | * @param string $token |
||
319 | * |
||
320 | * @throws \Exception |
||
321 | * |
||
322 | * @return array|\Psr\Http\Message\StreamInterface |
||
323 | */ |
||
324 | public function createBillingAgreement($token) |
||
332 | |||
333 | /** |
||
334 | * Perform a CreateRecurringPaymentsProfile API call on PayPal. |
||
335 | * |
||
336 | * @param array $data |
||
337 | * @param string $token |
||
338 | * |
||
339 | * @throws \Exception |
||
340 | * |
||
341 | * @return array|\Psr\Http\Message\StreamInterface |
||
342 | */ |
||
343 | public function createRecurringPaymentsProfile($data, $token) |
||
351 | |||
352 | /** |
||
353 | * Perform a GetRecurringPaymentsProfileDetails API call on PayPal. |
||
354 | * |
||
355 | * @param string $id |
||
356 | * |
||
357 | * @throws \Exception |
||
358 | * |
||
359 | * @return array|\Psr\Http\Message\StreamInterface |
||
360 | */ |
||
361 | public function getRecurringPaymentsProfileDetails($id) |
||
369 | |||
370 | /** |
||
371 | * Perform a UpdateRecurringPaymentsProfile API call on PayPal. |
||
372 | * |
||
373 | * @param array $data |
||
374 | * @param string $id |
||
375 | * |
||
376 | * @throws \Exception |
||
377 | * |
||
378 | * @return array|\Psr\Http\Message\StreamInterface |
||
379 | */ |
||
380 | public function updateRecurringPaymentsProfile($data, $id) |
||
388 | |||
389 | /** |
||
390 | * Change Recurring payment profile status on PayPal. |
||
391 | * |
||
392 | * @param string $id |
||
393 | * @param string $status |
||
394 | * |
||
395 | * @throws \Exception |
||
396 | * |
||
397 | * @return array|\Psr\Http\Message\StreamInterface |
||
398 | */ |
||
399 | protected function manageRecurringPaymentsProfileStatus($id, $status) |
||
408 | |||
409 | /** |
||
410 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to cancel a RecurringPaymentsProfile. |
||
411 | * |
||
412 | * @param string $id |
||
413 | * |
||
414 | * @throws \Exception |
||
415 | * |
||
416 | * @return array|\Psr\Http\Message\StreamInterface |
||
417 | */ |
||
418 | public function cancelRecurringPaymentsProfile($id) |
||
422 | |||
423 | /** |
||
424 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to suspend a RecurringPaymentsProfile. |
||
425 | * |
||
426 | * @param string $id |
||
427 | * |
||
428 | * @throws \Exception |
||
429 | * |
||
430 | * @return array|\Psr\Http\Message\StreamInterface |
||
431 | */ |
||
432 | public function suspendRecurringPaymentsProfile($id) |
||
436 | |||
437 | /** |
||
438 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to reactivate a RecurringPaymentsProfile. |
||
439 | * |
||
440 | * @param string $id |
||
441 | * |
||
442 | * @throws \Exception |
||
443 | * |
||
444 | * @return array|\Psr\Http\Message\StreamInterface |
||
445 | */ |
||
446 | public function reactivateRecurringPaymentsProfile($id) |
||
450 | } |
||
451 |