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 | * Function to perform Adaptive Payments API's PAY operation. |
||
72 | * |
||
73 | * @param array $data |
||
74 | * |
||
75 | * @throws \Exception |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function createPayRequest($data) |
||
101 | |||
102 | /** |
||
103 | * Function to perform Adaptive Payments API's SetPaymentOptions operation. |
||
104 | * |
||
105 | * @param string $payKey |
||
106 | * @param array $receivers |
||
107 | * |
||
108 | * @return array |
||
109 | */ |
||
110 | public function setPaymentOptions($payKey, $receivers) |
||
121 | |||
122 | /** |
||
123 | * Function to perform Adaptive Payments API's GetPaymentOptions operation. |
||
124 | * |
||
125 | * @param string $payKey |
||
126 | * @param bool $details |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | public function getPaymentOptions($payKey, $details = false) |
||
141 | |||
142 | /** |
||
143 | * Function to perform Adaptive Payments API's PaymentDetails operation. |
||
144 | * |
||
145 | * @param string $payKey |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | public function getPaymentDetails($payKey) |
||
153 | |||
154 | /** |
||
155 | * Get PayPal redirect url for processing payment. |
||
156 | * |
||
157 | * @param string $option |
||
158 | * @param string $payKey |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getRedirectUrl($option, $payKey) |
||
174 | |||
175 | /** |
||
176 | * Set receiver details for SetPaymentOptions. |
||
177 | * |
||
178 | * @param array $receivers |
||
179 | * @return array |
||
180 | */ |
||
181 | private function setPaymentOptionsReceiverDetails($receivers) |
||
199 | |||
200 | /** |
||
201 | * Create request payload to be sent to PayPal. |
||
202 | * |
||
203 | * @param string $method |
||
204 | */ |
||
205 | private function createRequestPayload($method) |
||
211 | |||
212 | /** |
||
213 | * Perform PayPal API request & return response. |
||
214 | * |
||
215 | * @throws \Exception |
||
216 | * |
||
217 | * @return \Psr\Http\Message\StreamInterface |
||
218 | */ |
||
219 | private function makeHttpRequest() |
||
234 | |||
235 | /** |
||
236 | * Function To Perform PayPal API Request. |
||
237 | * |
||
238 | * @param string $method |
||
239 | * |
||
240 | * @throws \Exception |
||
241 | * |
||
242 | * @return array|mixed|\Psr\Http\Message\StreamInterface |
||
243 | */ |
||
244 | private function doPayPalRequest($method) |
||
262 | } |
||
263 |