1 | <?php |
||
11 | trait PayPalRequest |
||
12 | { |
||
13 | /** |
||
14 | * @var HttpClient |
||
15 | */ |
||
16 | private $client; |
||
17 | |||
18 | /** |
||
19 | * @var \Illuminate\Support\Collection |
||
20 | */ |
||
21 | protected $post; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $config; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $currency; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $options; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $paymentAction; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | private $locale; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | private $notifyUrl; |
||
52 | |||
53 | /** |
||
54 | * Function To Set PayPal API Configuration. |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | private function setConfig() |
||
72 | |||
73 | /** |
||
74 | * Function to initialize Http Client. |
||
75 | * |
||
76 | * @return HttpClient |
||
77 | */ |
||
78 | protected function setClient() |
||
86 | |||
87 | /** |
||
88 | * Set PayPal API Credentials. |
||
89 | * |
||
90 | * @param array $credentials |
||
91 | * @param string $mode |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | public function setApiCredentials($credentials, $mode = '') |
||
143 | |||
144 | /** |
||
145 | * Setup request data to be sent to PayPal. |
||
146 | * |
||
147 | * @param array $data |
||
148 | * |
||
149 | * @return \Illuminate\Support\Collection |
||
150 | */ |
||
151 | protected function setRequestData(array $data = []) |
||
161 | |||
162 | /** |
||
163 | * Set other/override PayPal API parameters. |
||
164 | * |
||
165 | * @param array $options |
||
166 | * |
||
167 | * @return $this |
||
168 | */ |
||
169 | public function addOptions(array $options) |
||
175 | |||
176 | /** |
||
177 | * Function to set currency. |
||
178 | * |
||
179 | * @param string $currency |
||
180 | * |
||
181 | * @throws \Exception |
||
182 | * |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function setCurrency($currency = 'USD') |
||
198 | |||
199 | /** |
||
200 | * Retrieve PayPal IPN Response. |
||
201 | * |
||
202 | * @param array $post |
||
203 | * |
||
204 | * @return array |
||
205 | */ |
||
206 | public function verifyIPN($post) |
||
212 | |||
213 | /** |
||
214 | * Refund PayPal Transaction. |
||
215 | * |
||
216 | * @param string $transaction |
||
217 | * |
||
218 | * @return array |
||
219 | */ |
||
220 | public function refundTransaction($transaction) |
||
228 | |||
229 | /** |
||
230 | * Search Transactions On PayPal. |
||
231 | * |
||
232 | * @param array $post |
||
233 | * |
||
234 | * @return array |
||
235 | */ |
||
236 | public function searchTransactions($post) |
||
242 | |||
243 | /** |
||
244 | * Function To Perform PayPal API Request. |
||
245 | * |
||
246 | * @param string $method |
||
247 | * |
||
248 | * @throws \Exception |
||
249 | * |
||
250 | * @return array|\Psr\Http\Message\StreamInterface |
||
251 | */ |
||
252 | private function doPayPalRequest($method) |
||
314 | |||
315 | /** |
||
316 | * Parse PayPal NVP Response. |
||
317 | * |
||
318 | * @param string $request |
||
319 | * @param array $response |
||
320 | * |
||
321 | * @return array |
||
322 | */ |
||
323 | private function retrieveData($request, array $response = null) |
||
329 | } |
||
330 |