1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
<?php
namespace Stripe;
/**
* Class Stripe.
*/
class Stripe
{
/** @var string The Stripe API key to be used for requests. */
public static $apiKey;
/** @var string The Stripe client_id to be used for Connect requests. */
public static $clientId;
/** @var string The base URL for the Stripe API. */
public static $apiBase = 'https://api.stripe.com';
/** @var string The base URL for the OAuth API. */
public static $connectBase = 'https://connect.stripe.com';
/** @var string The base URL for the Stripe API uploads endpoint. */
public static $apiUploadBase = 'https://files.stripe.com';
/** @var null|string The version of the Stripe API to use for requests. */
public static $apiVersion = null;
/** @var null|string The account ID for connected accounts requests. */
public static $accountId = null;
/** @var string Path to the CA bundle used to verify SSL certificates */
public static $caBundlePath = null;
/** @var bool Defaults to true. */
public static $verifySslCerts = true;
/** @var array The application's information (name, version, URL) */
public static $appInfo = null;
/**
* @var null|Util\LoggerInterface the logger to which the library will
* produce messages
*/
public static $logger = null;
/** @var int Maximum number of request retries */
public static $maxNetworkRetries = 0;
/** @var bool Whether client telemetry is enabled. Defaults to true. */
public static $enableTelemetry = true;
/** @var float Maximum delay between retries, in seconds */
private static $maxNetworkRetryDelay = 2.0;
/** @var float Maximum delay between retries, in seconds, that will be respected from the Stripe API */
private static $maxRetryAfter = 60.0;
/** @var float Initial delay between retries, in seconds */
private static $initialNetworkRetryDelay = 0.5;
const VERSION = '7.128.0';
/**
* @return string the API key used for requests
*/
public static function getApiKey()
{
return self::$apiKey;
}
/**
* @return string the client_id used for Connect requests
*/
public static function getClientId()
{
return self::$clientId;
}
/**
* @return Util\LoggerInterface the logger to which the library will
* produce messages
*/
public static function getLogger()
{
if (null === self::$logger) {
return new Util\DefaultLogger();
}
return self::$logger;
}
/**
* @param Util\LoggerInterface $logger the logger to which the library
* will produce messages
*/
public static function setLogger($logger)
{
self::$logger = $logger;
}
/**
* Sets the API key to be used for requests.
*
* @param string $apiKey
*/
public static function setApiKey($apiKey)
{
self::$apiKey = $apiKey;
}
/**
* Sets the client_id to be used for Connect requests.
*
* @param string $clientId
*/
public static function setClientId($clientId)
{
self::$clientId = $clientId;
}
/**
* @return string The API version used for requests. null if we're using the
* latest version.
*/
public static function getApiVersion()
{
return self::$apiVersion;
}
/**
* @param string $apiVersion the API version to use for requests
*/
public static function setApiVersion($apiVersion)
{
self::$apiVersion = $apiVersion;
}
/**
* @return string
*/
private static function getDefaultCABundlePath()
{
return \realpath(__DIR__ . '/../data/ca-certificates.crt');
}
/**
* @return string
*/
public static function getCABundlePath()
{
return self::$caBundlePath ?: self::getDefaultCABundlePath();
}
/**
* @param string $caBundlePath
*/
public static function setCABundlePath($caBundlePath)
{
self::$caBundlePath = $caBundlePath;
}
/**
* @return bool
*/
public static function getVerifySslCerts()
{
return self::$verifySslCerts;
}
/**
* @param bool $verify
*/
public static function setVerifySslCerts($verify)
{
self::$verifySslCerts = $verify;
}
/**
* @return null|string The Stripe account ID for connected account
* requests
*/
public static function getAccountId()
{
return self::$accountId;
}
/**
* @param string $accountId the Stripe account ID to set for connected
* account requests
*/
public static function setAccountId($accountId)
{
self::$accountId = $accountId;
}
/**
* @return null|array The application's information
*/
public static function getAppInfo()
{
return self::$appInfo;
}
/**
* @param string $appName The application's name
* @param null|string $appVersion The application's version
* @param null|string $appUrl The application's URL
* @param null|string $appPartnerId The application's partner ID
*/
public static function setAppInfo($appName, $appVersion = null, $appUrl = null, $appPartnerId = null)
{
self::$appInfo = self::$appInfo ?: [];
self::$appInfo['name'] = $appName;
self::$appInfo['partner_id'] = $appPartnerId;
self::$appInfo['url'] = $appUrl;
self::$appInfo['version'] = $appVersion;
}
/**
* @return int Maximum number of request retries
*/
public static function getMaxNetworkRetries()
{
return self::$maxNetworkRetries;
}
/**
* @param int $maxNetworkRetries Maximum number of request retries
*/
public static function setMaxNetworkRetries($maxNetworkRetries)
{
self::$maxNetworkRetries = $maxNetworkRetries;
}
/**
* @return float Maximum delay between retries, in seconds
*/
public static function getMaxNetworkRetryDelay()
{
return self::$maxNetworkRetryDelay;
}
/**
* @return float Maximum delay between retries, in seconds, that will be respected from the Stripe API
*/
public static function getMaxRetryAfter()
{
return self::$maxRetryAfter;
}
/**
* @return float Initial delay between retries, in seconds
*/
public static function getInitialNetworkRetryDelay()
{
return self::$initialNetworkRetryDelay;
}
/**
* @return bool Whether client telemetry is enabled
*/
public static function getEnableTelemetry()
{
return self::$enableTelemetry;
}
/**
* @param bool $enableTelemetry Enables client telemetry.
*
* Client telemetry enables timing and request metrics to be sent back to Stripe as an HTTP Header
* with the current request. This enables Stripe to do latency and metrics analysis without adding extra
* overhead (such as extra network calls) on the client.
*/
public static function setEnableTelemetry($enableTelemetry)
{
self::$enableTelemetry = $enableTelemetry;
}
}
|