• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / #7310

16 Aug 2023 10:11PM UTC coverage: 70.903% (-0.05%) from 70.954%
#7310

push

php-coveralls

web-flow
Merge pull request #1542 from stripe/sdk-release/next-major

stripe-php v11 release

1 of 1 new or added line in 1 file covered. (100.0%)

1791 of 2526 relevant lines covered (70.9%)

3.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/lib/Stripe.php
1
<?php
2

3
namespace Stripe;
4

5
/**
6
 * Class Stripe.
7
 */
8
class Stripe
9
{
10
    /** @var string The Stripe API key to be used for requests. */
11
    public static $apiKey;
12

13
    /** @var string The Stripe client_id to be used for Connect requests. */
14
    public static $clientId;
15

16
    /** @var string The base URL for the Stripe API. */
17
    public static $apiBase = 'https://api.stripe.com';
18

19
    /** @var string The base URL for the OAuth API. */
20
    public static $connectBase = 'https://connect.stripe.com';
21

22
    /** @var string The base URL for the Stripe API uploads endpoint. */
23
    public static $apiUploadBase = 'https://files.stripe.com';
24

25
    /** @var string The version of the Stripe API to use for requests. */
26
    public static $apiVersion = \Stripe\Util\ApiVersion::CURRENT;
27

28
    /** @var null|string The account ID for connected accounts requests. */
29
    public static $accountId = null;
30

31
    /** @var string Path to the CA bundle used to verify SSL certificates */
32
    public static $caBundlePath = null;
33

34
    /** @var bool Defaults to true. */
35
    public static $verifySslCerts = true;
36

37
    /** @var array The application's information (name, version, URL) */
38
    public static $appInfo = null;
39

40
    /**
41
     * @var null|Util\LoggerInterface the logger to which the library will
42
     *   produce messages
43
     */
44
    public static $logger = null;
45

46
    /** @var int Maximum number of request retries */
47
    public static $maxNetworkRetries = 0;
48

49
    /** @var bool Whether client telemetry is enabled. Defaults to true. */
50
    public static $enableTelemetry = true;
51

52
    /** @var float Maximum delay between retries, in seconds */
53
    private static $maxNetworkRetryDelay = 2.0;
54

55
    /** @var float Maximum delay between retries, in seconds, that will be respected from the Stripe API */
56
    private static $maxRetryAfter = 60.0;
57

58
    /** @var float Initial delay between retries, in seconds */
59
    private static $initialNetworkRetryDelay = 0.5;
60

61
    const VERSION = '10.21.0';
62

63
    /**
64
     * @return string the API key used for requests
65
     */
66
    public static function getApiKey()
67
    {
68
        return self::$apiKey;
1✔
69
    }
70

71
    /**
72
     * @return string the client_id used for Connect requests
73
     */
74
    public static function getClientId()
75
    {
76
        return self::$clientId;
1✔
77
    }
78

79
    /**
80
     * @return Util\LoggerInterface the logger to which the library will
81
     *   produce messages
82
     */
83
    public static function getLogger()
84
    {
85
        if (null === self::$logger) {
×
86
            return new Util\DefaultLogger();
×
87
        }
88

89
        return self::$logger;
×
90
    }
91

92
    /**
93
     * @param \Psr\Log\LoggerInterface|Util\LoggerInterface $logger the logger to which the library
94
     *   will produce messages
95
     */
96
    public static function setLogger($logger)
97
    {
98
        self::$logger = $logger;
×
99
    }
100

101
    /**
102
     * Sets the API key to be used for requests.
103
     *
104
     * @param string $apiKey
105
     */
106
    public static function setApiKey($apiKey)
107
    {
108
        self::$apiKey = $apiKey;
1✔
109
    }
110

111
    /**
112
     * Sets the client_id to be used for Connect requests.
113
     *
114
     * @param string $clientId
115
     */
116
    public static function setClientId($clientId)
117
    {
118
        self::$clientId = $clientId;
1✔
119
    }
120

121
    /**
122
     * @return string the API version used for requests
123
     */
124
    public static function getApiVersion()
125
    {
126
        return self::$apiVersion;
1✔
127
    }
128

129
    /**
130
     * @param string $apiVersion the API version to use for requests
131
     */
132
    public static function setApiVersion($apiVersion)
133
    {
134
        self::$apiVersion = $apiVersion;
×
135
    }
136

137
    /**
138
     * @return string
139
     */
140
    private static function getDefaultCABundlePath()
141
    {
142
        return \realpath(__DIR__ . '/../data/ca-certificates.crt');
×
143
    }
144

145
    /**
146
     * @return string
147
     */
148
    public static function getCABundlePath()
149
    {
150
        return self::$caBundlePath ?: self::getDefaultCABundlePath();
1✔
151
    }
152

153
    /**
154
     * @param string $caBundlePath
155
     */
156
    public static function setCABundlePath($caBundlePath)
157
    {
158
        self::$caBundlePath = $caBundlePath;
1✔
159
    }
160

161
    /**
162
     * @return bool
163
     */
164
    public static function getVerifySslCerts()
165
    {
166
        return self::$verifySslCerts;
×
167
    }
168

169
    /**
170
     * @param bool $verify
171
     */
172
    public static function setVerifySslCerts($verify)
173
    {
174
        self::$verifySslCerts = $verify;
×
175
    }
176

177
    /**
178
     * @return null|string The Stripe account ID for connected account
179
     *   requests
180
     */
181
    public static function getAccountId()
182
    {
183
        return self::$accountId;
1✔
184
    }
185

186
    /**
187
     * @param null|string $accountId the Stripe account ID to set for connected
188
     *   account requests
189
     */
190
    public static function setAccountId($accountId)
191
    {
192
        self::$accountId = $accountId;
1✔
193
    }
194

195
    /**
196
     * @return null|array The application's information
197
     */
198
    public static function getAppInfo()
199
    {
200
        return self::$appInfo;
×
201
    }
202

203
    /**
204
     * @param string $appName The application's name
205
     * @param null|string $appVersion The application's version
206
     * @param null|string $appUrl The application's URL
207
     * @param null|string $appPartnerId The application's partner ID
208
     */
209
    public static function setAppInfo($appName, $appVersion = null, $appUrl = null, $appPartnerId = null)
210
    {
211
        self::$appInfo = self::$appInfo ?: [];
×
212
        self::$appInfo['name'] = $appName;
×
213
        self::$appInfo['partner_id'] = $appPartnerId;
×
214
        self::$appInfo['url'] = $appUrl;
×
215
        self::$appInfo['version'] = $appVersion;
×
216
    }
217

218
    /**
219
     * @return int Maximum number of request retries
220
     */
221
    public static function getMaxNetworkRetries()
222
    {
223
        return self::$maxNetworkRetries;
×
224
    }
225

226
    /**
227
     * @param int $maxNetworkRetries Maximum number of request retries
228
     */
229
    public static function setMaxNetworkRetries($maxNetworkRetries)
230
    {
231
        self::$maxNetworkRetries = $maxNetworkRetries;
×
232
    }
233

234
    /**
235
     * @return float Maximum delay between retries, in seconds
236
     */
237
    public static function getMaxNetworkRetryDelay()
238
    {
239
        return self::$maxNetworkRetryDelay;
×
240
    }
241

242
    /**
243
     * @return float Maximum delay between retries, in seconds, that will be respected from the Stripe API
244
     */
245
    public static function getMaxRetryAfter()
246
    {
247
        return self::$maxRetryAfter;
×
248
    }
249

250
    /**
251
     * @return float Initial delay between retries, in seconds
252
     */
253
    public static function getInitialNetworkRetryDelay()
254
    {
255
        return self::$initialNetworkRetryDelay;
×
256
    }
257

258
    /**
259
     * @return bool Whether client telemetry is enabled
260
     */
261
    public static function getEnableTelemetry()
262
    {
263
        return self::$enableTelemetry;
×
264
    }
265

266
    /**
267
     * @param bool $enableTelemetry Enables client telemetry.
268
     *
269
     * Client telemetry enables timing and request metrics to be sent back to Stripe as an HTTP Header
270
     * with the current request. This enables Stripe to do latency and metrics analysis without adding extra
271
     * overhead (such as extra network calls) on the client.
272
     */
273
    public static function setEnableTelemetry($enableTelemetry)
274
    {
275
        self::$enableTelemetry = $enableTelemetry;
1✔
276
    }
277
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc