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 | * Perform a SetExpressCheckout API call on PayPal. |
||
121 | * |
||
122 | * @param array $data |
||
123 | * @param bool $subscription |
||
124 | * |
||
125 | * @return array|\Psr\Http\Message\StreamInterface |
||
126 | * |
||
127 | * @throws \Exception |
||
128 | */ |
||
129 | public function setExpressCheckout($data, $subscription = false) |
||
156 | |||
157 | /** |
||
158 | * Perform a GetExpressCheckoutDetails API call on PayPal. |
||
159 | * |
||
160 | * @param string $token |
||
161 | * |
||
162 | * @return array|\Psr\Http\Message\StreamInterface |
||
163 | * |
||
164 | * @throws \Exception |
||
165 | */ |
||
166 | public function getExpressCheckoutDetails($token) |
||
174 | |||
175 | /** |
||
176 | * Perform DoExpressCheckoutPayment API call on PayPal. |
||
177 | * |
||
178 | * @param array $data |
||
179 | * @param string $token |
||
180 | * @param string $payerid |
||
181 | * |
||
182 | * @return array|\Psr\Http\Message\StreamInterface |
||
183 | * |
||
184 | * @throws \Exception |
||
185 | */ |
||
186 | public function doExpressCheckoutPayment($data, $token, $payerid) |
||
202 | |||
203 | /** |
||
204 | * Perform a DoAuthorization API call on PayPal. |
||
205 | * |
||
206 | * @param string $authorization_id Transaction ID |
||
207 | * @param float $amount Amount to capture |
||
208 | * @param array $data Optional request fields |
||
209 | * |
||
210 | * @return array|\Psr\Http\Message\StreamInterface |
||
211 | * |
||
212 | * @throws \Exception |
||
213 | */ |
||
214 | public function doAuthorization($authorization_id, $amount, $data = []) |
||
225 | |||
226 | /** |
||
227 | * Perform a DoCapture API call on PayPal. |
||
228 | * |
||
229 | * @param string $authorization_id Transaction ID |
||
230 | * @param float $amount Amount to capture |
||
231 | * @param string $complete Indicates whether or not this is the last capture. |
||
232 | * @param array $data Optional request fields |
||
233 | * |
||
234 | * @return array|\Psr\Http\Message\StreamInterface |
||
235 | * |
||
236 | * @throws \Exception |
||
237 | */ |
||
238 | public function doCapture($authorization_id, $amount, $complete = 'Complete', $data = []) |
||
251 | |||
252 | /** |
||
253 | * Perform a DoReauthorization API call on PayPal to reauthorize an existing authorization transaction. |
||
254 | * |
||
255 | * @param string $authorization_id |
||
256 | * @param float $amount |
||
257 | * @param array $data |
||
258 | * |
||
259 | * @return array|\Psr\Http\Message\StreamInterface |
||
260 | * |
||
261 | * @throws \Exception |
||
262 | */ |
||
263 | public function doReAuthorization($authorization_id, $amount, $data = []) |
||
274 | |||
275 | /** |
||
276 | * Perform a DoVoid API call on PayPal. |
||
277 | * |
||
278 | * @param string $authorization_id Transaction ID |
||
279 | * @param array $data Optional request fields |
||
280 | * |
||
281 | * @return array|\Psr\Http\Message\StreamInterface |
||
282 | * |
||
283 | * @throws \Exception |
||
284 | */ |
||
285 | public function doVoid($authorization_id, $data = []) |
||
295 | |||
296 | /** |
||
297 | * Perform a CreateBillingAgreement API call on PayPal. |
||
298 | * |
||
299 | * @param string $token |
||
300 | * |
||
301 | * @return array|\Psr\Http\Message\StreamInterface |
||
302 | * |
||
303 | * @throws \Exception |
||
304 | */ |
||
305 | public function createBillingAgreement($token) |
||
313 | |||
314 | /** |
||
315 | * Perform a CreateRecurringPaymentsProfile API call on PayPal. |
||
316 | * |
||
317 | * @param array $data |
||
318 | * @param string $token |
||
319 | * |
||
320 | * @return array|\Psr\Http\Message\StreamInterface |
||
321 | * |
||
322 | * @throws \Exception |
||
323 | */ |
||
324 | public function createRecurringPaymentsProfile($data, $token) |
||
332 | |||
333 | /** |
||
334 | * Perform a GetRecurringPaymentsProfileDetails API call on PayPal. |
||
335 | * |
||
336 | * @param string $id |
||
337 | * |
||
338 | * @return array|\Psr\Http\Message\StreamInterface |
||
339 | * |
||
340 | * @throws \Exception |
||
341 | */ |
||
342 | public function getRecurringPaymentsProfileDetails($id) |
||
350 | |||
351 | /** |
||
352 | * Perform a UpdateRecurringPaymentsProfile API call on PayPal. |
||
353 | * |
||
354 | * @param array $data |
||
355 | * @param string $id |
||
356 | * |
||
357 | * @return array|\Psr\Http\Message\StreamInterface |
||
358 | * |
||
359 | * @throws \Exception |
||
360 | */ |
||
361 | public function updateRecurringPaymentsProfile($data, $id) |
||
369 | |||
370 | /** |
||
371 | * Change Recurring payment profile status on PayPal. |
||
372 | * |
||
373 | * @param string $id |
||
374 | * @param string $status |
||
375 | * |
||
376 | * @return array|\Psr\Http\Message\StreamInterface |
||
377 | * |
||
378 | * @throws \Exception |
||
379 | */ |
||
380 | protected function manageRecurringPaymentsProfileStatus($id, $status) |
||
389 | |||
390 | /** |
||
391 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to cancel a RecurringPaymentsProfile. |
||
392 | * |
||
393 | * @param string $id |
||
394 | * |
||
395 | * @return array|\Psr\Http\Message\StreamInterface |
||
396 | * |
||
397 | * @throws \Exception |
||
398 | */ |
||
399 | public function cancelRecurringPaymentsProfile($id) |
||
403 | |||
404 | /** |
||
405 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to suspend a RecurringPaymentsProfile. |
||
406 | * |
||
407 | * @param string $id |
||
408 | * |
||
409 | * @return array|\Psr\Http\Message\StreamInterface |
||
410 | * |
||
411 | * @throws \Exception |
||
412 | */ |
||
413 | public function suspendRecurringPaymentsProfile($id) |
||
417 | |||
418 | /** |
||
419 | * Perform a ManageRecurringPaymentsProfileStatus API call on PayPal to reactivate a RecurringPaymentsProfile. |
||
420 | * |
||
421 | * @param string $id |
||
422 | * |
||
423 | * @return array|\Psr\Http\Message\StreamInterface |
||
424 | * |
||
425 | * @throws \Exception |
||
426 | */ |
||
427 | public function reactivateRecurringPaymentsProfile($id) |
||
431 | } |
||
432 |