Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stripe-php v7.0.0 #552

Merged
merged 28 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
94b5217
Drop support for PHP 5.4
ob-stripe Nov 15, 2018
5d2f936
Drop support for PHP 5.5
ob-stripe Nov 15, 2018
6815251
Bump dependencies
ob-stripe Nov 15, 2018
4eafdbe
Remove CURLFile check
ob-stripe Nov 15, 2018
65311fa
Update constant definitions for PHP >= 5.5
ob-stripe Nov 15, 2018
11afbc7
Remove FileUpload alias
ob-stripe Nov 15, 2018
3e6d640
Remove curl_reset check
ob-stripe Dec 11, 2018
f25a3f2
Replaced all cases of explicit class strings with the SomeClass:class…
nickdnk Apr 26, 2019
11358a1
Use array_column to flatten params
ob-stripe Aug 2, 2019
8a046cf
Remove deprecated methods
ob-stripe Aug 9, 2019
bc6bb02
Remove IssuerFraudRecord
ob-stripe Aug 16, 2019
97e131f
Update constructors of Stripe exception classes
ob-stripe Nov 16, 2018
147c8fa
Fix remaining TODOs
ob-stripe Aug 22, 2019
f139a16
Use yield for autopagination
ob-stripe Aug 22, 2019
2d2b327
Rename fake magic methods and rewrite array conversion
ob-stripe Aug 22, 2019
2f846ee
Add ErrorObject to Stripe exceptions
ob-stripe Aug 22, 2019
50177dc
Start using PHP CS Fixer
ob-stripe Aug 22, 2019
83aca09
Update error messages for nested resource operations
ob-stripe Aug 23, 2019
fe8ed87
Upgrade retry logic
ob-stripe Aug 22, 2019
9621cb5
Collection improvements / fixes
ob-stripe Aug 26, 2019
4699c5d
Modernize exceptions
ob-stripe Aug 23, 2019
6be66f6
Add constants for error codes
ob-stripe Aug 28, 2019
23ea985
Update certificate bundle
ob-stripe Aug 28, 2019
cbfa552
Retry requests on a 429 that's a lock timeout
ob-stripe Aug 28, 2019
106e6f9
Fix toArray() calls
ob-stripe Aug 28, 2019
d33b16b
Fix usage of array_key_exists for PHP 7.4
ob-stripe Aug 30, 2019
d6db072
Fix null array access for PHP 7.4
ob-stripe Aug 30, 2019
abfa251
Merge pull request #725 from stripe/ob-fix-php74
ob-stripe Aug 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ clover.xml

# Ignore IDE's configuration files
.idea

# Ignore PHP CS Fixer cache
.php_cs.cache
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ language: php

matrix:
include:
- php: 5.4
env: AUTOLOAD=1
dist: trusty
- php: 5.4
env: AUTOLOAD=0
dist: trusty
- php: 5.5
env: AUTOLOAD=1
dist: trusty
- php: 5.5
env: AUTOLOAD=0
dist: trusty
- php: 5.6
env: AUTOLOAD=1
dist: xenial
Expand Down Expand Up @@ -77,6 +65,8 @@ before_install:
STRIPE_MOCK_PID=$!
- export PATH="${PATH}:${PWD}/stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}"

script: ./build.php ${AUTOLOAD}
script:
- ./build.php ${AUTOLOAD}
- ./vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no .

after_script: ./vendor/bin/coveralls -v
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"felixfbecker.php-intellisense",
"ikappas.phpcs",
"emallin.phpunit",
"EditorConfig.editorconfig"
"EditorConfig.editorconfig",
"sophisticode.php-formatter"
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

// Formatting
"editor.formatOnSave": true,
"phpformatter.composer": true,
"phpformatter.arguments": [""],

// Linting
"phpcs.enable": true,
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ API.

## Requirements

PHP 5.4.0 and later.
PHP 5.6.0 and later.

## Composer

Expand Down Expand Up @@ -64,6 +64,10 @@ See the [PHP API docs](https://stripe.com/docs/api/php#intro).

## Legacy Version Support

### PHP 5.4 & 5.5

If you are using PHP 5.4 or 5.5, you can download v6.21.1 ([zip](https://github.com/stripe/stripe-php/archive/v6.21.1.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.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.3

If you are using PHP 5.3, you can download v5.9.2 ([zip](https://github.com/stripe/stripe-php/archive/v5.9.2.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.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.
Expand Down Expand Up @@ -235,6 +239,12 @@ Update bundled CA certificates from the [Mozilla cURL release][curl]:
./update_certs.php
```

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:

```bash
./vendor/bin/php-cs-fixer fix -v .
```

## 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 @@ -252,6 +262,7 @@ See the "SSL / TLS compatibility issues" paragraph above for full context. If yo
[composer]: https://getcomposer.org/
[connect]: https://stripe.com/connect
[curl]: http://curl.haxx.se/docs/caextract.html
[psr3]: http://www.php-fig.org/psr/psr-3/
[idempotency-keys]: https://stripe.com/docs/api/php#idempotent_requests
[php-cs-fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[psr3]: http://www.php-fig.org/psr/psr-3/
[stripe-mock]: https://github.com/stripe/stripe-mock
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=5.6.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"php-coveralls/php-coveralls": "1.*",
"squizlabs/php_codesniffer": "~2.0",
"symfony/process": "~2.8"
"phpunit/phpunit": "^5.7",
"php-coveralls/php-coveralls": "^2.1",
"squizlabs/php_codesniffer": "^3.3",
"symfony/process": "~3.4",
"friendsofphp/php-cs-fixer": "^2.15"
},
"autoload": {
"psr-4": { "Stripe\\" : "lib/" }
Expand Down
1,262 changes: 546 additions & 716 deletions data/ca-certificates.crt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'grant_type' => 'authorization_code',
'code' => $code,
]);
} catch (\Stripe\Error\OAuth\OAuthBase $e) {
} catch (\Stripe\Exception\OAuth\OAuthErrorException $e) {
exit("Error: " . $e->getMessage());
}

Expand All @@ -38,7 +38,7 @@
\Stripe\OAuth::deauthorize([
'stripe_user_id' => $accountId,
]);
} catch (\Stripe\Error\OAuth\OAuthBase $e) {
} catch (\Stripe\Exception\OAuth\OAuthErrorException $e) {
exit("Error: " . $e->getMessage());
}

Expand Down
49 changes: 27 additions & 22 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require(dirname(__FILE__) . '/lib/Stripe.php');

// Utilities
require(dirname(__FILE__) . '/lib/Util/AutoPagingIterator.php');
require(dirname(__FILE__) . '/lib/Util/CaseInsensitiveArray.php');
require(dirname(__FILE__) . '/lib/Util/LoggerInterface.php');
require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');
Expand All @@ -17,26 +16,32 @@
require(dirname(__FILE__) . '/lib/HttpClient/ClientInterface.php');
require(dirname(__FILE__) . '/lib/HttpClient/CurlClient.php');

// Errors
require(dirname(__FILE__) . '/lib/Error/Base.php');
require(dirname(__FILE__) . '/lib/Error/Api.php');
require(dirname(__FILE__) . '/lib/Error/ApiConnection.php');
require(dirname(__FILE__) . '/lib/Error/Authentication.php');
require(dirname(__FILE__) . '/lib/Error/Card.php');
require(dirname(__FILE__) . '/lib/Error/Idempotency.php');
require(dirname(__FILE__) . '/lib/Error/InvalidRequest.php');
require(dirname(__FILE__) . '/lib/Error/Permission.php');
require(dirname(__FILE__) . '/lib/Error/RateLimit.php');
require(dirname(__FILE__) . '/lib/Error/SignatureVerification.php');
// Exceptions
require(dirname(__FILE__) . '/lib/Exception/ExceptionInterface.php');
require(dirname(__FILE__) . '/lib/Exception/ApiErrorException.php');
require(dirname(__FILE__) . '/lib/Exception/ApiConnectionException.php');
require(dirname(__FILE__) . '/lib/Exception/AuthenticationException.php');
require(dirname(__FILE__) . '/lib/Exception/BadMethodCallException.php');
require(dirname(__FILE__) . '/lib/Exception/CardException.php');
require(dirname(__FILE__) . '/lib/Exception/IdempotencyException.php');
require(dirname(__FILE__) . '/lib/Exception/InvalidArgumentException.php');
require(dirname(__FILE__) . '/lib/Exception/InvalidRequestException.php');
require(dirname(__FILE__) . '/lib/Exception/PermissionException.php');
require(dirname(__FILE__) . '/lib/Exception/RateLimitException.php');
require(dirname(__FILE__) . '/lib/Exception/SignatureVerificationException.php');
require(dirname(__FILE__) . '/lib/Exception/UnexpectedValueException.php');
require(dirname(__FILE__) . '/lib/Exception/UnknownApiErrorException.php');

// OAuth errors
require(dirname(__FILE__) . '/lib/Error/OAuth/OAuthBase.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidClient.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidGrant.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidRequest.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidScope.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedGrantType.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedResponseType.php');
// OAuth exceptions
require(dirname(__FILE__) . '/lib/Exception/OAuth/ExceptionInterface.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/OAuthErrorException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/InvalidClientException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/InvalidGrantException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/InvalidRequestException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/InvalidScopeException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/UnknownOAuthErrorException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/UnsupportedGrantTypeException.php');
require(dirname(__FILE__) . '/lib/Exception/OAuth/UnsupportedResponseTypeException.php');

// API operations
require(dirname(__FILE__) . '/lib/ApiOperations/All.php');
Expand Down Expand Up @@ -80,15 +85,14 @@
require(dirname(__FILE__) . '/lib/Discount.php');
require(dirname(__FILE__) . '/lib/Dispute.php');
require(dirname(__FILE__) . '/lib/EphemeralKey.php');
require(dirname(__FILE__) . '/lib/ErrorObject.php');
require(dirname(__FILE__) . '/lib/Event.php');
require(dirname(__FILE__) . '/lib/ExchangeRate.php');
require(dirname(__FILE__) . '/lib/File.php');
require(dirname(__FILE__) . '/lib/FileLink.php');
require(dirname(__FILE__) . '/lib/FileUpload.php');
require(dirname(__FILE__) . '/lib/Invoice.php');
require(dirname(__FILE__) . '/lib/InvoiceItem.php');
require(dirname(__FILE__) . '/lib/InvoiceLineItem.php');
require(dirname(__FILE__) . '/lib/IssuerFraudRecord.php');
require(dirname(__FILE__) . '/lib/Issuing/Authorization.php');
require(dirname(__FILE__) . '/lib/Issuing/Card.php');
require(dirname(__FILE__) . '/lib/Issuing/CardDetails.php');
Expand Down Expand Up @@ -137,6 +141,7 @@

// OAuth
require(dirname(__FILE__) . '/lib/OAuth.php');
require(dirname(__FILE__) . '/lib/OAuthErrorObject.php');

// Webhooks
require(dirname(__FILE__) . '/lib/Webhook.php');
Expand Down
36 changes: 35 additions & 1 deletion lib/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public function instanceUrl()
* options array containing an `id` key.
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Account
*/
public static function retrieve($id = null, $opts = null)
Expand All @@ -118,6 +120,8 @@ public static function retrieve($id = null, $opts = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Account The rejected account.
*/
public function reject($params = null, $opts = null)
Expand All @@ -132,6 +136,8 @@ public function reject($params = null, $opts = null)
* @param array|null $clientId
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return StripeObject Object containing the response from the API.
*/
public function deauthorize($clientId = null, $opts = null)
Expand All @@ -156,6 +162,8 @@ public function deauthorize($clientId = null, $opts = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Capability
*/
public static function retrieveCapability($id, $capabilityId, $params = null, $opts = null)
Expand All @@ -181,6 +189,8 @@ public static function updateCapability($id, $capabilityId, $params = null, $opt
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Collection The list of capabilities.
*/
public static function allCapabilities($id, $params = null, $opts = null)
Expand All @@ -193,6 +203,8 @@ public static function allCapabilities($id, $params = null, $opts = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return BankAccount|Card
*/
public static function createExternalAccount($id, $params = null, $opts = null)
Expand All @@ -206,6 +218,8 @@ public static function createExternalAccount($id, $params = null, $opts = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return BankAccount|Card
*/
public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
Expand All @@ -219,6 +233,8 @@ public static function retrieveExternalAccount($id, $externalAccountId, $params
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return BankAccount|Card
*/
public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
Expand All @@ -232,6 +248,8 @@ public static function updateExternalAccount($id, $externalAccountId, $params =
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return BankAccount|Card
*/
public static function deleteExternalAccount($id, $externalAccountId, $params = null, $opts = null)
Expand All @@ -244,6 +262,8 @@ public static function deleteExternalAccount($id, $externalAccountId, $params =
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Collection The list of external accounts (BankAccount or Card).
*/
public static function allExternalAccounts($id, $params = null, $opts = null)
Expand All @@ -256,6 +276,8 @@ public static function allExternalAccounts($id, $params = null, $opts = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return LoginLink
*/
public static function createLoginLink($id, $params = null, $opts = null)
Expand All @@ -267,6 +289,8 @@ public static function createLoginLink($id, $params = null, $opts = null)
* @param array|null $params
* @param array|string|null $options
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Collection The list of persons.
*/
public function persons($params = null, $options = null)
Expand All @@ -283,6 +307,8 @@ public function persons($params = null, $options = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Person
*/
public static function createPerson($id, $params = null, $opts = null)
Expand All @@ -296,6 +322,8 @@ public static function createPerson($id, $params = null, $opts = null)
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Person
*/
public static function retrievePerson($id, $personId, $params = null, $opts = null)
Expand All @@ -309,6 +337,8 @@ public static function retrievePerson($id, $personId, $params = null, $opts = nu
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Person
*/
public static function updatePerson($id, $personId, $params = null, $opts = null)
Expand All @@ -322,6 +352,8 @@ public static function updatePerson($id, $personId, $params = null, $opts = null
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Person
*/
public static function deletePerson($id, $personId, $params = null, $opts = null)
Expand All @@ -334,6 +366,8 @@ public static function deletePerson($id, $personId, $params = null, $opts = null
* @param array|null $params
* @param array|string|null $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Collection The list of persons.
*/
public static function allPersons($id, $params = null, $opts = null)
Expand Down Expand Up @@ -370,7 +404,7 @@ private function serializeAdditionalOwners($legalEntity, $additionalOwners)
$originalValue = [];
}
if (($originalValue) && (count($originalValue) > count($additionalOwners))) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
"You cannot delete an item from an array, you must instead set a new array"
);
}
Expand Down
Loading