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 | * @param array $config |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | private function setConfig(array $config = []) |
||
76 | |||
77 | /** |
||
78 | * Function to initialize Http Client. |
||
79 | * |
||
80 | * @return HttpClient |
||
81 | */ |
||
82 | protected function setClient() |
||
90 | |||
91 | /** |
||
92 | * Set PayPal API Credentials. |
||
93 | * |
||
94 | * @param array $credentials |
||
95 | * @param string $mode |
||
96 | * |
||
97 | * @throws \Exception |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | public function setApiCredentials($credentials, $mode = '') |
||
149 | |||
150 | /** |
||
151 | * Setup request data to be sent to PayPal. |
||
152 | * |
||
153 | * @param array $data |
||
154 | * |
||
155 | * @return \Illuminate\Support\Collection |
||
156 | */ |
||
157 | protected function setRequestData(array $data = []) |
||
167 | |||
168 | /** |
||
169 | * Set other/override PayPal API parameters. |
||
170 | * |
||
171 | * @param array $options |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function addOptions(array $options) |
||
181 | |||
182 | /** |
||
183 | * Function to set currency. |
||
184 | * |
||
185 | * @param string $currency |
||
186 | * |
||
187 | * @throws \Exception |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function setCurrency($currency = 'USD') |
||
204 | |||
205 | /** |
||
206 | * Retrieve PayPal IPN Response. |
||
207 | * |
||
208 | * @param array $post |
||
209 | * |
||
210 | * @return array |
||
211 | */ |
||
212 | public function verifyIPN($post) |
||
218 | |||
219 | /** |
||
220 | * Refund PayPal Transaction. |
||
221 | * |
||
222 | * @param string $transaction |
||
223 | * |
||
224 | * @return array |
||
225 | */ |
||
226 | public function refundTransaction($transaction) |
||
234 | |||
235 | /** |
||
236 | * Search Transactions On PayPal. |
||
237 | * |
||
238 | * @param array $post |
||
239 | * |
||
240 | * @return array |
||
241 | */ |
||
242 | public function searchTransactions($post) |
||
248 | |||
249 | /** |
||
250 | * Function To Perform PayPal API Request. |
||
251 | * |
||
252 | * @param string $method |
||
253 | * |
||
254 | * @throws \Exception |
||
255 | * |
||
256 | * @return array|\Psr\Http\Message\StreamInterface |
||
257 | */ |
||
258 | private function doPayPalRequest($method) |
||
318 | |||
319 | /** |
||
320 | * Perform Http request and return response. |
||
321 | * |
||
322 | * @param string $url |
||
323 | * @return \Psr\Http\Message\ResponseInterface |
||
324 | */ |
||
325 | private function performHttpRequest($url) |
||
337 | |||
338 | /** |
||
339 | * Parse PayPal NVP Response. |
||
340 | * |
||
341 | * @param string $request |
||
342 | * @param array $response |
||
343 | * |
||
344 | * @return array |
||
345 | */ |
||
346 | private function retrieveData($request, array $response = null) |
||
352 | } |
||
353 |