PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.21
Booktics – Appointment Booking Calendar for Service Businesses v1.0.21
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / vendor / stripe / stripe-php / README.md

README.md in Booktics – Appointment Booking Calendar for Service Businesses 1.0.21, at vendor/stripe/stripe-php/README.md

271 lines 10.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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
8 The Stripe PHP library provides convenient access to the Stripe API from
9 applications written in the PHP language. It includes a pre-defined set of
10 classes for API resources that initialize themselves dynamically from API
11 responses which makes it compatible with a wide range of versions of the Stripe
12 API.
13
14 ## Requirements
15
16 PHP 5.6.0 and later.
17
18 ## Composer
19
20 You can install the bindings via [](http://getcomposer.org/Composer](http://getcomposer.org/](http://getcomposer.org/). Run the following command:
21
22 ```bash
23 composer require stripe/stripe-php
24 ```
25
26 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):
27
28 ```php
29 require_once('vendor/autoload.php');
30 ```
31
32 ## Manual Installation
33
34 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.
35
36 ```php
37 require_once('/path/to/stripe-php/init.php');
38 ```
39
40 ## Dependencies
41
42 The bindings require the following extensions in order to work properly:
43
44 - [](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
45 - [](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)
46 - [](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)
47
48 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.
49
50 ## Getting Started
51
52 Simple usage looks like:
53
54 ```php
55 $stripe = new \Stripe\StripeClient('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
56 $customer = $stripe->customers->create([
57 'description' => 'example customer',
58 'email' => '[email protected]',
59 'payment_method' => 'pm_card_visa',
60 ]);
61 echo $customer;
62 ```
63
64 ### Client/service patterns vs legacy patterns
65
66 You can continue to use the legacy integration patterns used prior to version [](https://github.com/stripe/stripe-php/blob/master/CHANGELOG.md#7330---2020-05-147.33.0](https://github.com/stripe/stripe-php/blob/master/CHANGELOG.md#7330---2020-05-14](https://github.com/stripe/stripe-php/blob/master/CHANGELOG.md#7330---2020-05-14). Review the [](https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0migration guide](https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0](https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0) for the backwards-compatible client/services pattern changes.
67
68 ## Documentation
69
70 See the [](https://stripe.com/docs/api/?lang=php#introPHP API docs](https://stripe.com/docs/api/?lang=php#intro](https://stripe.com/docs/api/?lang=php#intro).
71
72 See [video demonstrations][youtube-playlist] covering how to use the library.
73
74 ## Legacy Version Support
75
76 ### PHP 5.4 & 5.5
77
78 If you are using PHP 5.4 or 5.5, you should consider upgrading your environment as those versions have been past end of life since September 2015 and July 2016 respectively.
79 Otherwise, you can still use Stripe by downloading stripe-php v6.43.1 ([](https://github.com/stripe/stripe-php/archive/v6.43.1.zipzip](https://github.com/stripe/stripe-php/archive/v6.43.1.zip](https://github.com/stripe/stripe-php/archive/v6.43.1.zip), [](https://github.com/stripe/stripe-php/archive/6.43.1.tar.gztar.gz](https://github.com/stripe/stripe-php/archive/6.43.1.tar.gz](https://github.com/stripe/stripe-php/archive/6.43.1.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 work but might not support recent features we added since the version was released and upgrading PHP is the best course of action.
80
81 ### PHP 5.3
82
83 If you are using PHP 5.3, you should upgrade your environment as this version has been past end of life since August 2014.
84 Otherwise, 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.
85
86 ## Custom Request Timeouts
87
88 _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/?lang=php#idempotent_requestsidempotency tokens](https://stripe.com/docs/api/?lang=php#idempotent_requests](https://stripe.com/docs/api/?lang=php#idempotent_requests) to avoid executing the same transaction twice as a result of timeout retry logic.
89
90 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.
91
92 ```php
93 // set up your tweaked Curl client
94 $curl = new \Stripe\HttpClient\CurlClient();
95 $curl->setTimeout(10); // default is \Stripe\HttpClient\CurlClient::DEFAULT_TIMEOUT
96 $curl->setConnectTimeout(5); // default is \Stripe\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT
97
98 echo $curl->getTimeout(); // 10
99 echo $curl->getConnectTimeout(); // 5
100
101 // tell Stripe to use the tweaked client
102 \Stripe\ApiRequestor::setHttpClient($curl);
103
104 // use the Stripe API client as you normally would
105 ```
106
107 ## Custom cURL Options (e.g. proxies)
108
109 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.
110
111 ```php
112 // set up your tweaked Curl client
113 $curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
114 // tell Stripe to use the tweaked client
115 \Stripe\ApiRequestor::setHttpClient($curl);
116 ```
117
118 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.
119
120 ### Configuring a Logger
121
122 The library does minimal logging, but it can be configured
123 with a [`PSR-3` compatible logger][psr3] so that messages
124 end up there instead of `error_log`:
125
126 ```php
127 \Stripe\Stripe::setLogger($logger);
128 ```
129
130 ### Accessing response data
131
132 You can access the data from the last API response on any object via `getLastResponse()`.
133
134 ```php
135 $customer = $stripe->customers->create([
136 'description' => 'example customer',
137 ]);
138 echo $customer->getLastResponse()->headers['Request-Id'];
139 ```
140
141 ### SSL / TLS compatibility issues
142
143 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).".
144
145 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`:
146
147 ```php
148 $curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
149 \Stripe\ApiRequestor::setHttpClient($curl);
150 ```
151
152 ### Per-request Configuration
153
154 For apps that need to use multiple keys during the lifetime of a process, like
155 one that uses [Stripe Connect][connect], it's also possible to set a
156 per-request key and/or account:
157
158 ```php
159 $customers = $stripe->customers->all([],[
160 'api_key' => 'sk_test_...',
161 'stripe_account' => 'acct_...'
162 ]);
163
164 $stripe->customers->retrieve('cus_123456789', [], [
165 'api_key' => 'sk_test_...',
166 'stripe_account' => 'acct_...'
167 ]);
168 ```
169
170 ### Configuring CA Bundles
171
172 By default, the library will use its own internal bundle of known CA
173 certificates, but it's possible to configure your own:
174
175 ```php
176 \Stripe\Stripe::setCABundlePath("path/to/ca/bundle");
177 ```
178
179 ### Configuring Automatic Retries
180
181 The library can be configured to automatically retry requests that fail due to
182 an intermittent network problem:
183
184 ```php
185 \Stripe\Stripe::setMaxNetworkRetries(2);
186 ```
187
188 [Idempotency keys][idempotency-keys] are added to requests to guarantee that
189 retries are safe.
190
191 ### Request latency telemetry
192
193 By default, the library sends request latency telemetry to Stripe. These
194 numbers help Stripe improve the overall latency of its API for all users.
195
196 You can disable this behavior if you prefer:
197
198 ```php
199 \Stripe\Stripe::setEnableTelemetry(false);
200 ```
201
202 ## Development
203
204 Get [Composer][composer]. For example, on Mac OS:
205
206 ```bash
207 brew install composer
208 ```
209
210 Install dependencies:
211
212 ```bash
213 composer install
214 ```
215
216 The test suite depends on [stripe-mock], so make sure to fetch and run it from a
217 background terminal ([stripe-mock's README][stripe-mock] also contains
218 instructions for installing via Homebrew and other methods):
219
220 ```bash
221 go get -u github.com/stripe/stripe-mock
222 stripe-mock
223 ```
224
225 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:
226
227 ```bash
228 ./vendor/bin/phpunit
229 ```
230
231 Or to run an individual test file:
232
233 ```bash
234 ./vendor/bin/phpunit tests/Stripe/UtilTest.php
235 ```
236
237 Update bundled CA certificates from the [Mozilla cURL release][curl]:
238
239 ```bash
240 ./update_certs.php
241 ```
242
243 The library uses [PHP CS Fixer][php-cs-fixer] for code formatting. Code must be formatted before PRs are submitted, otherwise CI will fail. Run the formatter with:
244
245 ```bash
246 ./vendor/bin/php-cs-fixer fix -v .
247 ```
248
249 ## Attention plugin developers
250
251 Are you writing a plugin that integrates Stripe and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
252
253 ```php
254 \Stripe\Stripe::setAppInfo("MyAwesomePlugin", "1.2.34", "https://myawesomeplugin.info");
255 ```
256
257 The method should be called once, before any request is sent to the API. The second and third parameters are optional.
258
259 ### SSL / TLS configuration option
260
261 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`.
262
263 [composer]: https://getcomposer.org/
264 [connect]: https://stripe.com/connect
265 [curl]: http://curl.haxx.se/docs/caextract.html
266 [idempotency-keys]: https://stripe.com/docs/api/?lang=php#idempotent_requests
267 [php-cs-fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
268 [psr3]: http://www.php-fig.org/psr/psr-3/
269 [stripe-mock]: https://github.com/stripe/stripe-mock
270 [youtube-playlist]: https://www.youtube.com/playlist?list=PLy1nL-pvL2M6cUbiHrfMkXxZ9j9SGBxFE
271