1 | <?php |
||
11 | trait PayPalRequest |
||
12 | { |
||
13 | /** |
||
14 | * Http Client class object. |
||
15 | * |
||
16 | * @var HttpClient |
||
17 | */ |
||
18 | private $client; |
||
19 | |||
20 | /** |
||
21 | * PayPal API mode to be used. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | public $mode; |
||
26 | |||
27 | /** |
||
28 | * Request data to be sent to PayPal. |
||
29 | * |
||
30 | * @var \Illuminate\Support\Collection |
||
31 | */ |
||
32 | protected $post; |
||
33 | |||
34 | /** |
||
35 | * PayPal API configuration. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $config; |
||
40 | |||
41 | /** |
||
42 | * Default currency for PayPal. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $currency; |
||
47 | |||
48 | /** |
||
49 | * Additional options for PayPal API request. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | private $options; |
||
54 | |||
55 | /** |
||
56 | * Default payment action for PayPal. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | private $paymentAction; |
||
61 | |||
62 | /** |
||
63 | * Default locale for PayPal. |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | private $locale; |
||
68 | |||
69 | /** |
||
70 | * PayPal API Endpoint. |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | private $apiUrl; |
||
75 | |||
76 | /** |
||
77 | * IPN notification url for PayPal. |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | private $notifyUrl; |
||
82 | |||
83 | /** |
||
84 | * Http Client request body parameter name. |
||
85 | * |
||
86 | * @var string |
||
87 | */ |
||
88 | private $httpBodyParam; |
||
89 | |||
90 | /** |
||
91 | * Function To Set PayPal API Configuration. |
||
92 | * |
||
93 | * @param array $config |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | private function setConfig(array $config = []) |
||
116 | |||
117 | /** |
||
118 | * Function to initialize Http Client. |
||
119 | * |
||
120 | * @return HttpClient |
||
121 | */ |
||
122 | protected function setClient() |
||
130 | |||
131 | /** |
||
132 | * Set PayPal API Credentials. |
||
133 | * |
||
134 | * @param array $credentials |
||
135 | * |
||
136 | * @throws \Exception |
||
137 | * |
||
138 | * @return void |
||
139 | */ |
||
140 | public function setApiCredentials($credentials) |
||
163 | |||
164 | /** |
||
165 | * Set API environment to be used by PayPal. |
||
166 | * |
||
167 | * @param array $credentials |
||
168 | * |
||
169 | * @return void |
||
170 | */ |
||
171 | private function setApiEnvironment($credentials) |
||
179 | |||
180 | /** |
||
181 | * Set configuration details for the provider. |
||
182 | * |
||
183 | * @param array $credentials |
||
184 | * |
||
185 | * @throws \Exception |
||
186 | * |
||
187 | * @return void |
||
188 | */ |
||
189 | private function setApiProviderConfiguration($credentials) |
||
221 | |||
222 | /** |
||
223 | * Setup request data to be sent to PayPal. |
||
224 | * |
||
225 | * @param array $data |
||
226 | * |
||
227 | * @return \Illuminate\Support\Collection |
||
228 | */ |
||
229 | protected function setRequestData(array $data = []) |
||
239 | |||
240 | /** |
||
241 | * Set other/override PayPal API parameters. |
||
242 | * |
||
243 | * @param array $options |
||
244 | * |
||
245 | * @return $this |
||
246 | */ |
||
247 | public function addOptions(array $options) |
||
253 | |||
254 | /** |
||
255 | * Function to set currency. |
||
256 | * |
||
257 | * @param string $currency |
||
258 | * |
||
259 | * @throws \Exception |
||
260 | * |
||
261 | * @return $this |
||
262 | */ |
||
263 | public function setCurrency($currency = 'USD') |
||
276 | |||
277 | /** |
||
278 | * Retrieve PayPal IPN Response. |
||
279 | * |
||
280 | * @param array $post |
||
281 | * |
||
282 | * @return array |
||
283 | */ |
||
284 | public function verifyIPN($post) |
||
292 | |||
293 | /** |
||
294 | * Refund PayPal Transaction. |
||
295 | * |
||
296 | * @param string $transaction |
||
297 | * @param float $amount |
||
298 | * |
||
299 | * @return array |
||
300 | */ |
||
301 | public function refundTransaction($transaction, $amount = 0.00) |
||
316 | |||
317 | /** |
||
318 | * Search Transactions On PayPal. |
||
319 | * |
||
320 | * @param array $post |
||
321 | * |
||
322 | * @return array |
||
323 | */ |
||
324 | public function searchTransactions($post) |
||
330 | |||
331 | /** |
||
332 | * Create request payload to be sent to PayPal. |
||
333 | * |
||
334 | * @param string $method |
||
335 | */ |
||
336 | private function createRequestPayload($method) |
||
351 | |||
352 | /** |
||
353 | * Perform PayPal API request & return response. |
||
354 | * |
||
355 | * @throws \Exception |
||
356 | * |
||
357 | * @return \Psr\Http\Message\StreamInterface |
||
358 | */ |
||
359 | private function makeHttpRequest() |
||
373 | |||
374 | /** |
||
375 | * Function To Perform PayPal API Request. |
||
376 | * |
||
377 | * @param string $method |
||
378 | * |
||
379 | * @throws \Exception |
||
380 | * |
||
381 | * @return array|\Psr\Http\Message\StreamInterface |
||
382 | */ |
||
383 | private function doPayPalRequest($method) |
||
402 | |||
403 | /** |
||
404 | * Parse PayPal NVP Response. |
||
405 | * |
||
406 | * @param string $method |
||
407 | * @param mixed $response |
||
408 | * |
||
409 | * @return array |
||
410 | */ |
||
411 | private function retrieveData($method, $response) |
||
421 | } |
||
422 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.