Skip to content

Commit

Permalink
Merge pull request #412 from stripe/integration-v6
Browse files Browse the repository at this point in the history
stripe-php 6.0.0
  • Loading branch information
ob-stripe authored Feb 7, 2018
2 parents 5c2d7b3 + fec5aa9 commit 5e27a67
Show file tree
Hide file tree
Showing 113 changed files with 3,561 additions and 3,247 deletions.
55 changes: 15 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,27 @@ sudo: false

language: php

matrix:
include:
- php: 5.3
env: AUTOLOAD=1
dist: precise
- php: 5.3
env: AUTOLOAD=0
dist: precise
- php: 5.4
env: AUTOLOAD=1
- php: 5.4
env: AUTOLOAD=0
- php: 5.5
env: AUTOLOAD=1
- php: 5.5
env: AUTOLOAD=0
- php: 5.6
env: AUTOLOAD=1
- php: 5.6
env: AUTOLOAD=0
- php: 7.0
env: AUTOLOAD=1
- php: 7.0
env: AUTOLOAD=0
- php: 7.1
env: AUTOLOAD=1
- php: 7.1
env: AUTOLOAD=0
- php: 7.2
env: AUTOLOAD=1
- php: 7.2
env: AUTOLOAD=0
- php: hhvm
env: AUTOLOAD=1
- php: hhvm
env: AUTOLOAD=0
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

env:
global:
- STRIPE_MOCK_VERSION=0.5.0
matrix:
- AUTOLOAD=1
- AUTOLOAD=0

cache:
directories:
- $HOME/.composer/cache/files
- stripe-mock

env:
global:
- STRIPE_MOCK_VERSION=0.5.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
- |
Expand Down
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can sign up for a Stripe account at https://stripe.com.

## Requirements

PHP 5.3.3 and later.
PHP 5.4.0 and later.

## Composer

Expand All @@ -36,7 +36,7 @@ require_once('/path/to/stripe-php/init.php');

## Dependencies

The bindings require the following extension in order to work properly:
The bindings require the following extensions in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`json`](https://secure.php.net/manual/en/book.json.php)
Expand All @@ -50,7 +50,7 @@ Simple usage looks like:

```php
\Stripe\Stripe::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$charge = \Stripe\Charge::create(array('amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq' ));
$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq']);
echo $charge;
```

Expand All @@ -60,6 +60,12 @@ Please see https://stripe.com/docs/api for up-to-date documentation.

## Legacy Version Support

### PHP 5.3

If you are using PHP 5.3, you can download v5.8.0 ([zip](https://github.com/stripe/stripe-php/archive/v5.8.0.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.8.0.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.

### PHP 5.2

If you are using PHP 5.2, you can download v1.18.0 ([zip](https://github.com/stripe/stripe-php/archive/v1.18.0.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v1.18.0.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.

This legacy version may be included via `require_once("/path/to/stripe-php/lib/Stripe.php");`, and used like:
Expand Down Expand Up @@ -97,7 +103,7 @@ Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array t

```php
// set up your tweaked Curl client
$curl = new \Stripe\HttpClient\CurlClient(array(CURLOPT_PROXY => 'proxy.local:80'));
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
// tell Stripe to use the tweaked client
\Stripe\ApiRequestor::setHttpClient($curl);
```
Expand All @@ -119,7 +125,7 @@ end up there instead of `error_log`:
You can access the data from the last API response on any object via `getLastResponse()`.

```php
$charge = \Stripe\Charge::create(array('amount' => 2000, 'currency' => 'usd', 'source' => 'tok_visa'));
$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_visa']);
echo $charge->getLastResponse()->headers['Request-Id'];
```

Expand All @@ -130,10 +136,19 @@ Stripe's API now requires that [all connections use TLS 1.2](https://stripe.com/
The recommended course of action is to [upgrade 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) 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`:

```php
$curl = new \Stripe\HttpClient\CurlClient(array(CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1));
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
\Stripe\ApiRequestor::setHttpClient($curl);
```

### Configuring CA Bundles

By default, the library will use its own internal bundle of known CA
certificates, but it's possible to configure your own:

```php
\Stripe\Stripe::setCABundlePath("path/to/ca/bundle");
```

## Development

Install dependencies:
Expand All @@ -142,8 +157,6 @@ Install dependencies:
composer install
```

## Tests

The test suite depends on [stripe-mock], so make sure to fetch and run it from a
background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):
Expand All @@ -163,6 +176,12 @@ Or to run an individual test file:
./vendor/bin/phpunit tests/UtilTest.php
```

Update bundled CA certificates from the [Mozilla cURL release][curl]:

```bash
./update_certs.php
```

## Attention plugin developers

Are you writing a plugin that integrates Stripe and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
Expand All @@ -177,5 +196,6 @@ The method should be called once, before any request is sent to the API. The sec

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`.

[curl]: http://curl.haxx.se/docs/caextract.html
[psr3]: http://www.php-fig.org/psr/psr-3/
[stripe-mock]: https://github.com/stripe/stripe-mock
2 changes: 1 addition & 1 deletion build.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$composer = json_decode(file_get_contents('composer.json'), true);
unset($composer['autoload']);
unset($composer['require-dev']['squizlabs/php_codesniffer']);
file_put_contents('composer.json', json_encode($composer));
file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
}

passthru('composer install', $returnStatus);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.4.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"
Expand Down
Loading

0 comments on commit 5e27a67

Please sign in to comment.