1 | <?php namespace Arcanedev\Stripe; |
||
14 | abstract class Stripe implements StripeContract |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Constants |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * Library Version. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | const VERSION = '5.2.0'; |
||
27 | |||
28 | /* ----------------------------------------------------------------- |
||
29 | | Properties |
||
30 | | ----------------------------------------------------------------- |
||
31 | */ |
||
32 | |||
33 | /** |
||
34 | * The Stripe API key to be used for requests. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private static $apiKey; |
||
39 | |||
40 | /** |
||
41 | * The Stripe client_id to be used for Connect requests. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | public static $clientId; |
||
46 | |||
47 | /** |
||
48 | * The base URL for the Stripe API. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | public static $apiBaseUrl = 'https://api.stripe.com'; |
||
53 | |||
54 | /** |
||
55 | * The base URL for the OAuth API. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | public static $connectBase = 'https://connect.stripe.com'; |
||
60 | |||
61 | /** |
||
62 | * The base URL for the Stripe API uploads endpoint. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | public static $uploadBaseUrl = 'https://uploads.stripe.com'; |
||
67 | |||
68 | /** |
||
69 | * The version of the Stripe API to use for requests. |
||
70 | * |
||
71 | * @var string|null |
||
72 | */ |
||
73 | public static $apiVersion = null; |
||
74 | |||
75 | /** |
||
76 | * The account ID for connected accounts requests. |
||
77 | * |
||
78 | * @var string|null |
||
79 | */ |
||
80 | public static $accountId = null; |
||
81 | |||
82 | /** |
||
83 | * Verify SSL Certs. |
||
84 | * |
||
85 | * @var bool |
||
86 | */ |
||
87 | public static $verifySslCerts = true; |
||
88 | |||
89 | /** |
||
90 | * The application's information (name, version, URL). |
||
91 | * |
||
92 | * @var array |
||
93 | */ |
||
94 | public static $appInfo = []; |
||
95 | |||
96 | /** |
||
97 | * The logger instance. |
||
98 | * |
||
99 | * @var \Psr\Log\LoggerInterface |
||
100 | */ |
||
101 | public static $logger = null; |
||
102 | |||
103 | /* ----------------------------------------------------------------- |
||
104 | | Getters & Setters |
||
105 | | ----------------------------------------------------------------- |
||
106 | */ |
||
107 | |||
108 | /** |
||
109 | * Get the API key used for requests. |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 414 | public static function getApiKey() |
|
117 | |||
118 | /** |
||
119 | * Sets the API key to be used for requests. |
||
120 | * |
||
121 | * @param string $apiKey |
||
122 | */ |
||
123 | 690 | public static function setApiKey($apiKey) |
|
129 | |||
130 | /** |
||
131 | * Get API Base URL. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | 408 | public static function getApiBaseUrl() |
|
139 | |||
140 | /** |
||
141 | * Set API Base URL. |
||
142 | * |
||
143 | * @param string $apiBaseUrl |
||
144 | */ |
||
145 | 6 | public static function setApiBaseUrl($apiBaseUrl) |
|
151 | |||
152 | /** |
||
153 | * The client_id used for Connect requests. |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | 6 | public static function getClientId() |
|
161 | |||
162 | /** |
||
163 | * Sets the client_id to be used for Connect requests. |
||
164 | * |
||
165 | * @param string $clientId |
||
166 | */ |
||
167 | 12 | public static function setClientId($clientId) |
|
171 | |||
172 | /** |
||
173 | * Get Upload Base URL. |
||
174 | * |
||
175 | * @return string |
||
176 | */ |
||
177 | 8 | public static function getUploadBaseUrl() |
|
181 | |||
182 | /** |
||
183 | * Set Upload Base URL. |
||
184 | * |
||
185 | * @param string $uploadBaseUrl |
||
186 | */ |
||
187 | 6 | public static function setUploadBaseUrl($uploadBaseUrl) |
|
193 | |||
194 | /** |
||
195 | * The API version used for requests. null if we're using the latest version. |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | 324 | public static function getApiVersion() |
|
203 | |||
204 | /** |
||
205 | * The API version used for requests. null if we're using the latest version. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | 2 | public static function version() |
|
213 | |||
214 | /** |
||
215 | * Sets the API version to use for requests. |
||
216 | * |
||
217 | * @param string $apiVersion |
||
218 | */ |
||
219 | 690 | public static function setApiVersion($apiVersion) |
|
225 | |||
226 | /** |
||
227 | * Get the Stripe account ID for connected accounts requests. |
||
228 | * |
||
229 | * @return string|null |
||
230 | */ |
||
231 | 2 | public static function getAccountId() |
|
235 | |||
236 | /** |
||
237 | * Set the Stripe account ID to set for connected accounts requests. |
||
238 | * |
||
239 | * @param string $accountId |
||
240 | */ |
||
241 | 2 | public static function setAccountId($accountId) |
|
245 | |||
246 | /** |
||
247 | * Get Verify SSL Certs. |
||
248 | * |
||
249 | * @return bool |
||
250 | */ |
||
251 | 2 | public static function getVerifySslCerts() |
|
255 | |||
256 | /** |
||
257 | * Sets Verify SSL Certs. |
||
258 | * |
||
259 | * @param bool $verify |
||
260 | */ |
||
261 | 18 | public static function setVerifySslCerts($verify) |
|
265 | |||
266 | /** |
||
267 | * Get the Application's information. |
||
268 | * |
||
269 | * @return array |
||
270 | */ |
||
271 | 314 | public static function getAppInfo() |
|
275 | |||
276 | /** |
||
277 | * Set the Application's information. |
||
278 | * |
||
279 | * @param string $name The application's name |
||
280 | * @param string $version The application's version |
||
281 | * @param string $url The application's URL |
||
282 | */ |
||
283 | 4 | public static function setAppInfo($name, $version = null, $url = null) |
|
287 | |||
288 | /** |
||
289 | * Get the logger instance. |
||
290 | * |
||
291 | * @return \Psr\Log\LoggerInterface |
||
292 | */ |
||
293 | public static function getLogger() |
||
300 | |||
301 | /** |
||
302 | * Set the logger instance. |
||
303 | * |
||
304 | * @param \Psr\Log\LoggerInterface $logger |
||
305 | */ |
||
306 | public static function setLogger(LoggerInterface $logger) |
||
310 | |||
311 | /* ----------------------------------------------------------------- |
||
312 | | Main Methods |
||
313 | | ----------------------------------------------------------------- |
||
314 | */ |
||
315 | |||
316 | /** |
||
317 | * Init Stripe. |
||
318 | * |
||
319 | * @param string $apiKey |
||
320 | */ |
||
321 | 2 | public static function init($apiKey) |
|
325 | |||
326 | /* ----------------------------------------------------------------- |
||
327 | | Check Methods |
||
328 | | ----------------------------------------------------------------- |
||
329 | */ |
||
330 | |||
331 | /** |
||
332 | * Check API Key. |
||
333 | * |
||
334 | * @param string $apiKey |
||
335 | * |
||
336 | * @throws \Arcanedev\Stripe\Exceptions\ApiException |
||
337 | * @throws \Arcanedev\Stripe\Exceptions\ApiKeyNotSetException |
||
338 | */ |
||
339 | 690 | private static function checkApiKey(&$apiKey) |
|
349 | |||
350 | /** |
||
351 | * Check API Base URL. |
||
352 | * |
||
353 | * @param string $apiBaseUrl |
||
354 | * |
||
355 | * @throws \Arcanedev\Stripe\Exceptions\ApiException |
||
356 | */ |
||
357 | 6 | private static function checkApiBaseUrl($apiBaseUrl) |
|
367 | |||
368 | /** |
||
369 | * Check Upload Base URL. |
||
370 | * |
||
371 | * @param string $uploadBaseUrl |
||
372 | * |
||
373 | * @throws \Arcanedev\Stripe\Exceptions\ApiException |
||
374 | */ |
||
375 | 6 | private static function checkUploadBaseUrl($uploadBaseUrl) |
|
386 | |||
387 | /** |
||
388 | * Check API Version. |
||
389 | * |
||
390 | * @param string|null $apiVersion |
||
391 | * |
||
392 | * @throws \Arcanedev\Stripe\Exceptions\ApiException |
||
393 | */ |
||
394 | 690 | private static function checkApiVersion(&$apiVersion) |
|
411 | |||
412 | /** |
||
413 | * Check if API version exists. |
||
414 | * |
||
415 | * @return bool |
||
416 | */ |
||
417 | 314 | public static function hasApiVersion() |
|
421 | |||
422 | /** |
||
423 | * Check if the Stripe has account ID for connected accounts requests. |
||
424 | * |
||
425 | * @return bool |
||
426 | */ |
||
427 | 314 | public static function hasAccountId() |
|
431 | } |
||
432 |