PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.7.2
GiveWP – Donation Plugin and Fundraising Platform v2.7.2
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / vendor / stripe / stripe-php / README.md
give / vendor / stripe / stripe-php Last commit date
data 6 years ago lib 6 years ago .editorconfig 6 years ago .gitignore 6 years ago CHANGELOG.md 6 years ago LICENSE 6 years ago README.md 6 years ago VERSION 6 years ago build.php 6 years ago composer.json 6 years ago init.php 6 years ago update_certs.php 6 years ago
README.md
258 lines
1 # Stripe PHP bindings
2
3 [](https://travis-ci.org/stripe/stripe-php![Build Status](https://travis-ci.org/stripe/stripe-php.svg?branch=master)](https://travis-ci.org/stripe/stripe-php](https://travis-ci.org/stripe/stripe-php)
4 [](https://packagist.org/packages/stripe/stripe-php![Latest Stable Version](https://poser.pugx.org/stripe/stripe-php/v/stable.svg)](https://packagist.org/packages/stripe/stripe-php](https://packagist.org/packages/stripe/stripe-php)
5 [](https://packagist.org/packages/stripe/stripe-php![Total Downloads](https://poser.pugx.org/stripe/stripe-php/downloads.svg)](https://packagist.org/packages/stripe/stripe-php](https://packagist.org/packages/stripe/stripe-php)
6 [](https://packagist.org/packages/stripe/stripe-php![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php](https://packagist.org/packages/stripe/stripe-php)
7 [](https://coveralls.io/r/stripe/stripe-php?branch=master![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master](https://coveralls.io/r/stripe/stripe-php?branch=master)
8
9 The Stripe PHP library provides convenient access to the Stripe API from
10 applications written in the PHP language. It includes a pre-defined set of
11 classes for API resources that initialize themselves dynamically from API
12 responses which makes it compatible with a wide range of versions of the Stripe
13 API.
14
15 ## Requirements
16
17 PHP 5.4.0 and later.
18
19 ## Composer
20
21 You can install the bindings via [](http://getcomposer.org/Composer](http://getcomposer.org/](http://getcomposer.org/). Run the following command:
22
23 ```bash
24 composer require stripe/stripe-php
25 ```
26
27 To use the bindings, use Composer's [](https://getcomposer.org/doc/01-basic-usage.md#autoloadingautoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
28
29 ```php
30 require_once('vendor/autoload.php');
31 ```
32
33 ## Manual Installation
34
35 If you do not wish to use Composer, you can download the [](https://github.com/stripe/stripe-php/releaseslatest release](https://github.com/stripe/stripe-php/releases](https://github.com/stripe/stripe-php/releases). Then, to use the bindings, include the `init.php` file.
36
37 ```php
38 require_once('/path/to/stripe-php/init.php');
39 ```
40
41 ## Dependencies
42
43 The bindings require the following extensions in order to work properly:
44
45 - [](https://secure.php.net/manual/en/book.curl.php`curl`](https://secure.php.net/manual/en/book.curl.php](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
46 - [](https://secure.php.net/manual/en/book.json.php`json`](https://secure.php.net/manual/en/book.json.php](https://secure.php.net/manual/en/book.json.php)
47 - [](https://secure.php.net/manual/en/book.mbstring.php`mbstring`](https://secure.php.net/manual/en/book.mbstring.php](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)
48
49 If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
50
51 ## Getting Started
52
53 Simple usage looks like:
54
55 ```php
56 \Stripe\Stripe::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
57 $charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq']);
58 echo $charge;
59 ```
60
61 ## Documentation
62
63 See the [](https://stripe.com/docs/api/php#introPHP API docs](https://stripe.com/docs/api/php#intro](https://stripe.com/docs/api/php#intro).
64
65 ## Legacy Version Support
66
67 ### PHP 5.3
68
69 If you are using PHP 5.3, you can download v5.9.2 ([](https://github.com/stripe/stripe-php/archive/v5.9.2.zipzip](https://github.com/stripe/stripe-php/archive/v5.9.2.zip](https://github.com/stripe/stripe-php/archive/v5.9.2.zip), [](https://github.com/stripe/stripe-php/archive/v5.9.2.tar.gztar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.tar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.tar.gz)) from our [](https://github.com/stripe/stripe-php/releasesreleases page](https://github.com/stripe/stripe-php/releases](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
70
71 ### PHP 5.2
72
73 If you are using PHP 5.2, you can download v1.18.0 ([](https://github.com/stripe/stripe-php/archive/v1.18.0.zipzip](https://github.com/stripe/stripe-php/archive/v1.18.0.zip](https://github.com/stripe/stripe-php/archive/v1.18.0.zip), [](https://github.com/stripe/stripe-php/archive/v1.18.0.tar.gztar.gz](https://github.com/stripe/stripe-php/archive/v1.18.0.tar.gz](https://github.com/stripe/stripe-php/archive/v1.18.0.tar.gz)) from our [](https://github.com/stripe/stripe-php/releasesreleases page](https://github.com/stripe/stripe-php/releases](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
74
75 This legacy version may be included via `require_once("/path/to/stripe-php/lib/Stripe.php");`, and used like:
76
77 ```php
78 Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249');
79 $charge = Stripe_Charge::create(array('source' => 'tok_XXXXXXXX', 'amount' => 2000, 'currency' => 'usd'));
80 echo $charge;
81 ```
82
83 ## Custom Request Timeouts
84
85 *NOTE:* We do not recommend decreasing the timeout for non-read-only calls (e.g. charge creation), since even if you locally timeout, the request on Stripe's side can still complete. If you are decreasing timeouts on these calls, make sure to use [](https://stripe.com/docs/api/php#idempotent_requestsidempotency tokens](https://stripe.com/docs/api/php#idempotent_requests](https://stripe.com/docs/api/php#idempotent_requests) to avoid executing the same transaction twice as a result of timeout retry logic.
86
87 To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.
88
89 ```php
90 // set up your tweaked Curl client
91 $curl = new \Stripe\HttpClient\CurlClient();
92 $curl->setTimeout(10); // default is \Stripe\HttpClient\CurlClient::DEFAULT_TIMEOUT
93 $curl->setConnectTimeout(5); // default is \Stripe\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT
94
95 echo $curl->getTimeout(); // 10
96 echo $curl->getConnectTimeout(); // 5
97
98 // tell Stripe to use the tweaked client
99 \Stripe\ApiRequestor::setHttpClient($curl);
100
101 // use the Stripe API client as you normally would
102 ```
103
104 ## Custom cURL Options (e.g. proxies)
105
106 Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array to the CurlClient constructor, using the same syntax as `curl_stopt_array()`. This will set the default cURL options for each HTTP request made by the SDK, though many more common options (e.g. timeouts; see above on how to set those) will be overridden by the client even if set here.
107
108 ```php
109 // set up your tweaked Curl client
110 $curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
111 // tell Stripe to use the tweaked client
112 \Stripe\ApiRequestor::setHttpClient($curl);
113 ```
114
115 Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.
116
117 ### Configuring a Logger
118
119 The library does minimal logging, but it can be configured
120 with a [`PSR-3` compatible logger][psr3] so that messages
121 end up there instead of `error_log`:
122
123 ```php
124 \Stripe\Stripe::setLogger($logger);
125 ```
126
127 ### Accessing response data
128
129 You can access the data from the last API response on any object via `getLastResponse()`.
130
131 ```php
132 $charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_visa']);
133 echo $charge->getLastResponse()->headers['Request-Id'];
134 ```
135
136 ### SSL / TLS compatibility issues
137
138 Stripe's API now requires that [](https://stripe.com/blog/upgrading-tlsall connections use TLS 1.2](https://stripe.com/blog/upgrading-tls](https://stripe.com/blog/upgrading-tls). Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default. In this case, you'd get an `invalid_request_error` with the following error message: "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at [](https://stripe.com/blog/upgrading-tlshttps://stripe.com/blog/upgrading-tls](https://stripe.com/blog/upgrading-tls](https://stripe.com/blog/upgrading-tls).".
139
140 The recommended course of action is to [](https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#phpupgrade your cURL and OpenSSL packages](https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php](https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php) so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:
141
142 ```php
143 $curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
144 \Stripe\ApiRequestor::setHttpClient($curl);
145 ```
146
147 ### Per-request Configuration
148
149 For apps that need to use multiple keys during the lifetime of a process, like
150 one that uses [Stripe Connect][connect], it's also possible to set a
151 per-request key and/or account:
152
153 ```php
154 \Stripe\Charge::all([], [
155 'api_key' => 'sk_test_...',
156 'stripe_account' => 'acct_...'
157 ]);
158
159 \Stripe\Charge::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [
160 'api_key' => 'sk_test_...',
161 'stripe_account' => 'acct_...'
162 ]);
163 ```
164
165 ### Configuring CA Bundles
166
167 By default, the library will use its own internal bundle of known CA
168 certificates, but it's possible to configure your own:
169
170 ```php
171 \Stripe\Stripe::setCABundlePath("path/to/ca/bundle");
172 ```
173
174 ### Configuring Automatic Retries
175
176 The library can be configured to automatically retry requests that fail due to
177 an intermittent network problem:
178
179 ```php
180 \Stripe\Stripe::setMaxNetworkRetries(2);
181 ```
182
183 [Idempotency keys][idempotency-keys] are added to requests to guarantee that
184 retries are safe.
185
186 ### Request latency telemetry
187
188 By default, the library sends request latency telemetry to Stripe. These
189 numbers help Stripe improve the overall latency of its API for all users.
190
191 You can disable this behavior if you prefer:
192
193 ```php
194 \Stripe\Stripe::setEnableTelemetry(false);
195 ```
196
197 ## Development
198
199 Get [Composer][composer]. For example, on Mac OS:
200
201 ```bash
202 brew install composer
203 ```
204
205 Install dependencies:
206
207 ```bash
208 composer install
209 ```
210
211 The test suite depends on [stripe-mock], so make sure to fetch and run it from a
212 background terminal ([stripe-mock's README][stripe-mock] also contains
213 instructions for installing via Homebrew and other methods):
214
215 ```bash
216 go get -u github.com/stripe/stripe-mock
217 stripe-mock
218 ```
219
220 Install dependencies as mentioned above (which will resolve [](http://packagist.org/packages/phpunit/phpunitPHPUnit](http://packagist.org/packages/phpunit/phpunit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite:
221
222 ```bash
223 ./vendor/bin/phpunit
224 ```
225
226 Or to run an individual test file:
227
228 ```bash
229 ./vendor/bin/phpunit tests/UtilTest.php
230 ```
231
232 Update bundled CA certificates from the [Mozilla cURL release][curl]:
233
234 ```bash
235 ./update_certs.php
236 ```
237
238 ## Attention plugin developers
239
240 Are you writing a plugin that integrates Stripe and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
241
242 ```php
243 \Stripe\Stripe::setAppInfo("MyAwesomePlugin", "1.2.34", "https://myawesomeplugin.info");
244 ```
245
246 The method should be called once, before any request is sent to the API. The second and third parameters are optional.
247
248 ### SSL / TLS configuration option
249
250 See the "SSL / TLS compatibility issues" paragraph above for full context. If you want to ensure that your plugin can be used on all systems, you should add a configuration option to let your users choose between different values for `CURLOPT_SSLVERSION`: none (default), `CURL_SSLVERSION_TLSv1` and `CURL_SSLVERSION_TLSv1_2`.
251
252 [composer]: https://getcomposer.org/
253 [connect]: https://stripe.com/connect
254 [curl]: http://curl.haxx.se/docs/caextract.html
255 [psr3]: http://www.php-fig.org/psr/psr-3/
256 [idempotency-keys]: https://stripe.com/docs/api/php#idempotent_requests
257 [stripe-mock]: https://github.com/stripe/stripe-mock
258