1 | <?php |
||
7 | class AdaptivePayments |
||
8 | { |
||
9 | use PayPalAPIRequest; |
||
10 | |||
11 | /** |
||
12 | * PayPal Processor Constructor. |
||
13 | */ |
||
14 | public function __construct() |
||
19 | |||
20 | /** |
||
21 | * Set AdaptivePayments API endpoints & options. |
||
22 | * |
||
23 | * @return void |
||
24 | */ |
||
25 | public function setAdaptivePaymentsOptions() |
||
35 | |||
36 | /** |
||
37 | * Set Adaptive Payments API request headers. |
||
38 | * |
||
39 | * @return array |
||
40 | */ |
||
41 | private function setHeaders() |
||
54 | |||
55 | /** |
||
56 | * Set Adaptive Payments API request envelope. |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | private function setEnvelope() |
||
69 | |||
70 | /** |
||
71 | * Set request details for Pay API operation. |
||
72 | * |
||
73 | * @param array $data |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | private function setPayRequestDetails($data) |
||
93 | |||
94 | /** |
||
95 | * Function to perform Adaptive Payments API's PAY operation. |
||
96 | * |
||
97 | * @param array $data |
||
98 | * |
||
99 | * @throws \Exception |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | public function createPayRequest($data) |
||
113 | |||
114 | /** |
||
115 | * Function to perform Adaptive Payments API's SetPaymentOptions operation. |
||
116 | * |
||
117 | * @param string $payKey |
||
118 | * @param array $receivers |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | public function setPaymentOptions($payKey, $receivers) |
||
133 | |||
134 | /** |
||
135 | * Function to perform Adaptive Payments API's GetPaymentOptions operation. |
||
136 | * |
||
137 | * @param string $payKey |
||
138 | * @param bool $details |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | public function getPaymentOptions($payKey, $details = false) |
||
153 | |||
154 | /** |
||
155 | * Function to perform Adaptive Payments API's PaymentDetails operation. |
||
156 | * |
||
157 | * @param string $payKey |
||
158 | * |
||
159 | * @return array |
||
160 | */ |
||
161 | public function getPaymentDetails($payKey) |
||
165 | |||
166 | /** |
||
167 | * Get PayPal redirect url for processing payment. |
||
168 | * |
||
169 | * @param string $option |
||
170 | * @param string $payKey |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getRedirectUrl($option, $payKey) |
||
186 | |||
187 | /** |
||
188 | * Set receiver details for SetPaymentOptions. |
||
189 | * |
||
190 | * @param array $receivers |
||
191 | * |
||
192 | * @return array |
||
193 | */ |
||
194 | private function setPaymentOptionsReceiverDetails($receivers) |
||
212 | |||
213 | /** |
||
214 | * Create request payload to be sent to PayPal. |
||
215 | * |
||
216 | * @param string $method |
||
217 | */ |
||
218 | private function createRequestPayload($method) |
||
224 | |||
225 | /** |
||
226 | * Perform PayPal API request & return response. |
||
227 | * |
||
228 | * @throws \Exception |
||
229 | * |
||
230 | * @return \Psr\Http\Message\StreamInterface |
||
231 | */ |
||
232 | private function makeHttpRequest() |
||
247 | |||
248 | /** |
||
249 | * Function To Perform PayPal API Request. |
||
250 | * |
||
251 | * @param string $method |
||
252 | * |
||
253 | * @throws \Exception |
||
254 | * |
||
255 | * @return array|mixed|\Psr\Http\Message\StreamInterface |
||
256 | */ |
||
257 | private function doPayPalRequest($method) |
||
275 | } |
||
276 |