1 | <?php |
||
11 | trait PayPalRequest |
||
12 | { |
||
13 | /** |
||
14 | * Http Client class object. |
||
15 | * |
||
16 | * @var HttpClient |
||
17 | */ |
||
18 | private $client; |
||
19 | |||
20 | /** |
||
21 | * Request data to be sent to PayPal. |
||
22 | * |
||
23 | * @var \Illuminate\Support\Collection |
||
24 | */ |
||
25 | protected $post; |
||
26 | |||
27 | /** |
||
28 | * PayPal API configuration. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | private $config; |
||
33 | |||
34 | /** |
||
35 | * Default currency for PayPal. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $currency; |
||
40 | |||
41 | /** |
||
42 | * Additional options for PayPal API request. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | private $options; |
||
47 | |||
48 | /** |
||
49 | * Default payment action for PayPal. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | private $paymentAction; |
||
54 | |||
55 | /** |
||
56 | * Default locale for PayPal. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | private $locale; |
||
61 | |||
62 | /** |
||
63 | * IPN notification url for PayPal. |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | private $notifyUrl; |
||
68 | |||
69 | /** |
||
70 | * Http Client request body parameter name. |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | private $httpBodyParam; |
||
75 | |||
76 | /** |
||
77 | * Function To Set PayPal API Configuration. |
||
78 | * |
||
79 | * @param array $config |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | private function setConfig(array $config = []) |
||
99 | |||
100 | /** |
||
101 | * Function to initialize Http Client. |
||
102 | * |
||
103 | * @return HttpClient |
||
104 | */ |
||
105 | protected function setClient() |
||
113 | |||
114 | /** |
||
115 | * Set PayPal API Credentials. |
||
116 | * |
||
117 | * @param array $credentials |
||
118 | * @param string $mode |
||
119 | * |
||
120 | * @throws \Exception |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public function setApiCredentials($credentials, $mode = '') |
||
172 | |||
173 | /** |
||
174 | * Setup request data to be sent to PayPal. |
||
175 | * |
||
176 | * @param array $data |
||
177 | * |
||
178 | * @return \Illuminate\Support\Collection |
||
179 | */ |
||
180 | protected function setRequestData(array $data = []) |
||
190 | |||
191 | /** |
||
192 | * Set other/override PayPal API parameters. |
||
193 | * |
||
194 | * @param array $options |
||
195 | * |
||
196 | * @return $this |
||
197 | */ |
||
198 | public function addOptions(array $options) |
||
204 | |||
205 | /** |
||
206 | * Function to set currency. |
||
207 | * |
||
208 | * @param string $currency |
||
209 | * |
||
210 | * @throws \Exception |
||
211 | * |
||
212 | * @return $this |
||
213 | */ |
||
214 | public function setCurrency($currency = 'USD') |
||
227 | |||
228 | /** |
||
229 | * Retrieve PayPal IPN Response. |
||
230 | * |
||
231 | * @param array $post |
||
232 | * |
||
233 | * @return array |
||
234 | */ |
||
235 | public function verifyIPN($post) |
||
241 | |||
242 | /** |
||
243 | * Refund PayPal Transaction. |
||
244 | * |
||
245 | * @param string $transaction |
||
246 | * |
||
247 | * @return array |
||
248 | */ |
||
249 | public function refundTransaction($transaction) |
||
257 | |||
258 | /** |
||
259 | * Search Transactions On PayPal. |
||
260 | * |
||
261 | * @param array $post |
||
262 | * |
||
263 | * @return array |
||
264 | */ |
||
265 | public function searchTransactions($post) |
||
271 | |||
272 | /** |
||
273 | * Function To Perform PayPal API Request. |
||
274 | * |
||
275 | * @param string $method |
||
276 | * |
||
277 | * @throws \Exception |
||
278 | * |
||
279 | * @return array|\Psr\Http\Message\StreamInterface |
||
280 | */ |
||
281 | private function doPayPalRequest($method) |
||
343 | |||
344 | /** |
||
345 | * Parse PayPal NVP Response. |
||
346 | * |
||
347 | * @param string $request |
||
348 | * @param array $response |
||
349 | * |
||
350 | * @return array |
||
351 | */ |
||
352 | private function retrieveData($request, array $response = null) |
||
358 | } |
||
359 |