From b2aac1085369ea7ce8e910d8f640210feebdbfe5 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Wed, 12 Feb 2020 15:33:02 -0800 Subject: [PATCH] Another batch of PHP-CS-Fixer rule updates (#872) * Enable dir_constant rule * Enable include rule * Enable binary_operator_spaces rule * Enable blank_line_before_statement rule * Enable phpdoc_no_package rule * Remove custom configuration for phpdoc_types_order rule * Enable phpdoc_annotation_without_dot rule * Enable phpdoc_summary rule * Enable single_quote rule * Enable php_unit_strict rule --- .php_cs.dist | 12 - build.php | 2 +- examples/oauth.php | 10 +- init.php | 260 ++++++++-------- lib/Account.php | 168 +++++----- lib/AccountLink.php | 4 +- lib/AlipayAccount.php | 24 +- lib/ApiOperations/All.php | 5 +- lib/ApiOperations/Create.php | 7 +- lib/ApiOperations/Delete.php | 7 +- lib/ApiOperations/NestedResource.php | 39 ++- lib/ApiOperations/Request.php | 13 +- lib/ApiOperations/Retrieve.php | 7 +- lib/ApiOperations/Update.php | 14 +- lib/ApiRequestor.php | 39 ++- lib/ApiResource.php | 24 +- lib/ApiResponse.php | 12 +- lib/ApplePayDomain.php | 4 +- lib/ApplicationFee.php | 38 ++- lib/ApplicationFeeRefund.php | 13 +- lib/Balance.php | 6 +- lib/BalanceTransaction.php | 66 ++-- lib/BankAccount.php | 59 ++-- lib/BitcoinReceiver.php | 21 +- lib/BitcoinTransaction.php | 4 +- lib/Capability.php | 31 +- lib/Card.php | 78 ++--- lib/Charge.php | 161 +++++----- lib/Checkout/Session.php | 36 ++- lib/Collection.php | 36 +-- lib/CountrySpec.php | 4 +- lib/Coupon.php | 18 +- lib/CreditNote.php | 48 +-- lib/CreditNoteLineItem.php | 8 +- lib/Customer.php | 139 +++++---- lib/CustomerBalanceTransaction.php | 35 +-- lib/Discount.php | 4 +- lib/Dispute.php | 53 ++-- lib/EphemeralKey.php | 11 +- lib/ErrorObject.php | 188 ++++++------ lib/Event.php | 286 +++++++++--------- lib/Exception/ApiConnectionException.php | 2 - lib/Exception/ApiErrorException.php | 45 +-- lib/Exception/AuthenticationException.php | 2 - lib/Exception/CardException.php | 26 +- lib/Exception/ExceptionInterface.php | 4 - lib/Exception/IdempotencyException.php | 2 - lib/Exception/InvalidRequestException.php | 20 +- .../OAuth/InvalidClientException.php | 2 - lib/Exception/OAuth/InvalidGrantException.php | 2 - .../OAuth/InvalidRequestException.php | 2 - lib/Exception/OAuth/InvalidScopeException.php | 2 - .../OAuth/UnknownOAuthErrorException.php | 2 - .../OAuth/UnsupportedGrantTypeException.php | 2 - .../UnsupportedResponseTypeException.php | 2 - lib/Exception/PermissionException.php | 2 - lib/Exception/RateLimitException.php | 2 - .../SignatureVerificationException.php | 16 +- lib/Exception/UnknownApiErrorException.php | 2 - lib/ExchangeRate.php | 4 +- lib/File.php | 21 +- lib/FileLink.php | 8 +- lib/HttpClient/ClientInterface.php | 4 +- lib/HttpClient/CurlClient.php | 58 ++-- lib/Invoice.php | 152 +++++----- lib/InvoiceItem.php | 18 +- lib/InvoiceLineItem.php | 4 +- lib/Issuing/Authorization.php | 22 +- lib/Issuing/Card.php | 21 +- lib/Issuing/CardDetails.php | 4 +- lib/Issuing/Cardholder.php | 14 +- lib/Issuing/Dispute.php | 4 +- lib/Issuing/Transaction.php | 12 +- lib/LoginLink.php | 4 +- lib/Mandate.php | 4 +- lib/OAuth.php | 22 +- lib/OAuthErrorObject.php | 8 +- lib/Order.php | 42 +-- lib/OrderItem.php | 4 +- lib/OrderReturn.php | 8 +- lib/PaymentIntent.php | 81 ++--- lib/PaymentMethod.php | 20 +- lib/Payout.php | 61 ++-- lib/Person.php | 53 ++-- lib/Plan.php | 24 +- lib/Product.php | 22 +- lib/Radar/EarlyFraudWarning.php | 16 +- lib/Radar/ValueList.php | 4 +- lib/Radar/ValueListItem.php | 4 +- lib/Recipient.php | 18 +- lib/RecipientTransfer.php | 4 +- lib/Refund.php | 34 +-- lib/Reporting/ReportRun.php | 10 +- lib/Reporting/ReportType.php | 6 +- lib/RequestTelemetry.php | 8 +- lib/Review.php | 33 +- lib/SKU.php | 8 +- lib/SetupIntent.php | 52 ++-- lib/Sigma/ScheduledQueryRun.php | 8 +- lib/SingletonApiResource.php | 10 +- lib/Source.php | 65 ++-- lib/SourceTransaction.php | 4 +- lib/Stripe.php | 41 ++- lib/StripeObject.php | 61 ++-- lib/Subscription.php | 73 +++-- lib/SubscriptionItem.php | 29 +- lib/SubscriptionSchedule.php | 34 +-- lib/TaxId.php | 48 +-- lib/TaxRate.php | 8 +- lib/Terminal/ConnectionToken.php | 4 +- lib/Terminal/Location.php | 4 +- lib/Terminal/Reader.php | 12 +- lib/ThreeDSecure.php | 10 +- lib/Token.php | 12 +- lib/Topup.php | 33 +- lib/Transfer.php | 59 ++-- lib/TransferReversal.php | 13 +- lib/UsageRecord.php | 4 +- lib/UsageRecordSummary.php | 4 +- lib/Util/CaseInsensitiveArray.php | 3 + lib/Util/RandomGenerator.php | 1 + lib/Util/RequestOptions.php | 12 +- lib/Util/Util.php | 46 +-- lib/Webhook.php | 10 +- lib/WebhookEndpoint.php | 8 +- lib/WebhookSignature.php | 42 +-- tests/Stripe/AccountLinkTest.php | 8 +- tests/Stripe/AccountTest.php | 24 +- tests/Stripe/AlipayAccountTest.php | 7 +- tests/Stripe/ApiRequestorTest.php | 58 ++-- tests/Stripe/ApplePayDomainTest.php | 2 +- tests/Stripe/ApplicationFeeRefundTest.php | 2 +- tests/Stripe/BankAccountTest.php | 15 +- tests/Stripe/BitcoinReceiverTest.php | 5 +- tests/Stripe/CapabilityTest.php | 4 +- tests/Stripe/CardTest.php | 11 +- tests/Stripe/ChargeTest.php | 10 +- tests/Stripe/CollectionTest.php | 6 +- tests/Stripe/CouponTest.php | 12 +- tests/Stripe/CreditNoteTest.php | 10 +- .../Stripe/CustomerBalanceTransactionTest.php | 2 +- tests/Stripe/CustomerTest.php | 18 +- tests/Stripe/DisputeTest.php | 4 +- tests/Stripe/EphemeralKeyTest.php | 12 +- .../Exception/ApiErrorExceptionTest.php | 3 +- .../OAuth/OAuthErrorExceptionTest.php | 3 +- tests/Stripe/ExchangeRateTest.php | 6 +- tests/Stripe/FileCreationTest.php | 16 +- tests/Stripe/FileLinkTest.php | 6 +- tests/Stripe/HttpClient/CurlClientTest.php | 56 ++-- tests/Stripe/InvoiceItemTest.php | 10 +- tests/Stripe/InvoiceTest.php | 8 +- tests/Stripe/Issuing/AuthorizationTest.php | 6 +- tests/Stripe/Issuing/CardTest.php | 6 +- tests/Stripe/Issuing/CardholderTest.php | 22 +- tests/Stripe/Issuing/DisputeTest.php | 10 +- tests/Stripe/Issuing/TransactionTest.php | 6 +- tests/Stripe/OrderTest.php | 4 +- tests/Stripe/PaymentIntentTest.php | 8 +- tests/Stripe/PaymentMethodTest.php | 4 +- tests/Stripe/PayoutTest.php | 8 +- tests/Stripe/PersonTest.php | 6 +- tests/Stripe/PlanTest.php | 4 +- tests/Stripe/ProductTest.php | 4 +- tests/Stripe/Radar/ValueListItemTest.php | 6 +- tests/Stripe/Radar/ValueListTest.php | 8 +- tests/Stripe/RecipientTest.php | 8 +- tests/Stripe/RefundTest.php | 6 +- tests/Stripe/Reporting/ReportRunTest.php | 6 +- tests/Stripe/SKUTest.php | 12 +- tests/Stripe/SetupIntentTest.php | 4 +- tests/Stripe/SourceTest.php | 16 +- tests/Stripe/StripeObjectTest.php | 90 +++--- tests/Stripe/StripeTelemetryTest.php | 18 +- tests/Stripe/StripeTest.php | 2 +- tests/Stripe/SubscriptionItemTest.php | 18 +- tests/Stripe/SubscriptionScheduleTest.php | 10 +- tests/Stripe/SubscriptionTest.php | 6 +- tests/Stripe/TaxIdTest.php | 2 +- tests/Stripe/TaxRateTest.php | 10 +- tests/Stripe/Terminal/LocationTest.php | 34 +-- tests/Stripe/Terminal/ReaderTest.php | 8 +- tests/Stripe/ThreeDSecureTest.php | 6 +- tests/Stripe/TokenTest.php | 2 +- tests/Stripe/TopupTest.php | 14 +- tests/Stripe/TransferReversalTest.php | 2 +- tests/Stripe/TransferTest.php | 12 +- .../Stripe/Util/CaseInsensitiveArrayTest.php | 30 +- tests/Stripe/Util/DefaultLoggerTest.php | 4 +- tests/Stripe/Util/RequestOptionsTest.php | 10 +- tests/Stripe/Util/UtilTest.php | 12 +- tests/Stripe/WebhookTest.php | 33 +- tests/StripeMock.php | 14 +- tests/TestCase.php | 24 +- tests/bootstrap.php | 32 +- update_certs.php | 10 +- 196 files changed, 2257 insertions(+), 2303 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 5b0e16161..02a3637ac 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -11,27 +11,15 @@ return PhpCsFixer\Config::create() '@PHPUnit57Migration:risky' => true, // Diffs from @PhpCsFixer / @PhpCsFixer:risky - 'binary_operator_spaces' => false, - 'blank_line_before_statement' => false, 'concat_space' => [ 'spacing' => 'one', ], - 'dir_constant' => false, - 'include' => false, 'ordered_class_elements' => false, 'php_unit_internal_class' => false, - 'php_unit_strict' => false, 'php_unit_test_class_requires_covers' => false, 'phpdoc_align' => false, - 'phpdoc_annotation_without_dot' => false, - 'phpdoc_no_package' => false, - 'phpdoc_summary' => false, - 'phpdoc_types_order' => [ - 'null_adjustment' => 'always_last', - ], 'protected_to_private' => false, 'self_accessor' => false, - 'single_quote' => false, // Should be included in @PhpCsFixer / @PhpCsFixer:risky according to doc, but need to be // enabled manually for some reason. diff --git a/build.php b/build.php index 355c38a92..37360ffef 100755 --- a/build.php +++ b/build.php @@ -1,6 +1,6 @@ #!/usr/bin/env php $code, ]); } catch (\Stripe\Exception\OAuth\OAuthErrorException $e) { - exit("Error: " . $e->getMessage()); + exit('Error: ' . $e->getMessage()); } $accountId = $resp->stripe_user_id; @@ -27,7 +27,7 @@ $error = $_GET['error']; $error_description = $_GET['error_description']; - echo "

Error: code=" . \htmlspecialchars($error, \ENT_QUOTES) . ", description=" . \htmlspecialchars($error_description, \ENT_QUOTES) . "

\n"; + echo '

Error: code=' . \htmlspecialchars($error, \ENT_QUOTES) . ', description=' . \htmlspecialchars($error_description, \ENT_QUOTES) . "

\n"; echo "

Click here to restart the OAuth flow.

\n"; } elseif (isset($_GET['deauth'])) { // Deauthorization request @@ -38,10 +38,10 @@ 'stripe_user_id' => $accountId, ]); } catch (\Stripe\Exception\OAuth\OAuthErrorException $e) { - exit("Error: " . $e->getMessage()); + exit('Error: ' . $e->getMessage()); } - echo "

Success! Account " . \htmlspecialchars($accountId, \ENT_QUOTES) . " is disconnected.

\n"; + echo '

Success! Account ' . \htmlspecialchars($accountId, \ENT_QUOTES) . " is disconnected.

\n"; echo "

Click here to restart the OAuth flow.

\n"; } else { $url = \Stripe\OAuth::authorizeUrl([ diff --git a/init.php b/init.php index 7971fda84..d19490fff 100644 --- a/init.php +++ b/init.php @@ -1,151 +1,151 @@ Stripe supports in the account's country. * @property bool $details_submitted Whether account details have been submitted. Standard accounts cannot receive payouts before this is true. - * @property string|null $email The primary user's email address. + * @property null|string $email The primary user's email address. * @property \Stripe\Collection $external_accounts External accounts (bank accounts and debit cards) currently attached to this account * @property \Stripe\Person $individual * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property bool $payouts_enabled Whether Stripe can send payouts to this account. * @property \Stripe\StripeObject $requirements - * @property \Stripe\StripeObject|null $settings Options for customizing how the account functions within Stripe. + * @property null|\Stripe\StripeObject $settings Options for customizing how the account functions within Stripe. * @property \Stripe\StripeObject $tos_acceptance * @property string $type The Stripe account type. Can be standard, express, or custom. - * - * @package Stripe */ class Account extends ApiResource { @@ -47,7 +45,7 @@ class Account extends ApiResource * * @see https://stripe.com/docs/api/accounts/object#account_object-business_type */ - const BUSINESS_TYPE_COMPANY = 'company'; + const BUSINESS_TYPE_COMPANY = 'company'; const BUSINESS_TYPE_INDIVIDUAL = 'individual'; /** @@ -55,27 +53,27 @@ class Account extends ApiResource * * @see https://stripe.com/docs/api/accounts/object#account_object-capabilities */ - const CAPABILITY_CARD_PAYMENTS = 'card_payments'; - const CAPABILITY_LEGACY_PAYMENTS = 'legacy_payments'; + const CAPABILITY_CARD_PAYMENTS = 'card_payments'; + const CAPABILITY_LEGACY_PAYMENTS = 'legacy_payments'; const CAPABILITY_PLATFORM_PAYMENTS = 'platform_payments'; - const CAPABILITY_TRANSFERS = 'transfers'; + const CAPABILITY_TRANSFERS = 'transfers'; /** * Possible string representations of an account's capability status. * * @see https://stripe.com/docs/api/accounts/object#account_object-capabilities */ - const CAPABILITY_STATUS_ACTIVE = 'active'; + const CAPABILITY_STATUS_ACTIVE = 'active'; const CAPABILITY_STATUS_INACTIVE = 'inactive'; - const CAPABILITY_STATUS_PENDING = 'pending'; + const CAPABILITY_STATUS_PENDING = 'pending'; /** * Possible string representations of an account's type. * * @see https://stripe.com/docs/api/accounts/object#account_object-type */ - const TYPE_CUSTOM = 'custom'; - const TYPE_EXPRESS = 'express'; + const TYPE_CUSTOM = 'custom'; + const TYPE_EXPRESS = 'express'; const TYPE_STANDARD = 'standard'; public static function getSavedNestedResources() @@ -87,6 +85,7 @@ public static function getSavedNestedResources() 'bank_account', ]); } + return $savedNestedResources; } @@ -95,6 +94,7 @@ public function instanceUrl() if (null === $this['id']) { return '/v1/account'; } + return parent::instanceUrl(); } @@ -116,6 +116,7 @@ public function serializeParameters($force = false) $update['individual'] = $individual->serializeParameters($force); } } + return $update; } @@ -128,7 +129,7 @@ private function serializeAdditionalOwners($legalEntity, $additionalOwners) } if (($originalValue) && (\count($originalValue) > \count($additionalOwners))) { throw new Exception\InvalidArgumentException( - "You cannot delete an item from an array, you must instead set a new array" + 'You cannot delete an item from an array, you must instead set a new array' ); } @@ -144,13 +145,14 @@ private function serializeAdditionalOwners($legalEntity, $additionalOwners) } } } + return $updateArr; } /** - * @param array|string|null $id The ID of the account to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts + * @param null|array|string $id the ID of the account to retrieve, or an + * options array containing an `id` key + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -162,16 +164,17 @@ public static function retrieve($id = null, $opts = null) $opts = $id; $id = null; } + return self::_retrieve($id, $opts); } /** - * @param array|null $clientId - * @param array|string|null $opts + * @param null|array $clientId + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\StripeObject Object containing the response from the API. + * @return \Stripe\StripeObject object containing the response from the API */ public function deauthorize($clientId = null, $opts = null) { @@ -179,22 +182,24 @@ public function deauthorize($clientId = null, $opts = null) 'client_id' => $clientId, 'stripe_user_id' => $this->id, ]; + return OAuth::deauthorize($params, $opts); } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Account The rejected account. + * @return Account the rejected account */ public function reject($params = null, $opts = null) { $url = $this->instanceUrl() . '/reject'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } @@ -207,13 +212,13 @@ public function reject($params = null, $opts = null) const PATH_CAPABILITIES = '/capabilities'; /** - * @param string $id The ID of the account on which to retrieve the capabilities. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account on which to retrieve the capabilities + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of capabilities. + * @return \Stripe\Collection the list of capabilities */ public static function allCapabilities($id, $params = null, $opts = null) { @@ -221,10 +226,10 @@ public static function allCapabilities($id, $params = null, $opts = null) } /** - * @param string $id The ID of the account to which the capability belongs. - * @param string $capabilityId The ID of the capability to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the capability belongs + * @param string $capabilityId the ID of the capability to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -236,10 +241,10 @@ public static function retrieveCapability($id, $capabilityId, $params = null, $o } /** - * @param string $id The ID of the account to which the capability belongs. - * @param string $capabilityId The ID of the capability to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the capability belongs + * @param string $capabilityId the ID of the capability to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -253,13 +258,13 @@ public static function updateCapability($id, $capabilityId, $params = null, $opt const PATH_EXTERNAL_ACCOUNTS = '/external_accounts'; /** - * @param string $id The ID of the account on which to retrieve the external accounts. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account on which to retrieve the external accounts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of external accounts (BankAccount or Card). + * @return \Stripe\Collection the list of external accounts (BankAccount or Card) */ public static function allExternalAccounts($id, $params = null, $opts = null) { @@ -267,9 +272,9 @@ public static function allExternalAccounts($id, $params = null, $opts = null) } /** - * @param string $id The ID of the account on which to create the external account. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account on which to create the external account + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -281,10 +286,10 @@ public static function createExternalAccount($id, $params = null, $opts = null) } /** - * @param string $id The ID of the account to which the external account belongs. - * @param string $externalAccountId The ID of the external account to delete. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the external account belongs + * @param string $externalAccountId the ID of the external account to delete + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -296,10 +301,10 @@ public static function deleteExternalAccount($id, $externalAccountId, $params = } /** - * @param string $id The ID of the account to which the external account belongs. - * @param string $externalAccountId The ID of the external account to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the external account belongs + * @param string $externalAccountId the ID of the external account to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -311,10 +316,10 @@ public static function retrieveExternalAccount($id, $externalAccountId, $params } /** - * @param string $id The ID of the account to which the external account belongs. - * @param string $externalAccountId The ID of the external account to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the external account belongs + * @param string $externalAccountId the ID of the external account to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -328,9 +333,9 @@ public static function updateExternalAccount($id, $externalAccountId, $params = const PATH_LOGIN_LINKS = '/login_links'; /** - * @param string $id The ID of the account on which to create the login link. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account on which to create the login link + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -344,12 +349,12 @@ public static function createLoginLink($id, $params = null, $opts = null) const PATH_PERSONS = '/persons'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of persons. + * @return \Stripe\Collection the list of persons */ public function persons($params = null, $opts = null) { @@ -357,17 +362,18 @@ public function persons($params = null, $opts = null) list($response, $opts) = $this->_request('get', $url, $params, $opts); $obj = Util\Util::convertToStripeObject($response, $opts); $obj->setLastResponse($response); + return $obj; } /** - * @param string $id The ID of the account on which to retrieve the persons. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account on which to retrieve the persons + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of persons. + * @return \Stripe\Collection the list of persons */ public static function allPersons($id, $params = null, $opts = null) { @@ -375,9 +381,9 @@ public static function allPersons($id, $params = null, $opts = null) } /** - * @param string $id The ID of the account on which to create the person. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account on which to create the person + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -389,10 +395,10 @@ public static function createPerson($id, $params = null, $opts = null) } /** - * @param string $id The ID of the account to which the person belongs. - * @param string $personId The ID of the person to delete. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the person belongs + * @param string $personId the ID of the person to delete + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -404,10 +410,10 @@ public static function deletePerson($id, $personId, $params = null, $opts = null } /** - * @param string $id The ID of the account to which the person belongs. - * @param string $personId The ID of the person to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the person belongs + * @param string $personId the ID of the person to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -419,10 +425,10 @@ public static function retrievePerson($id, $personId, $params = null, $opts = nu } /** - * @param string $id The ID of the account to which the person belongs. - * @param string $personId The ID of the person to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the account to which the person belongs + * @param string $personId the ID of the person to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * diff --git a/lib/AccountLink.php b/lib/AccountLink.php index 4ffb61b32..79929f6e1 100644 --- a/lib/AccountLink.php +++ b/lib/AccountLink.php @@ -3,14 +3,12 @@ namespace Stripe; /** - * Class AccountLink + * Class AccountLink. * * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property int $expires_at The timestamp at which this account link will expire. * @property string $url The URL for the account link. - * - * @package Stripe */ class AccountLink extends ApiResource { diff --git a/lib/AlipayAccount.php b/lib/AlipayAccount.php index 5d6f6702e..1d6a5096f 100644 --- a/lib/AlipayAccount.php +++ b/lib/AlipayAccount.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class AlipayAccount - * - * @package Stripe + * Class AlipayAccount. * * @deprecated Alipay accounts are deprecated. Please use the sources API instead. * @see https://stripe.com/docs/sources/alipay @@ -28,17 +26,19 @@ public function instanceUrl() $parent = $this['customer']; $path = 'sources'; } else { - $msg = "Alipay accounts cannot be accessed without a customer ID."; + $msg = 'Alipay accounts cannot be accessed without a customer ID.'; + throw new Exception\UnexpectedValueException($msg); } $parentExtn = \urlencode(Util\Util::utf8($parent)); $extn = \urlencode(Util\Util::utf8($this['id'])); + return "{$base}/{$parentExtn}/{$path}/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException * @@ -47,16 +47,17 @@ public function instanceUrl() */ public static function retrieve($_id, $_opts = null) { - $msg = "Alipay accounts cannot be retrieved without a customer ID. " . - "Retrieve an Alipay account using `Customer::retrieveSource(" . + $msg = 'Alipay accounts cannot be retrieved without a customer ID. ' . + 'Retrieve an Alipay account using `Customer::retrieveSource(' . "'customer_id', 'alipay_account_id')`."; + throw new Exception\BadMethodCallException($msg); } /** * @param string $_id - * @param array|null $_params - * @param array|string|null $_options + * @param null|array $_params + * @param null|array|string $_options * * @throws \Stripe\Exception\BadMethodCallException * @@ -65,9 +66,10 @@ public static function retrieve($_id, $_opts = null) */ public static function update($_id, $_params = null, $_options = null) { - $msg = "Alipay accounts cannot be updated without a customer ID. " . - "Update an Alipay account using `Customer::updateSource(" . + $msg = 'Alipay accounts cannot be updated without a customer ID. ' . + 'Update an Alipay account using `Customer::updateSource(' . "'customer_id', 'alipay_account_id', \$updateParams)`."; + throw new Exception\BadMethodCallException($msg); } } diff --git a/lib/ApiOperations/All.php b/lib/ApiOperations/All.php index 59ac377f1..ff2955d18 100644 --- a/lib/ApiOperations/All.php +++ b/lib/ApiOperations/All.php @@ -10,8 +10,8 @@ trait All { /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -31,6 +31,7 @@ public static function all($params = null, $opts = null) } $obj->setLastResponse($response); $obj->setFilters($params); + return $obj; } } diff --git a/lib/ApiOperations/Create.php b/lib/ApiOperations/Create.php index 8dc3975ac..c4351321d 100644 --- a/lib/ApiOperations/Create.php +++ b/lib/ApiOperations/Create.php @@ -10,12 +10,12 @@ trait Create { /** - * @param array|null $params - * @param array|string|null $options + * @param null|array $params + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return static The created resource. + * @return static the created resource */ public static function create($params = null, $options = null) { @@ -25,6 +25,7 @@ public static function create($params = null, $options = null) list($response, $opts) = static::_staticRequest('post', $url, $params, $options); $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); + return $obj; } } diff --git a/lib/ApiOperations/Delete.php b/lib/ApiOperations/Delete.php index 62de777a6..c6082ff9f 100644 --- a/lib/ApiOperations/Delete.php +++ b/lib/ApiOperations/Delete.php @@ -10,12 +10,12 @@ trait Delete { /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return static The deleted resource. + * @return static the deleted resource */ public function delete($params = null, $opts = null) { @@ -24,6 +24,7 @@ public function delete($params = null, $opts = null) $url = $this->instanceUrl(); list($response, $opts) = $this->_request('delete', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/ApiOperations/NestedResource.php b/lib/ApiOperations/NestedResource.php index d921a2ea7..180cacd2c 100644 --- a/lib/ApiOperations/NestedResource.php +++ b/lib/ApiOperations/NestedResource.php @@ -12,8 +12,8 @@ trait NestedResource /** * @param string $method * @param string $url - * @param array|null $params - * @param array|string|null $options + * @param null|array $params + * @param null|array|string $options * * @return \Stripe\StripeObject */ @@ -24,13 +24,14 @@ protected static function _nestedResourceOperation($method, $url, $params = null list($response, $opts) = static::_staticRequest($method, $url, $params, $options); $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); + return $obj; } /** * @param string $id * @param string $nestedPath - * @param string|null $nestedId + * @param null|string $nestedId * * @return string */ @@ -40,14 +41,15 @@ protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null) if (null !== $nestedId) { $url .= "/{$nestedId}"; } + return $url; } /** * @param string $id * @param string $nestedPath - * @param array|null $params - * @param array|string|null $options + * @param null|array $params + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -56,15 +58,16 @@ protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null) protected static function _createNestedResource($id, $nestedPath, $params = null, $options = null) { $url = static::_nestedResourceUrl($id, $nestedPath); + return self::_nestedResourceOperation('post', $url, $params, $options); } /** * @param string $id * @param string $nestedPath - * @param string|null $nestedId - * @param array|null $params - * @param array|string|null $options + * @param null|string $nestedId + * @param null|array $params + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -73,15 +76,16 @@ protected static function _createNestedResource($id, $nestedPath, $params = null protected static function _retrieveNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null) { $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId); + return self::_nestedResourceOperation('get', $url, $params, $options); } /** * @param string $id * @param string $nestedPath - * @param string|null $nestedId - * @param array|null $params - * @param array|string|null $options + * @param null|string $nestedId + * @param null|array $params + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -90,15 +94,16 @@ protected static function _retrieveNestedResource($id, $nestedPath, $nestedId, $ protected static function _updateNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null) { $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId); + return self::_nestedResourceOperation('post', $url, $params, $options); } /** * @param string $id * @param string $nestedPath - * @param string|null $nestedId - * @param array|null $params - * @param array|string|null $options + * @param null|string $nestedId + * @param null|array $params + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -107,14 +112,15 @@ protected static function _updateNestedResource($id, $nestedPath, $nestedId, $pa protected static function _deleteNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null) { $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId); + return self::_nestedResourceOperation('delete', $url, $params, $options); } /** * @param string $id * @param string $nestedPath - * @param array|null $params - * @param array|string|null $options + * @param null|array $params + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -123,6 +129,7 @@ protected static function _deleteNestedResource($id, $nestedPath, $nestedId, $pa protected static function _allNestedResources($id, $nestedPath, $params = null, $options = null) { $url = static::_nestedResourceUrl($id, $nestedPath); + return self::_nestedResourceOperation('get', $url, $params, $options); } } diff --git a/lib/ApiOperations/Request.php b/lib/ApiOperations/Request.php index e9f4e7897..e300dc13f 100644 --- a/lib/ApiOperations/Request.php +++ b/lib/ApiOperations/Request.php @@ -10,17 +10,18 @@ trait Request { /** - * @param array|mixed|null $params The list of parameters to validate + * @param null|array|mixed $params The list of parameters to validate * * @throws \Stripe\Exception\InvalidArgumentException if $params exists and is not an array */ protected static function _validateParams($params = null) { if ($params && !\is_array($params)) { - $message = "You must pass an array as the first argument to Stripe API " - . "method calls. (HINT: an example call to create a charge " + $message = 'You must pass an array as the first argument to Stripe API ' + . 'method calls. (HINT: an example call to create a charge ' . "would be: \"Stripe\\Charge::create(['amount' => 100, " . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; + throw new \Stripe\Exception\InvalidArgumentException($message); } } @@ -29,7 +30,7 @@ protected static function _validateParams($params = null) * @param string $method HTTP method ('get', 'post', etc.) * @param string $url URL for the request * @param array $params list of parameters for the request - * @param array|string|null $options + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -40,6 +41,7 @@ protected function _request($method, $url, $params = [], $options = null) $opts = $this->_opts->merge($options); list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); $this->setLastResponse($resp); + return [$resp->json, $options]; } @@ -47,7 +49,7 @@ protected function _request($method, $url, $params = [], $options = null) * @param string $method HTTP method ('get', 'post', etc.) * @param string $url URL for the request * @param array $params list of parameters for the request - * @param array|string|null $options + * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -60,6 +62,7 @@ protected static function _staticRequest($method, $url, $params, $options) $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl); list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); $opts->discardNonPersistentHeaders(); + return [$response, $opts]; } } diff --git a/lib/ApiOperations/Retrieve.php b/lib/ApiOperations/Retrieve.php index 7e5d4206f..5170afb32 100644 --- a/lib/ApiOperations/Retrieve.php +++ b/lib/ApiOperations/Retrieve.php @@ -11,9 +11,9 @@ trait Retrieve { /** - * @param array|string $id The ID of the API resource to retrieve, - * or an options array containing an `id` key. - * @param array|string|null $opts + * @param array|string $id the ID of the API resource to retrieve, + * or an options array containing an `id` key + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -24,6 +24,7 @@ public static function retrieve($id, $opts = null) $opts = \Stripe\Util\RequestOptions::parse($opts); $instance = new static($id, $opts); $instance->refresh(); + return $instance; } } diff --git a/lib/ApiOperations/Update.php b/lib/ApiOperations/Update.php index 24ba80f65..688f0808a 100644 --- a/lib/ApiOperations/Update.php +++ b/lib/ApiOperations/Update.php @@ -11,13 +11,13 @@ trait Update { /** - * @param string $id The ID of the resource to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the resource to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return static The updated resource. + * @return static the updated resource */ public static function update($id, $params = null, $opts = null) { @@ -27,15 +27,16 @@ public static function update($id, $params = null, $opts = null) list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); + return $obj; } /** - * @param array|string|null $opts + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return static The saved resource. + * @return static the saved resource */ public function save($opts = null) { @@ -45,6 +46,7 @@ public function save($opts = null) list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); } + return $this; } } diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 3e2df1bd2..d587b8020 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -3,14 +3,12 @@ namespace Stripe; /** - * Class ApiRequestor - * - * @package Stripe + * Class ApiRequestor. */ class ApiRequestor { /** - * @var string|null + * @var null|string */ private $_apiKey; @@ -32,8 +30,8 @@ class ApiRequestor /** * ApiRequestor constructor. * - * @param string|null $apiKey - * @param string|null $apiBase + * @param null|string $apiKey + * @param null|string $apiBase */ public function __construct($apiKey = null, $apiBase = null) { @@ -45,7 +43,7 @@ public function __construct($apiKey = null, $apiBase = null) } /** - * Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers + * Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers. * * @static * @@ -66,8 +64,9 @@ private static function _telemetryJson($requestTelemetry) if (false !== $result) { return $result; } - Stripe::getLogger()->error("Serializing telemetry payload failed!"); - return "{}"; + Stripe::getLogger()->error('Serializing telemetry payload failed!'); + + return '{}'; } /** @@ -93,16 +92,18 @@ private static function _encodeObjects($d) foreach ($d as $k => $v) { $res[$k] = self::_encodeObjects($v); } + return $res; } + return Util\Util::utf8($d); } /** * @param string $method * @param string $url - * @param array|null $params - * @param array|null $headers + * @param null|array $params + * @param null|array $headers * * @throws Exception\ApiErrorException * @@ -116,11 +117,12 @@ public function request($method, $url, $params = null, $headers = null) $this->_requestRaw($method, $url, $params, $headers); $json = $this->_interpretResponse($rbody, $rcode, $rheaders); $resp = new ApiResponse($rbody, $rcode, $rheaders, $json); + return [$resp, $myApiKey]; } /** - * @param string $rbody A JSON string. + * @param string $rbody a JSON string * @param int $rcode * @param array $rheaders * @param array $resp @@ -133,6 +135,7 @@ public function handleErrorResponse($rbody, $rcode, $rheaders, $resp) if (!\is_array($resp) || !isset($resp['error'])) { $msg = "Invalid response object from API: {$rbody} " . "(HTTP response code was {$rcode})"; + throw new Exception\UnexpectedValueException($msg); } @@ -231,9 +234,9 @@ private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $e /** * @static * - * @param array|null $appInfo + * @param null|array $appInfo * - * @return string|null + * @return null|string */ private static function _formatAppInfo($appInfo) { @@ -245,8 +248,10 @@ private static function _formatAppInfo($appInfo) if (null !== $appInfo['url']) { $string .= ' (' . $appInfo['url'] . ')'; } + return $string; } + return null; } @@ -312,6 +317,7 @@ private function _requestRaw($method, $url, $params, $headers) . '"Stripe::setApiKey()". You can generate API keys from ' . 'the Stripe web interface. See https://stripe.com/api for ' . 'details, or email support@stripe.com if you have any questions.'; + throw new Exception\AuthenticationException($msg); } @@ -335,7 +341,7 @@ private function _requestRaw($method, $url, $params, $headers) } if (Stripe::$enableTelemetry && null !== self::$requestTelemetry) { - $defaultHeaders["X-Stripe-Client-Telemetry"] = self::_telemetryJson(self::$requestTelemetry); + $defaultHeaders['X-Stripe-Client-Telemetry'] = self::_telemetryJson(self::$requestTelemetry); } $hasFile = false; @@ -424,12 +430,14 @@ private function _interpretResponse($rbody, $rcode, $rheaders) if (null === $resp && \JSON_ERROR_NONE !== $jsonError) { $msg = "Invalid response body from API: {$rbody} " . "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})"; + throw new Exception\UnexpectedValueException($msg, $rcode); } if ($rcode < 200 || $rcode >= 300) { $this->handleErrorResponse($rbody, $rcode, $rheaders, $resp); } + return $resp; } @@ -461,6 +469,7 @@ private function httpClient() if (!self::$_httpClient) { self::$_httpClient = HttpClient\CurlClient::instance(); } + return self::$_httpClient; } } diff --git a/lib/ApiResource.php b/lib/ApiResource.php index 7e4f564a9..a142db819 100644 --- a/lib/ApiResource.php +++ b/lib/ApiResource.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class ApiResource - * - * @package Stripe + * Class ApiResource. */ abstract class ApiResource extends StripeObject { @@ -24,6 +22,7 @@ public static function getSavedNestedResources() if (null === $savedNestedResources) { $savedNestedResources = new Util\Set(); } + return $savedNestedResources; } @@ -44,13 +43,14 @@ public function __set($k, $v) ($v instanceof ApiResource)) { $v->saveWithParent = true; } + return $v; } /** * @throws Exception\ApiErrorException * - * @return ApiResource The refreshed resource. + * @return ApiResource the refreshed resource */ public function refresh() { @@ -65,11 +65,12 @@ public function refresh() ); $this->setLastResponse($response); $this->refreshFrom($response->json, $this->_opts); + return $this; } /** - * @return string The base URL for the given class. + * @return string the base URL for the given class */ public static function baseUrl() { @@ -77,39 +78,42 @@ public static function baseUrl() } /** - * @return string The endpoint URL for the given class. + * @return string the endpoint URL for the given class */ public static function classUrl() { // Replace dots with slashes for namespaced resources, e.g. if the object's name is // "foo.bar", then its URL will be "/v1/foo/bars". $base = \str_replace('.', '/', static::OBJECT_NAME); + return "/v1/{$base}s"; } /** - * @param string|null $id the ID of the resource + * @param null|string $id the ID of the resource * * @throws Exception\UnexpectedValueException if $id is null * - * @return string The instance endpoint URL for the given class. + * @return string the instance endpoint URL for the given class */ public static function resourceUrl($id) { if (null === $id) { $class = static::class; - $message = "Could not determine which URL to request: " + $message = 'Could not determine which URL to request: ' . "{$class} instance has invalid ID: {$id}"; + throw new Exception\UnexpectedValueException($message); } $id = Util\Util::utf8($id); $base = static::classUrl(); $extn = \urlencode($id); + return "{$base}/{$extn}"; } /** - * @return string The full API URL for this API resource. + * @return string the full API URL for this API resource */ public function instanceUrl() { diff --git a/lib/ApiResponse.php b/lib/ApiResponse.php index 3499e64be..e7ee2e9a9 100644 --- a/lib/ApiResponse.php +++ b/lib/ApiResponse.php @@ -5,14 +5,12 @@ use Stripe\Util\CaseInsensitiveArray; /** - * Class ApiResponse - * - * @package Stripe + * Class ApiResponse. */ class ApiResponse { /** - * @var array|CaseInsensitiveArray|null + * @var null|array|CaseInsensitiveArray */ public $headers; @@ -22,7 +20,7 @@ class ApiResponse public $body; /** - * @var array|null + * @var null|array */ public $json; @@ -34,8 +32,8 @@ class ApiResponse /** * @param string $body * @param int $code - * @param array|CaseInsensitiveArray|null $headers - * @param array|null $json + * @param null|array|CaseInsensitiveArray $headers + * @param null|array $json */ public function __construct($body, $code, $headers, $json) { diff --git a/lib/ApplePayDomain.php b/lib/ApplePayDomain.php index 87cfaa246..75323abe2 100644 --- a/lib/ApplePayDomain.php +++ b/lib/ApplePayDomain.php @@ -3,15 +3,13 @@ namespace Stripe; /** - * Class ApplePayDomain + * Class ApplePayDomain. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $domain_name * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * - * @package Stripe */ class ApplePayDomain extends ApiResource { diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index 717ce33fe..1e157fa15 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class ApplicationFee + * Class ApplicationFee. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,16 +11,14 @@ * @property int $amount Amount earned, in %s. * @property int $amount_refunded Amount in %s refunded (can be less than the amount attribute on the fee if a partial refund was issued) * @property string|\Stripe\StripeObject $application ID of the Connect application that earned the fee. - * @property string|\Stripe\BalanceTransaction|null $balance_transaction Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds). + * @property null|string|\Stripe\BalanceTransaction $balance_transaction Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds). * @property string|\Stripe\Charge $charge ID of the charge that the application fee was taken from. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|\Stripe\Charge|null $originating_transaction ID of the corresponding charge on the platform account, if this fee was the result of a charge using the destination parameter. + * @property null|string|\Stripe\Charge $originating_transaction ID of the corresponding charge on the platform account, if this fee was the result of a charge using the destination parameter. * @property bool $refunded Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false. * @property \Stripe\Collection $refunds A list of refunds that have been applied to the fee. - * - * @package Stripe */ class ApplicationFee extends ApiResource { @@ -33,13 +31,13 @@ class ApplicationFee extends ApiResource const PATH_REFUNDS = '/refunds'; /** - * @param string $id The ID of the application fee on which to retrieve the fee refunds. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the application fee on which to retrieve the fee refunds + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of fee refunds. + * @return \Stripe\Collection the list of fee refunds */ public static function allRefunds($id, $params = null, $opts = null) { @@ -47,9 +45,9 @@ public static function allRefunds($id, $params = null, $opts = null) } /** - * @param string $id The ID of the application fee on which to create the fee refund. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the application fee on which to create the fee refund + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -61,10 +59,10 @@ public static function createRefund($id, $params = null, $opts = null) } /** - * @param string $id The ID of the application fee to which the fee refund belongs. - * @param string $refundId The ID of the fee refund to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the application fee to which the fee refund belongs + * @param string $refundId the ID of the fee refund to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -76,10 +74,10 @@ public static function retrieveRefund($id, $refundId, $params = null, $opts = nu } /** - * @param string $id The ID of the application fee to which the fee refund belongs. - * @param string $refundId The ID of the fee refund to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the application fee to which the fee refund belongs + * @param string $refundId the ID of the fee refund to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * diff --git a/lib/ApplicationFeeRefund.php b/lib/ApplicationFeeRefund.php index 025656684..b25ec503e 100644 --- a/lib/ApplicationFeeRefund.php +++ b/lib/ApplicationFeeRefund.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class ApplicationFeeRefund + * Class ApplicationFeeRefund. * * @property string $id * @property string $object @@ -13,8 +13,6 @@ * @property string $currency * @property string $fee * @property \Stripe\StripeObject $metadata - * - * @package Stripe */ class ApplicationFeeRefund extends ApiResource { @@ -25,7 +23,7 @@ class ApplicationFeeRefund extends ApiResource } /** - * @return string The API URL for this Stripe refund. + * @return string the API URL for this Stripe refund */ public function instanceUrl() { @@ -33,7 +31,7 @@ public function instanceUrl() $fee = $this['fee']; if (!$id) { throw new Exception\UnexpectedValueException( - "Could not determine which URL to request: " . + 'Could not determine which URL to request: ' . "class instance has invalid ID: {$id}", null ); @@ -44,13 +42,14 @@ public function instanceUrl() $base = ApplicationFee::classUrl(); $feeExtn = \urlencode($fee); $extn = \urlencode($id); + return "{$base}/{$feeExtn}/refunds/{$extn}"; } /** - * @param array|string|null $opts + * @param null|array|string $opts * - * @return ApplicationFeeRefund The saved refund. + * @return ApplicationFeeRefund the saved refund */ public function save($opts = null) { diff --git a/lib/Balance.php b/lib/Balance.php index 20629e75f..0df4eab50 100644 --- a/lib/Balance.php +++ b/lib/Balance.php @@ -3,22 +3,20 @@ namespace Stripe; /** - * Class Balance + * Class Balance. * * @property string $object String representing the object's type. Objects of the same type share the same value. * @property \Stripe\StripeObject[] $available Funds that are available to be transferred or paid out, whether automatically by Stripe or explicitly via the Transfers API or Payouts API. The available balance for each currency and payment type can be found in the source_types property. * @property \Stripe\StripeObject[] $connect_reserved Funds held due to negative balances on connected Custom accounts. The connect reserve balance for each currency and payment type can be found in the source_types property. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject[] $pending Funds that are not yet available in the balance, due to the 7-day rolling pay cycle. The pending balance for each currency, and for each payment type, can be found in the source_types property. - * - * @package Stripe */ class Balance extends SingletonApiResource { const OBJECT_NAME = 'balance'; /** - * @param array|string|null $opts + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * diff --git a/lib/BalanceTransaction.php b/lib/BalanceTransaction.php index 2504f38ad..8b7f7f1c9 100644 --- a/lib/BalanceTransaction.php +++ b/lib/BalanceTransaction.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class BalanceTransaction + * Class BalanceTransaction. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,17 +11,15 @@ * @property int $available_on The date the transaction's net funds will become available in the Stripe balance. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property float|null $exchange_rate The exchange rate used, if applicable, for this transaction. Specifically, if money was converted from currency A to currency B, then the amount in currency A, times exchange_rate, would be the amount in currency B. For example, suppose you charged a customer 10.00 EUR. Then the PaymentIntent's amount would be 1000 and currency would be eur. Suppose this was converted into 12.34 USD in your Stripe account. Then the BalanceTransaction's amount would be 1234, currency would be usd, and exchange_rate would be 1.234. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|float $exchange_rate The exchange rate used, if applicable, for this transaction. Specifically, if money was converted from currency A to currency B, then the amount in currency A, times exchange_rate, would be the amount in currency B. For example, suppose you charged a customer 10.00 EUR. Then the PaymentIntent's amount would be 1000 and currency would be eur. Suppose this was converted into 12.34 USD in your Stripe account. Then the BalanceTransaction's amount would be 1234, currency would be usd, and exchange_rate would be 1.234. * @property int $fee Fees (in %s) paid for this transaction. * @property \Stripe\StripeObject[] $fee_details Detailed breakdown of fees (in %s) paid for this transaction. * @property int $net Net amount of the transaction, in %s. * @property string $reporting_category Learn more about how reporting categories can help you understand balance transactions from an accounting perspective. - * @property string|\Stripe\StripeObject|null $source The Stripe object to which this transaction is related. + * @property null|string|\Stripe\StripeObject $source The Stripe object to which this transaction is related. * @property string $status If the transaction's net funds are available in the Stripe balance yet. Either available or pending. * @property string $type Transaction type: adjustment, advance, advance_funding, application_fee, application_fee_refund, charge, connect_collection_transfer, issuing_authorization_hold, issuing_authorization_release, issuing_transaction, payment, payment_failure_refund, payment_refund, payout, payout_cancel, payout_failure, refund, refund_failure, reserve_transaction, reserved_funds, stripe_fee, stripe_fx_fee, tax_fee, topup, topup_reversal, transfer, transfer_cancel, transfer_failure, or transfer_refund. Learn more about balance transaction types and what they represent. If you are looking to classify transactions for accounting purposes, you might want to consider reporting_category instead. - * - * @package Stripe */ class BalanceTransaction extends ApiResource { @@ -35,33 +33,33 @@ class BalanceTransaction extends ApiResource * * @see https://stripe.com/docs/api/balance/balance_transaction#balance_transaction_object-type */ - const TYPE_ADJUSTMENT = 'adjustment'; - const TYPE_ADVANCE = 'advance'; - const TYPE_ADVANCE_FUNDING = 'advance_funding'; - const TYPE_APPLICATION_FEE = 'application_fee'; - const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund'; - const TYPE_CHARGE = 'charge'; - const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer'; - const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold'; + const TYPE_ADJUSTMENT = 'adjustment'; + const TYPE_ADVANCE = 'advance'; + const TYPE_ADVANCE_FUNDING = 'advance_funding'; + const TYPE_APPLICATION_FEE = 'application_fee'; + const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund'; + const TYPE_CHARGE = 'charge'; + const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer'; + const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold'; const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release'; - const TYPE_ISSUING_TRANSACTION = 'issuing_transaction'; - const TYPE_PAYMENT = 'payment'; - const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund'; - const TYPE_PAYMENT_REFUND = 'payment_refund'; - const TYPE_PAYOUT = 'payout'; - const TYPE_PAYOUT_CANCEL = 'payout_cancel'; - const TYPE_PAYOUT_FAILURE = 'payout_failure'; - const TYPE_REFUND = 'refund'; - const TYPE_REFUND_FAILURE = 'refund_failure'; - const TYPE_RESERVE_TRANSACTION = 'reserve_transaction'; - const TYPE_RESERVED_FUNDS = 'reserved_funds'; - const TYPE_STRIPE_FEE = 'stripe_fee'; - const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee'; - const TYPE_TAX_FEE = 'tax_fee'; - const TYPE_TOPUP = 'topup'; - const TYPE_TOPUP_REVERSAL = 'topup_reversal'; - const TYPE_TRANSFER = 'transfer'; - const TYPE_TRANSFER_CANCEL = 'transfer_cancel'; - const TYPE_TRANSFER_FAILURE = 'transfer_failure'; - const TYPE_TRANSFER_REFUND = 'transfer_refund'; + const TYPE_ISSUING_TRANSACTION = 'issuing_transaction'; + const TYPE_PAYMENT = 'payment'; + const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund'; + const TYPE_PAYMENT_REFUND = 'payment_refund'; + const TYPE_PAYOUT = 'payout'; + const TYPE_PAYOUT_CANCEL = 'payout_cancel'; + const TYPE_PAYOUT_FAILURE = 'payout_failure'; + const TYPE_REFUND = 'refund'; + const TYPE_REFUND_FAILURE = 'refund_failure'; + const TYPE_RESERVE_TRANSACTION = 'reserve_transaction'; + const TYPE_RESERVED_FUNDS = 'reserved_funds'; + const TYPE_STRIPE_FEE = 'stripe_fee'; + const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee'; + const TYPE_TAX_FEE = 'tax_fee'; + const TYPE_TOPUP = 'topup'; + const TYPE_TOPUP_REVERSAL = 'topup_reversal'; + const TYPE_TRANSFER = 'transfer'; + const TYPE_TRANSFER_CANCEL = 'transfer_cancel'; + const TYPE_TRANSFER_FAILURE = 'transfer_failure'; + const TYPE_TRANSFER_REFUND = 'transfer_refund'; } diff --git a/lib/BankAccount.php b/lib/BankAccount.php index 87c391b92..8994fd588 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -3,25 +3,23 @@ namespace Stripe; /** - * Class BankAccount + * Class BankAccount. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|\Stripe\Account|null $account The ID of the account that the bank account is associated with. - * @property string|null $account_holder_name The name of the person or business that owns the bank account. - * @property string|null $account_holder_type The type of entity that holds the account. This can be either individual or company. - * @property string|null $bank_name Name of the bank associated with the routing number (e.g., WELLS FARGO). + * @property null|string|\Stripe\Account $account The ID of the account that the bank account is associated with. + * @property null|string $account_holder_name The name of the person or business that owns the bank account. + * @property null|string $account_holder_type The type of entity that holds the account. This can be either individual or company. + * @property null|string $bank_name Name of the bank associated with the routing number (e.g., WELLS FARGO). * @property string $country Two-letter ISO code representing the country the bank account is located in. * @property string $currency Three-letter ISO code for the currency paid out to the bank account. - * @property string|\Stripe\Customer|null $customer The ID of the customer that the bank account is associated with. - * @property bool|null $default_for_currency Whether this bank account is the default external account for its currency. - * @property string|null $fingerprint Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. + * @property null|string|\Stripe\Customer $customer The ID of the customer that the bank account is associated with. + * @property null|bool $default_for_currency Whether this bank account is the default external account for its currency. + * @property null|string $fingerprint Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. * @property string $last4 The last four digits of the bank account number. - * @property \Stripe\StripeObject|null $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $routing_number The routing transit number for the bank account. + * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + * @property null|string $routing_number The routing transit number for the bank account. * @property string $status

For bank accounts, possible values are new, validated, verified, verification_failed, or errored. A bank account that hasn't had any activity or validation performed is new. If Stripe can determine that the bank account exists, its status will be validated. Note that there often isn’t enough information to know (e.g., for smaller credit unions), and the validation is not always run. If customer bank account verification has succeeded, the bank account status will be verified. If the verification failed for any reason, such as microdeposit failure, the status will be verification_failed. If a transfer sent to this bank account fails, we'll set the status to errored and will not continue to send transfers until the bank details are updated.

For external accounts, possible values are new and errored. Validations aren't run against external accounts because they're only used for payouts. This means the other statuses don't apply. If a transfer fails, the status is set to errored and transfers are stopped until account details are updated.

- * - * @package Stripe */ class BankAccount extends ApiResource { @@ -35,11 +33,11 @@ class BankAccount extends ApiResource * * @see https://stripe.com/docs/api/external_account_bank_accounts/object#account_bank_account_object-status */ - const STATUS_NEW = 'new'; - const STATUS_VALIDATED = 'validated'; - const STATUS_VERIFIED = 'verified'; + const STATUS_NEW = 'new'; + const STATUS_VALIDATED = 'validated'; + const STATUS_VERIFIED = 'verified'; const STATUS_VERIFICATION_FAILED = 'verification_failed'; - const STATUS_ERRORED = 'errored'; + const STATUS_ERRORED = 'errored'; /** * @return string The instance URL for this resource. It needs to be special @@ -56,60 +54,65 @@ public function instanceUrl() $parent = $this['account']; $path = 'external_accounts'; } else { - $msg = "Bank accounts cannot be accessed without a customer ID or account ID."; + $msg = 'Bank accounts cannot be accessed without a customer ID or account ID.'; + throw new Exception\UnexpectedValueException($msg, null); } $parentExtn = \urlencode(Util\Util::utf8($parent)); $extn = \urlencode(Util\Util::utf8($this['id'])); + return "{$base}/{$parentExtn}/{$path}/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException */ public static function retrieve($_id, $_opts = null) { - $msg = "Bank accounts cannot be retrieved without a customer ID or " . - "an account ID. Retrieve a bank account using " . + $msg = 'Bank accounts cannot be retrieved without a customer ID or ' . + 'an account ID. Retrieve a bank account using ' . "`Customer::retrieveSource('customer_id', " . "'bank_account_id')` or `Account::retrieveExternalAccount(" . "'account_id', 'bank_account_id')`."; + throw new Exception\BadMethodCallException($msg, null); } /** * @param string $_id - * @param array|null $_params - * @param array|string|null $_options + * @param null|array $_params + * @param null|array|string $_options * * @throws \Stripe\Exception\BadMethodCallException */ public static function update($_id, $_params = null, $_options = null) { - $msg = "Bank accounts cannot be updated without a customer ID or an " . - "account ID. Update a bank account using " . + $msg = 'Bank accounts cannot be updated without a customer ID or an ' . + 'account ID. Update a bank account using ' . "`Customer::updateSource('customer_id', 'bank_account_id', " . - "\$updateParams)` or `Account::updateExternalAccount(" . + '$updateParams)` or `Account::updateExternalAccount(' . "'account_id', 'bank_account_id', \$updateParams)`."; + throw new Exception\BadMethodCallException($msg, null); } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return BankAccount The verified bank account. + * @return BankAccount the verified bank account */ public function verify($params = null, $opts = null) { $url = $this->instanceUrl() . '/verify'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/BitcoinReceiver.php b/lib/BitcoinReceiver.php index 7e8885fcc..155d42057 100644 --- a/lib/BitcoinReceiver.php +++ b/lib/BitcoinReceiver.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class BitcoinReceiver + * Class BitcoinReceiver. * * @deprecated Bitcoin receivers are deprecated. Please use the sources API instead. * @see https://stripe.com/docs/sources/bitcoin @@ -18,20 +18,18 @@ * @property string $bitcoin_uri This URI can be displayed to the customer as a clickable link (to activate their bitcoin client) or as a QR code (for mobile wallets). * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO code for the currency to which the bitcoin will be converted. - * @property string|null $customer The customer ID of the bitcoin receiver. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property string|null $email The customer's email address, set by the API call that creates the receiver. + * @property null|string $customer The customer ID of the bitcoin receiver. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string $email The customer's email address, set by the API call that creates the receiver. * @property bool $filled This flag is initially false and updates to true when the customer sends the bitcoin_amount to this receiver. * @property string $inbound_address A bitcoin address that is specific to this receiver. The customer can send bitcoin to this address to fill the receiver. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $payment The ID of the payment created from the receiver, if any. Hidden when viewing the receiver with a publishable key. - * @property string|null $refund_address The refund address of this bitcoin receiver. + * @property null|string $payment The ID of the payment created from the receiver, if any. Hidden when viewing the receiver with a publishable key. + * @property null|string $refund_address The refund address of this bitcoin receiver. * @property \Stripe\Collection $transactions A list with one entry for each time that the customer sent bitcoin to the receiver. Hidden when viewing the receiver with a publishable key. * @property bool $uncaptured_funds This receiver contains uncaptured funds that can be used for a payment or refunded. - * @property bool|null $used_for_payment Indicate if this source is used for payment. - * - * @package Stripe + * @property null|bool $used_for_payment Indicate if this source is used for payment. */ class BitcoinReceiver extends ApiResource { @@ -46,7 +44,7 @@ class BitcoinReceiver extends ApiResource */ public static function classUrl() { - return "/v1/bitcoin/receivers"; + return '/v1/bitcoin/receivers'; } /** @@ -61,10 +59,13 @@ public function instanceUrl() $path = 'sources'; $parentExtn = \urlencode(Util\Util::utf8($parent)); $extn = \urlencode(Util\Util::utf8($this['id'])); + return "{$base}/{$parentExtn}/{$path}/{$extn}"; } + $base = BitcoinReceiver::classUrl(); $extn = \urlencode(Util\Util::utf8($this['id'])); + return "{$base}/{$extn}"; } } diff --git a/lib/BitcoinTransaction.php b/lib/BitcoinTransaction.php index 72aaeb372..1e96c680c 100644 --- a/lib/BitcoinTransaction.php +++ b/lib/BitcoinTransaction.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class BitcoinTransaction - * - * @package Stripe + * Class BitcoinTransaction. */ class BitcoinTransaction extends ApiResource { diff --git a/lib/Capability.php b/lib/Capability.php index 6e9936a9a..8985d23a6 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class Capability - * - * @package Stripe + * Class Capability. * * @property string $id * @property string $object @@ -26,13 +24,13 @@ class Capability extends ApiResource * * @see https://stripe.com/docs/api/capabilities/object#capability_object-status */ - const STATUS_ACTIVE = 'active'; - const STATUS_INACTIVE = 'inactive'; - const STATUS_PENDING = 'pending'; + const STATUS_ACTIVE = 'active'; + const STATUS_INACTIVE = 'inactive'; + const STATUS_PENDING = 'pending'; const STATUS_UNREQUESTED = 'unrequested'; /** - * @return string The API URL for this Stripe account reversal. + * @return string the API URL for this Stripe account reversal */ public function instanceUrl() { @@ -40,7 +38,7 @@ public function instanceUrl() $account = $this['account']; if (!$id) { throw new Exception\UnexpectedValueException( - "Could not determine which URL to request: " . + 'Could not determine which URL to request: ' . "class instance has invalid ID: {$id}", null ); @@ -51,35 +49,38 @@ public function instanceUrl() $base = Account::classUrl(); $accountExtn = \urlencode($account); $extn = \urlencode($id); + return "{$base}/{$accountExtn}/capabilities/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException */ public static function retrieve($_id, $_opts = null) { - $msg = "Capabilities cannot be retrieved without an account ID. " . - "Retrieve a capability using `Account::retrieveCapability(" . + $msg = 'Capabilities cannot be retrieved without an account ID. ' . + 'Retrieve a capability using `Account::retrieveCapability(' . "'account_id', 'capability_id')`."; + throw new Exception\BadMethodCallException($msg, null); } /** * @param string $_id - * @param array|null $_params - * @param array|string|null $_options + * @param null|array $_params + * @param null|array|string $_options * * @throws \Stripe\Exception\BadMethodCallException */ public static function update($_id, $_params = null, $_options = null) { - $msg = "Capabilities cannot be updated without an account ID. " . - "Update a capability using `Account::updateCapability(" . + $msg = 'Capabilities cannot be updated without an account ID. ' . + 'Update a capability using `Account::updateCapability(' . "'account_id', 'capability_id', \$updateParams)`."; + throw new Exception\BadMethodCallException($msg, null); } } diff --git a/lib/Card.php b/lib/Card.php index b66563706..6e27276eb 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -3,38 +3,36 @@ namespace Stripe; /** - * Class Card + * Class Card. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|\Stripe\Account|null $account The account this card belongs to. This attribute will not be in the card object if the card belongs to a customer or recipient instead. - * @property string|null $address_city City/District/Suburb/Town/Village. - * @property string|null $address_country Billing address country, if provided when creating card. - * @property string|null $address_line1 Address line 1 (Street address/PO Box/Company name). - * @property string|null $address_line1_check If address_line1 was provided, results of the check: pass, fail, unavailable, or unchecked. - * @property string|null $address_line2 Address line 2 (Apartment/Suite/Unit/Building). - * @property string|null $address_state State/County/Province/Region. - * @property string|null $address_zip ZIP or postal code. - * @property string|null $address_zip_check If address_zip was provided, results of the check: pass, fail, unavailable, or unchecked. - * @property string[]|null $available_payout_methods A set of available payout methods for this card. Will be either ["standard"] or ["standard", "instant"]. Only values from this set should be passed as the method when creating a transfer. + * @property null|string|\Stripe\Account $account The account this card belongs to. This attribute will not be in the card object if the card belongs to a customer or recipient instead. + * @property null|string $address_city City/District/Suburb/Town/Village. + * @property null|string $address_country Billing address country, if provided when creating card. + * @property null|string $address_line1 Address line 1 (Street address/PO Box/Company name). + * @property null|string $address_line1_check If address_line1 was provided, results of the check: pass, fail, unavailable, or unchecked. + * @property null|string $address_line2 Address line 2 (Apartment/Suite/Unit/Building). + * @property null|string $address_state State/County/Province/Region. + * @property null|string $address_zip ZIP or postal code. + * @property null|string $address_zip_check If address_zip was provided, results of the check: pass, fail, unavailable, or unchecked. + * @property null|string[] $available_payout_methods A set of available payout methods for this card. Will be either ["standard"] or ["standard", "instant"]. Only values from this set should be passed as the method when creating a transfer. * @property string $brand Card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown. - * @property string|null $country Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you've collected. - * @property string|null $currency - * @property string|\Stripe\Customer|null $customer The customer that this card belongs to. This attribute will not be in the card object if the card belongs to an account or recipient instead. - * @property string|null $cvc_check If a CVC was provided, results of the check: pass, fail, unavailable, or unchecked. - * @property bool|null $default_for_currency Whether this card is the default external account for its currency. - * @property string|null $dynamic_last4 (For tokenized numbers only.) The last four digits of the device account number. + * @property null|string $country Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you've collected. + * @property null|string $currency + * @property null|string|\Stripe\Customer $customer The customer that this card belongs to. This attribute will not be in the card object if the card belongs to an account or recipient instead. + * @property null|string $cvc_check If a CVC was provided, results of the check: pass, fail, unavailable, or unchecked. + * @property null|bool $default_for_currency Whether this card is the default external account for its currency. + * @property null|string $dynamic_last4 (For tokenized numbers only.) The last four digits of the device account number. * @property int $exp_month Two-digit number representing the card's expiration month. * @property int $exp_year Four-digit number representing the card's expiration year. - * @property string|null $fingerprint Uniquely identifies this particular card number. You can use this attribute to check whether two customers who've signed up with you are using the same card number, for example. + * @property null|string $fingerprint Uniquely identifies this particular card number. You can use this attribute to check whether two customers who've signed up with you are using the same card number, for example. * @property string $funding Card funding type. Can be credit, debit, prepaid, or unknown. * @property string $last4 The last four digits of the card. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $name Cardholder name. - * @property string|\Stripe\Recipient|null $recipient The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead. - * @property string|null $tokenization_method If the card number is tokenized, this is the method that was used. Can be amex_express_checkout, android_pay (includes Google Pay), apple_pay, masterpass, visa_checkout, or null. - * - * @package Stripe + * @property null|string $name Cardholder name. + * @property null|string|\Stripe\Recipient $recipient The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead. + * @property null|string $tokenization_method If the card number is tokenized, this is the method that was used. Can be amex_express_checkout, android_pay (includes Google Pay), apple_pay, masterpass, visa_checkout, or null. */ class Card extends ApiResource { @@ -48,18 +46,18 @@ class Card extends ApiResource * * @see https://stripe.com/docs/api/cards/object#card_object-cvc_check */ - const CVC_CHECK_FAIL = 'fail'; - const CVC_CHECK_PASS = 'pass'; + const CVC_CHECK_FAIL = 'fail'; + const CVC_CHECK_PASS = 'pass'; const CVC_CHECK_UNAVAILABLE = 'unavailable'; - const CVC_CHECK_UNCHECKED = 'unchecked'; + const CVC_CHECK_UNCHECKED = 'unchecked'; /** * Possible string representations of the funding of the card. * * @see https://stripe.com/docs/api/cards/object#card_object-funding */ - const FUNDING_CREDIT = 'credit'; - const FUNDING_DEBIT = 'debit'; + const FUNDING_CREDIT = 'credit'; + const FUNDING_DEBIT = 'debit'; const FUNDING_PREPAID = 'prepaid'; const FUNDING_UNKNOWN = 'unknown'; @@ -68,7 +66,7 @@ class Card extends ApiResource * * @see https://stripe.com/docs/api/cards/object#card_object-tokenization_method */ - const TOKENIZATION_METHOD_APPLE_PAY = 'apple_pay'; + const TOKENIZATION_METHOD_APPLE_PAY = 'apple_pay'; const TOKENIZATION_METHOD_GOOGLE_PAY = 'google_pay'; /** @@ -91,43 +89,47 @@ public function instanceUrl() $parent = $this['recipient']; $path = 'cards'; } else { - $msg = "Cards cannot be accessed without a customer ID, account ID or recipient ID."; + $msg = 'Cards cannot be accessed without a customer ID, account ID or recipient ID.'; + throw new Exception\UnexpectedValueException($msg); } $parentExtn = \urlencode(Util\Util::utf8($parent)); $extn = \urlencode(Util\Util::utf8($this['id'])); + return "{$base}/{$parentExtn}/{$path}/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException */ public static function retrieve($_id, $_opts = null) { - $msg = "Cards cannot be retrieved without a customer ID or an " . - "account ID. Retrieve a card using " . + $msg = 'Cards cannot be retrieved without a customer ID or an ' . + 'account ID. Retrieve a card using ' . "`Customer::retrieveSource('customer_id', 'card_id')` or " . "`Account::retrieveExternalAccount('account_id', 'card_id')`."; + throw new Exception\BadMethodCallException($msg); } /** * @param string $_id - * @param array|null $_params - * @param array|string|null $_options + * @param null|array $_params + * @param null|array|string $_options * * @throws \Stripe\Exception\BadMethodCallException */ public static function update($_id, $_params = null, $_options = null) { - $msg = "Cards cannot be updated without a customer ID or an " . - "account ID. Update a card using " . + $msg = 'Cards cannot be updated without a customer ID or an ' . + 'account ID. Update a card using ' . "`Customer::updateSource('customer_id', 'card_id', " . - "\$updateParams)` or `Account::updateExternalAccount(" . + '$updateParams)` or `Account::updateExternalAccount(' . "'account_id', 'card_id', \$updateParams)`."; + throw new Exception\BadMethodCallException($msg); } } diff --git a/lib/Charge.php b/lib/Charge.php index 468a3ca1a..136a88ba4 100644 --- a/lib/Charge.php +++ b/lib/Charge.php @@ -3,55 +3,53 @@ namespace Stripe; /** - * Class Charge + * Class Charge. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). * @property int $amount_refunded Amount in %s refunded (can be less than the amount attribute on the charge if a partial refund was issued). - * @property string|\Stripe\StripeObject|null $application ID of the Connect application that created the charge. - * @property string|\Stripe\ApplicationFee|null $application_fee The application fee (if any) for the charge. See the Connect documentation for details. - * @property int|null $application_fee_amount The amount of the application fee (if any) for the charge. See the Connect documentation for details. - * @property string|\Stripe\BalanceTransaction|null $balance_transaction ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes). + * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the charge. + * @property null|string|\Stripe\ApplicationFee $application_fee The application fee (if any) for the charge. See the Connect documentation for details. + * @property null|int $application_fee_amount The amount of the application fee (if any) for the charge. See the Connect documentation for details. + * @property null|string|\Stripe\BalanceTransaction $balance_transaction ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes). * @property \Stripe\StripeObject $billing_details * @property bool $captured If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|\Stripe\Customer|null $customer ID of the customer this charge is for if one exists. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property string|\Stripe\Account|null $destination ID of an existing, connected Stripe account to transfer funds to if transfer_data was specified in the charge request. - * @property string|\Stripe\Dispute|null $dispute Details about the dispute if the charge has been disputed. + * @property null|string|\Stripe\Customer $customer ID of the customer this charge is for if one exists. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string|\Stripe\Account $destination ID of an existing, connected Stripe account to transfer funds to if transfer_data was specified in the charge request. + * @property null|string|\Stripe\Dispute $dispute Details about the dispute if the charge has been disputed. * @property bool $disputed Whether the charge has been disputed. - * @property string|null $failure_code Error code explaining reason for charge failure if available (see the errors section for a list of codes). - * @property string|null $failure_message Message to user further explaining reason for charge failure if available. - * @property \Stripe\StripeObject|null $fraud_details Information on fraud assessments for the charge. - * @property string|\Stripe\Invoice|null $invoice ID of the invoice this charge is for if one exists. + * @property null|string $failure_code Error code explaining reason for charge failure if available (see the errors section for a list of codes). + * @property null|string $failure_message Message to user further explaining reason for charge failure if available. + * @property null|\Stripe\StripeObject $fraud_details Information on fraud assessments for the charge. + * @property null|string|\Stripe\Invoice $invoice ID of the invoice this charge is for if one exists. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|\Stripe\Account|null $on_behalf_of The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the Connect documentation for details. - * @property string|\Stripe\Order|null $order ID of the order this charge is for if one exists. - * @property \Stripe\StripeObject|null $outcome Details about whether the payment was accepted, and why. See understanding declines for details. + * @property null|string|\Stripe\Account $on_behalf_of The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the Connect documentation for details. + * @property null|string|\Stripe\Order $order ID of the order this charge is for if one exists. + * @property null|\Stripe\StripeObject $outcome Details about whether the payment was accepted, and why. See understanding declines for details. * @property bool $paid true if the charge succeeded, or was successfully authorized for later capture. - * @property string|null $payment_intent ID of the PaymentIntent associated with this charge, if one exists. - * @property string|null $payment_method ID of the payment method used in this charge. - * @property \Stripe\StripeObject|null $payment_method_details Details about the payment method at the time of the transaction. - * @property string|null $receipt_email This is the email address that the receipt for this charge was sent to. - * @property string|null $receipt_number This is the transaction number that appears on email receipts sent for this charge. This attribute will be null until a receipt has been sent. + * @property null|string $payment_intent ID of the PaymentIntent associated with this charge, if one exists. + * @property null|string $payment_method ID of the payment method used in this charge. + * @property null|\Stripe\StripeObject $payment_method_details Details about the payment method at the time of the transaction. + * @property null|string $receipt_email This is the email address that the receipt for this charge was sent to. + * @property null|string $receipt_number This is the transaction number that appears on email receipts sent for this charge. This attribute will be null until a receipt has been sent. * @property string $receipt_url This is the URL to view the receipt for this charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds. If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt. * @property bool $refunded Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false. * @property \Stripe\Collection $refunds A list of refunds that have been applied to the charge. - * @property string|\Stripe\Review|null $review ID of the review associated with this charge if one exists. - * @property \Stripe\StripeObject|null $shipping Shipping information for the charge. - * @property \Stripe\StripeObject|null $source This is a legacy field that will be removed in the future. It contains the Source, Card, or BankAccount object used for the charge. For details about the payment method used for this charge, refer to payment_method or payment_method_details instead. - * @property string|\Stripe\Transfer|null $source_transfer The transfer ID which created this charge. Only present if the charge came from another Stripe account. See the Connect documentation for details. - * @property string|null $statement_descriptor For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters. - * @property string|null $statement_descriptor_suffix Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. + * @property null|string|\Stripe\Review $review ID of the review associated with this charge if one exists. + * @property null|\Stripe\StripeObject $shipping Shipping information for the charge. + * @property null|\Stripe\StripeObject $source This is a legacy field that will be removed in the future. It contains the Source, Card, or BankAccount object used for the charge. For details about the payment method used for this charge, refer to payment_method or payment_method_details instead. + * @property null|string|\Stripe\Transfer $source_transfer The transfer ID which created this charge. Only present if the charge came from another Stripe account. See the Connect documentation for details. + * @property null|string $statement_descriptor For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters. + * @property null|string $statement_descriptor_suffix Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. * @property string $status The status of the payment is either succeeded, pending, or failed. * @property string|\Stripe\Transfer $transfer ID of the transfer to the destination account (only applicable if the charge was created using the destination parameter). - * @property \Stripe\StripeObject|null $transfer_data An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details. - * @property string|null $transfer_group A string that identifies this transaction as part of a group. See the Connect documentation for details. - * - * @package Stripe + * @property null|\Stripe\StripeObject $transfer_data An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details. + * @property null|string $transfer_group A string that identifies this transaction as part of a group. See the Connect documentation for details. */ class Charge extends ApiResource { @@ -68,75 +66,76 @@ class Charge extends ApiResource * * @see https://stripe.com/docs/declines/codes */ - const DECLINED_AUTHENTICATION_REQUIRED = 'authentication_required'; - const DECLINED_APPROVE_WITH_ID = 'approve_with_id'; - const DECLINED_CALL_ISSUER = 'call_issuer'; - const DECLINED_CARD_NOT_SUPPORTED = 'card_not_supported'; - const DECLINED_CARD_VELOCITY_EXCEEDED = 'card_velocity_exceeded'; - const DECLINED_CURRENCY_NOT_SUPPORTED = 'currency_not_supported'; - const DECLINED_DO_NOT_HONOR = 'do_not_honor'; - const DECLINED_DO_NOT_TRY_AGAIN = 'do_not_try_again'; - const DECLINED_DUPLICATED_TRANSACTION = 'duplicate_transaction'; - const DECLINED_EXPIRED_CARD = 'expired_card'; - const DECLINED_FRAUDULENT = 'fraudulent'; - const DECLINED_GENERIC_DECLINE = 'generic_decline'; - const DECLINED_INCORRECT_NUMBER = 'incorrect_number'; - const DECLINED_INCORRECT_CVC = 'incorrect_cvc'; - const DECLINED_INCORRECT_PIN = 'incorrect_pin'; - const DECLINED_INCORRECT_ZIP = 'incorrect_zip'; - const DECLINED_INSUFFICIENT_FUNDS = 'insufficient_funds'; - const DECLINED_INVALID_ACCOUNT = 'invalid_account'; - const DECLINED_INVALID_AMOUNT = 'invalid_amount'; - const DECLINED_INVALID_CVC = 'invalid_cvc'; - const DECLINED_INVALID_EXPIRY_YEAR = 'invalid_expiry_year'; - const DECLINED_INVALID_NUMBER = 'invalid_number'; - const DECLINED_INVALID_PIN = 'invalid_pin'; - const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available'; - const DECLINED_LOST_CARD = 'lost_card'; - const DECLINED_MERCHANT_BLACKLIST = 'merchant_blacklist'; + const DECLINED_AUTHENTICATION_REQUIRED = 'authentication_required'; + const DECLINED_APPROVE_WITH_ID = 'approve_with_id'; + const DECLINED_CALL_ISSUER = 'call_issuer'; + const DECLINED_CARD_NOT_SUPPORTED = 'card_not_supported'; + const DECLINED_CARD_VELOCITY_EXCEEDED = 'card_velocity_exceeded'; + const DECLINED_CURRENCY_NOT_SUPPORTED = 'currency_not_supported'; + const DECLINED_DO_NOT_HONOR = 'do_not_honor'; + const DECLINED_DO_NOT_TRY_AGAIN = 'do_not_try_again'; + const DECLINED_DUPLICATED_TRANSACTION = 'duplicate_transaction'; + const DECLINED_EXPIRED_CARD = 'expired_card'; + const DECLINED_FRAUDULENT = 'fraudulent'; + const DECLINED_GENERIC_DECLINE = 'generic_decline'; + const DECLINED_INCORRECT_NUMBER = 'incorrect_number'; + const DECLINED_INCORRECT_CVC = 'incorrect_cvc'; + const DECLINED_INCORRECT_PIN = 'incorrect_pin'; + const DECLINED_INCORRECT_ZIP = 'incorrect_zip'; + const DECLINED_INSUFFICIENT_FUNDS = 'insufficient_funds'; + const DECLINED_INVALID_ACCOUNT = 'invalid_account'; + const DECLINED_INVALID_AMOUNT = 'invalid_amount'; + const DECLINED_INVALID_CVC = 'invalid_cvc'; + const DECLINED_INVALID_EXPIRY_YEAR = 'invalid_expiry_year'; + const DECLINED_INVALID_NUMBER = 'invalid_number'; + const DECLINED_INVALID_PIN = 'invalid_pin'; + const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available'; + const DECLINED_LOST_CARD = 'lost_card'; + const DECLINED_MERCHANT_BLACKLIST = 'merchant_blacklist'; const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available'; - const DECLINED_NO_ACTION_TAKEN = 'no_action_taken'; - const DECLINED_NOT_PERMITTED = 'not_permitted'; - const DECLINED_OFFLINE_PIN_REQUIRED = 'offline_pin_required'; - const DECLINED_ONLINE_OR_OFFLINE_PIN_REQUIRED = 'online_or_offline_pin_required'; - const DECLINED_PICKUP_CARD = 'pickup_card'; - const DECLINED_PIN_TRY_EXCEEDED = 'pin_try_exceeded'; - const DECLINED_PROCESSING_ERROR = 'processing_error'; - const DECLINED_REENTER_TRANSACTION = 'reenter_transaction'; - const DECLINED_RESTRICTED_CARD = 'restricted_card'; - const DECLINED_REVOCATION_OF_ALL_AUTHORIZATIONS = 'revocation_of_all_authorizations'; - const DECLINED_REVOCATION_OF_AUTHORIZATION = 'revocation_of_authorization'; - const DECLINED_SECURITY_VIOLATION = 'security_violation'; - const DECLINED_SERVICE_NOT_ALLOWED = 'service_not_allowed'; - const DECLINED_STOLEN_CARD = 'stolen_card'; - const DECLINED_STOP_PAYMENT_ORDER = 'stop_payment_order'; - const DECLINED_TESTMODE_DECLINE = 'testmode_decline'; - const DECLINED_TRANSACTION_NOT_ALLOWED = 'transaction_not_allowed'; - const DECLINED_TRY_AGAIN_LATER = 'try_again_later'; - const DECLINED_WITHDRAWAL_COUNT_LIMIT_EXCEEDED = 'withdrawal_count_limit_exceeded'; + const DECLINED_NO_ACTION_TAKEN = 'no_action_taken'; + const DECLINED_NOT_PERMITTED = 'not_permitted'; + const DECLINED_OFFLINE_PIN_REQUIRED = 'offline_pin_required'; + const DECLINED_ONLINE_OR_OFFLINE_PIN_REQUIRED = 'online_or_offline_pin_required'; + const DECLINED_PICKUP_CARD = 'pickup_card'; + const DECLINED_PIN_TRY_EXCEEDED = 'pin_try_exceeded'; + const DECLINED_PROCESSING_ERROR = 'processing_error'; + const DECLINED_REENTER_TRANSACTION = 'reenter_transaction'; + const DECLINED_RESTRICTED_CARD = 'restricted_card'; + const DECLINED_REVOCATION_OF_ALL_AUTHORIZATIONS = 'revocation_of_all_authorizations'; + const DECLINED_REVOCATION_OF_AUTHORIZATION = 'revocation_of_authorization'; + const DECLINED_SECURITY_VIOLATION = 'security_violation'; + const DECLINED_SERVICE_NOT_ALLOWED = 'service_not_allowed'; + const DECLINED_STOLEN_CARD = 'stolen_card'; + const DECLINED_STOP_PAYMENT_ORDER = 'stop_payment_order'; + const DECLINED_TESTMODE_DECLINE = 'testmode_decline'; + const DECLINED_TRANSACTION_NOT_ALLOWED = 'transaction_not_allowed'; + const DECLINED_TRY_AGAIN_LATER = 'try_again_later'; + const DECLINED_WITHDRAWAL_COUNT_LIMIT_EXCEEDED = 'withdrawal_count_limit_exceeded'; /** * Possible string representations of the status of the charge. * * @see https://stripe.com/docs/api/charges/object#charge_object-status */ - const STATUS_FAILED = 'failed'; - const STATUS_PENDING = 'pending'; + const STATUS_FAILED = 'failed'; + const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Charge The captured charge. + * @return Charge the captured charge */ public function capture($params = null, $opts = null) { $url = $this->instanceUrl() . '/capture'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/Checkout/Session.php b/lib/Checkout/Session.php index 1a4e6fd78..169b958ff 100644 --- a/lib/Checkout/Session.php +++ b/lib/Checkout/Session.php @@ -3,28 +3,26 @@ namespace Stripe\Checkout; /** - * Class Session + * Class Session. * * @property string $id Unique identifier for the object. Used to pass to redirectToCheckout in Stripe.js. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|null $billing_address_collection The value (auto or required) for whether Checkout collected the customer's billing address. + * @property null|string $billing_address_collection The value (auto or required) for whether Checkout collected the customer's billing address. * @property string $cancel_url The URL the customer will be directed to if they decide to cancel payment and return to your website. - * @property string|null $client_reference_id A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems. - * @property string|\Stripe\Customer|null $customer The ID of the customer for this session. For Checkout Sessions in payment or subscription mode, Checkout will create a new customer object based on information provided during the session unless an existing customer was provided when the session was created. - * @property string|null $customer_email If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the customer field. - * @property \Stripe\StripeObject[]|null $display_items The line items, plans, or SKUs purchased by the customer. + * @property null|string $client_reference_id A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems. + * @property null|string|\Stripe\Customer $customer The ID of the customer for this session. For Checkout Sessions in payment or subscription mode, Checkout will create a new customer object based on information provided during the session unless an existing customer was provided when the session was created. + * @property null|string $customer_email If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the customer field. + * @property null|\Stripe\StripeObject[] $display_items The line items, plans, or SKUs purchased by the customer. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|null $locale The IETF language tag of the locale Checkout is displayed in. If blank or auto, the browser's locale is used. - * @property \Stripe\StripeObject|null $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $mode The mode of the Checkout Session, one of payment, setup, or subscription. - * @property string|\Stripe\PaymentIntent|null $payment_intent The ID of the PaymentIntent for Checkout Sessions in payment mode. + * @property null|string $locale The IETF language tag of the locale Checkout is displayed in. If blank or auto, the browser's locale is used. + * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + * @property null|string $mode The mode of the Checkout Session, one of payment, setup, or subscription. + * @property null|string|\Stripe\PaymentIntent $payment_intent The ID of the PaymentIntent for Checkout Sessions in payment mode. * @property string[] $payment_method_types A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept. - * @property string|\Stripe\SetupIntent|null $setup_intent The ID of the SetupIntent for Checkout Sessions in setup mode. - * @property string|null $submit_type Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. submit_type can only be specified on Checkout Sessions in payment mode, but not Checkout Sessions in subscription or setup mode. - * @property string|\Stripe\Subscription|null $subscription The ID of the subscription for Checkout Sessions in subscription mode. + * @property null|string|\Stripe\SetupIntent $setup_intent The ID of the SetupIntent for Checkout Sessions in setup mode. + * @property null|string $submit_type Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. submit_type can only be specified on Checkout Sessions in payment mode, but not Checkout Sessions in subscription or setup mode. + * @property null|string|\Stripe\Subscription $subscription The ID of the subscription for Checkout Sessions in subscription mode. * @property string $success_url The URL the customer will be directed to after the payment or subscription creation is successful. - * - * @package Stripe\Checkout */ class Session extends \Stripe\ApiResource { @@ -38,8 +36,8 @@ class Session extends \Stripe\ApiResource * * @see https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-submit_type */ - const SUBMIT_TYPE_AUTO = 'auto'; - const SUBMIT_TYPE_BOOK = 'book'; - const SUBMIT_TYPE_DONATE = 'donate'; - const SUBMIT_TYPE_PAY = 'pay'; + const SUBMIT_TYPE_AUTO = 'auto'; + const SUBMIT_TYPE_BOOK = 'book'; + const SUBMIT_TYPE_DONATE = 'donate'; + const SUBMIT_TYPE_PAY = 'pay'; } diff --git a/lib/Collection.php b/lib/Collection.php index 6e232e008..96cf6cbc1 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -3,14 +3,12 @@ namespace Stripe; /** - * Class Collection + * Class Collection. * * @property string $object * @property string $url * @property bool $has_more * @property \Stripe\StripeObject[] $data - * - * @package Stripe */ class Collection extends StripeObject implements \IteratorAggregate { @@ -22,7 +20,7 @@ class Collection extends StripeObject implements \IteratorAggregate protected $filters = []; /** - * @return string The base URL for the given class. + * @return string the base URL for the given class */ public static function baseUrl() { @@ -32,7 +30,7 @@ public static function baseUrl() /** * Returns the filters. * - * @return array The filters. + * @return array the filters */ public function getFilters() { @@ -42,7 +40,7 @@ public function getFilters() /** * Sets the filters, removing paging options. * - * @param array $filters The filters. + * @param array $filters the filters */ public function setFilters($filters) { @@ -55,9 +53,10 @@ public function offsetGet($k) return parent::offsetGet($k); } $msg = "You tried to access the {$k} index, but Collection " . - "types only support string keys. (HINT: List calls " . - "return an object with a `data` (which is the data " . + 'types only support string keys. (HINT: List calls ' . + 'return an object with a `data` (which is the data ' . "array). You likely want to call ->data[{$k}])"; + throw new Exception\InvalidArgumentException($msg); } @@ -74,6 +73,7 @@ public function all($params = null, $opts = null) ); } $obj->setFilters($params); + return $obj; } @@ -83,6 +83,7 @@ public function create($params = null, $opts = null) list($url, $params) = $this->extractPathAndUpdateParams($params); list($response, $opts) = $this->_request('post', $url, $params, $opts); + return Util\Util::convertToStripeObject($response, $opts); } @@ -99,12 +100,13 @@ public function retrieve($id, $params = null, $opts = null) $params, $opts ); + return Util\Util::convertToStripeObject($response, $opts); } /** - * @return \ArrayIterator An iterator that can be used to iterate - * across objects in the current page. + * @return \ArrayIterator an iterator that can be used to iterate + * across objects in the current page */ public function getIterator() { @@ -112,8 +114,8 @@ public function getIterator() } /** - * @return \ArrayIterator An iterator that can be used to iterate - * backwards across objects in the current page. + * @return \ArrayIterator an iterator that can be used to iterate + * backwards across objects in the current page */ public function getReverseIterator() { @@ -156,7 +158,7 @@ public function autoPagingIterator() * when we know that there isn't a next page in order to replicate the * behavior of the API when it attempts to return a page beyond the last. * - * @param array|string|null $opts + * @param null|array|string $opts * * @return Collection */ @@ -181,8 +183,8 @@ public function isEmpty() * This method will try to respect the limit of the current page. If none * was given, the default limit will be fetched again. * - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @return Collection */ @@ -209,8 +211,8 @@ public function nextPage($params = null, $opts = null) * This method will try to respect the limit of the current page. If none * was given, the default limit will be fetched again. * - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @return Collection */ diff --git a/lib/CountrySpec.php b/lib/CountrySpec.php index ba6400d6b..ea0eb342e 100644 --- a/lib/CountrySpec.php +++ b/lib/CountrySpec.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class CountrySpec + * Class CountrySpec. * * @property string $id Unique identifier for the object. Represented as the ISO country code for this country. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -13,8 +13,6 @@ * @property string[] $supported_payment_methods Payment methods available in the specified country. You may need to enable some payment methods (e.g., ACH) on your account before they appear in this list. The stripe payment method refers to charging through your platform. * @property string[] $supported_transfer_countries Countries that can accept transfers from the specified country. * @property \Stripe\StripeObject $verification_fields - * - * @package Stripe */ class CountrySpec extends ApiResource { diff --git a/lib/Coupon.php b/lib/Coupon.php index a02726220..ea3b8c073 100644 --- a/lib/Coupon.php +++ b/lib/Coupon.php @@ -3,25 +3,23 @@ namespace Stripe; /** - * Class Coupon + * Class Coupon. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property int|null $amount_off Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. + * @property null|int $amount_off Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $currency If amount_off has been set, the three-letter ISO code for the currency of the amount to take off. + * @property null|string $currency If amount_off has been set, the three-letter ISO code for the currency of the amount to take off. * @property string $duration One of forever, once, and repeating. Describes how long a customer who applies this coupon will get the discount. - * @property int|null $duration_in_months If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. + * @property null|int $duration_in_months If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property int|null $max_redemptions Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. + * @property null|int $max_redemptions Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $name Name of the coupon displayed to customers on for instance invoices or receipts. - * @property float|null $percent_off Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a %s100 invoice %s50 instead. - * @property int|null $redeem_by Date after which the coupon can no longer be redeemed. + * @property null|string $name Name of the coupon displayed to customers on for instance invoices or receipts. + * @property null|float $percent_off Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a %s100 invoice %s50 instead. + * @property null|int $redeem_by Date after which the coupon can no longer be redeemed. * @property int $times_redeemed Number of times this coupon has been applied to a customer. * @property bool $valid Taking account of the above properties, whether this coupon can still be applied to a customer. - * - * @package Stripe */ class Coupon extends ApiResource { diff --git a/lib/CreditNote.php b/lib/CreditNote.php index 5f48275d7..5c64cb161 100644 --- a/lib/CreditNote.php +++ b/lib/CreditNote.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class CreditNote + * Class CreditNote. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,26 +11,24 @@ * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property string|\Stripe\Customer $customer ID of the customer. - * @property string|\Stripe\CustomerBalanceTransaction|null $customer_balance_transaction Customer balance transaction related to this credit note. + * @property null|string|\Stripe\CustomerBalanceTransaction $customer_balance_transaction Customer balance transaction related to this credit note. * @property int $discount_amount The integer amount in %s representing the amount of the discount that was credited. * @property string|\Stripe\Invoice $invoice ID of the invoice. * @property \Stripe\Collection $lines Line items that make up the credit note * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|null $memo Customer-facing text that appears on the credit note PDF. + * @property null|string $memo Customer-facing text that appears on the credit note PDF. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $number A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice. - * @property int|null $out_of_band_amount Amount that was credited outside of Stripe. + * @property null|int $out_of_band_amount Amount that was credited outside of Stripe. * @property string $pdf The link to download the PDF of the credit note. - * @property string|null $reason Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactory - * @property string|\Stripe\Refund|null $refund Refund related to this credit note. + * @property null|string $reason Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactory + * @property null|string|\Stripe\Refund $refund Refund related to this credit note. * @property string $status Status of this credit note, one of issued or void. Learn more about voiding credit notes. * @property int $subtotal The integer amount in %s representing the amount of the credit note, excluding tax and discount. * @property \Stripe\StripeObject[] $tax_amounts The aggregate amounts calculated per tax rate for all line items. * @property int $total The integer amount in %s representing the total amount of the credit note, including tax and discount. * @property string $type Type of this credit note, one of pre_payment or post_payment. A pre_payment credit note means it was issued when the invoice was open. A post_payment credit note means it was issued when the invoice was paid. - * @property int|null $voided_at The time that the credit note was voided. - * - * @package Stripe + * @property null|int $voided_at The time that the credit note was voided. */ class CreditNote extends ApiResource { @@ -47,9 +45,9 @@ class CreditNote extends ApiResource * * @see https://stripe.com/docs/api/credit_notes/object#credit_note_object-reason */ - const REASON_DUPLICATE = 'duplicate'; - const REASON_FRAUDULENT = 'fraudulent'; - const REASON_ORDER_CHANGE = 'order_change'; + const REASON_DUPLICATE = 'duplicate'; + const REASON_FRAUDULENT = 'fraudulent'; + const REASON_ORDER_CHANGE = 'order_change'; const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory'; /** @@ -58,7 +56,7 @@ class CreditNote extends ApiResource * @see https://stripe.com/docs/api/credit_notes/object#credit_note_object-status */ const STATUS_ISSUED = 'issued'; - const STATUS_VOID = 'void'; + const STATUS_VOID = 'void'; /** * Possible string representations of the credit note type. @@ -66,15 +64,15 @@ class CreditNote extends ApiResource * @see https://stripe.com/docs/api/credit_notes/object#credit_note_object-status */ const TYPE_POST_PAYMENT = 'post_payment'; - const TYPE_PRE_PAYMENT = 'pre_payment'; + const TYPE_PRE_PAYMENT = 'pre_payment'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\CreditNote The previewed credit note. + * @return \Stripe\CreditNote the previewed credit note */ public static function preview($params = null, $opts = null) { @@ -82,35 +80,37 @@ public static function preview($params = null, $opts = null) list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); $obj = Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); + return $obj; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return CreditNote The voided credit note. + * @return CreditNote the voided credit note */ public function voidCreditNote($params = null, $opts = null) { $url = $this->instanceUrl() . '/void'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } const PATH_LINES = '/lines'; /** - * @param string $id The ID of the credit note on which to retrieve the credit note line items. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the credit note on which to retrieve the credit note line items + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of credit note line items. + * @return \Stripe\Collection the list of credit note line items */ public static function allLines($id, $params = null, $opts = null) { diff --git a/lib/CreditNoteLineItem.php b/lib/CreditNoteLineItem.php index 5860e6e2e..8e274b977 100644 --- a/lib/CreditNoteLineItem.php +++ b/lib/CreditNoteLineItem.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class InvoiceLineItem + * Class InvoiceLineItem. * * @property string $id * @property string $object @@ -16,10 +16,8 @@ * @property array $tax_amounts * @property array $tax_rates * @property string $type - * @property int|null $unit_amount - * @property string|null $unit_amount_decimal - * - * @package Stripe + * @property null|int $unit_amount + * @property null|string $unit_amount_decimal */ class CreditNoteLineItem extends ApiResource { diff --git a/lib/Customer.php b/lib/Customer.php index 4a08055c6..9f29831e5 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -3,33 +3,31 @@ namespace Stripe; /** - * Class Customer + * Class Customer. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property \Stripe\StripeObject|null $address The customer's address. + * @property null|\Stripe\StripeObject $address The customer's address. * @property int $balance Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $currency Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes. - * @property string|\Stripe\StripeObject|null $default_source

ID of the default payment source for the customer.

If you are using payment methods created via the PaymentMethods API, see the invoice_settings.default_payment_method field instead.

- * @property bool|null $delinquent When the customer's latest invoice is billed by charging automatically, delinquent is true if the invoice's latest charge is failed. When the customer's latest invoice is billed by sending an invoice, delinquent is true if the invoice is not paid by its due date. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property \Stripe\Discount|null $discount Describes the current discount active on the customer, if there is one. - * @property string|null $email The customer's email address. - * @property string|null $invoice_prefix The prefix for the customer used to generate unique invoice numbers. + * @property null|string $currency Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes. + * @property null|string|\Stripe\StripeObject $default_source

ID of the default payment source for the customer.

If you are using payment methods created via the PaymentMethods API, see the invoice_settings.default_payment_method field instead.

+ * @property null|bool $delinquent When the customer's latest invoice is billed by charging automatically, delinquent is true if the invoice's latest charge is failed. When the customer's latest invoice is billed by sending an invoice, delinquent is true if the invoice is not paid by its due date. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|\Stripe\Discount $discount Describes the current discount active on the customer, if there is one. + * @property null|string $email The customer's email address. + * @property null|string $invoice_prefix The prefix for the customer used to generate unique invoice numbers. * @property \Stripe\StripeObject $invoice_settings * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $name The customer's full name or business name. - * @property string|null $phone The customer's phone number. - * @property string[]|null $preferred_locales The customer's preferred locales (languages), ordered by preference. - * @property \Stripe\StripeObject|null $shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer. + * @property null|string $name The customer's full name or business name. + * @property null|string $phone The customer's phone number. + * @property null|string[] $preferred_locales The customer's preferred locales (languages), ordered by preference. + * @property null|\Stripe\StripeObject $shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer. * @property \Stripe\Collection $sources The customer's payment sources, if any. * @property \Stripe\Collection $subscriptions The customer's current subscriptions, if any. - * @property string|null $tax_exempt Describes the customer's tax exemption status. One of none, exempt, or reverse. When set to reverse, invoice and receipt PDFs include the text "Reverse charge". + * @property null|string $tax_exempt Describes the customer's tax exemption status. One of none, exempt, or reverse. When set to reverse, invoice and receipt PDFs include the text "Reverse charge". * @property \Stripe\Collection $tax_ids The customer's tax IDs. - * - * @package Stripe */ class Customer extends ApiResource { @@ -47,8 +45,8 @@ class Customer extends ApiResource * * @see https://stripe.com/docs/api/customers/object#customer_object-tax_exempt */ - const TAX_EXEMPT_NONE = 'none'; - const TAX_EXEMPT_EXEMPT = 'exempt'; + const TAX_EXEMPT_NONE = 'none'; + const TAX_EXEMPT_EXEMPT = 'exempt'; const TAX_EXEMPT_REVERSE = 'reverse'; public static function getSavedNestedResources() @@ -59,14 +57,15 @@ public static function getSavedNestedResources() 'source', ]); } + return $savedNestedResources; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * - * @return \Stripe\Customer The updated customer. + * @return \Stripe\Customer the updated customer */ public function deleteDiscount($params = null, $opts = null) { @@ -78,13 +77,13 @@ public function deleteDiscount($params = null, $opts = null) const PATH_BALANCE_TRANSACTIONS = '/balance_transactions'; /** - * @param string $id The ID of the customer on which to retrieve the customer balance transactions. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer on which to retrieve the customer balance transactions + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of customer balance transactions. + * @return \Stripe\Collection the list of customer balance transactions */ public static function allBalanceTransactions($id, $params = null, $opts = null) { @@ -92,9 +91,9 @@ public static function allBalanceTransactions($id, $params = null, $opts = null) } /** - * @param string $id The ID of the customer on which to create the customer balance transaction. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer on which to create the customer balance transaction + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -106,10 +105,10 @@ public static function createBalanceTransaction($id, $params = null, $opts = nul } /** - * @param string $id The ID of the customer to which the customer balance transaction belongs. - * @param string $balanceTransactionId The ID of the customer balance transaction to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the customer balance transaction belongs + * @param string $balanceTransactionId the ID of the customer balance transaction to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -121,10 +120,10 @@ public static function retrieveBalanceTransaction($id, $balanceTransactionId, $p } /** - * @param string $id The ID of the customer to which the customer balance transaction belongs. - * @param string $balanceTransactionId The ID of the customer balance transaction to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the customer balance transaction belongs + * @param string $balanceTransactionId the ID of the customer balance transaction to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -138,13 +137,13 @@ public static function updateBalanceTransaction($id, $balanceTransactionId, $par const PATH_SOURCES = '/sources'; /** - * @param string $id The ID of the customer on which to retrieve the payment sources. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer on which to retrieve the payment sources + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of payment sources (AlipayAccount, BankAccount, BitcoinReceiver, Card or Source). + * @return \Stripe\Collection the list of payment sources (AlipayAccount, BankAccount, BitcoinReceiver, Card or Source) */ public static function allSources($id, $params = null, $opts = null) { @@ -152,9 +151,9 @@ public static function allSources($id, $params = null, $opts = null) } /** - * @param string $id The ID of the customer on which to create the payment source. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer on which to create the payment source + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -166,10 +165,10 @@ public static function createSource($id, $params = null, $opts = null) } /** - * @param string $id The ID of the customer to which the payment source belongs. - * @param string $sourceId The ID of the payment source to delete. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the payment source belongs + * @param string $sourceId the ID of the payment source to delete + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -181,10 +180,10 @@ public static function deleteSource($id, $sourceId, $params = null, $opts = null } /** - * @param string $id The ID of the customer to which the payment source belongs. - * @param string $sourceId The ID of the payment source to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the payment source belongs + * @param string $sourceId the ID of the payment source to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -196,10 +195,10 @@ public static function retrieveSource($id, $sourceId, $params = null, $opts = nu } /** - * @param string $id The ID of the customer to which the payment source belongs. - * @param string $sourceId The ID of the payment source to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the payment source belongs + * @param string $sourceId the ID of the payment source to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -213,13 +212,13 @@ public static function updateSource($id, $sourceId, $params = null, $opts = null const PATH_TAX_IDS = '/tax_ids'; /** - * @param string $id The ID of the customer on which to retrieve the tax ids. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer on which to retrieve the tax ids + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of tax ids. + * @return \Stripe\Collection the list of tax ids */ public static function allTaxIds($id, $params = null, $opts = null) { @@ -227,9 +226,9 @@ public static function allTaxIds($id, $params = null, $opts = null) } /** - * @param string $id The ID of the customer on which to create the tax id. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer on which to create the tax id + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -241,10 +240,10 @@ public static function createTaxId($id, $params = null, $opts = null) } /** - * @param string $id The ID of the customer to which the tax id belongs. - * @param string $taxIdId The ID of the tax id to delete. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the tax id belongs + * @param string $taxIdId the ID of the tax id to delete + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -256,10 +255,10 @@ public static function deleteTaxId($id, $taxIdId, $params = null, $opts = null) } /** - * @param string $id The ID of the customer to which the tax id belongs. - * @param string $taxIdId The ID of the tax id to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the customer to which the tax id belongs + * @param string $taxIdId the ID of the tax id to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * diff --git a/lib/CustomerBalanceTransaction.php b/lib/CustomerBalanceTransaction.php index a0a7b32a5..368445806 100644 --- a/lib/CustomerBalanceTransaction.php +++ b/lib/CustomerBalanceTransaction.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class CustomerBalanceTransaction - * - * @package Stripe + * Class CustomerBalanceTransaction. * * @property string $id * @property string $object @@ -30,16 +28,16 @@ class CustomerBalanceTransaction extends ApiResource * * @see https://stripe.com/docs/api/customers/customer_balance_transaction_object#customer_balance_transaction_object-type */ - const TYPE_ADJUSTEMENT = 'adjustment'; - const TYPE_APPLIED_TO_INVOICE = 'applied_to_invoice'; - const TYPE_CREDIT_NOTE = 'credit_note'; - const TYPE_INITIAL = 'initial'; - const TYPE_INVOICE_TOO_LARGE = 'invoice_too_large'; - const TYPE_INVOICE_TOO_SMALL = 'invoice_too_small'; + const TYPE_ADJUSTEMENT = 'adjustment'; + const TYPE_APPLIED_TO_INVOICE = 'applied_to_invoice'; + const TYPE_CREDIT_NOTE = 'credit_note'; + const TYPE_INITIAL = 'initial'; + const TYPE_INVOICE_TOO_LARGE = 'invoice_too_large'; + const TYPE_INVOICE_TOO_SMALL = 'invoice_too_small'; const TYPE_UNSPENT_RECEIVER_CREDIT = 'unspent_receiver_credit'; /** - * @return string The API URL for this balance transaction. + * @return string the API URL for this balance transaction */ public function instanceUrl() { @@ -57,37 +55,40 @@ public function instanceUrl() $base = Customer::classUrl(); $customerExtn = \urlencode($customer); $extn = \urlencode($id); + return "{$base}/{$customerExtn}/balance_transactions/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException */ public static function retrieve($_id, $_opts = null) { - $msg = "Customer Balance Transactions cannot be retrieved without a " . - "customer ID. Retrieve a Customer Balance Transaction using " . + $msg = 'Customer Balance Transactions cannot be retrieved without a ' . + 'customer ID. Retrieve a Customer Balance Transaction using ' . "`Customer::retrieveBalanceTransaction('customer_id', " . "'balance_transaction_id')`."; + throw new Exception\BadMethodCallException($msg, null); } /** * @param string $_id - * @param array|null $_params - * @param array|string|null $_options + * @param null|array $_params + * @param null|array|string $_options * * @throws \Stripe\Exception\BadMethodCallException */ public static function update($_id, $_params = null, $_options = null) { - $msg = "Customer Balance Transactions cannot be updated without a " . - "customer ID. Update a Customer Balance Transaction using " . + $msg = 'Customer Balance Transactions cannot be updated without a ' . + 'customer ID. Update a Customer Balance Transaction using ' . "`Customer::updateBalanceTransaction('customer_id', " . "'balance_transaction_id', \$updateParams)`."; + throw new Exception\BadMethodCallException($msg, null); } } diff --git a/lib/Discount.php b/lib/Discount.php index 6af84fec1..d4656052e 100644 --- a/lib/Discount.php +++ b/lib/Discount.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class Discount + * Class Discount. * * @property string $object * @property Coupon $coupon @@ -11,8 +11,6 @@ * @property int $end * @property int $start * @property string $subscription - * - * @package Stripe */ class Discount extends StripeObject { diff --git a/lib/Dispute.php b/lib/Dispute.php index 2b0c19234..66c35b40f 100644 --- a/lib/Dispute.php +++ b/lib/Dispute.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class Dispute + * Class Dispute. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -17,12 +17,10 @@ * @property bool $is_charge_refundable If true, it is still possible to refund the disputed payment. Once the payment has been fully refunded, no further funds will be withdrawn from your Stripe account as a result of this dispute. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $network_reason_code Network-dependent reason code for the dispute. - * @property string|\Stripe\PaymentIntent|null $payment_intent ID of the PaymentIntent that was disputed. + * @property null|string $network_reason_code Network-dependent reason code for the dispute. + * @property null|string|\Stripe\PaymentIntent $payment_intent ID of the PaymentIntent that was disputed. * @property string $reason Reason given by cardholder for dispute. Possible values are bank_cannot_process, check_returned, credit_not_processed, customer_initiated, debit_not_authorized, duplicate, fraudulent, general, incorrect_account_details, insufficient_funds, product_not_received, product_unacceptable, subscription_canceled, or unrecognized. Read more about dispute reasons. * @property string $status Current status of dispute. Possible values are warning_needs_response, warning_under_review, warning_closed, needs_response, under_review, charge_refunded, won, or lost. - * - * @package Stripe */ class Dispute extends ApiResource { @@ -37,41 +35,41 @@ class Dispute extends ApiResource * * @see https://stripe.com/docs/api#dispute_object */ - const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process'; - const REASON_CHECK_RETURNED = 'check_returned'; - const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed'; - const REASON_CUSTOMER_INITIATED = 'customer_initiated'; - const REASON_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized'; - const REASON_DUPLICATE = 'duplicate'; - const REASON_FRAUDULENT = 'fraudulent'; - const REASON_GENERAL = 'general'; + const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process'; + const REASON_CHECK_RETURNED = 'check_returned'; + const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed'; + const REASON_CUSTOMER_INITIATED = 'customer_initiated'; + const REASON_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized'; + const REASON_DUPLICATE = 'duplicate'; + const REASON_FRAUDULENT = 'fraudulent'; + const REASON_GENERAL = 'general'; const REASON_INCORRECT_ACCOUNT_DETAILS = 'incorrect_account_details'; - const REASON_INSUFFICIENT_FUNDS = 'insufficient_funds'; - const REASON_PRODUCT_NOT_RECEIVED = 'product_not_received'; - const REASON_PRODUCT_UNACCEPTABLE = 'product_unacceptable'; - const REASON_SUBSCRIPTION_CANCELED = 'subscription_canceled'; - const REASON_UNRECOGNIZED = 'unrecognized'; + const REASON_INSUFFICIENT_FUNDS = 'insufficient_funds'; + const REASON_PRODUCT_NOT_RECEIVED = 'product_not_received'; + const REASON_PRODUCT_UNACCEPTABLE = 'product_unacceptable'; + const REASON_SUBSCRIPTION_CANCELED = 'subscription_canceled'; + const REASON_UNRECOGNIZED = 'unrecognized'; /** * Possible string representations of dispute statuses. * * @see https://stripe.com/docs/api#dispute_object */ - const STATUS_CHARGE_REFUNDED = 'charge_refunded'; - const STATUS_LOST = 'lost'; - const STATUS_NEEDS_RESPONSE = 'needs_response'; - const STATUS_UNDER_REVIEW = 'under_review'; - const STATUS_WARNING_CLOSED = 'warning_closed'; + const STATUS_CHARGE_REFUNDED = 'charge_refunded'; + const STATUS_LOST = 'lost'; + const STATUS_NEEDS_RESPONSE = 'needs_response'; + const STATUS_UNDER_REVIEW = 'under_review'; + const STATUS_WARNING_CLOSED = 'warning_closed'; const STATUS_WARNING_NEEDS_RESPONSE = 'warning_needs_response'; - const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review'; - const STATUS_WON = 'won'; + const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review'; + const STATUS_WON = 'won'; /** - * @param array|string|null $opts + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Dispute The closed dispute. + * @return \Stripe\Dispute the closed dispute */ // TODO: add $params to standardize signature public function close($opts = null) @@ -79,6 +77,7 @@ public function close($opts = null) $url = $this->instanceUrl() . '/close'; list($response, $opts) = $this->_request('post', $url, null, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/EphemeralKey.php b/lib/EphemeralKey.php index 3cd85d7d0..c2275457a 100644 --- a/lib/EphemeralKey.php +++ b/lib/EphemeralKey.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class EphemeralKey + * Class EphemeralKey. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -12,8 +12,6 @@ * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property string $secret The key's secret. You can use this value to make authorized requests to the Stripe API. * @property array $associated_objects - * - * @package Stripe */ class EphemeralKey extends ApiResource { @@ -26,19 +24,20 @@ class EphemeralKey extends ApiResource } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\InvalidArgumentException if stripe_version is missing * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\EphemeralKey The created key. + * @return \Stripe\EphemeralKey the created key */ public static function create($params = null, $opts = null) { if (!$opts || !isset($opts['stripe_version'])) { throw new Exception\InvalidArgumentException('stripe_version must be specified to create an ephemeral key'); } + return self::_create($params, $opts); } } diff --git a/lib/ErrorObject.php b/lib/ErrorObject.php index d54eb8349..d2b97d472 100644 --- a/lib/ErrorObject.php +++ b/lib/ErrorObject.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class ErrorObject + * Class ErrorObject. * * @property string $charge For card errors, the ID of the failed charge. * @property string $code For some errors that could be handled @@ -31,8 +31,6 @@ * `api_connection_error`, `api_error`, `authentication_error`, * `card_error`, `idempotency_error`, `invalid_request_error`, or * `rate_limit_error`. - * - * @package Stripe */ class ErrorObject extends StripeObject { @@ -41,104 +39,104 @@ class ErrorObject extends StripeObject * * @see https://stripe.com/docs/error-codes */ - const CODE_ACCOUNT_ALREADY_EXISTS = 'account_already_exists'; - const CODE_ACCOUNT_COUNTRY_INVALID_ADDRESS = 'account_country_invalid_address'; - const CODE_ACCOUNT_INVALID = 'account_invalid'; - const CODE_ACCOUNT_NUMBER_INVALID = 'account_number_invalid'; - const CODE_ALIPAY_UPGRADE_REQUIRED = 'alipay_upgrade_required'; - const CODE_AMOUNT_TOO_LARGE = 'amount_too_large'; - const CODE_AMOUNT_TOO_SMALL = 'amount_too_small'; - const CODE_API_KEY_EXPIRED = 'api_key_expired'; - const CODE_BALANCE_INSUFFICIENT = 'balance_insufficient'; - const CODE_BANK_ACCOUNT_EXISTS = 'bank_account_exists'; - const CODE_BANK_ACCOUNT_UNUSABLE = 'bank_account_unusable'; - const CODE_BANK_ACCOUNT_UNVERIFIED = 'bank_account_unverified'; - const CODE_BITCOIN_UPGRADE_REQUIRED = 'bitcoin_upgrade_required'; - const CODE_CARD_DECLINED = 'card_declined'; - const CODE_CHARGE_ALREADY_CAPTURED = 'charge_already_captured'; - const CODE_CHARGE_ALREADY_REFUNDED = 'charge_already_refunded'; - const CODE_CHARGE_DISPUTED = 'charge_disputed'; - const CODE_CHARGE_EXCEEDS_SOURCE_LIMIT = 'charge_exceeds_source_limit'; - const CODE_CHARGE_EXPIRED_FOR_CAPTURE = 'charge_expired_for_capture'; - const CODE_COUNTRY_UNSUPPORTED = 'country_unsupported'; - const CODE_COUPON_EXPIRED = 'coupon_expired'; - const CODE_CUSTOMER_MAX_SUBSCRIPTIONS = 'customer_max_subscriptions'; - const CODE_EMAIL_INVALID = 'email_invalid'; - const CODE_EXPIRED_CARD = 'expired_card'; - const CODE_IDEMPOTENCY_KEY_IN_USE = 'idempotency_key_in_use'; - const CODE_INCORRECT_ADDRESS = 'incorrect_address'; - const CODE_INCORRECT_CVC = 'incorrect_cvc'; - const CODE_INCORRECT_NUMBER = 'incorrect_number'; - const CODE_INCORRECT_ZIP = 'incorrect_zip'; - const CODE_INSTANT_PAYOUTS_UNSUPPORTED = 'instant_payouts_unsupported'; - const CODE_INVALID_CARD_TYPE = 'invalid_card_type'; - const CODE_INVALID_CHARGE_AMOUNT = 'invalid_charge_amount'; - const CODE_INVALID_CVC = 'invalid_cvc'; - const CODE_INVALID_EXPIRY_MONTH = 'invalid_expiry_month'; - const CODE_INVALID_EXPIRY_YEAR = 'invalid_expiry_year'; - const CODE_INVALID_NUMBER = 'invalid_number'; - const CODE_INVALID_SOURCE_USAGE = 'invalid_source_usage'; - const CODE_INVOICE_NO_CUSTOMER_LINE_ITEMS = 'invoice_no_customer_line_items'; - const CODE_INVOICE_NO_SUBSCRIPTION_LINE_ITEMS = 'invoice_no_subscription_line_items'; - const CODE_INVOICE_NOT_EDITABLE = 'invoice_not_editable'; - const CODE_INVOICE_PAYMENT_INTENT_REQUIRES_ACTION = 'invoice_payment_intent_requires_action'; - const CODE_INVOICE_UPCOMING_NONE = 'invoice_upcoming_none'; - const CODE_LIVEMODE_MISMATCH = 'livemode_mismatch'; - const CODE_LOCK_TIMEOUT = 'lock_timeout'; - const CODE_MISSING = 'missing'; - const CODE_NOT_ALLOWED_ON_STANDARD_ACCOUNT = 'not_allowed_on_standard_account'; - const CODE_ORDER_CREATION_FAILED = 'order_creation_failed'; - const CODE_ORDER_REQUIRED_SETTINGS = 'order_required_settings'; - const CODE_ORDER_STATUS_INVALID = 'order_status_invalid'; - const CODE_ORDER_UPSTREAM_TIMEOUT = 'order_upstream_timeout'; - const CODE_OUT_OF_INVENTORY = 'out_of_inventory'; - const CODE_PARAMETER_INVALID_EMPTY = 'parameter_invalid_empty'; - const CODE_PARAMETER_INVALID_INTEGER = 'parameter_invalid_integer'; - const CODE_PARAMETER_INVALID_STRING_BLANK = 'parameter_invalid_string_blank'; - const CODE_PARAMETER_INVALID_STRING_EMPTY = 'parameter_invalid_string_empty'; - const CODE_PARAMETER_MISSING = 'parameter_missing'; - const CODE_PARAMETER_UNKNOWN = 'parameter_unknown'; - const CODE_PARAMETERS_EXCLUSIVE = 'parameters_exclusive'; - const CODE_PAYMENT_INTENT_AUTHENTICATION_FAILURE = 'payment_intent_authentication_failure'; + const CODE_ACCOUNT_ALREADY_EXISTS = 'account_already_exists'; + const CODE_ACCOUNT_COUNTRY_INVALID_ADDRESS = 'account_country_invalid_address'; + const CODE_ACCOUNT_INVALID = 'account_invalid'; + const CODE_ACCOUNT_NUMBER_INVALID = 'account_number_invalid'; + const CODE_ALIPAY_UPGRADE_REQUIRED = 'alipay_upgrade_required'; + const CODE_AMOUNT_TOO_LARGE = 'amount_too_large'; + const CODE_AMOUNT_TOO_SMALL = 'amount_too_small'; + const CODE_API_KEY_EXPIRED = 'api_key_expired'; + const CODE_BALANCE_INSUFFICIENT = 'balance_insufficient'; + const CODE_BANK_ACCOUNT_EXISTS = 'bank_account_exists'; + const CODE_BANK_ACCOUNT_UNUSABLE = 'bank_account_unusable'; + const CODE_BANK_ACCOUNT_UNVERIFIED = 'bank_account_unverified'; + const CODE_BITCOIN_UPGRADE_REQUIRED = 'bitcoin_upgrade_required'; + const CODE_CARD_DECLINED = 'card_declined'; + const CODE_CHARGE_ALREADY_CAPTURED = 'charge_already_captured'; + const CODE_CHARGE_ALREADY_REFUNDED = 'charge_already_refunded'; + const CODE_CHARGE_DISPUTED = 'charge_disputed'; + const CODE_CHARGE_EXCEEDS_SOURCE_LIMIT = 'charge_exceeds_source_limit'; + const CODE_CHARGE_EXPIRED_FOR_CAPTURE = 'charge_expired_for_capture'; + const CODE_COUNTRY_UNSUPPORTED = 'country_unsupported'; + const CODE_COUPON_EXPIRED = 'coupon_expired'; + const CODE_CUSTOMER_MAX_SUBSCRIPTIONS = 'customer_max_subscriptions'; + const CODE_EMAIL_INVALID = 'email_invalid'; + const CODE_EXPIRED_CARD = 'expired_card'; + const CODE_IDEMPOTENCY_KEY_IN_USE = 'idempotency_key_in_use'; + const CODE_INCORRECT_ADDRESS = 'incorrect_address'; + const CODE_INCORRECT_CVC = 'incorrect_cvc'; + const CODE_INCORRECT_NUMBER = 'incorrect_number'; + const CODE_INCORRECT_ZIP = 'incorrect_zip'; + const CODE_INSTANT_PAYOUTS_UNSUPPORTED = 'instant_payouts_unsupported'; + const CODE_INVALID_CARD_TYPE = 'invalid_card_type'; + const CODE_INVALID_CHARGE_AMOUNT = 'invalid_charge_amount'; + const CODE_INVALID_CVC = 'invalid_cvc'; + const CODE_INVALID_EXPIRY_MONTH = 'invalid_expiry_month'; + const CODE_INVALID_EXPIRY_YEAR = 'invalid_expiry_year'; + const CODE_INVALID_NUMBER = 'invalid_number'; + const CODE_INVALID_SOURCE_USAGE = 'invalid_source_usage'; + const CODE_INVOICE_NO_CUSTOMER_LINE_ITEMS = 'invoice_no_customer_line_items'; + const CODE_INVOICE_NO_SUBSCRIPTION_LINE_ITEMS = 'invoice_no_subscription_line_items'; + const CODE_INVOICE_NOT_EDITABLE = 'invoice_not_editable'; + const CODE_INVOICE_PAYMENT_INTENT_REQUIRES_ACTION = 'invoice_payment_intent_requires_action'; + const CODE_INVOICE_UPCOMING_NONE = 'invoice_upcoming_none'; + const CODE_LIVEMODE_MISMATCH = 'livemode_mismatch'; + const CODE_LOCK_TIMEOUT = 'lock_timeout'; + const CODE_MISSING = 'missing'; + const CODE_NOT_ALLOWED_ON_STANDARD_ACCOUNT = 'not_allowed_on_standard_account'; + const CODE_ORDER_CREATION_FAILED = 'order_creation_failed'; + const CODE_ORDER_REQUIRED_SETTINGS = 'order_required_settings'; + const CODE_ORDER_STATUS_INVALID = 'order_status_invalid'; + const CODE_ORDER_UPSTREAM_TIMEOUT = 'order_upstream_timeout'; + const CODE_OUT_OF_INVENTORY = 'out_of_inventory'; + const CODE_PARAMETER_INVALID_EMPTY = 'parameter_invalid_empty'; + const CODE_PARAMETER_INVALID_INTEGER = 'parameter_invalid_integer'; + const CODE_PARAMETER_INVALID_STRING_BLANK = 'parameter_invalid_string_blank'; + const CODE_PARAMETER_INVALID_STRING_EMPTY = 'parameter_invalid_string_empty'; + const CODE_PARAMETER_MISSING = 'parameter_missing'; + const CODE_PARAMETER_UNKNOWN = 'parameter_unknown'; + const CODE_PARAMETERS_EXCLUSIVE = 'parameters_exclusive'; + const CODE_PAYMENT_INTENT_AUTHENTICATION_FAILURE = 'payment_intent_authentication_failure'; const CODE_PAYMENT_INTENT_INCOMPATIBLE_PAYMENT_METHOD = 'payment_intent_incompatible_payment_method'; - const CODE_PAYMENT_INTENT_INVALID_PARAMETER = 'payment_intent_invalid_parameter'; - const CODE_PAYMENT_INTENT_PAYMENT_ATTEMPT_FAILED = 'payment_intent_payment_attempt_failed'; - const CODE_PAYMENT_INTENT_UNEXPECTED_STATE = 'payment_intent_unexpected_state'; - const CODE_PAYMENT_METHOD_UNACTIVATED = 'payment_method_unactivated'; - const CODE_PAYMENT_METHOD_UNEXPECTED_STATE = 'payment_method_unexpected_state'; - const CODE_PAYOUTS_NOT_ALLOWED = 'payouts_not_allowed'; - const CODE_PLATFORM_API_KEY_EXPIRED = 'platform_api_key_expired'; - const CODE_POSTAL_CODE_INVALID = 'postal_code_invalid'; - const CODE_PROCESSING_ERROR = 'processing_error'; - const CODE_PRODUCT_INACTIVE = 'product_inactive'; - const CODE_RATE_LIMIT = 'rate_limit'; - const CODE_RESOURCE_ALREADY_EXISTS = 'resource_already_exists'; - const CODE_RESOURCE_MISSING = 'resource_missing'; - const CODE_ROUTING_NUMBER_INVALID = 'routing_number_invalid'; - const CODE_SECRET_KEY_REQUIRED = 'secret_key_required'; - const CODE_SEPA_UNSUPPORTED_ACCOUNT = 'sepa_unsupported_account'; - const CODE_SETUP_ATTEMPT_FAILED = 'setup_attempt_failed'; - const CODE_SETUP_INTENT_AUTHENTICATION_FAILURE = 'setup_intent_authentication_failure'; - const CODE_SETUP_INTENT_UNEXPECTED_STATE = 'setup_intent_unexpected_state'; - const CODE_SHIPPING_CALCULATION_FAILED = 'shipping_calculation_failed'; - const CODE_SKU_INACTIVE = 'sku_inactive'; - const CODE_STATE_UNSUPPORTED = 'state_unsupported'; - const CODE_TAX_ID_INVALID = 'tax_id_invalid'; - const CODE_TAXES_CALCULATION_FAILED = 'taxes_calculation_failed'; - const CODE_TESTMODE_CHARGES_ONLY = 'testmode_charges_only'; - const CODE_TLS_VERSION_UNSUPPORTED = 'tls_version_unsupported'; - const CODE_TOKEN_ALREADY_USED = 'token_already_used'; - const CODE_TOKEN_IN_USE = 'token_in_use'; - const CODE_TRANSFERS_NOT_ALLOWED = 'transfers_not_allowed'; - const CODE_UPSTREAM_ORDER_CREATION_FAILED = 'upstream_order_creation_failed'; - const CODE_URL_INVALID = 'url_invalid'; + const CODE_PAYMENT_INTENT_INVALID_PARAMETER = 'payment_intent_invalid_parameter'; + const CODE_PAYMENT_INTENT_PAYMENT_ATTEMPT_FAILED = 'payment_intent_payment_attempt_failed'; + const CODE_PAYMENT_INTENT_UNEXPECTED_STATE = 'payment_intent_unexpected_state'; + const CODE_PAYMENT_METHOD_UNACTIVATED = 'payment_method_unactivated'; + const CODE_PAYMENT_METHOD_UNEXPECTED_STATE = 'payment_method_unexpected_state'; + const CODE_PAYOUTS_NOT_ALLOWED = 'payouts_not_allowed'; + const CODE_PLATFORM_API_KEY_EXPIRED = 'platform_api_key_expired'; + const CODE_POSTAL_CODE_INVALID = 'postal_code_invalid'; + const CODE_PROCESSING_ERROR = 'processing_error'; + const CODE_PRODUCT_INACTIVE = 'product_inactive'; + const CODE_RATE_LIMIT = 'rate_limit'; + const CODE_RESOURCE_ALREADY_EXISTS = 'resource_already_exists'; + const CODE_RESOURCE_MISSING = 'resource_missing'; + const CODE_ROUTING_NUMBER_INVALID = 'routing_number_invalid'; + const CODE_SECRET_KEY_REQUIRED = 'secret_key_required'; + const CODE_SEPA_UNSUPPORTED_ACCOUNT = 'sepa_unsupported_account'; + const CODE_SETUP_ATTEMPT_FAILED = 'setup_attempt_failed'; + const CODE_SETUP_INTENT_AUTHENTICATION_FAILURE = 'setup_intent_authentication_failure'; + const CODE_SETUP_INTENT_UNEXPECTED_STATE = 'setup_intent_unexpected_state'; + const CODE_SHIPPING_CALCULATION_FAILED = 'shipping_calculation_failed'; + const CODE_SKU_INACTIVE = 'sku_inactive'; + const CODE_STATE_UNSUPPORTED = 'state_unsupported'; + const CODE_TAX_ID_INVALID = 'tax_id_invalid'; + const CODE_TAXES_CALCULATION_FAILED = 'taxes_calculation_failed'; + const CODE_TESTMODE_CHARGES_ONLY = 'testmode_charges_only'; + const CODE_TLS_VERSION_UNSUPPORTED = 'tls_version_unsupported'; + const CODE_TOKEN_ALREADY_USED = 'token_already_used'; + const CODE_TOKEN_IN_USE = 'token_in_use'; + const CODE_TRANSFERS_NOT_ALLOWED = 'transfers_not_allowed'; + const CODE_UPSTREAM_ORDER_CREATION_FAILED = 'upstream_order_creation_failed'; + const CODE_URL_INVALID = 'url_invalid'; /** * Refreshes this object using the provided values. * * @param array $values - * @param array|string|Util\RequestOptions|null $opts - * @param bool $partial Defaults to false. + * @param null|array|string|Util\RequestOptions $opts + * @param bool $partial defaults to false */ public function refreshFrom($values, $opts, $partial = false) { diff --git a/lib/Event.php b/lib/Event.php index e3fe65814..4999418ff 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -3,20 +3,18 @@ namespace Stripe; /** - * Class Event + * Class Event. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property string $account The connected account that originated the event. - * @property string|null $api_version The Stripe API version used to render data. Note: This property is populated only for events on or after October 31, 2014. + * @property null|string $api_version The Stripe API version used to render data. Note: This property is populated only for events on or after October 31, 2014. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property \Stripe\StripeObject $data * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property int $pending_webhooks Number of webhooks that have yet to be successfully delivered (i.e., to return a 20x response) to the URLs you've specified. - * @property \Stripe\StripeObject|null $request Information on the API request that instigated the event. + * @property null|\Stripe\StripeObject $request Information on the API request that instigated the event. * @property string $type Description of the event (e.g., invoice.created or charge.refunded). - * - * @package Stripe */ class Event extends ApiResource { @@ -30,144 +28,144 @@ class Event extends ApiResource * * @see https://stripe.com/docs/api#event_types */ - const ACCOUNT_UPDATED = 'account.updated'; - const ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized'; - const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized'; - const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created'; - const ACCOUNT_EXTERNAL_ACCOUNT_DELETED = 'account.external_account.deleted'; - const ACCOUNT_EXTERNAL_ACCOUNT_UPDATED = 'account.external_account.updated'; - const APPLICATION_FEE_CREATED = 'application_fee.created'; - const APPLICATION_FEE_REFUNDED = 'application_fee.refunded'; - const APPLICATION_FEE_REFUND_UPDATED = 'application_fee.refund.updated'; - const BALANCE_AVAILABLE = 'balance.available'; - const CHARGE_CAPTURED = 'charge.captured'; - const CHARGE_EXPIRED = 'charge.expired'; - const CHARGE_FAILED = 'charge.failed'; - const CHARGE_PENDING = 'charge.pending'; - const CHARGE_REFUNDED = 'charge.refunded'; - const CHARGE_SUCCEEDED = 'charge.succeeded'; - const CHARGE_UPDATED = 'charge.updated'; - const CHARGE_DISPUTE_CLOSED = 'charge.dispute.closed'; - const CHARGE_DISPUTE_CREATED = 'charge.dispute.created'; - const CHARGE_DISPUTE_FUNDS_REINSTATED = 'charge.dispute.funds_reinstated'; - const CHARGE_DISPUTE_FUNDS_WITHDRAWN = 'charge.dispute.funds_withdrawn'; - const CHARGE_DISPUTE_UPDATED = 'charge.dispute.updated'; - const CHARGE_REFUND_UPDATED = 'charge.refund.updated'; - const CHECKOUT_SESSION_COMPLETED = 'checkout.session.completed'; - const COUPON_CREATED = 'coupon.created'; - const COUPON_DELETED = 'coupon.deleted'; - const COUPON_UPDATED = 'coupon.updated'; - const CREDIT_NOTE_CREATED = 'credit_note.created'; - const CREDIT_NOTE_UPDATED = 'credit_note.updated'; - const CREDIT_NOTE_VOIDED = 'credit_note.voided'; - const CUSTOMER_CREATED = 'customer.created'; - const CUSTOMER_DELETED = 'customer.deleted'; - const CUSTOMER_UPDATED = 'customer.updated'; - const CUSTOMER_DISCOUNT_CREATED = 'customer.discount.created'; - const CUSTOMER_DISCOUNT_DELETED = 'customer.discount.deleted'; - const CUSTOMER_DISCOUNT_UPDATED = 'customer.discount.updated'; - const CUSTOMER_SOURCE_CREATED = 'customer.source.created'; - const CUSTOMER_SOURCE_DELETED = 'customer.source.deleted'; - const CUSTOMER_SOURCE_EXPIRING = 'customer.source.expiring'; - const CUSTOMER_SOURCE_UPDATED = 'customer.source.updated'; - const CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created'; - const CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted'; - const CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end'; - const CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated'; - const FILE_CREATED = 'file.created'; - const INVOICE_CREATED = 'invoice.created'; - const INVOICE_DELETED = 'invoice.deleted'; - const INVOICE_FINALIZED = 'invoice.finalized'; - const INVOICE_MARKED_UNCOLLECTIBLE = 'invoice.marked_uncollectible'; - const INVOICE_PAYMENT_ACTION_REQUIRED = 'invoice.payment_action_required'; - const INVOICE_PAYMENT_FAILED = 'invoice.payment_failed'; - const INVOICE_PAYMENT_SUCCEEDED = 'invoice.payment_succeeded'; - const INVOICE_SENT = 'invoice.sent'; - const INVOICE_UPCOMING = 'invoice.upcoming'; - const INVOICE_UPDATED = 'invoice.updated'; - const INVOICE_VOIDED = 'invoice.voided'; - const INVOICEITEM_CREATED = 'invoiceitem.created'; - const INVOICEITEM_DELETED = 'invoiceitem.deleted'; - const INVOICEITEM_UPDATED = 'invoiceitem.updated'; - const ISSUER_FRAUD_RECORD_CREATED = 'issuer_fraud_record.created'; - const ISSUING_AUTHORIZATION_CREATED = 'issuing_authorization.created'; - const ISSUING_AUTHORIZATION_REQUEST = 'issuing_authorization.request'; - const ISSUING_AUTHORIZATION_UPDATED = 'issuing_authorization.updated'; - const ISSUING_CARD_CREATED = 'issuing_card.created'; - const ISSUING_CARD_UPDATED = 'issuing_card.updated'; - const ISSUING_CARDHOLDER_CREATED = 'issuing_cardholder.created'; - const ISSUING_CARDHOLDER_UPDATED = 'issuing_cardholder.updated'; - const ISSUING_DISPUTE_CREATED = 'issuing_dispute.created'; - const ISSUING_DISPUTE_UPDATED = 'issuing_dispute.updated'; - const ISSUING_TRANSACTION_CREATED = 'issuing_transaction.created'; - const ISSUING_TRANSACTION_UPDATED = 'issuing_transaction.updated'; - const ORDER_CREATED = 'order.created'; - const ORDER_PAYMENT_FAILED = 'order.payment_failed'; - const ORDER_PAYMENT_SUCCEEDED = 'order.payment_succeeded'; - const ORDER_UPDATED = 'order.updated'; - const ORDER_RETURN_CREATED = 'order_return.created'; - const PAYMENT_INTENT_AMOUNT_CAPTURABLE_UPDATED = 'payment_intent.amount_capturable_updated'; - const PAYMENT_INTENT_CANCELED = 'payment_intent.canceled'; - const PAYMENT_INTENT_CREATED = 'payment_intent.created'; - const PAYMENT_INTENT_PAYMENT_FAILED = 'payment_intent.payment_failed'; - const PAYMENT_INTENT_SUCCEEDED = 'payment_intent.succeeded'; - const PAYMENT_METHOD_ATTACHED = 'payment_method.attached'; + const ACCOUNT_UPDATED = 'account.updated'; + const ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized'; + const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized'; + const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created'; + const ACCOUNT_EXTERNAL_ACCOUNT_DELETED = 'account.external_account.deleted'; + const ACCOUNT_EXTERNAL_ACCOUNT_UPDATED = 'account.external_account.updated'; + const APPLICATION_FEE_CREATED = 'application_fee.created'; + const APPLICATION_FEE_REFUNDED = 'application_fee.refunded'; + const APPLICATION_FEE_REFUND_UPDATED = 'application_fee.refund.updated'; + const BALANCE_AVAILABLE = 'balance.available'; + const CHARGE_CAPTURED = 'charge.captured'; + const CHARGE_EXPIRED = 'charge.expired'; + const CHARGE_FAILED = 'charge.failed'; + const CHARGE_PENDING = 'charge.pending'; + const CHARGE_REFUNDED = 'charge.refunded'; + const CHARGE_SUCCEEDED = 'charge.succeeded'; + const CHARGE_UPDATED = 'charge.updated'; + const CHARGE_DISPUTE_CLOSED = 'charge.dispute.closed'; + const CHARGE_DISPUTE_CREATED = 'charge.dispute.created'; + const CHARGE_DISPUTE_FUNDS_REINSTATED = 'charge.dispute.funds_reinstated'; + const CHARGE_DISPUTE_FUNDS_WITHDRAWN = 'charge.dispute.funds_withdrawn'; + const CHARGE_DISPUTE_UPDATED = 'charge.dispute.updated'; + const CHARGE_REFUND_UPDATED = 'charge.refund.updated'; + const CHECKOUT_SESSION_COMPLETED = 'checkout.session.completed'; + const COUPON_CREATED = 'coupon.created'; + const COUPON_DELETED = 'coupon.deleted'; + const COUPON_UPDATED = 'coupon.updated'; + const CREDIT_NOTE_CREATED = 'credit_note.created'; + const CREDIT_NOTE_UPDATED = 'credit_note.updated'; + const CREDIT_NOTE_VOIDED = 'credit_note.voided'; + const CUSTOMER_CREATED = 'customer.created'; + const CUSTOMER_DELETED = 'customer.deleted'; + const CUSTOMER_UPDATED = 'customer.updated'; + const CUSTOMER_DISCOUNT_CREATED = 'customer.discount.created'; + const CUSTOMER_DISCOUNT_DELETED = 'customer.discount.deleted'; + const CUSTOMER_DISCOUNT_UPDATED = 'customer.discount.updated'; + const CUSTOMER_SOURCE_CREATED = 'customer.source.created'; + const CUSTOMER_SOURCE_DELETED = 'customer.source.deleted'; + const CUSTOMER_SOURCE_EXPIRING = 'customer.source.expiring'; + const CUSTOMER_SOURCE_UPDATED = 'customer.source.updated'; + const CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created'; + const CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted'; + const CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end'; + const CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated'; + const FILE_CREATED = 'file.created'; + const INVOICE_CREATED = 'invoice.created'; + const INVOICE_DELETED = 'invoice.deleted'; + const INVOICE_FINALIZED = 'invoice.finalized'; + const INVOICE_MARKED_UNCOLLECTIBLE = 'invoice.marked_uncollectible'; + const INVOICE_PAYMENT_ACTION_REQUIRED = 'invoice.payment_action_required'; + const INVOICE_PAYMENT_FAILED = 'invoice.payment_failed'; + const INVOICE_PAYMENT_SUCCEEDED = 'invoice.payment_succeeded'; + const INVOICE_SENT = 'invoice.sent'; + const INVOICE_UPCOMING = 'invoice.upcoming'; + const INVOICE_UPDATED = 'invoice.updated'; + const INVOICE_VOIDED = 'invoice.voided'; + const INVOICEITEM_CREATED = 'invoiceitem.created'; + const INVOICEITEM_DELETED = 'invoiceitem.deleted'; + const INVOICEITEM_UPDATED = 'invoiceitem.updated'; + const ISSUER_FRAUD_RECORD_CREATED = 'issuer_fraud_record.created'; + const ISSUING_AUTHORIZATION_CREATED = 'issuing_authorization.created'; + const ISSUING_AUTHORIZATION_REQUEST = 'issuing_authorization.request'; + const ISSUING_AUTHORIZATION_UPDATED = 'issuing_authorization.updated'; + const ISSUING_CARD_CREATED = 'issuing_card.created'; + const ISSUING_CARD_UPDATED = 'issuing_card.updated'; + const ISSUING_CARDHOLDER_CREATED = 'issuing_cardholder.created'; + const ISSUING_CARDHOLDER_UPDATED = 'issuing_cardholder.updated'; + const ISSUING_DISPUTE_CREATED = 'issuing_dispute.created'; + const ISSUING_DISPUTE_UPDATED = 'issuing_dispute.updated'; + const ISSUING_TRANSACTION_CREATED = 'issuing_transaction.created'; + const ISSUING_TRANSACTION_UPDATED = 'issuing_transaction.updated'; + const ORDER_CREATED = 'order.created'; + const ORDER_PAYMENT_FAILED = 'order.payment_failed'; + const ORDER_PAYMENT_SUCCEEDED = 'order.payment_succeeded'; + const ORDER_UPDATED = 'order.updated'; + const ORDER_RETURN_CREATED = 'order_return.created'; + const PAYMENT_INTENT_AMOUNT_CAPTURABLE_UPDATED = 'payment_intent.amount_capturable_updated'; + const PAYMENT_INTENT_CANCELED = 'payment_intent.canceled'; + const PAYMENT_INTENT_CREATED = 'payment_intent.created'; + const PAYMENT_INTENT_PAYMENT_FAILED = 'payment_intent.payment_failed'; + const PAYMENT_INTENT_SUCCEEDED = 'payment_intent.succeeded'; + const PAYMENT_METHOD_ATTACHED = 'payment_method.attached'; const PAYMENT_METHOD_CARD_AUTOMATICALLY_UPDATED = 'payment_method.card_automatically_updated'; - const PAYMENT_METHOD_DETACHED = 'payment_method.detached'; - const PAYMENT_METHOD_UPDATED = 'payment_method.updated'; - const PAYOUT_CANCELED = 'payout.canceled'; - const PAYOUT_CREATED = 'payout.created'; - const PAYOUT_FAILED = 'payout.failed'; - const PAYOUT_PAID = 'payout.paid'; - const PAYOUT_UPDATED = 'payout.updated'; - const PERSON_CREATED = 'person.created'; - const PERSON_DELETED = 'person.deleted'; - const PERSON_UPDATED = 'person.updated'; - const PING = 'ping'; - const PLAN_CREATED = 'plan.created'; - const PLAN_DELETED = 'plan.deleted'; - const PLAN_UPDATED = 'plan.updated'; - const PRODUCT_CREATED = 'product.created'; - const PRODUCT_DELETED = 'product.deleted'; - const PRODUCT_UPDATED = 'product.updated'; - const RECIPIENT_CREATED = 'recipient.created'; - const RECIPIENT_DELETED = 'recipient.deleted'; - const RECIPIENT_UPDATED = 'recipient.updated'; - const REPORTING_REPORT_RUN_FAILED = 'reporting.report_run.failed'; - const REPORTING_REPORT_RUN_SUCCEEDED = 'reporting.report_run.succeeded'; - const REPORTING_REPORT_TYPE_UPDATED = 'reporting.report_type.updated'; - const REVIEW_CLOSED = 'review.closed'; - const REVIEW_OPENED = 'review.opened'; - const SETUP_INTENT_CANCELED = 'setup_intent.canceled'; - const SETUP_INTENT_CREATED = 'setup_intent.created'; - const SETUP_INTENT_SETUP_FAILED = 'setup_intent.setup_failed'; - const SETUP_INTENT_SUCCEEDED = 'setup_intent.succeeded'; - const SIGMA_SCHEDULED_QUERY_RUN_CREATED = 'sigma.scheduled_query_run.created'; - const SKU_CREATED = 'sku.created'; - const SKU_DELETED = 'sku.deleted'; - const SKU_UPDATED = 'sku.updated'; - const SOURCE_CANCELED = 'source.canceled'; - const SOURCE_CHARGEABLE = 'source.chargeable'; - const SOURCE_FAILED = 'source.failed'; - const SOURCE_MANDATE_NOTIFICATION = 'source.mandate_notification'; - const SOURCE_REFUND_ATTRIBUTES_REQUIRED = 'source.refund_attributes_required'; - const SOURCE_TRANSACTION_CREATED = 'source.transaction.created'; - const SOURCE_TRANSACTION_UPDATED = 'source.transaction.updated'; - const SUBSCRIPTION_SCHEDULE_ABORTED = 'subscription_schedule.aborted'; - const SUBSCRIPTION_SCHEDULE_CANCELED = 'subscription_schedule.canceled'; - const SUBSCRIPTION_SCHEDULE_COMPLETED = 'subscription_schedule.completed'; - const SUBSCRIPTION_SCHEDULE_CREATED = 'subscription_schedule.created'; - const SUBSCRIPTION_SCHEDULE_EXPIRING = 'subscription_schedule.expiring'; - const SUBSCRIPTION_SCHEDULE_RELEASED = 'subscription_schedule.released'; - const SUBSCRIPTION_SCHEDULE_UPDATED = 'subscription_schedule.updated'; - const TAX_RATE_CREATED = 'tax_rate.created'; - const TAX_RATE_UPDATED = 'tax_rate.updated'; - const TOPUP_CANCELED = 'topup.canceled'; - const TOPUP_CREATED = 'topup.created'; - const TOPUP_FAILED = 'topup.failed'; - const TOPUP_REVERSED = 'topup.reversed'; - const TOPUP_SUCCEEDED = 'topup.succeeded'; - const TRANSFER_CREATED = 'transfer.created'; - const TRANSFER_REVERSED = 'transfer.reversed'; - const TRANSFER_UPDATED = 'transfer.updated'; + const PAYMENT_METHOD_DETACHED = 'payment_method.detached'; + const PAYMENT_METHOD_UPDATED = 'payment_method.updated'; + const PAYOUT_CANCELED = 'payout.canceled'; + const PAYOUT_CREATED = 'payout.created'; + const PAYOUT_FAILED = 'payout.failed'; + const PAYOUT_PAID = 'payout.paid'; + const PAYOUT_UPDATED = 'payout.updated'; + const PERSON_CREATED = 'person.created'; + const PERSON_DELETED = 'person.deleted'; + const PERSON_UPDATED = 'person.updated'; + const PING = 'ping'; + const PLAN_CREATED = 'plan.created'; + const PLAN_DELETED = 'plan.deleted'; + const PLAN_UPDATED = 'plan.updated'; + const PRODUCT_CREATED = 'product.created'; + const PRODUCT_DELETED = 'product.deleted'; + const PRODUCT_UPDATED = 'product.updated'; + const RECIPIENT_CREATED = 'recipient.created'; + const RECIPIENT_DELETED = 'recipient.deleted'; + const RECIPIENT_UPDATED = 'recipient.updated'; + const REPORTING_REPORT_RUN_FAILED = 'reporting.report_run.failed'; + const REPORTING_REPORT_RUN_SUCCEEDED = 'reporting.report_run.succeeded'; + const REPORTING_REPORT_TYPE_UPDATED = 'reporting.report_type.updated'; + const REVIEW_CLOSED = 'review.closed'; + const REVIEW_OPENED = 'review.opened'; + const SETUP_INTENT_CANCELED = 'setup_intent.canceled'; + const SETUP_INTENT_CREATED = 'setup_intent.created'; + const SETUP_INTENT_SETUP_FAILED = 'setup_intent.setup_failed'; + const SETUP_INTENT_SUCCEEDED = 'setup_intent.succeeded'; + const SIGMA_SCHEDULED_QUERY_RUN_CREATED = 'sigma.scheduled_query_run.created'; + const SKU_CREATED = 'sku.created'; + const SKU_DELETED = 'sku.deleted'; + const SKU_UPDATED = 'sku.updated'; + const SOURCE_CANCELED = 'source.canceled'; + const SOURCE_CHARGEABLE = 'source.chargeable'; + const SOURCE_FAILED = 'source.failed'; + const SOURCE_MANDATE_NOTIFICATION = 'source.mandate_notification'; + const SOURCE_REFUND_ATTRIBUTES_REQUIRED = 'source.refund_attributes_required'; + const SOURCE_TRANSACTION_CREATED = 'source.transaction.created'; + const SOURCE_TRANSACTION_UPDATED = 'source.transaction.updated'; + const SUBSCRIPTION_SCHEDULE_ABORTED = 'subscription_schedule.aborted'; + const SUBSCRIPTION_SCHEDULE_CANCELED = 'subscription_schedule.canceled'; + const SUBSCRIPTION_SCHEDULE_COMPLETED = 'subscription_schedule.completed'; + const SUBSCRIPTION_SCHEDULE_CREATED = 'subscription_schedule.created'; + const SUBSCRIPTION_SCHEDULE_EXPIRING = 'subscription_schedule.expiring'; + const SUBSCRIPTION_SCHEDULE_RELEASED = 'subscription_schedule.released'; + const SUBSCRIPTION_SCHEDULE_UPDATED = 'subscription_schedule.updated'; + const TAX_RATE_CREATED = 'tax_rate.created'; + const TAX_RATE_UPDATED = 'tax_rate.updated'; + const TOPUP_CANCELED = 'topup.canceled'; + const TOPUP_CREATED = 'topup.created'; + const TOPUP_FAILED = 'topup.failed'; + const TOPUP_REVERSED = 'topup.reversed'; + const TOPUP_SUCCEEDED = 'topup.succeeded'; + const TRANSFER_CREATED = 'transfer.created'; + const TRANSFER_REVERSED = 'transfer.reversed'; + const TRANSFER_UPDATED = 'transfer.updated'; } diff --git a/lib/Exception/ApiConnectionException.php b/lib/Exception/ApiConnectionException.php index 880fc43d2..33f2ede9e 100644 --- a/lib/Exception/ApiConnectionException.php +++ b/lib/Exception/ApiConnectionException.php @@ -6,8 +6,6 @@ * ApiConnection is thrown in the event that the SDK can't connect to Stripe's * servers. That can be for a variety of different reasons from a downed * network to a bad TLS certificate. - * - * @package Stripe\Exception */ class ApiConnectionException extends ApiErrorException { diff --git a/lib/Exception/ApiErrorException.php b/lib/Exception/ApiErrorException.php index 30225a54a..995a42e69 100644 --- a/lib/Exception/ApiErrorException.php +++ b/lib/Exception/ApiErrorException.php @@ -18,12 +18,12 @@ abstract class ApiErrorException extends \Exception implements ExceptionInterfac /** * Creates a new API error exception. * - * @param string $message The exception message. - * @param int|null $httpStatus The HTTP status code. - * @param string|null $httpBody The HTTP body as a string. - * @param array|null $jsonBody The JSON deserialized body. - * @param array|\Stripe\Util\CaseInsensitiveArray|null $httpHeaders The HTTP headers array. - * @param string|null $stripeCode The Stripe error code. + * @param string $message the exception message + * @param null|int $httpStatus the HTTP status code + * @param null|string $httpBody the HTTP body as a string + * @param null|array $jsonBody the JSON deserialized body + * @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array + * @param null|string $stripeCode the Stripe error code * * @return static */ @@ -55,7 +55,7 @@ public static function factory( /** * Gets the Stripe error object. * - * @return \Stripe\ErrorObject|null + * @return null|\Stripe\ErrorObject */ public function getError() { @@ -65,7 +65,7 @@ public function getError() /** * Sets the Stripe error object. * - * @param \Stripe\ErrorObject|null $error + * @param null|\Stripe\ErrorObject $error */ public function setError($error) { @@ -75,7 +75,7 @@ public function setError($error) /** * Gets the HTTP body as a string. * - * @return string|null + * @return null|string */ public function getHttpBody() { @@ -85,7 +85,7 @@ public function getHttpBody() /** * Sets the HTTP body as a string. * - * @param string|null $httpBody + * @param null|string $httpBody */ public function setHttpBody($httpBody) { @@ -95,7 +95,7 @@ public function setHttpBody($httpBody) /** * Gets the HTTP headers array. * - * @return array|\Stripe\Util\CaseInsensitiveArray|null + * @return null|array|\Stripe\Util\CaseInsensitiveArray */ public function getHttpHeaders() { @@ -105,7 +105,7 @@ public function getHttpHeaders() /** * Sets the HTTP headers array. * - * @param array|\Stripe\Util\CaseInsensitiveArray|null $httpHeaders + * @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders */ public function setHttpHeaders($httpHeaders) { @@ -115,7 +115,7 @@ public function setHttpHeaders($httpHeaders) /** * Gets the HTTP status code. * - * @return int|null + * @return null|int */ public function getHttpStatus() { @@ -125,7 +125,7 @@ public function getHttpStatus() /** * Sets the HTTP status code. * - * @param int|null $httpStatus + * @param null|int $httpStatus */ public function setHttpStatus($httpStatus) { @@ -135,7 +135,7 @@ public function setHttpStatus($httpStatus) /** * Gets the JSON deserialized body. * - * @return array|null + * @return null|array */ public function getJsonBody() { @@ -145,7 +145,7 @@ public function getJsonBody() /** * Sets the JSON deserialized body. * - * @param array|null $jsonBody + * @param null|array $jsonBody */ public function setJsonBody($jsonBody) { @@ -155,7 +155,7 @@ public function setJsonBody($jsonBody) /** * Gets the Stripe request ID. * - * @return string|null + * @return null|string */ public function getRequestId() { @@ -165,7 +165,7 @@ public function getRequestId() /** * Sets the Stripe request ID. * - * @param string|null $requestId + * @param null|string $requestId */ public function setRequestId($requestId) { @@ -178,7 +178,7 @@ public function setRequestId($requestId) * Cf. the `CODE_*` constants on {@see \Stripe\ErrorObject} for possible * values. * - * @return string|null + * @return null|string */ public function getStripeCode() { @@ -188,7 +188,7 @@ public function getStripeCode() /** * Sets the Stripe error code. * - * @param string|null $stripeCode + * @param null|string $stripeCode */ public function setStripeCode($stripeCode) { @@ -202,8 +202,9 @@ public function setStripeCode($stripeCode) */ public function __toString() { - $statusStr = (null === $this->getHttpStatus()) ? "" : "(Status {$this->getHttpStatus()}) "; - $idStr = (null === $this->getRequestId()) ? "" : "(Request {$this->getRequestId()}) "; + $statusStr = (null === $this->getHttpStatus()) ? '' : "(Status {$this->getHttpStatus()}) "; + $idStr = (null === $this->getRequestId()) ? '' : "(Request {$this->getRequestId()}) "; + return "{$statusStr}{$idStr}{$this->getMessage()}"; } diff --git a/lib/Exception/AuthenticationException.php b/lib/Exception/AuthenticationException.php index dd9cbf827..9e5c718b1 100644 --- a/lib/Exception/AuthenticationException.php +++ b/lib/Exception/AuthenticationException.php @@ -5,8 +5,6 @@ /** * AuthenticationException is thrown when invalid credentials are used to * connect to Stripe's servers. - * - * @package Stripe\Exception */ class AuthenticationException extends ApiErrorException { diff --git a/lib/Exception/CardException.php b/lib/Exception/CardException.php index ad6216339..43df9c7b0 100644 --- a/lib/Exception/CardException.php +++ b/lib/Exception/CardException.php @@ -5,8 +5,6 @@ /** * CardException is thrown when a user enters a card that can't be charged for * some reason. - * - * @package Stripe\Exception */ class CardException extends ApiErrorException { @@ -16,14 +14,14 @@ class CardException extends ApiErrorException /** * Creates a new CardException exception. * - * @param string $message The exception message. - * @param int|null $httpStatus The HTTP status code. - * @param string|null $httpBody The HTTP body as a string. - * @param array|null $jsonBody The JSON deserialized body. - * @param array|\Stripe\Util\CaseInsensitiveArray|null $httpHeaders The HTTP headers array. - * @param string|null $stripeCode The Stripe error code. - * @param string|null $declineCode The decline code. - * @param string|null $stripeParam The parameter related to the error. + * @param string $message the exception message + * @param null|int $httpStatus the HTTP status code + * @param null|string $httpBody the HTTP body as a string + * @param null|array $jsonBody the JSON deserialized body + * @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array + * @param null|string $stripeCode the Stripe error code + * @param null|string $declineCode the decline code + * @param null|string $stripeParam the parameter related to the error * * @return CardException */ @@ -47,7 +45,7 @@ public static function factory( /** * Gets the decline code. * - * @return string|null + * @return null|string */ public function getDeclineCode() { @@ -57,7 +55,7 @@ public function getDeclineCode() /** * Sets the decline code. * - * @param string|null $declineCode + * @param null|string $declineCode */ public function setDeclineCode($declineCode) { @@ -67,7 +65,7 @@ public function setDeclineCode($declineCode) /** * Gets the parameter related to the error. * - * @return string|null + * @return null|string */ public function getStripeParam() { @@ -77,7 +75,7 @@ public function getStripeParam() /** * Sets the parameter related to the error. * - * @param string|null $stripeParam + * @param null|string $stripeParam */ public function setStripeParam($stripeParam) { diff --git a/lib/Exception/ExceptionInterface.php b/lib/Exception/ExceptionInterface.php index dd47fec38..c84f37de7 100644 --- a/lib/Exception/ExceptionInterface.php +++ b/lib/Exception/ExceptionInterface.php @@ -6,8 +6,6 @@ if (\interface_exists(\Throwable::class, false)) { /** * The base interface for all Stripe exceptions. - * - * @package Stripe\Exception */ interface ExceptionInterface extends \Throwable { @@ -15,8 +13,6 @@ interface ExceptionInterface extends \Throwable } else { /** * The base interface for all Stripe exceptions. - * - * @package Stripe\Exception */ // phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses interface ExceptionInterface diff --git a/lib/Exception/IdempotencyException.php b/lib/Exception/IdempotencyException.php index c184ecd07..09dbf07f7 100644 --- a/lib/Exception/IdempotencyException.php +++ b/lib/Exception/IdempotencyException.php @@ -5,8 +5,6 @@ /** * IdempotencyException is thrown in cases where an idempotency key was used * improperly. - * - * @package Stripe\Exception */ class IdempotencyException extends ApiErrorException { diff --git a/lib/Exception/InvalidRequestException.php b/lib/Exception/InvalidRequestException.php index aec090f8a..ed4f8d0d4 100644 --- a/lib/Exception/InvalidRequestException.php +++ b/lib/Exception/InvalidRequestException.php @@ -5,8 +5,6 @@ /** * InvalidRequestException is thrown when a request is initiated with invalid * parameters. - * - * @package Stripe\Exception */ class InvalidRequestException extends ApiErrorException { @@ -15,13 +13,13 @@ class InvalidRequestException extends ApiErrorException /** * Creates a new InvalidRequestException exception. * - * @param string $message The exception message. - * @param int|null $httpStatus The HTTP status code. - * @param string|null $httpBody The HTTP body as a string. - * @param array|null $jsonBody The JSON deserialized body. - * @param array|\Stripe\Util\CaseInsensitiveArray|null $httpHeaders The HTTP headers array. - * @param string|null $stripeCode The Stripe error code. - * @param string|null $stripeParam The parameter related to the error. + * @param string $message the exception message + * @param null|int $httpStatus the HTTP status code + * @param null|string $httpBody the HTTP body as a string + * @param null|array $jsonBody the JSON deserialized body + * @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array + * @param null|string $stripeCode the Stripe error code + * @param null|string $stripeParam the parameter related to the error * * @return InvalidRequestException */ @@ -43,7 +41,7 @@ public static function factory( /** * Gets the parameter related to the error. * - * @return string|null + * @return null|string */ public function getStripeParam() { @@ -53,7 +51,7 @@ public function getStripeParam() /** * Sets the parameter related to the error. * - * @param string|null $stripeParam + * @param null|string $stripeParam */ public function setStripeParam($stripeParam) { diff --git a/lib/Exception/OAuth/InvalidClientException.php b/lib/Exception/OAuth/InvalidClientException.php index 603369c2d..139345197 100644 --- a/lib/Exception/OAuth/InvalidClientException.php +++ b/lib/Exception/OAuth/InvalidClientException.php @@ -6,8 +6,6 @@ * InvalidClientException is thrown when the client_id does not belong to you, * the stripe_user_id does not exist or is not connected to your application, * or the API key mode (live or test mode) does not match the client_id mode. - * - * @package Stripe\Exception\OAuth */ class InvalidClientException extends OAuthErrorException { diff --git a/lib/Exception/OAuth/InvalidGrantException.php b/lib/Exception/OAuth/InvalidGrantException.php index 6fcd3b05b..898b3a776 100644 --- a/lib/Exception/OAuth/InvalidGrantException.php +++ b/lib/Exception/OAuth/InvalidGrantException.php @@ -7,8 +7,6 @@ * expired, has been used, or doesn't belong to you; a refresh token doesn't * exist, or doesn't belong to you; or if an API key's mode (live or test) * doesn't match the mode of a code or refresh token. - * - * @package Stripe\Exception\OAuth */ class InvalidGrantException extends OAuthErrorException { diff --git a/lib/Exception/OAuth/InvalidRequestException.php b/lib/Exception/OAuth/InvalidRequestException.php index 45422c0be..59dac7c0f 100644 --- a/lib/Exception/OAuth/InvalidRequestException.php +++ b/lib/Exception/OAuth/InvalidRequestException.php @@ -5,8 +5,6 @@ /** * InvalidRequestException is thrown when a code, refresh token, or grant * type parameter is not provided, but was required. - * - * @package Stripe\Exception\OAuth */ class InvalidRequestException extends OAuthErrorException { diff --git a/lib/Exception/OAuth/InvalidScopeException.php b/lib/Exception/OAuth/InvalidScopeException.php index 7b64e094e..091729d93 100644 --- a/lib/Exception/OAuth/InvalidScopeException.php +++ b/lib/Exception/OAuth/InvalidScopeException.php @@ -4,8 +4,6 @@ /** * InvalidScopeException is thrown when an invalid scope parameter is provided. - * - * @package Stripe\Exception\OAuth */ class InvalidScopeException extends OAuthErrorException { diff --git a/lib/Exception/OAuth/UnknownOAuthErrorException.php b/lib/Exception/OAuth/UnknownOAuthErrorException.php index 90195b4e2..c8dba29bf 100644 --- a/lib/Exception/OAuth/UnknownOAuthErrorException.php +++ b/lib/Exception/OAuth/UnknownOAuthErrorException.php @@ -6,8 +6,6 @@ * UnknownApiErrorException is thrown when the client library receives an * error from the OAuth API it doesn't know about. Receiving this error usually * means that your client library is outdated and should be upgraded. - * - * @package Stripe\Exception */ class UnknownOAuthErrorException extends OAuthErrorException { diff --git a/lib/Exception/OAuth/UnsupportedGrantTypeException.php b/lib/Exception/OAuth/UnsupportedGrantTypeException.php index 004c932e8..418635d44 100644 --- a/lib/Exception/OAuth/UnsupportedGrantTypeException.php +++ b/lib/Exception/OAuth/UnsupportedGrantTypeException.php @@ -5,8 +5,6 @@ /** * UnsupportedGrantTypeException is thrown when an unuspported grant type * parameter is specified. - * - * @package Stripe\Exception\OAuth */ class UnsupportedGrantTypeException extends OAuthErrorException { diff --git a/lib/Exception/OAuth/UnsupportedResponseTypeException.php b/lib/Exception/OAuth/UnsupportedResponseTypeException.php index 456193ace..26742a806 100644 --- a/lib/Exception/OAuth/UnsupportedResponseTypeException.php +++ b/lib/Exception/OAuth/UnsupportedResponseTypeException.php @@ -5,8 +5,6 @@ /** * UnsupportedResponseTypeException is thrown when an unsupported response type * parameter is specified. - * - * @package Stripe\Exception\OAuth */ class UnsupportedResponseTypeException extends OAuthErrorException { diff --git a/lib/Exception/PermissionException.php b/lib/Exception/PermissionException.php index 4582f22e4..5cf5154bf 100644 --- a/lib/Exception/PermissionException.php +++ b/lib/Exception/PermissionException.php @@ -5,8 +5,6 @@ /** * PermissionException is thrown in cases where access was attempted on a * resource that wasn't allowed. - * - * @package Stripe\Exception */ class PermissionException extends ApiErrorException { diff --git a/lib/Exception/RateLimitException.php b/lib/Exception/RateLimitException.php index 21fdd9ad6..f28f450fd 100644 --- a/lib/Exception/RateLimitException.php +++ b/lib/Exception/RateLimitException.php @@ -6,8 +6,6 @@ * RateLimitException is thrown in cases where an account is putting too much * load on Stripe's API servers (usually by performing too many requests). * Please back off on request rate. - * - * @package Stripe\Exception */ class RateLimitException extends InvalidRequestException { diff --git a/lib/Exception/SignatureVerificationException.php b/lib/Exception/SignatureVerificationException.php index bd1a06cf0..b08534a8f 100644 --- a/lib/Exception/SignatureVerificationException.php +++ b/lib/Exception/SignatureVerificationException.php @@ -5,8 +5,6 @@ /** * SignatureVerificationException is thrown when the signature verification for * a webhook fails. - * - * @package Stripe\Exception */ class SignatureVerificationException extends \Exception implements ExceptionInterface { @@ -16,9 +14,9 @@ class SignatureVerificationException extends \Exception implements ExceptionInte /** * Creates a new SignatureVerificationException exception. * - * @param string $message The exception message. - * @param string|null $httpBody The HTTP body as a string. - * @param string|null $sigHeader The `Stripe-Signature` HTTP header. + * @param string $message the exception message + * @param null|string $httpBody the HTTP body as a string + * @param null|string $sigHeader the `Stripe-Signature` HTTP header * * @return SignatureVerificationException */ @@ -37,7 +35,7 @@ public static function factory( /** * Gets the HTTP body as a string. * - * @return string|null + * @return null|string */ public function getHttpBody() { @@ -47,7 +45,7 @@ public function getHttpBody() /** * Sets the HTTP body as a string. * - * @param string|null $httpBody + * @param null|string $httpBody */ public function setHttpBody($httpBody) { @@ -57,7 +55,7 @@ public function setHttpBody($httpBody) /** * Gets the `Stripe-Signature` HTTP header. * - * @return string|null + * @return null|string */ public function getSigHeader() { @@ -67,7 +65,7 @@ public function getSigHeader() /** * Sets the `Stripe-Signature` HTTP header. * - * @param string|null $sigHeader + * @param null|string $sigHeader */ public function setSigHeader($sigHeader) { diff --git a/lib/Exception/UnknownApiErrorException.php b/lib/Exception/UnknownApiErrorException.php index bfa1c6cee..7873bf8b6 100644 --- a/lib/Exception/UnknownApiErrorException.php +++ b/lib/Exception/UnknownApiErrorException.php @@ -6,8 +6,6 @@ * UnknownApiErrorException is thrown when the client library receives an * error from the API it doesn't know about. Receiving this error usually * means that your client library is outdated and should be upgraded. - * - * @package Stripe\Exception */ class UnknownApiErrorException extends ApiErrorException { diff --git a/lib/ExchangeRate.php b/lib/ExchangeRate.php index 003a27c5b..39482b48e 100644 --- a/lib/ExchangeRate.php +++ b/lib/ExchangeRate.php @@ -3,13 +3,11 @@ namespace Stripe; /** - * Class ExchangeRate + * Class ExchangeRate. * * @property string $id Unique identifier for the object. Represented as the three-letter ISO currency code in lowercase. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property \Stripe\StripeObject $rates Hash where the keys are supported currencies and the values are the exchange rate at which the base id currency converts to the key currency. - * - * @package Stripe */ class ExchangeRate extends ApiResource { diff --git a/lib/File.php b/lib/File.php index 1a81142c6..c85f58c67 100644 --- a/lib/File.php +++ b/lib/File.php @@ -3,20 +3,18 @@ namespace Stripe; /** - * Class File + * Class File. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $filename A filename for the file, suitable for saving to a filesystem. - * @property \Stripe\Collection|null $links A list of file links that point at this file. + * @property null|string $filename A filename for the file, suitable for saving to a filesystem. + * @property null|\Stripe\Collection $links A list of file links that point at this file. * @property string $purpose The purpose of the file. Possible values are additional_verification, business_icon, business_logo, customer_signature, dispute_evidence, finance_report_run, identity_document, pci_document, sigma_scheduled_query, or tax_document_user_upload. * @property int $size The size in bytes of the file object. - * @property string|null $title A user friendly title for the document. - * @property string|null $type The type of the file returned (e.g., csv, pdf, jpg, or png). - * @property string|null $url The URL from which the file can be downloaded using your live secret API key. - * - * @package Stripe + * @property null|string $title A user friendly title for the document. + * @property null|string $type The type of the file returned (e.g., csv, pdf, jpg, or png). + * @property null|string $url The URL from which the file can be downloaded using your live secret API key. */ class File extends ApiResource { @@ -41,12 +39,12 @@ public static function classUrl() } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\File The created resource. + * @return \Stripe\File the created file */ public static function create($params = null, $opts = null) { @@ -57,6 +55,7 @@ public static function create($params = null, $opts = null) // Manually flatten params, otherwise curl's multipart encoder will // choke on nested arrays. $flatParams = \array_column(\Stripe\Util\Util::flattenParams($params), 1, 0); + return static::_create($flatParams, $opts); } } diff --git a/lib/FileLink.php b/lib/FileLink.php index 7b6c9e551..7da35fade 100644 --- a/lib/FileLink.php +++ b/lib/FileLink.php @@ -3,19 +3,17 @@ namespace Stripe; /** - * Class FileLink + * Class FileLink. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property bool $expired Whether this link is already expired. - * @property int|null $expires_at Time at which the link expires. + * @property null|int $expires_at Time at which the link expires. * @property string|\Stripe\File $file The file object this link points to. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $url The publicly accessible URL to download the file. - * - * @package Stripe + * @property null|string $url The publicly accessible URL to download the file. */ class FileLink extends ApiResource { diff --git a/lib/HttpClient/ClientInterface.php b/lib/HttpClient/ClientInterface.php index ec4ef3a6b..3c7861e59 100644 --- a/lib/HttpClient/ClientInterface.php +++ b/lib/HttpClient/ClientInterface.php @@ -15,8 +15,8 @@ interface ClientInterface * @throws \Stripe\Exception\ApiConnectionException * @throws \Stripe\Exception\UnexpectedValueException * - * @return array An array whose first element is raw request body, second - * element is HTTP status code and third array of HTTP headers. + * @return array an array whose first element is raw request body, second + * element is HTTP status code and third array of HTTP headers */ public function request($method, $absUrl, $headers, $params, $hasFile); } diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index 8e5d2a6e0..1f9f0d5e2 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -33,6 +33,7 @@ public static function instance() if (!self::$instance) { self::$instance = new self(); } + return self::$instance; } @@ -62,8 +63,8 @@ public static function instance() * Note that request() will silently ignore a non-callable, non-array $defaultOptions, and will * throw an exception if $defaultOptions returns a non-array value. * - * @param array|callable|null $defaultOptions - * @param \Stripe\Util\RandomGenerator|null $randomGenerator + * @param null|array|callable $defaultOptions + * @param null|\Stripe\Util\RandomGenerator $randomGenerator */ public function __construct($defaultOptions = null, $randomGenerator = null) { @@ -83,7 +84,7 @@ public function initUserAgentInfo() { $curlVersion = \curl_version(); $this->userAgentInfo = [ - 'httplib' => 'curl ' . $curlVersion['version'], + 'httplib' => 'curl ' . $curlVersion['version'], 'ssllib' => $curlVersion['ssl_version'], ]; } @@ -131,7 +132,7 @@ public function setEnableHttp2($enable) } /** - * @return callable|null + * @return null|callable */ public function getRequestStatusCallback() { @@ -141,16 +142,17 @@ public function getRequestStatusCallback() /** * Sets a callback that is called after each request. The callback will * receive the following parameters: + *
    + *
  1. string $rbody The response body
  2. + *
  3. integer $rcode The response status code
  4. + *
  5. \Stripe\Util\CaseInsensitiveArray $rheaders The response headers
  6. + *
  7. integer $errno The curl error number
  8. + *
  9. string|null $message The curl error message
  10. + *
  11. boolean $shouldRetry Whether the request will be retried
  12. + *
  13. integer $numRetries The number of the retry attempt
  14. + *
. * - * 1. string $rbody The response body - * 2. integer $rcode The response status code - * 3. \Stripe\Util\CaseInsensitiveArray $rheaders The response headers - * 4. integer $errno The curl error number - * 5. string|null $message The curl error message - * 6. boolean $shouldRetry Whether the request will be retried - * 7. integer $numRetries The number of the retry attempt - * - * @param callable|null $requestStatusCallback + * @param null|callable $requestStatusCallback */ public function setRequestStatusCallback($requestStatusCallback) { @@ -168,12 +170,14 @@ public function setRequestStatusCallback($requestStatusCallback) public function setTimeout($seconds) { $this->timeout = (int) \max($seconds, 0); + return $this; } public function setConnectTimeout($seconds) { $this->connectTimeout = (int) \max($seconds, 0); + return $this; } @@ -197,7 +201,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) if (\is_callable($this->defaultOptions)) { // call defaultOptions callback, set options to return value $opts = \call_user_func_array($this->defaultOptions, \func_get_args()); if (!\is_array($opts)) { - throw new Exception\UnexpectedValueException("Non-array value returned by defaultOptions CurlClient callback"); + throw new Exception\UnexpectedValueException('Non-array value returned by defaultOptions CurlClient callback'); } } elseif (\is_array($this->defaultOptions)) { // set default curlopts from array $opts = $this->defaultOptions; @@ -208,7 +212,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) if ('get' === $method) { if ($hasFile) { throw new Exception\UnexpectedValueException( - "Issuing a GET request with a file parameter" + 'Issuing a GET request with a file parameter' ); } $opts[\CURLOPT_HTTPGET] = 1; @@ -232,7 +236,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) // It is only safe to retry network failures on POST requests if we // add an Idempotency-Key header if (('post' === $method) && (Stripe::$maxNetworkRetries > 0)) { - if (!$this->hasHeader($headers, "Idempotency-Key")) { + if (!$this->hasHeader($headers, 'Idempotency-Key')) { \array_push($headers, 'Idempotency-Key: ' . $this->randomGenerator->uuid()); } } @@ -290,11 +294,12 @@ private function executeRequestWithRetries($opts, $absUrl) $rheaders = new Util\CaseInsensitiveArray(); $headerCallback = function ($curl, $header_line) use (&$rheaders) { // Ignore the HTTP request line (HTTP/1.1 200 OK) - if (false === \strpos($header_line, ":")) { + if (false === \strpos($header_line, ':')) { return \strlen($header_line); } - list($key, $value) = \explode(":", \trim($header_line), 2); + list($key, $value) = \explode(':', \trim($header_line), 2); $rheaders[\trim($key)] = \trim($value); + return \strlen($header_line); }; $opts[\CURLOPT_HEADERFUNCTION] = $headerCallback; @@ -353,22 +358,24 @@ private function handleCurlError($url, $errno, $message, $numRetries) case \CURLE_COULDNT_RESOLVE_HOST: case \CURLE_OPERATION_TIMEOUTED: $msg = "Could not connect to Stripe ({$url}). Please check your " - . "internet connection and try again. If this problem persists, " + . 'internet connection and try again. If this problem persists, ' . "you should check Stripe's service status at " - . "https://twitter.com/stripestatus, or"; + . 'https://twitter.com/stripestatus, or'; + break; case \CURLE_SSL_CACERT: case \CURLE_SSL_PEER_CERTIFICATE: $msg = "Could not verify Stripe's SSL certificate. Please make sure " - . "that your network is not intercepting certificates. " + . 'that your network is not intercepting certificates. ' . "(Try going to {$url} in your browser.) " - . "If this problem persists,"; + . 'If this problem persists,'; + break; default: - $msg = "Unexpected error communicating with Stripe. " - . "If this problem persists,"; + $msg = 'Unexpected error communicating with Stripe. ' + . 'If this problem persists,'; } - $msg .= " let us know at support@stripe.com."; + $msg .= ' let us know at support@stripe.com.'; $msg .= "\n\n(Network error [errno {$errno}]: {$message})"; @@ -514,6 +521,7 @@ private function canSafelyUseHttp2() // Versions of curl older than 7.60.0 don't respect GOAWAY frames // (cf. https://github.com/curl/curl/issues/2416), which Stripe use. $curlVersion = \curl_version()['version']; + return \version_compare($curlVersion, '7.60.0') >= 0; } diff --git a/lib/Invoice.php b/lib/Invoice.php index beb4f0ec1..8d787f709 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -3,70 +3,68 @@ namespace Stripe; /** - * Class Invoice + * Class Invoice. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|null $account_country The country of the business associated with this invoice, most often the business creating the invoice. - * @property string|null $account_name The public name of the business associated with this invoice, most often the business creating the invoice. + * @property null|string $account_country The country of the business associated with this invoice, most often the business creating the invoice. + * @property null|string $account_name The public name of the business associated with this invoice, most often the business creating the invoice. * @property int $amount_due Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the amount_due may be 0. If there is a positive starting_balance for the invoice (the customer owes money), the amount_due will also take that into account. The charge that gets generated for the invoice will be for the amount specified in amount_due. * @property int $amount_paid The amount, in %s, that was paid. * @property int $amount_remaining The amount remaining, in %s, that is due. - * @property int|null $application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid. + * @property null|int $application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid. * @property int $attempt_count Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule. * @property bool $attempted Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the invoice.created webhook, for example, so you might not want to display that invoice as unpaid to your users. * @property bool $auto_advance Controls whether Stripe will perform automatic collection of the invoice. When false, the invoice's state will not automatically advance without an explicit action. - * @property string|null $billing_reason Indicates the reason why the invoice was created. subscription_cycle indicates an invoice created by a subscription advancing into a new period. subscription_create indicates an invoice created due to creating a subscription. subscription_update indicates an invoice created due to updating a subscription. subscription is set for all old invoices to indicate either a change to a subscription or a period advancement. manual is set for all invoices unrelated to a subscription (for example: created via the invoice editor). The upcoming value is reserved for simulated invoices per the upcoming invoice endpoint. subscription_threshold indicates an invoice created due to a billing threshold being reached. - * @property string|\Stripe\Charge|null $charge ID of the latest charge generated for this invoice, if any. - * @property string|null $collection_method Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions. + * @property null|string $billing_reason Indicates the reason why the invoice was created. subscription_cycle indicates an invoice created by a subscription advancing into a new period. subscription_create indicates an invoice created due to creating a subscription. subscription_update indicates an invoice created due to updating a subscription. subscription is set for all old invoices to indicate either a change to a subscription or a period advancement. manual is set for all invoices unrelated to a subscription (for example: created via the invoice editor). The upcoming value is reserved for simulated invoices per the upcoming invoice endpoint. subscription_threshold indicates an invoice created due to a billing threshold being reached. + * @property null|string|\Stripe\Charge $charge ID of the latest charge generated for this invoice, if any. + * @property null|string $collection_method Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property \Stripe\StripeObject[]|null $custom_fields Custom fields displayed on the invoice. + * @property null|\Stripe\StripeObject[] $custom_fields Custom fields displayed on the invoice. * @property string|\Stripe\Customer $customer The ID of the customer who will be billed. - * @property \Stripe\StripeObject|null $customer_address The customer's address. Until the invoice is finalized, this field will equal customer.address. Once the invoice is finalized, this field will no longer be updated. - * @property string|null $customer_email The customer's email. Until the invoice is finalized, this field will equal customer.email. Once the invoice is finalized, this field will no longer be updated. - * @property string|null $customer_name The customer's name. Until the invoice is finalized, this field will equal customer.name. Once the invoice is finalized, this field will no longer be updated. - * @property string|null $customer_phone The customer's phone number. Until the invoice is finalized, this field will equal customer.phone. Once the invoice is finalized, this field will no longer be updated. - * @property \Stripe\StripeObject|null $customer_shipping The customer's shipping information. Until the invoice is finalized, this field will equal customer.shipping. Once the invoice is finalized, this field will no longer be updated. - * @property string|null $customer_tax_exempt The customer's tax exempt status. Until the invoice is finalized, this field will equal customer.tax_exempt. Once the invoice is finalized, this field will no longer be updated. - * @property \Stripe\StripeObject[]|null $customer_tax_ids The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as customer.tax_ids. Once the invoice is finalized, this field will no longer be updated. - * @property string|\Stripe\PaymentMethod|null $default_payment_method ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings. - * @property string|\Stripe\StripeObject|null $default_source ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source. - * @property \Stripe\TaxRate[]|null $default_tax_rates The tax rates applied to this invoice, if any. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard. - * @property \Stripe\Discount|null $discount Describes the current discount applied to this invoice, if there is one. - * @property int|null $due_date The date on which payment for this invoice is due. This value will be null for invoices where collection_method=charge_automatically. - * @property int|null $ending_balance Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null. - * @property string|null $footer Footer displayed on the invoice. - * @property string|null $hosted_invoice_url The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null. - * @property string|null $invoice_pdf The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null. + * @property null|\Stripe\StripeObject $customer_address The customer's address. Until the invoice is finalized, this field will equal customer.address. Once the invoice is finalized, this field will no longer be updated. + * @property null|string $customer_email The customer's email. Until the invoice is finalized, this field will equal customer.email. Once the invoice is finalized, this field will no longer be updated. + * @property null|string $customer_name The customer's name. Until the invoice is finalized, this field will equal customer.name. Once the invoice is finalized, this field will no longer be updated. + * @property null|string $customer_phone The customer's phone number. Until the invoice is finalized, this field will equal customer.phone. Once the invoice is finalized, this field will no longer be updated. + * @property null|\Stripe\StripeObject $customer_shipping The customer's shipping information. Until the invoice is finalized, this field will equal customer.shipping. Once the invoice is finalized, this field will no longer be updated. + * @property null|string $customer_tax_exempt The customer's tax exempt status. Until the invoice is finalized, this field will equal customer.tax_exempt. Once the invoice is finalized, this field will no longer be updated. + * @property null|\Stripe\StripeObject[] $customer_tax_ids The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as customer.tax_ids. Once the invoice is finalized, this field will no longer be updated. + * @property null|string|\Stripe\PaymentMethod $default_payment_method ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings. + * @property null|string|\Stripe\StripeObject $default_source ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source. + * @property null|\Stripe\TaxRate[] $default_tax_rates The tax rates applied to this invoice, if any. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard. + * @property null|\Stripe\Discount $discount Describes the current discount applied to this invoice, if there is one. + * @property null|int $due_date The date on which payment for this invoice is due. This value will be null for invoices where collection_method=charge_automatically. + * @property null|int $ending_balance Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null. + * @property null|string $footer Footer displayed on the invoice. + * @property null|string $hosted_invoice_url The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null. + * @property null|string $invoice_pdf The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null. * @property \Stripe\Collection $lines The individual line items that make up the invoice. lines is sorted as follows: invoice items in reverse chronological order, followed by the subscription, if any. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property \Stripe\StripeObject|null $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property int|null $next_payment_attempt The time at which payment will next be attempted. This value will be null for invoices where collection_method=send_invoice. - * @property string|null $number A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified. + * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + * @property null|int $next_payment_attempt The time at which payment will next be attempted. This value will be null for invoices where collection_method=send_invoice. + * @property null|string $number A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified. * @property bool $paid Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer's account balance. - * @property string|\Stripe\PaymentIntent|null $payment_intent The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent. + * @property null|string|\Stripe\PaymentIntent $payment_intent The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent. * @property int $period_end End of the usage period during which invoice items were added to this invoice. * @property int $period_start Start of the usage period during which invoice items were added to this invoice. * @property int $post_payment_credit_notes_amount Total amount of all post-payment credit notes issued for this invoice. * @property int $pre_payment_credit_notes_amount Total amount of all pre-payment credit notes issued for this invoice. - * @property string|null $receipt_number This is the transaction number that appears on email receipts sent for this invoice. + * @property null|string $receipt_number This is the transaction number that appears on email receipts sent for this invoice. * @property int $starting_balance Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. - * @property string|null $statement_descriptor Extra information about an invoice for the customer's credit card statement. - * @property string|null $status The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more + * @property null|string $statement_descriptor Extra information about an invoice for the customer's credit card statement. + * @property null|string $status The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more * @property \Stripe\StripeObject $status_transitions - * @property string|\Stripe\Subscription|null $subscription The subscription that this invoice was prepared for, if any. + * @property null|string|\Stripe\Subscription $subscription The subscription that this invoice was prepared for, if any. * @property int $subscription_proration_date Only set for upcoming invoices that preview prorations. The time used to calculate prorations. * @property int $subtotal Total of all subscriptions, invoice items, and prorations on the invoice before any discount or tax is applied. - * @property int|null $tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice. - * @property float|null $tax_percent This percentage of the subtotal has been added to the total amount of the invoice, including invoice line items and discounts. This field is inherited from the subscription's tax_percent field, but can be changed before the invoice is paid. This field defaults to null. + * @property null|int $tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice. + * @property null|float $tax_percent This percentage of the subtotal has been added to the total amount of the invoice, including invoice line items and discounts. This field is inherited from the subscription's tax_percent field, but can be changed before the invoice is paid. This field defaults to null. * @property \Stripe\StripeObject $threshold_reason * @property int $total Total after discounts and taxes. - * @property \Stripe\StripeObject[]|null $total_tax_amounts The aggregate amounts calculated per tax rate for all line items. - * @property int|null $webhooks_delivered_at The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to deliver, this will match created). Invoice payment is delayed until webhooks are delivered, or until all webhook delivery attempts have been exhausted. - * - * @package Stripe + * @property null|\Stripe\StripeObject[] $total_tax_amounts The aggregate amounts calculated per tax rate for all line items. + * @property null|int $webhooks_delivered_at The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to deliver, this will match created). Invoice payment is delayed until webhooks are delivered, or until all webhook delivery attempts have been exhausted. */ class Invoice extends ApiResource { @@ -85,13 +83,13 @@ class Invoice extends ApiResource * * @see https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason */ - const BILLING_REASON_MANUAL = 'manual'; - const BILLING_REASON_SUBSCRIPTION = 'subscription'; - const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create'; - const BILLING_REASON_SUBSCRIPTION_CYCLE = 'subscription_cycle'; + const BILLING_REASON_MANUAL = 'manual'; + const BILLING_REASON_SUBSCRIPTION = 'subscription'; + const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create'; + const BILLING_REASON_SUBSCRIPTION_CYCLE = 'subscription_cycle'; const BILLING_REASON_SUBSCRIPTION_THRESHOLD = 'subscription_threshold'; - const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update'; - const BILLING_REASON_UPCOMING = 'upcoming'; + const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update'; + const BILLING_REASON_UPCOMING = 'upcoming'; /** * Possible string representations of the `collection_method` property. @@ -99,37 +97,37 @@ class Invoice extends ApiResource * @see https://stripe.com/docs/api/invoices/object#invoice_object-collection_method */ const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically'; - const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice'; + const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice'; /** * Possible string representations of the invoice status. * * @see https://stripe.com/docs/api/invoices/object#invoice_object-status */ - const STATUS_DRAFT = 'draft'; - const STATUS_OPEN = 'open'; - const STATUS_PAID = 'paid'; + const STATUS_DRAFT = 'draft'; + const STATUS_OPEN = 'open'; + const STATUS_PAID = 'paid'; const STATUS_UNCOLLECTIBLE = 'uncollectible'; - const STATUS_VOID = 'void'; + const STATUS_VOID = 'void'; /** * Possible string representations of the `billing` property. * - * @deprecated Use `collection_method` instead. + * @deprecated use `collection_method` instead * @see https://stripe.com/docs/api/invoices/object#invoice_object-billing */ const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically'; - const BILLING_SEND_INVOICE = 'send_invoice'; + const BILLING_SEND_INVOICE = 'send_invoice'; const PATH_LINES = '/lines'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Invoice The upcoming invoice. + * @return \Stripe\Invoice the upcoming invoice */ public static function upcoming($params = null, $opts = null) { @@ -137,17 +135,18 @@ public static function upcoming($params = null, $opts = null) list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); $obj = Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); + return $obj; } /** - * @param string $id The ID of the invoice on which to retrieve the lines. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the invoice on which to retrieve the lines + * @param null|array $params + * @param null|array|string $opts * * @throws StripeExceptionApiErrorException if the request fails * - * @return \Stripe\Collection The list of lines (InvoiceLineItem). + * @return \Stripe\Collection the list of lines (InvoiceLineItem) */ public static function allLines($id, $params = null, $opts = null) { @@ -155,82 +154,87 @@ public static function allLines($id, $params = null, $opts = null) } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Invoice The finalized invoice. + * @return Invoice the finalized invoice */ public function finalizeInvoice($params = null, $opts = null) { $url = $this->instanceUrl() . '/finalize'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Invoice The uncollectible invoice. + * @return Invoice the uncollectible invoice */ public function markUncollectible($params = null, $opts = null) { $url = $this->instanceUrl() . '/mark_uncollectible'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Invoice The paid invoice. + * @return Invoice the paid invoice */ public function pay($params = null, $opts = null) { $url = $this->instanceUrl() . '/pay'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Invoice The sent invoice. + * @return Invoice the sent invoice */ public function sendInvoice($params = null, $opts = null) { $url = $this->instanceUrl() . '/send'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Invoice The voided invoice. + * @return Invoice the voided invoice */ public function voidInvoice($params = null, $opts = null) { $url = $this->instanceUrl() . '/void'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/InvoiceItem.php b/lib/InvoiceItem.php index 7da70a0aa..553443dd3 100644 --- a/lib/InvoiceItem.php +++ b/lib/InvoiceItem.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class InvoiceItem + * Class InvoiceItem. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,23 +11,21 @@ * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property string|\Stripe\Customer $customer The ID of the customer who will be billed when this invoice item is billed. * @property int $date Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. * @property bool $discountable If true, discounts will apply to this invoice item. Always false for prorations. - * @property string|\Stripe\Invoice|null $invoice The ID of the invoice this invoice item belongs to. + * @property null|string|\Stripe\Invoice $invoice The ID of the invoice this invoice item belongs to. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\StripeObject $period - * @property \Stripe\Plan|null $plan If the invoice item is a proration, the plan of the subscription that the proration was computed for. + * @property null|\Stripe\Plan $plan If the invoice item is a proration, the plan of the subscription that the proration was computed for. * @property bool $proration Whether the invoice item was created automatically as a proration adjustment when the customer switched plans. * @property int $quantity Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for. - * @property string|\Stripe\Subscription|null $subscription The subscription that this invoice item has been created for, if any. + * @property null|string|\Stripe\Subscription $subscription The subscription that this invoice item has been created for, if any. * @property string $subscription_item The subscription item that this invoice item has been created for, if any. - * @property \Stripe\TaxRate[]|null $tax_rates The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item. + * @property null|\Stripe\TaxRate[] $tax_rates The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item. * @property bool $unified_proration For prorations this indicates whether Stripe automatically grouped multiple related debit and credit line items into a single combined line item. - * @property int|null $unit_amount Unit Amount (in the currency specified) of the invoice item. - * @property string|null $unit_amount_decimal Same as unit_amount, but contains a decimal value with at most 12 decimal places. - * - * @package Stripe + * @property null|int $unit_amount Unit Amount (in the currency specified) of the invoice item. + * @property null|string $unit_amount_decimal Same as unit_amount, but contains a decimal value with at most 12 decimal places. */ class InvoiceItem extends ApiResource { diff --git a/lib/InvoiceLineItem.php b/lib/InvoiceLineItem.php index ddb8cb8f3..6da4e871f 100644 --- a/lib/InvoiceLineItem.php +++ b/lib/InvoiceLineItem.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class InvoiceLineItem + * Class InvoiceLineItem. * * @property string $id * @property string $object @@ -23,8 +23,6 @@ * @property array $tax_amounts * @property array $tax_rates * @property string $type - * - * @package Stripe */ class InvoiceLineItem extends ApiResource { diff --git a/lib/Issuing/Authorization.php b/lib/Issuing/Authorization.php index 83261b194..50ac53395 100644 --- a/lib/Issuing/Authorization.php +++ b/lib/Issuing/Authorization.php @@ -3,7 +3,7 @@ namespace Stripe\Issuing; /** - * Class Authorization + * Class Authorization. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -13,7 +13,7 @@ * @property string $authorized_currency The currency that was presented to the cardholder for the authorization. Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property \Stripe\BalanceTransaction[] $balance_transactions List of balance transactions associated with this authorization. * @property \Stripe\Issuing\Card $card - * @property string|\Stripe\Issuing\Cardholder|null $cardholder The cardholder to whom this authorization belongs. + * @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this authorization belongs. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property int $held_amount The amount the authorization is expected to be in held_currency. When Stripe holds funds from you, this is the amount reserved for the authorization. This will be 0 when the object is created, and increase after it has been approved. For multi-currency transactions, held_amount can be used to determine the expected exchange rate. * @property string $held_currency The currency of the held amount. This will always be the card currency. @@ -27,9 +27,7 @@ * @property string $status The current status of the authorization in its lifecycle. * @property \Stripe\Issuing\Transaction[] $transactions List of transactions associated with this authorization. * @property \Stripe\StripeObject $verification_data - * @property string|null $wallet_provider What, if any, digital wallet was used for this authorization. One of apple_pay, google_pay, or samsung_pay. - * - * @package Stripe\Issuing + * @property null|string $wallet_provider What, if any, digital wallet was used for this authorization. One of apple_pay, google_pay, or samsung_pay. */ class Authorization extends \Stripe\ApiResource { @@ -40,34 +38,36 @@ class Authorization extends \Stripe\ApiResource use \Stripe\ApiOperations\Update; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Authorization The approved authorization. + * @return Authorization the approved authorization */ public function approve($params = null, $opts = null) { $url = $this->instanceUrl() . '/approve'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Authorization The declined authorization. + * @return Authorization the declined authorization */ public function decline($params = null, $opts = null) { $url = $this->instanceUrl() . '/decline'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/Issuing/Card.php b/lib/Issuing/Card.php index 452330e9f..dc775a79b 100644 --- a/lib/Issuing/Card.php +++ b/lib/Issuing/Card.php @@ -3,13 +3,13 @@ namespace Stripe\Issuing; /** - * Class Card + * Class Card. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property \Stripe\StripeObject $authorization_controls * @property string $brand The brand of the card. - * @property \Stripe\Issuing\Cardholder|null $cardholder The Cardholder object to which the card belongs. + * @property null|\Stripe\Issuing\Cardholder $cardholder The Cardholder object to which the card belongs. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property int $exp_month The expiration month of the card. @@ -18,14 +18,12 @@ * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $name The name of the cardholder, printed on the card. - * @property \Stripe\StripeObject|null $pin Metadata about the PIN on the card. - * @property string|\Stripe\Issuing\Card|null $replacement_for The card this card replaces, if any. - * @property string|null $replacement_reason The reason why the previous card needed to be replaced. - * @property \Stripe\StripeObject|null $shipping Where and how the card will be shipped. + * @property null|\Stripe\StripeObject $pin Metadata about the PIN on the card. + * @property null|string|\Stripe\Issuing\Card $replacement_for The card this card replaces, if any. + * @property null|string $replacement_reason The reason why the previous card needed to be replaced. + * @property null|\Stripe\StripeObject $shipping Where and how the card will be shipped. * @property string $status Whether authorizations can be approved on this card. * @property string $type The type of the card. - * - * @package Stripe\Issuing */ class Card extends \Stripe\ApiResource { @@ -37,12 +35,12 @@ class Card extends \Stripe\ApiResource use \Stripe\ApiOperations\Update; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Issuing\CardDetails The card details associated with that issuing card. + * @return \Stripe\Issuing\CardDetails the card details associated with that issuing card */ public function details($params = null, $opts = null) { @@ -50,6 +48,7 @@ public function details($params = null, $opts = null) list($response, $opts) = $this->_request('get', $url, $params, $opts); $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts); $obj->setLastResponse($response); + return $obj; } } diff --git a/lib/Issuing/CardDetails.php b/lib/Issuing/CardDetails.php index 349a1c21f..98f4e0b87 100644 --- a/lib/Issuing/CardDetails.php +++ b/lib/Issuing/CardDetails.php @@ -3,7 +3,7 @@ namespace Stripe\Issuing; /** - * Class CardDetails + * Class CardDetails. * * @property string $id * @property string $object @@ -12,8 +12,6 @@ * @property int $exp_month * @property int $exp_year * @property string $number - * - * @package Stripe\Issuing */ class CardDetails extends \Stripe\ApiResource { diff --git a/lib/Issuing/Cardholder.php b/lib/Issuing/Cardholder.php index e1f554f55..cbe55ba2d 100644 --- a/lib/Issuing/Cardholder.php +++ b/lib/Issuing/Cardholder.php @@ -3,26 +3,24 @@ namespace Stripe\Issuing; /** - * Class Cardholder + * Class Cardholder. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property \Stripe\StripeObject|null $authorization_controls Spending rules that give you some control over how this cardholder's cards can be used. Refer to our authorizations documentation for more details. + * @property null|\Stripe\StripeObject $authorization_controls Spending rules that give you some control over how this cardholder's cards can be used. Refer to our authorizations documentation for more details. * @property \Stripe\StripeObject $billing - * @property \Stripe\StripeObject|null $company Additional information about a business_entity cardholder. + * @property null|\Stripe\StripeObject $company Additional information about a business_entity cardholder. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $email The cardholder's email address. - * @property \Stripe\StripeObject|null $individual Additional information about an individual cardholder. + * @property null|string $email The cardholder's email address. + * @property null|\Stripe\StripeObject $individual Additional information about an individual cardholder. * @property bool $is_default Whether or not this cardholder is the default cardholder. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $name The cardholder's name. This will be printed on cards issued to them. - * @property string|null $phone_number The cardholder's phone number. + * @property null|string $phone_number The cardholder's phone number. * @property \Stripe\StripeObject $requirements * @property string $status Specifies whether to permit authorizations on this cardholder's cards. * @property string $type One of individual or business_entity. - * - * @package Stripe\Issuing */ class Cardholder extends \Stripe\ApiResource { diff --git a/lib/Issuing/Dispute.php b/lib/Issuing/Dispute.php index 985b1f526..26498fa12 100644 --- a/lib/Issuing/Dispute.php +++ b/lib/Issuing/Dispute.php @@ -3,7 +3,7 @@ namespace Stripe\Issuing; /** - * Class Dispute + * Class Dispute. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -16,8 +16,6 @@ * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $reason Reason for this dispute. One of fraudulent or other. * @property string $status Current status of dispute. One of unsubmitted, under_review, won, or lost. - * - * @package Stripe\Issuing */ class Dispute extends \Stripe\ApiResource { diff --git a/lib/Issuing/Transaction.php b/lib/Issuing/Transaction.php index 6494d45bd..353a2e946 100644 --- a/lib/Issuing/Transaction.php +++ b/lib/Issuing/Transaction.php @@ -3,26 +3,24 @@ namespace Stripe\Issuing; /** - * Class Transaction + * Class Transaction. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount The amount of this transaction in your currency. This is the amount that your balance will be updated by. - * @property string|\Stripe\Issuing\Authorization|null $authorization The Authorization object that led to this transaction. - * @property string|\Stripe\BalanceTransaction|null $balance_transaction ID of the balance transaction associated with this transaction. + * @property null|string|\Stripe\Issuing\Authorization $authorization The Authorization object that led to this transaction. + * @property null|string|\Stripe\BalanceTransaction $balance_transaction ID of the balance transaction associated with this transaction. * @property string|\Stripe\Issuing\Card $card The card used to make this transaction. - * @property string|\Stripe\Issuing\Cardholder|null $cardholder The cardholder to whom this transaction belongs. + * @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this transaction belongs. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|\Stripe\Issuing\Dispute|null $dispute If you've disputed the transaction, the ID of the dispute object. + * @property null|string|\Stripe\Issuing\Dispute $dispute If you've disputed the transaction, the ID of the dispute object. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property int $merchant_amount The amount that the merchant will receive, denominated in merchant_currency. It will be different from amount if the merchant is taking payment in a different currency. * @property string $merchant_currency The currency with which the merchant is taking payment. * @property \Stripe\StripeObject $merchant_data * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $type The nature of the transaction. - * - * @package Stripe\Issuing */ class Transaction extends \Stripe\ApiResource { diff --git a/lib/LoginLink.php b/lib/LoginLink.php index 010933c20..f7b83bf5d 100644 --- a/lib/LoginLink.php +++ b/lib/LoginLink.php @@ -3,13 +3,11 @@ namespace Stripe; /** - * Class LoginLink + * Class LoginLink. * * @property string $object * @property int $created * @property string $url - * - * @package Stripe */ class LoginLink extends ApiResource { diff --git a/lib/Mandate.php b/lib/Mandate.php index 15ea3764e..04795bd50 100644 --- a/lib/Mandate.php +++ b/lib/Mandate.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class Mandate + * Class Mandate. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -15,8 +15,6 @@ * @property \Stripe\StripeObject $single_use * @property string $status The status of the Mandate, one of pending, inactive, or active. The Mandate can be used to initiate a payment only if status=active. * @property string $type The type of the mandate, one of single_use or multi_use - * - * @package Stripe */ class Mandate extends ApiResource { diff --git a/lib/OAuth.php b/lib/OAuth.php index 7ab1fd4e6..7b0886e30 100644 --- a/lib/OAuth.php +++ b/lib/OAuth.php @@ -7,10 +7,10 @@ abstract class OAuth /** * Generates a URL to Stripe's OAuth form. * - * @param array|null $params - * @param array|null $opts + * @param null|array $params + * @param null|array $opts * - * @return string The URL to Stripe's OAuth form. + * @return string the URL to Stripe's OAuth form */ public static function authorizeUrl($params = null, $opts = null) { @@ -31,12 +31,12 @@ public static function authorizeUrl($params = null, $opts = null) * Use an authoriztion code to connect an account to your platform and * fetch the user's credentials. * - * @param array|null $params - * @param array|null $opts + * @param null|array $params + * @param null|array $opts * * @throws \Stripe\Exception\OAuth\OAuthErrorException if the request fails * - * @return StripeObject Object containing the response from the API. + * @return StripeObject object containing the response from the API */ public static function token($params = null, $opts = null) { @@ -48,18 +48,19 @@ public static function token($params = null, $opts = null) $params, null ); + return Util\Util::convertToStripeObject($response->json, $opts); } /** * Disconnects an account from your platform. * - * @param array|null $params - * @param array|null $opts + * @param null|array $params + * @param null|array $opts * * @throws \Stripe\Exception\OAuth\OAuthErrorException if the request fails * - * @return StripeObject Object containing the response from the API. + * @return StripeObject object containing the response from the API */ public static function deauthorize($params = null, $opts = null) { @@ -73,6 +74,7 @@ public static function deauthorize($params = null, $opts = null) $params, null ); + return Util\Util::convertToStripeObject($response->json, $opts); } @@ -90,8 +92,10 @@ private static function _getClientId($params = null) . 'after registering your account as a platform. See ' . 'https://stripe.com/docs/connect/standard-accounts for details, ' . 'or email support@stripe.com if you have any questions.'; + throw new Exception\AuthenticationException($msg); } + return $clientId; } } diff --git a/lib/OAuthErrorObject.php b/lib/OAuthErrorObject.php index 6cd355fd6..620c5bb27 100644 --- a/lib/OAuthErrorObject.php +++ b/lib/OAuthErrorObject.php @@ -3,12 +3,10 @@ namespace Stripe; /** - * Class OAuthErrorObject + * Class OAuthErrorObject. * * @property string $error * @property string $error_description - * - * @package Stripe */ class OAuthErrorObject extends StripeObject { @@ -16,8 +14,8 @@ class OAuthErrorObject extends StripeObject * Refreshes this object using the provided values. * * @param array $values - * @param array|string|Util\RequestOptions|null $opts - * @param bool $partial Defaults to false. + * @param null|array|string|Util\RequestOptions $opts + * @param bool $partial defaults to false */ public function refreshFrom($values, $opts, $partial = false) { diff --git a/lib/Order.php b/lib/Order.php index 99200980b..2fc4eadd7 100644 --- a/lib/Order.php +++ b/lib/Order.php @@ -3,33 +3,31 @@ namespace Stripe; /** - * Class Order + * Class Order. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the order. - * @property int|null $amount_returned The total amount that was returned to the customer. - * @property string|null $application ID of the Connect Application that created the order. - * @property int|null $application_fee A fee in cents that will be applied to the order and transferred to the application owner’s Stripe account. The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, see the application fees documentation. - * @property string|\Stripe\Charge|null $charge The ID of the payment used to pay for the order. Present if the order status is paid, fulfilled, or refunded. + * @property null|int $amount_returned The total amount that was returned to the customer. + * @property null|string $application ID of the Connect Application that created the order. + * @property null|int $application_fee A fee in cents that will be applied to the order and transferred to the application owner’s Stripe account. The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, see the application fees documentation. + * @property null|string|\Stripe\Charge $charge The ID of the payment used to pay for the order. Present if the order status is paid, fulfilled, or refunded. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|\Stripe\Customer|null $customer The customer used for the order. - * @property string|null $email The email address of the customer placing the order. + * @property null|string|\Stripe\Customer $customer The customer used for the order. + * @property null|string $email The email address of the customer placing the order. * @property string $external_coupon_code External coupon code to load for this order. * @property \Stripe\OrderItem[] $items List of items constituting the order. An order can have up to 25 items. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property \Stripe\Collection|null $returns A list of returns that have taken place for this order. - * @property string|null $selected_shipping_method The shipping method that is currently selected for this order, if any. If present, it is equal to one of the ids of shipping methods in the shipping_methods array. At order creation time, if there are multiple shipping methods, Stripe will automatically selected the first method. - * @property \Stripe\StripeObject|null $shipping The shipping address for the order. Present if the order is for goods to be shipped. - * @property \Stripe\StripeObject[]|null $shipping_methods A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or when paying it. + * @property null|\Stripe\Collection $returns A list of returns that have taken place for this order. + * @property null|string $selected_shipping_method The shipping method that is currently selected for this order, if any. If present, it is equal to one of the ids of shipping methods in the shipping_methods array. At order creation time, if there are multiple shipping methods, Stripe will automatically selected the first method. + * @property null|\Stripe\StripeObject $shipping The shipping address for the order. Present if the order is for goods to be shipped. + * @property null|\Stripe\StripeObject[] $shipping_methods A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or when paying it. * @property string $status Current order status. One of created, paid, canceled, fulfilled, or returned. More details in the Orders Guide. - * @property \Stripe\StripeObject|null $status_transitions The timestamps at which the order status was updated. - * @property int|null $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. + * @property null|\Stripe\StripeObject $status_transitions The timestamps at which the order status was updated. + * @property null|int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. * @property string $upstream_id The user's order ID if it is different from the Stripe order ID. - * - * @package Stripe */ class Order extends ApiResource { @@ -41,33 +39,35 @@ class Order extends ApiResource use ApiOperations\Update; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\OrderReturn The newly created return. + * @return \Stripe\OrderReturn the newly created return */ public function returnOrder($params = null, $opts = null) { $url = $this->instanceUrl() . '/returns'; list($response, $opts) = $this->_request('post', $url, $params, $opts); + return Util\Util::convertToStripeObject($response, $opts); } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Order The paid order. + * @return Order the paid order */ public function pay($params = null, $opts = null) { $url = $this->instanceUrl() . '/pay'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/OrderItem.php b/lib/OrderItem.php index 6bdafc97e..e2e6e39a2 100644 --- a/lib/OrderItem.php +++ b/lib/OrderItem.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class OrderItem + * Class OrderItem. * * @property string $object * @property int $amount @@ -12,8 +12,6 @@ * @property string $parent * @property int $quantity * @property string $type - * - * @package Stripe */ class OrderItem extends StripeObject { diff --git a/lib/OrderReturn.php b/lib/OrderReturn.php index 4140adc1b..617428126 100644 --- a/lib/OrderReturn.php +++ b/lib/OrderReturn.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class OrderReturn + * Class OrderReturn. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -12,10 +12,8 @@ * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property \Stripe\OrderItem[] $items The items included in this order return. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|\Stripe\Order|null $order The order that this return includes items from. - * @property string|\Stripe\Refund|null $refund The ID of the refund issued for this return. - * - * @package Stripe + * @property null|string|\Stripe\Order $order The order that this return includes items from. + * @property null|string|\Stripe\Refund $refund The ID of the refund issued for this return. */ class OrderReturn extends ApiResource { diff --git a/lib/PaymentIntent.php b/lib/PaymentIntent.php index a09f32ee3..4f9ee93c2 100644 --- a/lib/PaymentIntent.php +++ b/lib/PaymentIntent.php @@ -3,46 +3,44 @@ namespace Stripe; /** - * Class PaymentIntent + * Class PaymentIntent. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). * @property int $amount_capturable Amount that can be captured from this PaymentIntent. * @property int $amount_received Amount that was collected by this PaymentIntent. - * @property string|\Stripe\StripeObject|null $application ID of the Connect application that created the PaymentIntent. - * @property int|null $application_fee_amount The amount of the application fee (if any) for the resulting payment. See the PaymentIntents use case for connected accounts for details. - * @property int|null $canceled_at Populated when status is canceled, this is the time at which the PaymentIntent was canceled. Measured in seconds since the Unix epoch. - * @property string|null $cancellation_reason Reason for cancellation of this PaymentIntent, either user-provided (duplicate, fraudulent, requested_by_customer, or abandoned) or generated by Stripe internally (failed_invoice, void_invoice, or automatic). + * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the PaymentIntent. + * @property null|int $application_fee_amount The amount of the application fee (if any) for the resulting payment. See the PaymentIntents use case for connected accounts for details. + * @property null|int $canceled_at Populated when status is canceled, this is the time at which the PaymentIntent was canceled. Measured in seconds since the Unix epoch. + * @property null|string $cancellation_reason Reason for cancellation of this PaymentIntent, either user-provided (duplicate, fraudulent, requested_by_customer, or abandoned) or generated by Stripe internally (failed_invoice, void_invoice, or automatic). * @property string $capture_method Controls when the funds will be captured from the customer's account. * @property \Stripe\Collection $charges Charges that were created by this PaymentIntent, if any. - * @property string|null $client_secret

The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete a payment from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

Refer to our docs to accept a payment and learn about how client_secret should be handled.

+ * @property null|string $client_secret

The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete a payment from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

Refer to our docs to accept a payment and learn about how client_secret should be handled.

* @property string $confirmation_method * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|\Stripe\Customer|null $customer

ID of the Customer this PaymentIntent belongs to, if one exists.

If present, payment methods used with this PaymentIntent can only be attached to this Customer, and payment methods attached to other Customers cannot be used with this PaymentIntent.

- * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property string|\Stripe\Invoice|null $invoice ID of the invoice that created this PaymentIntent, if it exists. - * @property \Stripe\ErrorObject|null $last_payment_error The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason. + * @property null|string|\Stripe\Customer $customer

ID of the Customer this PaymentIntent belongs to, if one exists.

If present, payment methods used with this PaymentIntent can only be attached to this Customer, and payment methods attached to other Customers cannot be used with this PaymentIntent.

+ * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string|\Stripe\Invoice $invoice ID of the invoice that created this PaymentIntent, if it exists. + * @property null|\Stripe\ErrorObject $last_payment_error The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. For more information, see the documentation. - * @property \Stripe\StripeObject|null $next_action If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source. - * @property string|\Stripe\Account|null $on_behalf_of The account (if any) for which the funds of the PaymentIntent are intended. See the PaymentIntents use case for connected accounts for details. - * @property string|\Stripe\PaymentMethod|null $payment_method ID of the payment method used in this PaymentIntent. - * @property \Stripe\StripeObject|null $payment_method_options Payment-method-specific configuration for this PaymentIntent. + * @property null|\Stripe\StripeObject $next_action If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source. + * @property null|string|\Stripe\Account $on_behalf_of The account (if any) for which the funds of the PaymentIntent are intended. See the PaymentIntents use case for connected accounts for details. + * @property null|string|\Stripe\PaymentMethod $payment_method ID of the payment method used in this PaymentIntent. + * @property null|\Stripe\StripeObject $payment_method_options Payment-method-specific configuration for this PaymentIntent. * @property string[] $payment_method_types The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. - * @property string|null $receipt_email Email address that the receipt for the resulting payment will be sent to. - * @property string|\Stripe\Review|null $review ID of the review associated with this PaymentIntent, if any. - * @property string|null $setup_future_usage

Indicates that you intend to make future payments with this PaymentIntent's payment method.

If present, the payment method used with this PaymentIntent can be attached to a Customer, even after the transaction completes.

For more, learn to save card details after a payment.

Stripe uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules. For example, if your customer is impacted by SCA, using off_session will ensure that they are authenticated while processing this PaymentIntent. You will then be able to collect off-session payments for this customer.

- * @property \Stripe\StripeObject|null $shipping Shipping information for this PaymentIntent. - * @property string|\Stripe\StripeObject|null $source This is a legacy field that will be removed in the future. It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied. - * @property string|null $statement_descriptor For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters. - * @property string|null $statement_descriptor_suffix Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. + * @property null|string $receipt_email Email address that the receipt for the resulting payment will be sent to. + * @property null|string|\Stripe\Review $review ID of the review associated with this PaymentIntent, if any. + * @property null|string $setup_future_usage

Indicates that you intend to make future payments with this PaymentIntent's payment method.

If present, the payment method used with this PaymentIntent can be attached to a Customer, even after the transaction completes.

For more, learn to save card details after a payment.

Stripe uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules. For example, if your customer is impacted by SCA, using off_session will ensure that they are authenticated while processing this PaymentIntent. You will then be able to collect off-session payments for this customer.

+ * @property null|\Stripe\StripeObject $shipping Shipping information for this PaymentIntent. + * @property null|string|\Stripe\StripeObject $source This is a legacy field that will be removed in the future. It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied. + * @property null|string $statement_descriptor For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters. + * @property null|string $statement_descriptor_suffix Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. * @property string $status Status of this PaymentIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, requires_capture, canceled, or succeeded. Read more about each PaymentIntent status. - * @property \Stripe\StripeObject|null $transfer_data The data with which to automatically create a Transfer when the payment is finalized. See the PaymentIntents use case for connected accounts for details. - * @property string|null $transfer_group A string that identifies the resulting payment as part of a group. See the PaymentIntents use case for connected accounts for details. - * - * @package Stripe + * @property null|\Stripe\StripeObject $transfer_data The data with which to automatically create a Transfer when the payment is finalized. See the PaymentIntents use case for connected accounts for details. + * @property null|string $transfer_group A string that identifies the resulting payment as part of a group. See the PaymentIntents use case for connected accounts for details. */ class PaymentIntent extends ApiResource { @@ -58,59 +56,62 @@ class PaymentIntent extends ApiResource * * @see https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status */ - const STATUS_CANCELED = 'canceled'; - const STATUS_PROCESSING = 'processing'; - const STATUS_REQUIRES_ACTION = 'requires_action'; - const STATUS_REQUIRES_CAPTURE = 'requires_capture'; - const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation'; + const STATUS_CANCELED = 'canceled'; + const STATUS_PROCESSING = 'processing'; + const STATUS_REQUIRES_ACTION = 'requires_action'; + const STATUS_REQUIRES_CAPTURE = 'requires_capture'; + const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation'; const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method'; - const STATUS_SUCCEEDED = 'succeeded'; + const STATUS_SUCCEEDED = 'succeeded'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return PaymentIntent The canceled payment intent. + * @return PaymentIntent the canceled payment intent */ public function cancel($params = null, $opts = null) { $url = $this->instanceUrl() . '/cancel'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return PaymentIntent The captured payment intent. + * @return PaymentIntent the captured payment intent */ public function capture($params = null, $opts = null) { $url = $this->instanceUrl() . '/capture'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return PaymentIntent The confirmed payment intent. + * @return PaymentIntent the confirmed payment intent */ public function confirm($params = null, $opts = null) { $url = $this->instanceUrl() . '/confirm'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/PaymentMethod.php b/lib/PaymentMethod.php index 2e8167e55..ad5e2bf78 100644 --- a/lib/PaymentMethod.php +++ b/lib/PaymentMethod.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class PaymentMethod + * Class PaymentMethod. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -12,15 +12,13 @@ * @property \Stripe\StripeObject $card * @property \Stripe\StripeObject $card_present * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|\Stripe\Customer|null $customer The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer. + * @property null|string|\Stripe\Customer $customer The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer. * @property \Stripe\StripeObject $fpx * @property \Stripe\StripeObject $ideal * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\StripeObject $sepa_debit * @property string $type The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type. - * - * @package Stripe */ class PaymentMethod extends ApiResource { @@ -32,34 +30,36 @@ class PaymentMethod extends ApiResource use ApiOperations\Update; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return PaymentMethod The attached payment method. + * @return PaymentMethod the attached payment method */ public function attach($params = null, $opts = null) { $url = $this->instanceUrl() . '/attach'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return PaymentMethod The detached payment method. + * @return PaymentMethod the detached payment method */ public function detach($params = null, $opts = null) { $url = $this->instanceUrl() . '/detach'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/Payout.php b/lib/Payout.php index 160ee0119..c0e38c7af 100644 --- a/lib/Payout.php +++ b/lib/Payout.php @@ -3,30 +3,28 @@ namespace Stripe; /** - * Class Payout + * Class Payout. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount Amount (in %s) to be transferred to your bank account or debit card. * @property int $arrival_date Date the payout is expected to arrive in the bank. This factors in delays like weekends or bank holidays. * @property bool $automatic Returns true if the payout was created by an automated payout schedule, and false if it was requested manually. - * @property string|\Stripe\BalanceTransaction|null $balance_transaction ID of the balance transaction that describes the impact of this payout on your account balance. + * @property null|string|\Stripe\BalanceTransaction $balance_transaction ID of the balance transaction that describes the impact of this payout on your account balance. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property string|\Stripe\StripeObject|null $destination ID of the bank account or card the payout was sent to. - * @property string|\Stripe\BalanceTransaction|null $failure_balance_transaction If the payout failed or was canceled, this will be the ID of the balance transaction that reversed the initial balance transaction, and puts the funds from the failed payout back in your balance. - * @property string|null $failure_code Error code explaining reason for payout failure if available. See Types of payout failures for a list of failure codes. - * @property string|null $failure_message Message to user further explaining reason for payout failure if available. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string|\Stripe\StripeObject $destination ID of the bank account or card the payout was sent to. + * @property null|string|\Stripe\BalanceTransaction $failure_balance_transaction If the payout failed or was canceled, this will be the ID of the balance transaction that reversed the initial balance transaction, and puts the funds from the failed payout back in your balance. + * @property null|string $failure_code Error code explaining reason for payout failure if available. See Types of payout failures for a list of failure codes. + * @property null|string $failure_message Message to user further explaining reason for payout failure if available. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $method The method used to send this payout, which can be standard or instant. instant is only supported for payouts to debit cards. (See Instant payouts for marketplaces for more information.) * @property string $source_type The source balance this payout came from. One of card, fpx, or bank_account. - * @property string|null $statement_descriptor Extra information about a payout to be displayed on the user's bank statement. + * @property null|string $statement_descriptor Extra information about a payout to be displayed on the user's bank statement. * @property string $status Current status of the payout (paid, pending, in_transit, canceled or failed). A payout will be pending until it is submitted to the bank, at which point it becomes in_transit. It will then change to paid if the transaction goes through. If it does not go through successfully, its status will change to failed or canceled. * @property string $type Can be bank_account or card. - * - * @package Stripe */ class Payout extends ApiResource { @@ -42,19 +40,19 @@ class Payout extends ApiResource * * @see https://stripe.com/docs/api#payout_failures */ - const FAILURE_ACCOUNT_CLOSED = 'account_closed'; - const FAILURE_ACCOUNT_FROZEN = 'account_frozen'; - const FAILURE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted'; - const FAILURE_BANK_OWNERSHIP_CHANGED = 'bank_ownership_changed'; - const FAILURE_COULD_NOT_PROCESS = 'could_not_process'; - const FAILURE_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized'; - const FAILURE_DECLINED = 'declined'; + const FAILURE_ACCOUNT_CLOSED = 'account_closed'; + const FAILURE_ACCOUNT_FROZEN = 'account_frozen'; + const FAILURE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted'; + const FAILURE_BANK_OWNERSHIP_CHANGED = 'bank_ownership_changed'; + const FAILURE_COULD_NOT_PROCESS = 'could_not_process'; + const FAILURE_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized'; + const FAILURE_DECLINED = 'declined'; const FAILURE_INCORRECT_ACCOUNT_HOLDER_NAME = 'incorrect_account_holder_name'; - const FAILURE_INSUFFICIENT_FUNDS = 'insufficient_funds'; - const FAILURE_INVALID_ACCOUNT_NUMBER = 'invalid_account_number'; - const FAILURE_INVALID_CURRENCY = 'invalid_currency'; - const FAILURE_NO_ACCOUNT = 'no_account'; - const FAILURE_UNSUPPORTED_CARD = 'unsupported_card'; + const FAILURE_INSUFFICIENT_FUNDS = 'insufficient_funds'; + const FAILURE_INVALID_ACCOUNT_NUMBER = 'invalid_account_number'; + const FAILURE_INVALID_CURRENCY = 'invalid_currency'; + const FAILURE_NO_ACCOUNT = 'no_account'; + const FAILURE_UNSUPPORTED_CARD = 'unsupported_card'; /** * Possible string representations of the payout methods. @@ -62,18 +60,18 @@ class Payout extends ApiResource * @see https://stripe.com/docs/api/payouts/object#payout_object-method */ const METHOD_STANDARD = 'standard'; - const METHOD_INSTANT = 'instant'; + const METHOD_INSTANT = 'instant'; /** * Possible string representations of the status of the payout. * * @see https://stripe.com/docs/api/payouts/object#payout_object-status */ - const STATUS_CANCELED = 'canceled'; + const STATUS_CANCELED = 'canceled'; const STATUS_IN_TRANSIT = 'in_transit'; - const STATUS_FAILED = 'failed'; - const STATUS_PAID = 'paid'; - const STATUS_PENDING = 'pending'; + const STATUS_FAILED = 'failed'; + const STATUS_PAID = 'paid'; + const STATUS_PENDING = 'pending'; /** * Possible string representations of the type of payout. @@ -81,21 +79,22 @@ class Payout extends ApiResource * @see https://stripe.com/docs/api/payouts/object#payout_object-type */ const TYPE_BANK_ACCOUNT = 'bank_account'; - const TYPE_CARD = 'card'; + const TYPE_CARD = 'card'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Payout The canceled payout. + * @return Payout the canceled payout */ public function cancel($params = null, $opts = null) { $url = $this->instanceUrl() . '/cancel'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/Person.php b/lib/Person.php index 40339b3a3..0d475be7b 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -3,33 +3,31 @@ namespace Stripe; /** - * Class Person - * - * @package Stripe + * Class Person. * * @property string $id * @property string $object * @property string $account * @property \Stripe\StripeObject $address - * @property \Stripe\StripeObject|null $address_kana - * @property \Stripe\StripeObject|null $address_kanji + * @property null|\Stripe\StripeObject $address_kana + * @property null|\Stripe\StripeObject $address_kanji * @property int $created * @property bool $deleted * @property \Stripe\StripeObject $dob - * @property string|null $email - * @property string|null $first_name - * @property string|null $first_name_kana - * @property string|null $first_name_kanji - * @property string|null $gender + * @property null|string $email + * @property null|string $first_name + * @property null|string $first_name_kana + * @property null|string $first_name_kanji + * @property null|string $gender * @property bool $id_number_provided - * @property string|null $last_name - * @property string|null $last_name_kana - * @property string|null $last_name_kanji - * @property string|null $maiden_name + * @property null|string $last_name + * @property null|string $last_name_kana + * @property null|string $last_name_kanji + * @property null|string $maiden_name * @property \Stripe\StripeObject $metadata - * @property string|null $phone + * @property null|string $phone * @property \Stripe\StripeObject $relationship - * @property \Stripe\StripeObject|null $requirements + * @property null|\Stripe\StripeObject $requirements * @property bool $ssn_last_4_provided * @property \Stripe\StripeObject $verification */ @@ -45,7 +43,7 @@ class Person extends ApiResource * * @see https://stripe.com/docs/api/persons/object#person_object-gender */ - const GENDER_MALE = 'male'; + const GENDER_MALE = 'male'; const GENDER_FEMALE = 'female'; /** @@ -53,12 +51,12 @@ class Person extends ApiResource * * @see https://stripe.com/docs/api/persons/object#person_object-verification-status */ - const VERIFICATION_STATUS_PENDING = 'pending'; + const VERIFICATION_STATUS_PENDING = 'pending'; const VERIFICATION_STATUS_UNVERIFIED = 'unverified'; - const VERIFICATION_STATUS_VERIFIED = 'verified'; + const VERIFICATION_STATUS_VERIFIED = 'verified'; /** - * @return string The API URL for this Stripe account reversal. + * @return string the API URL for this Stripe account reversal */ public function instanceUrl() { @@ -66,7 +64,7 @@ public function instanceUrl() $account = $this['account']; if (!$id) { throw new Exception\UnexpectedValueException( - "Could not determine which URL to request: " . + 'Could not determine which URL to request: ' . "class instance has invalid ID: {$id}", null ); @@ -77,35 +75,38 @@ public function instanceUrl() $base = Account::classUrl(); $accountExtn = \urlencode($account); $extn = \urlencode($id); + return "{$base}/{$accountExtn}/persons/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException */ public static function retrieve($_id, $_opts = null) { - $msg = "Persons cannot be retrieved without an account ID. Retrieve " . + $msg = 'Persons cannot be retrieved without an account ID. Retrieve ' . "a person using `Account::retrievePerson('account_id', " . "'person_id')`."; + throw new Exception\BadMethodCallException($msg, null); } /** * @param string $_id - * @param array|null $_params - * @param array|string|null $_options + * @param null|array $_params + * @param null|array|string $_options * * @throws \Stripe\Exception\BadMethodCallException */ public static function update($_id, $_params = null, $_options = null) { - $msg = "Persons cannot be updated without an account ID. Update " . + $msg = 'Persons cannot be updated without an account ID. Update ' . "a person using `Account::updatePerson('account_id', " . "'person_id', \$updateParams)`."; + throw new Exception\BadMethodCallException($msg, null); } } diff --git a/lib/Plan.php b/lib/Plan.php index 4c15260b3..5e691014f 100644 --- a/lib/Plan.php +++ b/lib/Plan.php @@ -3,30 +3,28 @@ namespace Stripe; /** - * Class Plan + * Class Plan. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property bool $active Whether the plan is currently available for new subscriptions. - * @property string|null $aggregate_usage Specifies a usage aggregation strategy for plans of usage_type=metered. Allowed values are sum for summing up all usage during a period, last_during_period for using the last usage record reported within a period, last_ever for using the last usage record ever (across period bounds) or max which uses the usage record with the maximum reported usage during a period. Defaults to sum. - * @property int|null $amount The amount in %s to be charged on the interval specified. - * @property string|null $amount_decimal Same as amount, but contains a decimal value with at most 12 decimal places. - * @property string|null $billing_scheme Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with usage_type=licensed), or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes. + * @property null|string $aggregate_usage Specifies a usage aggregation strategy for plans of usage_type=metered. Allowed values are sum for summing up all usage during a period, last_during_period for using the last usage record reported within a period, last_ever for using the last usage record ever (across period bounds) or max which uses the usage record with the maximum reported usage during a period. Defaults to sum. + * @property null|int $amount The amount in %s to be charged on the interval specified. + * @property null|string $amount_decimal Same as amount, but contains a decimal value with at most 12 decimal places. + * @property null|string $billing_scheme Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with usage_type=licensed), or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property string $interval The frequency at which a subscription is billed. One of day, week, month or year. * @property int $interval_count The number of intervals (specified in the interval attribute) between subscription billings. For example, interval=month and interval_count=3 bills every 3 months. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|null $nickname A brief description of the plan, hidden from customers. - * @property string|\Stripe\Product|null $product The product whose pricing this plan determines. - * @property \Stripe\StripeObject[]|null $tiers Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered. See also the documentation for billing_scheme. - * @property string|null $tiers_mode Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price. In graduated tiering, pricing can change as the quantity grows. - * @property \Stripe\StripeObject|null $transform_usage Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with tiers. - * @property int|null $trial_period_days Default number of trial days when subscribing a customer to this plan using trial_from_plan=true. + * @property null|string $nickname A brief description of the plan, hidden from customers. + * @property null|string|\Stripe\Product $product The product whose pricing this plan determines. + * @property null|\Stripe\StripeObject[] $tiers Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered. See also the documentation for billing_scheme. + * @property null|string $tiers_mode Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price. In graduated tiering, pricing can change as the quantity grows. + * @property null|\Stripe\StripeObject $transform_usage Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with tiers. + * @property null|int $trial_period_days Default number of trial days when subscribing a customer to this plan using trial_from_plan=true. * @property string $usage_type Configures how the quantity per period should be determined. Can be either metered or licensed. licensed automatically bills the quantity set when adding it to a subscription. metered aggregates the total usage based on usage records. Defaults to licensed. - * - * @package Stripe */ class Plan extends ApiResource { diff --git a/lib/Product.php b/lib/Product.php index 89fad8106..03cb4fae1 100644 --- a/lib/Product.php +++ b/lib/Product.php @@ -3,29 +3,27 @@ namespace Stripe; /** - * Class Product + * Class Product. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property bool $active Whether the product is currently available for purchase. - * @property string[]|null $attributes A list of up to 5 attributes that each SKU can provide values for (e.g., ["color", "size"]). - * @property string|null $caption A short one-line description of the product, meant to be displayable to the customer. Only applicable to products of type=good. + * @property null|string[] $attributes A list of up to 5 attributes that each SKU can provide values for (e.g., ["color", "size"]). + * @property null|string $caption A short one-line description of the product, meant to be displayable to the customer. Only applicable to products of type=good. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string[] $deactivate_on An array of connect application identifiers that cannot purchase this product. Only applicable to products of type=good. - * @property string|null $description The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. + * @property null|string $description The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. * @property string[] $images A list of up to 8 URLs of images for this product, meant to be displayable to the customer. Only applicable to products of type=good. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $name The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. - * @property \Stripe\StripeObject|null $package_dimensions The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own package_dimensions. Only applicable to products of type=good. - * @property bool|null $shippable Whether this product is a shipped good. Only applicable to products of type=good. - * @property string|null $statement_descriptor Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. + * @property null|\Stripe\StripeObject $package_dimensions The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own package_dimensions. Only applicable to products of type=good. + * @property null|bool $shippable Whether this product is a shipped good. Only applicable to products of type=good. + * @property null|string $statement_descriptor Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. * @property string $type The type of the product. The product is either of type good, which is eligible for use with Orders and SKUs, or service, which is eligible for use with Subscriptions and Plans. - * @property string|null $unit_label A label that represents units of this product in Stripe and on customers’ receipts and invoices. When set, this will be included in associated invoice line item descriptions. + * @property null|string $unit_label A label that represents units of this product in Stripe and on customers’ receipts and invoices. When set, this will be included in associated invoice line item descriptions. * @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. - * @property string|null $url A URL of a publicly-accessible webpage for this product. Only applicable to products of type=good. - * - * @package Stripe + * @property null|string $url A URL of a publicly-accessible webpage for this product. Only applicable to products of type=good. */ class Product extends ApiResource { @@ -42,6 +40,6 @@ class Product extends ApiResource * * @see https://stripe.com/docs/api/service_products/object#service_product_object-type */ - const TYPE_GOOD = 'good'; + const TYPE_GOOD = 'good'; const TYPE_SERVICE = 'service'; } diff --git a/lib/Radar/EarlyFraudWarning.php b/lib/Radar/EarlyFraudWarning.php index d44793603..e4be06bb5 100644 --- a/lib/Radar/EarlyFraudWarning.php +++ b/lib/Radar/EarlyFraudWarning.php @@ -3,7 +3,7 @@ namespace Stripe\Radar; /** - * Class EarlyFraudWarning + * Class EarlyFraudWarning. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -12,8 +12,6 @@ * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $fraud_type The type of fraud labelled by the issuer. One of card_never_received, fraudulent_card_application, made_with_counterfeit_card, made_with_lost_card, made_with_stolen_card, misc, unauthorized_use_of_card. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * - * @package Stripe\Radar */ class EarlyFraudWarning extends \Stripe\ApiResource { @@ -27,11 +25,11 @@ class EarlyFraudWarning extends \Stripe\ApiResource * * @see https://stripe.com/docs/api/early_fraud_warnings/object#early_fraud_warning_object-fraud_type */ - const FRAUD_TYPE_CARD_NEVER_RECEIVED = 'card_never_received'; + const FRAUD_TYPE_CARD_NEVER_RECEIVED = 'card_never_received'; const FRAUD_TYPE_FRAUDULENT_CARD_APPLICATION = 'fraudulent_card_application'; - const FRAUD_TYPE_MADE_WITH_COUNTERFEIT_CARD = 'made_with_counterfeit_card'; - const FRAUD_TYPE_MADE_WITH_LOST_CARD = 'made_with_lost_card'; - const FRAUD_TYPE_MADE_WITH_STOLEN_CARD = 'made_with_stolen_card'; - const FRAUD_TYPE_MISC = 'misc'; - const FRAUD_TYPE_UNAUTHORIZED_USE_OF_CARD = 'unauthorized_use_of_card'; + const FRAUD_TYPE_MADE_WITH_COUNTERFEIT_CARD = 'made_with_counterfeit_card'; + const FRAUD_TYPE_MADE_WITH_LOST_CARD = 'made_with_lost_card'; + const FRAUD_TYPE_MADE_WITH_STOLEN_CARD = 'made_with_stolen_card'; + const FRAUD_TYPE_MISC = 'misc'; + const FRAUD_TYPE_UNAUTHORIZED_USE_OF_CARD = 'unauthorized_use_of_card'; } diff --git a/lib/Radar/ValueList.php b/lib/Radar/ValueList.php index 10731e953..b6783621c 100644 --- a/lib/Radar/ValueList.php +++ b/lib/Radar/ValueList.php @@ -3,7 +3,7 @@ namespace Stripe\Radar; /** - * Class ValueList + * Class ValueList. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -15,8 +15,6 @@ * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $name The name of the value list. - * - * @package Stripe\Radar */ class ValueList extends \Stripe\ApiResource { diff --git a/lib/Radar/ValueListItem.php b/lib/Radar/ValueListItem.php index 9b9edb45c..8bf5ce873 100644 --- a/lib/Radar/ValueListItem.php +++ b/lib/Radar/ValueListItem.php @@ -3,7 +3,7 @@ namespace Stripe\Radar; /** - * Class ValueListItem + * Class ValueListItem. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -12,8 +12,6 @@ * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property string $value The value of the item. * @property string $value_list The identifier of the value list this item belongs to. - * - * @package Stripe\Radar */ class ValueListItem extends \Stripe\ApiResource { diff --git a/lib/Recipient.php b/lib/Recipient.php index cd5458f51..68e5f856e 100644 --- a/lib/Recipient.php +++ b/lib/Recipient.php @@ -3,25 +3,23 @@ namespace Stripe; /** - * Class Recipient + * Class Recipient. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property \Stripe\BankAccount|null $active_account Hash describing the current account on the recipient, if there is one. - * @property \Stripe\Collection|null $cards + * @property null|\Stripe\BankAccount $active_account Hash describing the current account on the recipient, if there is one. + * @property null|\Stripe\Collection $cards * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|\Stripe\Card|null $default_card The default card to use for creating transfers to this recipient. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property string|null $email + * @property null|string|\Stripe\Card $default_card The default card to use for creating transfers to this recipient. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string $email * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|\Stripe\Account|null $migrated_to The ID of the Custom account this recipient was migrated to. If set, the recipient can no longer be updated, nor can transfers be made to it: use the Custom account instead. - * @property string|null $name Full, legal name of the recipient. + * @property null|string|\Stripe\Account $migrated_to The ID of the Custom account this recipient was migrated to. If set, the recipient can no longer be updated, nor can transfers be made to it: use the Custom account instead. + * @property null|string $name Full, legal name of the recipient. * @property string|\Stripe\Account $rolled_back_from * @property string $type Type of the recipient, one of individual or corporation. * @property bool $verified Whether the recipient has been verified. This field is non-standard, and maybe removed in the future - * - * @package Stripe */ class Recipient extends ApiResource { diff --git a/lib/RecipientTransfer.php b/lib/RecipientTransfer.php index 8e16f6bf4..5e2d4365d 100644 --- a/lib/RecipientTransfer.php +++ b/lib/RecipientTransfer.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class RecipientTransfer + * Class RecipientTransfer. * * @property string $id * @property string $object @@ -29,8 +29,6 @@ * @property string $statement_descriptor * @property string $status * @property string $type - * - * @package Stripe */ class RecipientTransfer extends ApiResource { diff --git a/lib/Refund.php b/lib/Refund.php index 6b4822625..f559a07bf 100644 --- a/lib/Refund.php +++ b/lib/Refund.php @@ -3,27 +3,25 @@ namespace Stripe; /** - * Class Refund + * Class Refund. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount Amount, in %s. - * @property string|\Stripe\BalanceTransaction|null $balance_transaction Balance transaction that describes the impact on your account balance. - * @property string|\Stripe\Charge|null $charge ID of the charge that was refunded. + * @property null|string|\Stripe\BalanceTransaction $balance_transaction Balance transaction that describes the impact on your account balance. + * @property null|string|\Stripe\Charge $charge ID of the charge that was refunded. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property string $description An arbitrary string attached to the object. Often useful for displaying to users. (Available on non-card refunds only) * @property string|\Stripe\BalanceTransaction $failure_balance_transaction If the refund failed, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction. * @property string $failure_reason If the refund failed, the reason for refund failure if known. Possible values are lost_or_stolen_card, expired_or_canceled_card, or unknown. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string|\Stripe\PaymentIntent|null $payment_intent ID of the PaymentIntent that was refunded. - * @property string|null $reason Reason for the refund, either user-provided (duplicate, fraudulent, or requested_by_customer) or generated by Stripe internally (expired_uncaptured_charge). - * @property string|null $receipt_number This is the transaction number that appears on email receipts sent for this refund. - * @property string|\Stripe\TransferReversal|null $source_transfer_reversal The transfer reversal that is associated with the refund. Only present if the charge came from another Stripe account. See the Connect documentation for details. - * @property string|null $status Status of the refund. For credit card refunds, this can be pending, succeeded, or failed. For other types of refunds, it can be pending, succeeded, failed, or canceled. Refer to our refunds documentation for more details. - * @property string|\Stripe\TransferReversal|null $transfer_reversal If the accompanying transfer was reversed, the transfer reversal object. Only applicable if the charge was created using the destination parameter. - * - * @package Stripe + * @property null|string|\Stripe\PaymentIntent $payment_intent ID of the PaymentIntent that was refunded. + * @property null|string $reason Reason for the refund, either user-provided (duplicate, fraudulent, or requested_by_customer) or generated by Stripe internally (expired_uncaptured_charge). + * @property null|string $receipt_number This is the transaction number that appears on email receipts sent for this refund. + * @property null|string|\Stripe\TransferReversal $source_transfer_reversal The transfer reversal that is associated with the refund. Only present if the charge came from another Stripe account. See the Connect documentation for details. + * @property null|string $status Status of the refund. For credit card refunds, this can be pending, succeeded, or failed. For other types of refunds, it can be pending, succeeded, failed, or canceled. Refer to our refunds documentation for more details. + * @property null|string|\Stripe\TransferReversal $transfer_reversal If the accompanying transfer was reversed, the transfer reversal object. Only applicable if the charge was created using the destination parameter. */ class Refund extends ApiResource { @@ -39,17 +37,17 @@ class Refund extends ApiResource * * @see https://stripe.com/docs/api/refunds/object#refund_object-failure_reason */ - const FAILURE_REASON = 'expired_or_canceled_card'; + const FAILURE_REASON = 'expired_or_canceled_card'; const FAILURE_REASON_LOST_OR_STOLEN_CARD = 'lost_or_stolen_card'; - const FAILURE_REASON_UNKNOWN = 'unknown'; + const FAILURE_REASON_UNKNOWN = 'unknown'; /** * Possible string representations of the refund reason. * * @see https://stripe.com/docs/api/refunds/object#refund_object-reason */ - const REASON_DUPLICATE = 'duplicate'; - const REASON_FRAUDULENT = 'fraudulent'; + const REASON_DUPLICATE = 'duplicate'; + const REASON_FRAUDULENT = 'fraudulent'; const REASON_REQUESTED_BY_CUSTOMER = 'requested_by_customer'; /** @@ -57,8 +55,8 @@ class Refund extends ApiResource * * @see https://stripe.com/docs/api/refunds/object#refund_object-status */ - const STATUS_CANCELED = 'canceled'; - const STATUS_FAILED = 'failed'; - const STATUS_PENDING = 'pending'; + const STATUS_CANCELED = 'canceled'; + const STATUS_FAILED = 'failed'; + const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; } diff --git a/lib/Reporting/ReportRun.php b/lib/Reporting/ReportRun.php index 66c0e9a17..03467a2e3 100644 --- a/lib/Reporting/ReportRun.php +++ b/lib/Reporting/ReportRun.php @@ -3,20 +3,18 @@ namespace Stripe\Reporting; /** - * Class ReportRun + * Class ReportRun. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $error If something should go wrong during the run, a message about the failure (populated when status=failed). + * @property null|string $error If something should go wrong during the run, a message about the failure (populated when status=failed). * @property bool $livemode Always true: reports can only be run on live-mode data. * @property \Stripe\StripeObject $parameters * @property string $report_type The ID of the report type to run, such as "balance.summary.1". - * @property \Stripe\File|null $result The file object representing the result of the report run (populated when status=succeeded). + * @property null|\Stripe\File $result The file object representing the result of the report run (populated when status=succeeded). * @property string $status Status of this report run. This will be pending when the run is initially created. When the run finishes, this will be set to succeeded and the result field will be populated. Rarely, we may encounter an error, at which point this will be set to failed and the error field will be populated. - * @property int|null $succeeded_at Timestamp at which this run successfully finished (populated when status=succeeded). Measured in seconds since the Unix epoch. - * - * @package Stripe\Reporting + * @property null|int $succeeded_at Timestamp at which this run successfully finished (populated when status=succeeded). Measured in seconds since the Unix epoch. */ class ReportRun extends \Stripe\ApiResource { diff --git a/lib/Reporting/ReportType.php b/lib/Reporting/ReportType.php index 4cb621c18..d34b8cb5d 100644 --- a/lib/Reporting/ReportType.php +++ b/lib/Reporting/ReportType.php @@ -3,18 +3,16 @@ namespace Stripe\Reporting; /** - * Class ReportType + * Class ReportType. * * @property string $id The ID of the Report Type, such as balance.summary.1. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $data_available_end Most recent time for which this Report Type is available. Measured in seconds since the Unix epoch. * @property int $data_available_start Earliest time for which this Report Type is available. Measured in seconds since the Unix epoch. - * @property string[]|null $default_columns List of column names that are included by default when this Report Type gets run. (If the Report Type doesn't support the columns parameter, this will be null.) + * @property null|string[] $default_columns List of column names that are included by default when this Report Type gets run. (If the Report Type doesn't support the columns parameter, this will be null.) * @property string $name Human-readable name of the Report Type * @property int $updated When this Report Type was latest updated. Measured in seconds since the Unix epoch. * @property int $version Version of the Report Type. Different versions report with the same ID will have the same purpose, but may take different run parameters or have different result schemas. - * - * @package Stripe\Reporting */ class ReportType extends \Stripe\ApiResource { diff --git a/lib/RequestTelemetry.php b/lib/RequestTelemetry.php index 1d01ae75c..bf9074acb 100644 --- a/lib/RequestTelemetry.php +++ b/lib/RequestTelemetry.php @@ -3,11 +3,9 @@ namespace Stripe; /** - * Class RequestTelemetry + * Class RequestTelemetry. * * Tracks client request telemetry - * - * @package Stripe */ class RequestTelemetry { @@ -17,8 +15,8 @@ class RequestTelemetry /** * Initialize a new telemetry object. * - * @param string $requestId The request's request ID. - * @param int $requestDuration The request's duration in milliseconds. + * @param string $requestId the request's request ID + * @param int $requestDuration the request's duration in milliseconds */ public function __construct($requestId, $requestDuration) { diff --git a/lib/Review.php b/lib/Review.php index c44302116..0364e0074 100644 --- a/lib/Review.php +++ b/lib/Review.php @@ -3,24 +3,22 @@ namespace Stripe; /** - * Class Review + * Class Review. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|null $billing_zip The ZIP or postal code of the card used, if applicable. - * @property string|\Stripe\Charge|null $charge The charge associated with this review. - * @property string|null $closed_reason The reason the review was closed, or null if it has not yet been closed. One of approved, refunded, refunded_as_fraud, or disputed. + * @property null|string $billing_zip The ZIP or postal code of the card used, if applicable. + * @property null|string|\Stripe\Charge $charge The charge associated with this review. + * @property null|string $closed_reason The reason the review was closed, or null if it has not yet been closed. One of approved, refunded, refunded_as_fraud, or disputed. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $ip_address The IP address where the payment originated. - * @property \Stripe\StripeObject|null $ip_address_location Information related to the location of the payment. Note that this information is an approximation and attempts to locate the nearest population center - it should not be used to determine a specific address. + * @property null|string $ip_address The IP address where the payment originated. + * @property null|\Stripe\StripeObject $ip_address_location Information related to the location of the payment. Note that this information is an approximation and attempts to locate the nearest population center - it should not be used to determine a specific address. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property bool $open If true, the review needs action. * @property string $opened_reason The reason the review was opened. One of rule or manual. * @property string|\Stripe\PaymentIntent $payment_intent The PaymentIntent ID associated with this review, if one exists. * @property string $reason The reason the review is currently open or closed. One of rule, manual, approved, refunded, refunded_as_fraud, or disputed. - * @property \Stripe\StripeObject|null $session Information related to the browsing session of the user who initiated the payment. - * - * @package Stripe + * @property null|\Stripe\StripeObject $session Information related to the browsing session of the user who initiated the payment. */ class Review extends ApiResource { @@ -36,26 +34,27 @@ class Review extends ApiResource * * @see https://stripe.com/docs/api/radar/reviews/object */ - const REASON_APPROVED = 'approved'; - const REASON_DISPUTED = 'disputed'; - const REASON_MANUAL = 'manual'; - const REASON_REFUNDED = 'refunded'; + const REASON_APPROVED = 'approved'; + const REASON_DISPUTED = 'disputed'; + const REASON_MANUAL = 'manual'; + const REASON_REFUNDED = 'refunded'; const REASON_REFUNDED_AS_FRAUD = 'refunded_as_fraud'; - const REASON_RULE = 'rule'; + const REASON_RULE = 'rule'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Review The approved review. + * @return Review the approved review */ public function approve($params = null, $opts = null) { $url = $this->instanceUrl() . '/approve'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/SKU.php b/lib/SKU.php index 6bb068990..7d61ac6d8 100644 --- a/lib/SKU.php +++ b/lib/SKU.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class SKU + * Class SKU. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,16 +11,14 @@ * @property \Stripe\StripeObject $attributes A dictionary of attributes and values for the attributes defined by the product. If, for example, a product's attributes are ["size", "gender"], a valid SKU has the following dictionary of attributes: {"size": "Medium", "gender": "Unisex"}. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|null $image The URL of an image for this SKU, meant to be displayable to the customer. + * @property null|string $image The URL of an image for this SKU, meant to be displayable to the customer. * @property \Stripe\StripeObject $inventory * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property \Stripe\StripeObject|null $package_dimensions The dimensions of this SKU for shipping purposes. + * @property null|\Stripe\StripeObject $package_dimensions The dimensions of this SKU for shipping purposes. * @property int $price The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 100 to charge ¥100, Japanese Yen being a zero-decimal currency). * @property string|\Stripe\Product $product The ID of the product this SKU is associated with. The product must be currently active. * @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. - * - * @package Stripe */ class SKU extends ApiResource { diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index 6c0719511..8dbeea1d6 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -3,30 +3,28 @@ namespace Stripe; /** - * Class SetupIntent + * Class SetupIntent. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|\Stripe\StripeObject|null $application ID of the Connect application that created the SetupIntent. - * @property string|null $cancellation_reason Reason for cancellation of this SetupIntent, one of abandoned, requested_by_customer, or duplicate. - * @property string|null $client_secret

The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

+ * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the SetupIntent. + * @property null|string $cancellation_reason Reason for cancellation of this SetupIntent, one of abandoned, requested_by_customer, or duplicate. + * @property null|string $client_secret

The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|\Stripe\Customer|null $customer

ID of the Customer this SetupIntent belongs to, if one exists.

If present, payment methods used with this SetupIntent can only be attached to this Customer, and payment methods attached to other Customers cannot be used with this SetupIntent.

- * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property \Stripe\ErrorObject|null $last_setup_error The error encountered in the previous SetupIntent confirmation. + * @property null|string|\Stripe\Customer $customer

ID of the Customer this SetupIntent belongs to, if one exists.

If present, payment methods used with this SetupIntent can only be attached to this Customer, and payment methods attached to other Customers cannot be used with this SetupIntent.

+ * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|\Stripe\ErrorObject $last_setup_error The error encountered in the previous SetupIntent confirmation. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|\Stripe\Mandate|null $mandate ID of the multi use Mandate generated by the SetupIntent. + * @property null|string|\Stripe\Mandate $mandate ID of the multi use Mandate generated by the SetupIntent. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property \Stripe\StripeObject|null $next_action If present, this property tells you what actions you need to take in order for your customer to continue payment setup. - * @property string|\Stripe\Account|null $on_behalf_of The account (if any) for which the setup is intended. - * @property string|\Stripe\PaymentMethod|null $payment_method ID of the payment method used with this SetupIntent. - * @property \Stripe\StripeObject|null $payment_method_options Payment-method-specific configuration for this SetupIntent. + * @property null|\Stripe\StripeObject $next_action If present, this property tells you what actions you need to take in order for your customer to continue payment setup. + * @property null|string|\Stripe\Account $on_behalf_of The account (if any) for which the setup is intended. + * @property null|string|\Stripe\PaymentMethod $payment_method ID of the payment method used with this SetupIntent. + * @property null|\Stripe\StripeObject $payment_method_options Payment-method-specific configuration for this SetupIntent. * @property string[] $payment_method_types The list of payment method types (e.g. card) that this SetupIntent is allowed to set up. - * @property string|\Stripe\Mandate|null $single_use_mandate ID of the single_use Mandate generated by the SetupIntent. + * @property null|string|\Stripe\Mandate $single_use_mandate ID of the single_use Mandate generated by the SetupIntent. * @property string $status Status of this SetupIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, canceled, or succeeded. * @property string $usage

Indicates how the payment method is intended to be used in the future.

Use on_session if you intend to only reuse the payment method when the customer is in your checkout flow. Use off_session if your customer may or may not be in your checkout flow. If not provided, this value defaults to off_session.

- * - * @package Stripe */ class SetupIntent extends ApiResource { @@ -42,42 +40,44 @@ class SetupIntent extends ApiResource * * @see https://stripe.com/docs/api/setup_intents/object#setup_intent_object-status */ - const STATUS_CANCELED = 'canceled'; - const STATUS_PROCESSING = 'processing'; - const STATUS_REQUIRES_ACTION = 'requires_action'; - const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation'; + const STATUS_CANCELED = 'canceled'; + const STATUS_PROCESSING = 'processing'; + const STATUS_REQUIRES_ACTION = 'requires_action'; + const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation'; const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method'; - const STATUS_SUCCEEDED = 'succeeded'; + const STATUS_SUCCEEDED = 'succeeded'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return SetupIntent The canceled setup intent. + * @return SetupIntent the canceled setup intent */ public function cancel($params = null, $opts = null) { $url = $this->instanceUrl() . '/cancel'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return SetupIntent The confirmed setup intent. + * @return SetupIntent the confirmed setup intent */ public function confirm($params = null, $opts = null) { $url = $this->instanceUrl() . '/confirm'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/Sigma/ScheduledQueryRun.php b/lib/Sigma/ScheduledQueryRun.php index 6ad1699f1..cfdd25f34 100644 --- a/lib/Sigma/ScheduledQueryRun.php +++ b/lib/Sigma/ScheduledQueryRun.php @@ -3,21 +3,19 @@ namespace Stripe\Sigma; /** - * Class ScheduledQueryRun + * Class ScheduledQueryRun. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property int $data_load_time When the query was run, Sigma contained a snapshot of your Stripe data at this time. * @property \Stripe\StripeObject $error - * @property \Stripe\File|null $file The file object representing the results of the query. + * @property null|\Stripe\File $file The file object representing the results of the query. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property int $result_available_until Time at which the result expires and is no longer available for download. * @property string $sql SQL for the query. * @property string $status The query's execution status, which will be completed for successful runs, and canceled, failed, or timed_out otherwise. * @property string $title Title of the query. - * - * @package Stripe\Sigma */ class ScheduledQueryRun extends \Stripe\ApiResource { @@ -28,6 +26,6 @@ class ScheduledQueryRun extends \Stripe\ApiResource public static function classUrl() { - return "/v1/sigma/scheduled_query_runs"; + return '/v1/sigma/scheduled_query_runs'; } } diff --git a/lib/SingletonApiResource.php b/lib/SingletonApiResource.php index 922c9ce39..704cff874 100644 --- a/lib/SingletonApiResource.php +++ b/lib/SingletonApiResource.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class SingletonApiResource - * - * @package Stripe + * Class SingletonApiResource. */ abstract class SingletonApiResource extends ApiResource { @@ -14,22 +12,24 @@ protected static function _singletonRetrieve($options = null) $opts = Util\RequestOptions::parse($options); $instance = new static(null, $opts); $instance->refresh(); + return $instance; } /** - * @return string The endpoint associated with this singleton class. + * @return string the endpoint associated with this singleton class */ public static function classUrl() { // Replace dots with slashes for namespaced resources, e.g. if the object's name is // "foo.bar", then its URL will be "/v1/foo/bar". $base = \str_replace('.', '/', static::OBJECT_NAME); + return "/v1/{$base}"; } /** - * @return string The endpoint associated with this singleton API resource. + * @return string the endpoint associated with this singleton API resource */ public function instanceUrl() { diff --git a/lib/Source.php b/lib/Source.php index a7238f56c..1b8d3e2bc 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class Source + * Class Source. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,7 +11,7 @@ * @property \Stripe\StripeObject $ach_debit * @property \Stripe\StripeObject $acss_debit * @property \Stripe\StripeObject $alipay - * @property int|null $amount A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for single_use sources. + * @property null|int $amount A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for single_use sources. * @property \Stripe\StripeObject $au_becs_debit * @property \Stripe\StripeObject $bancontact * @property \Stripe\StripeObject $card @@ -19,7 +19,7 @@ * @property string $client_secret The client secret of the source. Used for client-side retrieval using a publishable key. * @property \Stripe\StripeObject $code_verification * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $currency Three-letter ISO code for the currency associated with the source. This is the currency for which the source will be chargeable once ready. Required for single_use sources. + * @property null|string $currency Three-letter ISO code for the currency associated with the source. This is the currency for which the source will be chargeable once ready. Required for single_use sources. * @property string $customer The ID of the customer to which this source is attached. This will not be present when the source has not been attached to a customer. * @property \Stripe\StripeObject $eps * @property string $flow The authentication flow of the source. flow is one of redirect, receiver, code_verification, none. @@ -27,9 +27,9 @@ * @property \Stripe\StripeObject $ideal * @property \Stripe\StripeObject $klarna * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property \Stripe\StripeObject|null $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\StripeObject $multibanco - * @property \Stripe\StripeObject|null $owner Information about the owner of the payment instrument that may be used or required by particular source types. + * @property null|\Stripe\StripeObject $owner Information about the owner of the payment instrument that may be used or required by particular source types. * @property \Stripe\StripeObject $p24 * @property \Stripe\StripeObject $receiver * @property \Stripe\StripeObject $redirect @@ -37,14 +37,12 @@ * @property \Stripe\StripeObject $sepa_debit * @property \Stripe\StripeObject $sofort * @property \Stripe\StripeObject $source_order - * @property string|null $statement_descriptor Extra information about a source. This will appear on your customer's statement every time you charge the source. + * @property null|string $statement_descriptor Extra information about a source. This will appear on your customer's statement every time you charge the source. * @property string $status The status of the source, one of canceled, chargeable, consumed, failed, or pending. Only chargeable sources can be used to create a charge. * @property \Stripe\StripeObject $three_d_secure * @property string $type The type of the source. The type is a payment method, one of ach_credit_transfer, ach_debit, alipay, bancontact, card, card_present, eps, giropay, ideal, multibanco, klarna, p24, sepa_debit, sofort, three_d_secure, or wechat. An additional hash is included on the source with a name matching this value. It contains additional information specific to the payment method used. - * @property string|null $usage Either reusable or single_use. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while others may leave the option at creation. If an incompatible value is passed, an error will be returned. + * @property null|string $usage Either reusable or single_use. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while others may leave the option at creation. If an incompatible value is passed, an error will be returned. * @property \Stripe\StripeObject $wechat - * - * @package Stripe */ class Source extends ApiResource { @@ -61,38 +59,38 @@ class Source extends ApiResource * * @see https://stripe.com/docs/api#source_object-flow */ - const FLOW_REDIRECT = 'redirect'; - const FLOW_RECEIVER = 'receiver'; + const FLOW_REDIRECT = 'redirect'; + const FLOW_RECEIVER = 'receiver'; const FLOW_CODE_VERIFICATION = 'code_verification'; - const FLOW_NONE = 'none'; + const FLOW_NONE = 'none'; /** * Possible string representations of source statuses. * * @see https://stripe.com/docs/api#source_object-status */ - const STATUS_CANCELED = 'canceled'; + const STATUS_CANCELED = 'canceled'; const STATUS_CHARGEABLE = 'chargeable'; - const STATUS_CONSUMED = 'consumed'; - const STATUS_FAILED = 'failed'; - const STATUS_PENDING = 'pending'; + const STATUS_CONSUMED = 'consumed'; + const STATUS_FAILED = 'failed'; + const STATUS_PENDING = 'pending'; /** * Possible string representations of source usage. * * @see https://stripe.com/docs/api#source_object-usage */ - const USAGE_REUSABLE = 'reusable'; + const USAGE_REUSABLE = 'reusable'; const USAGE_SINGLE_USE = 'single_use'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\UnexpectedValueException if the source is not attached to a customer * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Source The detached source. + * @return \Stripe\Source the detached source */ public function detach($params = null, $opts = null) { @@ -103,6 +101,7 @@ public function detach($params = null, $opts = null) $class = \get_class($this); $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}"; + throw new Exception\UnexpectedValueException($msg, null); } @@ -114,22 +113,24 @@ public function detach($params = null, $opts = null) list($response, $opts) = $this->_request('delete', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } - $message = "This source object does not appear to be currently attached " - . "to a customer object."; + $message = 'This source object does not appear to be currently attached ' + . 'to a customer object.'; + throw new Exception\UnexpectedValueException($message); } /** * @deprecated sourceTransactions is deprecated. Please use Source::allSourceTransactions instead. * - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of source transactions. + * @return \Stripe\Collection the list of source transactions */ public function sourceTransactions($params = null, $opts = null) { @@ -137,17 +138,18 @@ public function sourceTransactions($params = null, $opts = null) list($response, $opts) = $this->_request('get', $url, $params, $opts); $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts); $obj->setLastResponse($response); + return $obj; } /** * @param string $id - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of source transactions. + * @return \Stripe\Collection the list of source transactions */ public static function allSourceTransactions($id, $params = null, $opts = null) { @@ -155,18 +157,19 @@ public static function allSourceTransactions($id, $params = null, $opts = null) } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Source The verified source. + * @return Source the verified source */ public function verify($params = null, $opts = null) { $url = $this->instanceUrl() . '/verify'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/SourceTransaction.php b/lib/SourceTransaction.php index 3f38c082b..281f2a710 100644 --- a/lib/SourceTransaction.php +++ b/lib/SourceTransaction.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class SourceTransaction + * Class SourceTransaction. * * @property string $id * @property string $object @@ -13,8 +13,6 @@ * @property string $customer_data * @property string $currency * @property string $type - * - * @package Stripe */ class SourceTransaction extends ApiResource { diff --git a/lib/Stripe.php b/lib/Stripe.php index 7b8c4a8e1..91ddbccb7 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class Stripe - * - * @package Stripe + * Class Stripe. */ class Stripe { @@ -24,10 +22,10 @@ class Stripe /** @var string The base URL for the Stripe API uploads endpoint. */ public static $apiUploadBase = 'https://files.stripe.com'; - /** @var string|null The version of the Stripe API to use for requests. */ + /** @var null|string The version of the Stripe API to use for requests. */ public static $apiVersion = null; - /** @var string|null The account ID for connected accounts requests. */ + /** @var null|string The account ID for connected accounts requests. */ public static $accountId = null; /** @var string Path to the CA bundle used to verify SSL certificates */ @@ -40,8 +38,8 @@ class Stripe public static $appInfo = null; /** - * @var Util\LoggerInterface|null The logger to which the library will - * produce messages. + * @var null|Util\LoggerInterface the logger to which the library will + * produce messages */ public static $logger = null; @@ -63,7 +61,7 @@ class Stripe const VERSION = '7.24.0'; /** - * @return string The API key used for requests. + * @return string the API key used for requests */ public static function getApiKey() { @@ -71,7 +69,7 @@ public static function getApiKey() } /** - * @return string The client_id used for Connect requests. + * @return string the client_id used for Connect requests */ public static function getClientId() { @@ -79,20 +77,21 @@ public static function getClientId() } /** - * @return Util\LoggerInterface The logger to which the library will - * produce messages. + * @return Util\LoggerInterface the logger to which the library will + * produce messages */ public static function getLogger() { if (null === self::$logger) { return new Util\DefaultLogger(); } + return self::$logger; } /** - * @param Util\LoggerInterface $logger The logger to which the library - * will produce messages. + * @param Util\LoggerInterface $logger the logger to which the library + * will produce messages */ public static function setLogger($logger) { @@ -129,7 +128,7 @@ public static function getApiVersion() } /** - * @param string $apiVersion The API version to use for requests. + * @param string $apiVersion the API version to use for requests */ public static function setApiVersion($apiVersion) { @@ -141,7 +140,7 @@ public static function setApiVersion($apiVersion) */ private static function getDefaultCABundlePath() { - return \realpath(\dirname(__FILE__) . '/../data/ca-certificates.crt'); + return \realpath(__DIR__ . '/../data/ca-certificates.crt'); } /** @@ -178,7 +177,7 @@ public static function setVerifySslCerts($verify) /** * @return string | null The Stripe account ID for connected account - * requests. + * requests */ public static function getAccountId() { @@ -186,8 +185,8 @@ public static function getAccountId() } /** - * @param string $accountId The Stripe account ID to set for connected - * account requests. + * @param string $accountId the Stripe account ID to set for connected + * account requests */ public static function setAccountId($accountId) { @@ -204,9 +203,9 @@ public static function getAppInfo() /** * @param string $appName The application's name - * @param string|null $appVersion The application's version - * @param string|null $appUrl The application's URL - * @param string|null $appPartnerId The application's partner ID + * @param null|string $appVersion The application's version + * @param null|string $appUrl The application's URL + * @param null|string $appPartnerId The application's partner ID */ public static function setAppInfo($appName, $appVersion = null, $appUrl = null, $appPartnerId = null) { diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 434eab472..cf61f7de2 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class StripeObject - * - * @package Stripe + * Class StripeObject. */ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable { @@ -29,12 +27,14 @@ public static function getPermanentAttributes() 'id', ]); } + return $permanentAttributes; } /** * Additive objects are subobjects in the API that don't have the same * semantics as most subobjects, which are fully replaced when they're set. + * * This is best illustrated by example. The `source` parameter sent when * updating a subscription is *not* additive; if we set it: * @@ -96,6 +96,7 @@ public static function getAdditiveParams() 'metadata', ]); } + return $additiveParams; } @@ -122,7 +123,7 @@ public function __set($k, $v) ); } - if ("" === $v) { + if ('' === $v) { throw new Exception\InvalidArgumentException( 'You cannot set \'' . $k . '\'to an empty string. ' . 'We interpret empty strings as NULL in requests. ' @@ -159,15 +160,17 @@ public function &__get($k) $attrs = \implode(', ', \array_keys($this->_values)); $message = "Stripe Notice: Undefined property of {$class} instance: {$k}. " . "HINT: The {$k} attribute was set in the past, however. " - . "It was then wiped when refreshing the object " + . 'It was then wiped when refreshing the object ' . "with the result returned by Stripe's API, " - . "probably as a result of a save(). The attributes currently " + . 'probably as a result of a save(). The attributes currently ' . "available on this object are: {$attrs}"; Stripe::getLogger()->error($message); + return $nullval; } $class = \get_class($this); Stripe::getLogger()->error("Stripe Notice: Undefined property of {$class} instance: {$k}"); + return $nullval; } @@ -215,17 +218,18 @@ public function values() } /** - * This unfortunately needs to be public to be used in Util\Util + * This unfortunately needs to be public to be used in Util\Util. * * @param array $values - * @param array|string|Util\RequestOptions|null $opts + * @param null|array|string|Util\RequestOptions $opts * - * @return static The object constructed from the given values. + * @return static the object constructed from the given values */ public static function constructFrom($values, $opts = null) { $obj = new static(isset($values['id']) ? $values['id'] : null); $obj->refreshFrom($values, $opts); + return $obj; } @@ -233,8 +237,8 @@ public static function constructFrom($values, $opts = null) * Refreshes this object using the provided values. * * @param array $values - * @param array|string|Util\RequestOptions|null $opts - * @param bool $partial Defaults to false. + * @param null|array|string|Util\RequestOptions $opts + * @param bool $partial defaults to false */ public function refreshFrom($values, $opts, $partial = false) { @@ -270,8 +274,8 @@ public function refreshFrom($values, $opts, $partial = false) * Mass assigns attributes on the model. * * @param array $values - * @param array|string|Util\RequestOptions|null $opts - * @param bool $dirty Defaults to true. + * @param null|array|string|Util\RequestOptions $opts + * @param bool $dirty defaults to true */ public function updateAttributes($values, $opts = null, $dirty = true) { @@ -280,7 +284,7 @@ public function updateAttributes($values, $opts = null, $dirty = true) // This is necessary in case metadata is empty, as PHP arrays do // not differentiate between lists and hashes, and we consider // empty arrays to be lists. - if (("metadata" === $k) && (\is_array($v))) { + if (('metadata' === $k) && (\is_array($v))) { $this->_values[$k] = StripeObject::constructFrom($v, $opts); } else { $this->_values[$k] = Util\Util::convertToStripeObject($v, $opts); @@ -293,10 +297,10 @@ public function updateAttributes($values, $opts = null, $dirty = true) } /** - * @param bool $force Defaults to false. + * @param bool $force defaults to false * - * @return array A recursive mapping of attributes to values for this object, - * including the proper value for deleted attributes. + * @return array a recursive mapping of attributes to values for this object, + * including the proper value for deleted attributes */ public function serializeParameters($force = false) { @@ -361,7 +365,7 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = // anything with it because the integration is probably not working as the // user intended it to. if (null === $value) { - return ""; + return ''; } if (($value instanceof ApiResource) && (!$value->saveWithParent)) { if (!$unsaved) { @@ -370,10 +374,11 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = if (isset($value->id)) { return $value; } + throw new Exception\InvalidArgumentException( "Cannot save property `{$key}` containing an API resource of type " . \get_class($value) . ". It doesn't appear to be persisted and is " . - "not marked as `saveWithParent`." + 'not marked as `saveWithParent`.' ); } if (\is_array($value)) { @@ -396,6 +401,7 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = if ($original && $unsaved && $key && static::getAdditiveParams()->includes($key)) { $update = \array_merge(self::emptyValues($original), $update); } + return $update; } else { return $value; @@ -411,7 +417,7 @@ public function jsonSerialize() * Returns an associative array with the key and values composing the * Stripe object. * - * @return array The associative array. + * @return array the associative array */ public function toArray() { @@ -433,6 +439,7 @@ public function toArray() } else { $acc[$k] = $maybeToArray($v); } + return $acc; }, []); } @@ -440,7 +447,7 @@ public function toArray() /** * Returns a pretty JSON representation of the Stripe object. * - * @return string The JSON representation of the Stripe object. + * @return string the JSON representation of the Stripe object */ public function toJSON() { @@ -450,6 +457,7 @@ public function toJSON() public function __toString() { $class = \get_class($this); + return $class . ' JSON: ' . $this->toJSON(); } @@ -491,6 +499,7 @@ protected static function deepCopy($obj) foreach ($obj as $k => $v) { $copy[$k] = self::deepCopy($v); } + return $copy; } if ($obj instanceof StripeObject) { @@ -499,6 +508,7 @@ protected static function deepCopy($obj) clone $obj->_opts ); } + return $obj; } @@ -516,10 +526,11 @@ public static function emptyValues($obj) $values = $obj->_values; } else { throw new Exception\InvalidArgumentException( - "empty_values got unexpected object type: " . \get_class($obj) + 'empty_values got unexpected object type: ' . \get_class($obj) ); } - return \array_fill_keys(\array_keys($values), ""); + + return \array_fill_keys(\array_keys($values), ''); } /** @@ -531,7 +542,7 @@ public function getLastResponse() } /** - * Sets the last response from the Stripe API + * Sets the last response from the Stripe API. * * @param ApiResponse $resp */ @@ -545,7 +556,7 @@ public function setLastResponse($resp) * Note that some, but not all, resources can indicate whether they have * been deleted. * - * @return bool Whether the resource is deleted. + * @return bool whether the resource is deleted */ public function isDeleted() { diff --git a/lib/Subscription.php b/lib/Subscription.php index 44f2087d1..b3e9e5880 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -3,45 +3,43 @@ namespace Stripe; /** - * Class Subscription + * Class Subscription. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property float|null $application_fee_percent A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account. + * @property null|float $application_fee_percent A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account. * @property int $billing_cycle_anchor Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices. - * @property \Stripe\StripeObject|null $billing_thresholds Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period - * @property int|null $cancel_at A date in the future at which the subscription will automatically get canceled + * @property null|\Stripe\StripeObject $billing_thresholds Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period + * @property null|int $cancel_at A date in the future at which the subscription will automatically get canceled * @property bool $cancel_at_period_end If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period. - * @property int|null $canceled_at If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state. - * @property string|null $collection_method Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions. + * @property null|int $canceled_at If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state. + * @property null|string $collection_method Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property int $current_period_end End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. * @property int $current_period_start Start of the current period that the subscription has been invoiced for. * @property string|\Stripe\Customer $customer ID of the customer who owns the subscription. - * @property int|null $days_until_due Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where collection_method=charge_automatically. - * @property string|\Stripe\PaymentMethod|null $default_payment_method ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. If not set, invoices will use the default payment method in the customer's invoice settings. - * @property string|\Stripe\StripeObject|null $default_source ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If not set, defaults to the customer's default source. - * @property \Stripe\TaxRate[]|null $default_tax_rates The tax rates that will apply to any subscription item that does not have tax_rates set. Invoices created will have their default_tax_rates populated from the subscription. - * @property \Stripe\Discount|null $discount Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis. - * @property int|null $ended_at If the subscription has ended, the date the subscription ended. + * @property null|int $days_until_due Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where collection_method=charge_automatically. + * @property null|string|\Stripe\PaymentMethod $default_payment_method ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. If not set, invoices will use the default payment method in the customer's invoice settings. + * @property null|string|\Stripe\StripeObject $default_source ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If not set, defaults to the customer's default source. + * @property null|\Stripe\TaxRate[] $default_tax_rates The tax rates that will apply to any subscription item that does not have tax_rates set. Invoices created will have their default_tax_rates populated from the subscription. + * @property null|\Stripe\Discount $discount Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis. + * @property null|int $ended_at If the subscription has ended, the date the subscription ended. * @property \Stripe\Collection $items List of subscription items, each with an attached plan. - * @property string|\Stripe\Invoice|null $latest_invoice The most recent invoice this subscription has generated. + * @property null|string|\Stripe\Invoice $latest_invoice The most recent invoice this subscription has generated. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property int|null $next_pending_invoice_item_invoice Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at pending_invoice_item_interval. - * @property \Stripe\StripeObject|null $pending_invoice_item_interval Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval. - * @property string|\Stripe\SetupIntent|null $pending_setup_intent You can use this SetupIntent to collect user authentication when creating a subscription without immediate payment or updating a subscription's payment method, allowing you to optimize for off-session payments. Learn more in the SCA Migration Guide. - * @property \Stripe\StripeObject|null $pending_update If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid. - * @property \Stripe\Plan|null $plan Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan. - * @property int|null $quantity The quantity of the plan to which the customer is subscribed. For example, if your plan is $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly. Only set if the subscription contains a single plan. - * @property string|\Stripe\SubscriptionSchedule|null $schedule The schedule attached to the subscription + * @property null|int $next_pending_invoice_item_invoice Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at pending_invoice_item_interval. + * @property null|\Stripe\StripeObject $pending_invoice_item_interval Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval. + * @property null|string|\Stripe\SetupIntent $pending_setup_intent You can use this SetupIntent to collect user authentication when creating a subscription without immediate payment or updating a subscription's payment method, allowing you to optimize for off-session payments. Learn more in the SCA Migration Guide. + * @property null|\Stripe\StripeObject $pending_update If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid. + * @property null|\Stripe\Plan $plan Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan. + * @property null|int $quantity The quantity of the plan to which the customer is subscribed. For example, if your plan is $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly. Only set if the subscription contains a single plan. + * @property null|string|\Stripe\SubscriptionSchedule $schedule The schedule attached to the subscription * @property int $start_date Date when the subscription was first created. The date might differ from the created date due to backdating. * @property string $status

Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid.

For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active state. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal state, the open invoice will be voided and no further invoices will be generated.

A subscription that is currently in a trial period is trialing and moves to active when the trial period is over.

If subscription collection_method=charge_automatically it becomes past_due when payment to renew it fails and canceled or unpaid (depending on your subscriptions settings) when Stripe has exhausted all payment retry attempts.

If subscription collection_method=send_invoice it becomes past_due when its invoice is not paid by the due date, and canceled or unpaid if it is still not paid by an additional deadline after that. Note that when a subscription has a status of unpaid, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.

- * @property float|null $tax_percent If provided, each invoice created by this subscription will apply the tax rate, increasing the amount billed to the customer. - * @property int|null $trial_end If the subscription has a trial, the end of that trial. - * @property int|null $trial_start If the subscription has a trial, the beginning of that trial. - * - * @package Stripe + * @property null|float $tax_percent If provided, each invoice created by this subscription will apply the tax rate, increasing the amount billed to the customer. + * @property null|int $trial_end If the subscription has a trial, the end of that trial. + * @property null|int $trial_start If the subscription has a trial, the beginning of that trial. */ class Subscription extends ApiResource { @@ -57,12 +55,12 @@ class Subscription extends ApiResource * * @see https://stripe.com/docs/api#subscription_object-status */ - const STATUS_ACTIVE = 'active'; - const STATUS_CANCELED = 'canceled'; - const STATUS_PAST_DUE = 'past_due'; - const STATUS_TRIALING = 'trialing'; - const STATUS_UNPAID = 'unpaid'; - const STATUS_INCOMPLETE = 'incomplete'; + const STATUS_ACTIVE = 'active'; + const STATUS_CANCELED = 'canceled'; + const STATUS_PAST_DUE = 'past_due'; + const STATUS_TRIALING = 'trialing'; + const STATUS_UNPAID = 'unpaid'; + const STATUS_INCOMPLETE = 'incomplete'; const STATUS_INCOMPLETE_EXPIRED = 'incomplete_expired'; use ApiOperations\Delete { @@ -77,16 +75,17 @@ public static function getSavedNestedResources() 'source', ]); } + return $savedNestedResources; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Subscription The deleted subscription. + * @return \Stripe\Subscription the deleted subscription */ public function cancel($params = null, $opts = null) { @@ -94,12 +93,12 @@ public function cancel($params = null, $opts = null) } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Subscription The updated subscription. + * @return \Stripe\Subscription the updated subscription */ public function deleteDiscount($params = null, $opts = null) { diff --git a/lib/SubscriptionItem.php b/lib/SubscriptionItem.php index b8a658ff4..a8ff1f3eb 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -3,19 +3,17 @@ namespace Stripe; /** - * Class SubscriptionItem + * Class SubscriptionItem. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property \Stripe\StripeObject|null $billing_thresholds Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period + * @property null|\Stripe\StripeObject $billing_thresholds Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\Plan $plan * @property int $quantity The quantity of the plan to which the customer should be subscribed. * @property string $subscription The subscription this subscription_item belongs to. - * @property \Stripe\TaxRate[]|null $tax_rates The tax rates which apply to this subscription_item. When set, the default_tax_rates on the subscription do not apply to this subscription_item. - * - * @package Stripe + * @property null|\Stripe\TaxRate[] $tax_rates The tax rates which apply to this subscription_item. When set, the default_tax_rates on the subscription do not apply to this subscription_item. */ class SubscriptionItem extends ApiResource { @@ -31,9 +29,9 @@ class SubscriptionItem extends ApiResource const PATH_USAGE_RECORDS = '/usage_records'; /** - * @param string|null $id The ID of the subscription item on which to create the usage record. - * @param array|null $params - * @param array|string|null $opts + * @param null|string $id the ID of the subscription item on which to create the usage record + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -47,12 +45,12 @@ public static function createUsageRecord($id, $params = null, $opts = null) /** * @deprecated usageRecordSummaries is deprecated. Please use SubscriptionItem::allUsageRecordSummaries instead. * - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of usage record summaries. + * @return \Stripe\Collection the list of usage record summaries */ public function usageRecordSummaries($params = null, $opts = null) { @@ -60,19 +58,20 @@ public function usageRecordSummaries($params = null, $opts = null) list($response, $opts) = $this->_request('get', $url, $params, $opts); $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts); $obj->setLastResponse($response); + return $obj; } const PATH_USAGE_RECORD_SUMMARIES = '/usage_record_summaries'; /** - * @param string $id The ID of the subscription item on which to retrieve the usage record summaries. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the subscription item on which to retrieve the usage record summaries + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of usage record summaries. + * @return \Stripe\Collection the list of usage record summaries */ public static function allUsageRecordSummaries($id, $params = null, $opts = null) { diff --git a/lib/SubscriptionSchedule.php b/lib/SubscriptionSchedule.php index 640354350..53add60e3 100644 --- a/lib/SubscriptionSchedule.php +++ b/lib/SubscriptionSchedule.php @@ -3,27 +3,25 @@ namespace Stripe; /** - * Class SubscriptionSchedule + * Class SubscriptionSchedule. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property int|null $canceled_at Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch. - * @property int|null $completed_at Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch. + * @property null|int $canceled_at Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch. + * @property null|int $completed_at Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property \Stripe\StripeObject|null $current_phase Object representing the start and end dates for the current phase of the subscription schedule, if it is active. + * @property null|\Stripe\StripeObject $current_phase Object representing the start and end dates for the current phase of the subscription schedule, if it is active. * @property string|\Stripe\Customer $customer ID of the customer who owns the subscription schedule. * @property \Stripe\StripeObject $default_settings * @property string $end_behavior Behavior of the subscription schedule and underlying subscription when it ends. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property \Stripe\StripeObject|null $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\StripeObject[] $phases Configuration for the subscription schedule's phases. - * @property int|null $released_at Time at which the subscription schedule was released. Measured in seconds since the Unix epoch. - * @property string|null $released_subscription ID of the subscription once managed by the subscription schedule (if it is released). - * @property \Stripe\StripeObject|null $renewal_interval This field has been deprecated. Interval and duration at which the subscription schedule renews for when it ends if renewal_behavior is renew. + * @property null|int $released_at Time at which the subscription schedule was released. Measured in seconds since the Unix epoch. + * @property null|string $released_subscription ID of the subscription once managed by the subscription schedule (if it is released). + * @property null|\Stripe\StripeObject $renewal_interval This field has been deprecated. Interval and duration at which the subscription schedule renews for when it ends if renewal_behavior is renew. * @property string $status The present status of the subscription schedule. Possible values are not_started, active, completed, released, and canceled. You can read more about the different states in our behavior guide. - * @property string|\Stripe\Subscription|null $subscription ID of the subscription managed by the subscription schedule. - * - * @package Stripe + * @property null|string|\Stripe\Subscription $subscription ID of the subscription managed by the subscription schedule. */ class SubscriptionSchedule extends ApiResource { @@ -35,34 +33,36 @@ class SubscriptionSchedule extends ApiResource use ApiOperations\Update; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return SubscriptionSchedule The canceled subscription schedule. + * @return SubscriptionSchedule the canceled subscription schedule */ public function cancel($params = null, $opts = null) { $url = $this->instanceUrl() . '/cancel'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return SubscriptionSchedule The released subscription schedule. + * @return SubscriptionSchedule the released subscription schedule */ public function release($params = null, $opts = null) { $url = $this->instanceUrl() . '/release'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/TaxId.php b/lib/TaxId.php index 821cea66d..36bf0c1aa 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class TaxId - * - * @package Stripe + * Class TaxId. * * @property string $id * @property string $object @@ -28,35 +26,35 @@ class TaxId extends ApiResource * * @see https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type */ - const TYPE_AU_ABN = 'au_abn'; - const TYPE_CA_BN = 'ca_bn'; - const TYPE_CH_VAT = 'ch_vat'; - const TYPE_ES_CIF = 'es_cif'; - const TYPE_EU_VAT = 'eu_vat'; - const TYPE_HK_BR = 'hk_br'; - const TYPE_IN_GST = 'in_gst'; - const TYPE_MX_RFC = 'mx_rfc'; - const TYPE_NO_VAT = 'no_vat'; - const TYPE_NZ_GST = 'nz_gst'; - const TYPE_RU_INN = 'ru_inn'; - const TYPE_SG_UEN = 'sg_uen'; - const TYPE_TH_VAT = 'th_vat'; - const TYPE_TW_VAT = 'tw_vat'; + const TYPE_AU_ABN = 'au_abn'; + const TYPE_CA_BN = 'ca_bn'; + const TYPE_CH_VAT = 'ch_vat'; + const TYPE_ES_CIF = 'es_cif'; + const TYPE_EU_VAT = 'eu_vat'; + const TYPE_HK_BR = 'hk_br'; + const TYPE_IN_GST = 'in_gst'; + const TYPE_MX_RFC = 'mx_rfc'; + const TYPE_NO_VAT = 'no_vat'; + const TYPE_NZ_GST = 'nz_gst'; + const TYPE_RU_INN = 'ru_inn'; + const TYPE_SG_UEN = 'sg_uen'; + const TYPE_TH_VAT = 'th_vat'; + const TYPE_TW_VAT = 'tw_vat'; const TYPE_UNKNOWN = 'unknown'; - const TYPE_ZA_VAT = 'za_vat'; + const TYPE_ZA_VAT = 'za_vat'; /** * Possible string representations of the verification status. * * @see https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-verification */ - const VERIFICATION_STATUS_PENDING = 'pending'; + const VERIFICATION_STATUS_PENDING = 'pending'; const VERIFICATION_STATUS_UNAVAILABLE = 'unavailable'; - const VERIFICATION_STATUS_UNVERIFIED = 'unverified'; - const VERIFICATION_STATUS_VERIFIED = 'verified'; + const VERIFICATION_STATUS_UNVERIFIED = 'unverified'; + const VERIFICATION_STATUS_VERIFIED = 'verified'; /** - * @return string The API URL for this tax id. + * @return string the API URL for this tax id */ public function instanceUrl() { @@ -73,20 +71,22 @@ public function instanceUrl() $base = Customer::classUrl(); $customerExtn = \urlencode($customer); $extn = \urlencode($id); + return "{$base}/{$customerExtn}/tax_ids/{$extn}"; } /** * @param array|string $_id - * @param array|string|null $_opts + * @param null|array|string $_opts * * @throws \Stripe\Exception\BadMethodCallException */ public static function retrieve($_id, $_opts = null) { - $msg = "Tax IDs cannot be retrieved without a customer ID. Retrieve " . + $msg = 'Tax IDs cannot be retrieved without a customer ID. Retrieve ' . "a tax ID using `Customer::retrieveTaxId('customer_id', " . "'tax_id_id')`."; + throw new Exception\BadMethodCallException($msg); } } diff --git a/lib/TaxRate.php b/lib/TaxRate.php index 5e582016f..57df63284 100644 --- a/lib/TaxRate.php +++ b/lib/TaxRate.php @@ -3,21 +3,19 @@ namespace Stripe; /** - * Class TaxRate + * Class TaxRate. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property bool $active Defaults to true. When set to false, this tax rate cannot be applied to objects in the API, but will still be applied to subscriptions and invoices that already have it set. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string|null $description An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers. + * @property null|string $description An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers. * @property string $display_name The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page. * @property bool $inclusive This specifies if the tax rate is inclusive or exclusive. - * @property string|null $jurisdiction The jurisdiction for the tax rate. + * @property null|string $jurisdiction The jurisdiction for the tax rate. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property float $percentage This represents the tax rate percent out of 100. - * - * @package Stripe */ class TaxRate extends ApiResource { diff --git a/lib/Terminal/ConnectionToken.php b/lib/Terminal/ConnectionToken.php index a36fd18de..16571e0cc 100644 --- a/lib/Terminal/ConnectionToken.php +++ b/lib/Terminal/ConnectionToken.php @@ -3,13 +3,11 @@ namespace Stripe\Terminal; /** - * Class ConnectionToken + * Class ConnectionToken. * * @property string $object String representing the object's type. Objects of the same type share the same value. * @property string $location The id of the location that this connection token is scoped to. * @property string $secret Your application should pass this token to the Stripe Terminal SDK. - * - * @package Stripe\Terminal */ class ConnectionToken extends \Stripe\ApiResource { diff --git a/lib/Terminal/Location.php b/lib/Terminal/Location.php index e8bc6d582..92e38ab11 100644 --- a/lib/Terminal/Location.php +++ b/lib/Terminal/Location.php @@ -3,7 +3,7 @@ namespace Stripe\Terminal; /** - * Class Location + * Class Location. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -11,8 +11,6 @@ * @property string $display_name The display name of the location. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * - * @package Stripe\Terminal */ class Location extends \Stripe\ApiResource { diff --git a/lib/Terminal/Reader.php b/lib/Terminal/Reader.php index 9a11a13f1..2b480ee91 100644 --- a/lib/Terminal/Reader.php +++ b/lib/Terminal/Reader.php @@ -3,21 +3,19 @@ namespace Stripe\Terminal; /** - * Class Reader + * Class Reader. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|null $device_sw_version The current software version of the reader. + * @property null|string $device_sw_version The current software version of the reader. * @property string $device_type Type of reader, one of bbpos_chipper2x or verifone_P400. - * @property string|null $ip_address The local IP address of the reader. + * @property null|string $ip_address The local IP address of the reader. * @property string $label Custom label given to the reader for easier identification. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|null $location The location identifier of the reader. + * @property null|string $location The location identifier of the reader. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $serial_number Serial number of the reader. - * @property string|null $status The networking status of the reader. - * - * @package Stripe\Terminal + * @property null|string $status The networking status of the reader. */ class Reader extends \Stripe\ApiResource { diff --git a/lib/ThreeDSecure.php b/lib/ThreeDSecure.php index 3ba59176e..4b353b84b 100644 --- a/lib/ThreeDSecure.php +++ b/lib/ThreeDSecure.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class ThreeDSecure + * Class ThreeDSecure. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. @@ -13,10 +13,8 @@ * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property string|null $redirect_url If present, this is the URL that you should send the cardholder to for authentication. If you are going to use Stripe.js to display the authentication page in an iframe, you should use the value "_callback". + * @property null|string $redirect_url If present, this is the URL that you should send the cardholder to for authentication. If you are going to use Stripe.js to display the authentication page in an iframe, you should use the value "_callback". * @property string $status Possible values are redirect_pending, succeeded, or failed. When the cardholder can be authenticated, the object starts with status redirect_pending. When liability will be shifted to the cardholder's bank (either because the cardholder was successfully authenticated, or because the bank has not implemented 3D Secure, the object wlil be in status succeeded. failed indicates that authentication was attempted unsuccessfully. - * - * @package Stripe */ class ThreeDSecure extends ApiResource { @@ -26,10 +24,10 @@ class ThreeDSecure extends ApiResource use ApiOperations\Retrieve; /** - * @return string The endpoint URL for the given class. + * @return string the endpoint URL for the given class */ public static function classUrl() { - return "/v1/3d_secure"; + return '/v1/3d_secure'; } } diff --git a/lib/Token.php b/lib/Token.php index c9a850882..d33be31bb 100644 --- a/lib/Token.php +++ b/lib/Token.php @@ -3,19 +3,17 @@ namespace Stripe; /** - * Class Token + * Class Token. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property \Stripe\BankAccount $bank_account * @property \Stripe\Card $card - * @property string|null $client_ip IP address of the client that generated the token. + * @property null|string $client_ip IP address of the client that generated the token. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property string $type Type of the token: account, bank_account, card, or pii. * @property bool $used Whether this token has already been used (tokens can be used only once). - * - * @package Stripe */ class Token extends ApiResource { @@ -29,8 +27,8 @@ class Token extends ApiResource * * @see https://stripe.com/docs/api/tokens/object#token_object-type */ - const TYPE_ACCOUNT = 'account'; + const TYPE_ACCOUNT = 'account'; const TYPE_BANK_ACCOUNT = 'bank_account'; - const TYPE_CARD = 'card'; - const TYPE_PII = 'pii'; + const TYPE_CARD = 'card'; + const TYPE_PII = 'pii'; } diff --git a/lib/Topup.php b/lib/Topup.php index 5cd92e78b..ec1dad1f9 100644 --- a/lib/Topup.php +++ b/lib/Topup.php @@ -3,26 +3,24 @@ namespace Stripe; /** - * Class Topup + * Class Topup. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount Amount transferred. - * @property string|\Stripe\BalanceTransaction|null $balance_transaction ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up. + * @property null|string|\Stripe\BalanceTransaction $balance_transaction ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property int|null $expected_availability_date Date the funds are expected to arrive in your Stripe account for payouts. This factors in delays like weekends or bank holidays. May not be specified depending on status of top-up. - * @property string|null $failure_code Error code explaining reason for top-up failure if available (see the errors section for a list of codes). - * @property string|null $failure_message Message to user further explaining reason for top-up failure if available. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|int $expected_availability_date Date the funds are expected to arrive in your Stripe account for payouts. This factors in delays like weekends or bank holidays. May not be specified depending on status of top-up. + * @property null|string $failure_code Error code explaining reason for top-up failure if available (see the errors section for a list of codes). + * @property null|string $failure_message Message to user further explaining reason for top-up failure if available. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\Source $source - * @property string|null $statement_descriptor Extra information about a top-up. This will appear on your source's bank statement. It must contain at least one letter. + * @property null|string $statement_descriptor Extra information about a top-up. This will appear on your source's bank statement. It must contain at least one letter. * @property string $status The status of the top-up is either canceled, failed, pending, reversed, or succeeded. - * @property string|null $transfer_group A string that identifies this top-up as part of a group. - * - * @package Stripe + * @property null|string $transfer_group A string that identifies this top-up as part of a group. */ class Topup extends ApiResource { @@ -38,25 +36,26 @@ class Topup extends ApiResource * * @see https://stripe.com/docs/api/topups/object#topup_object-status */ - const STATUS_CANCELED = 'canceled'; - const STATUS_FAILED = 'failed'; - const STATUS_PENDING = 'pending'; - const STATUS_REVERSED = 'reversed'; + const STATUS_CANCELED = 'canceled'; + const STATUS_FAILED = 'failed'; + const STATUS_PENDING = 'pending'; + const STATUS_REVERSED = 'reversed'; const STATUS_SUCCEEDED = 'succeeded'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Topup The canceled topup. + * @return Topup the canceled topup */ public function cancel($params = null, $opts = null) { $url = $this->instanceUrl() . '/cancel'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } } diff --git a/lib/Transfer.php b/lib/Transfer.php index 71842b798..70eb617b4 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -3,27 +3,25 @@ namespace Stripe; /** - * Class Transfer + * Class Transfer. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. * @property int $amount Amount in %s to be transferred. * @property int $amount_reversed Amount in %s reversed (can be less than the amount attribute on the transfer if a partial reversal was issued). - * @property string|\Stripe\BalanceTransaction|null $balance_transaction Balance transaction that describes the impact of this transfer on your account balance. + * @property null|string|\Stripe\BalanceTransaction $balance_transaction Balance transaction that describes the impact of this transfer on your account balance. * @property int $created Time that this record of the transfer was first created. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property string|null $description An arbitrary string attached to the object. Often useful for displaying to users. - * @property string|\Stripe\Account|null $destination ID of the Stripe account the transfer was sent to. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string|\Stripe\Account $destination ID of the Stripe account the transfer was sent to. * @property string|\Stripe\Charge $destination_payment If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\Collection $reversals A list of reversals that have been applied to the transfer. * @property bool $reversed Whether the transfer has been fully reversed. If the transfer is only partially reversed, this attribute will still be false. - * @property string|\Stripe\Charge|null $source_transaction ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance. - * @property string|null $source_type The source balance this transfer came from. One of card, fpx, or bank_account. - * @property string|null $transfer_group A string that identifies this transaction as part of a group. See the Connect documentation for details. - * - * @package Stripe + * @property null|string|\Stripe\Charge $source_transaction ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance. + * @property null|string $source_type The source balance this transfer came from. One of card, fpx, or bank_account. + * @property null|string $transfer_group A string that identifies this transaction as part of a group. See the Connect documentation for details. */ class Transfer extends ApiResource { @@ -41,36 +39,37 @@ class Transfer extends ApiResource * @see https://stripe.com/docs/api/transfers/object#transfer_object-source_type */ const SOURCE_TYPE_ALIPAY_ACCOUNT = 'alipay_account'; - const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account'; - const SOURCE_TYPE_CARD = 'card'; - const SOURCE_TYPE_FINANCING = 'financing'; + const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account'; + const SOURCE_TYPE_CARD = 'card'; + const SOURCE_TYPE_FINANCING = 'financing'; /** - * @param array|null $params - * @param array|string|null $opts + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return Transfer The canceled transfer. + * @return Transfer the canceled transfer */ public function cancel($params = null, $opts = null) { $url = $this->instanceUrl() . '/cancel'; list($response, $opts) = $this->_request('post', $url, $params, $opts); $this->refreshFrom($response, $opts); + return $this; } const PATH_REVERSALS = '/reversals'; /** - * @param string $id The ID of the transfer on which to retrieve the transfer reversals. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the transfer on which to retrieve the transfer reversals + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection The list of transfer reversals. + * @return \Stripe\Collection the list of transfer reversals */ public static function allReversals($id, $params = null, $opts = null) { @@ -78,9 +77,9 @@ public static function allReversals($id, $params = null, $opts = null) } /** - * @param string $id The ID of the transfer on which to create the transfer reversal. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the transfer on which to create the transfer reversal + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -92,10 +91,10 @@ public static function createReversal($id, $params = null, $opts = null) } /** - * @param string $id The ID of the transfer to which the transfer reversal belongs. - * @param string $reversalId The ID of the transfer reversal to retrieve. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the transfer to which the transfer reversal belongs + * @param string $reversalId the ID of the transfer reversal to retrieve + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * @@ -107,10 +106,10 @@ public static function retrieveReversal($id, $reversalId, $params = null, $opts } /** - * @param string $id The ID of the transfer to which the transfer reversal belongs. - * @param string $reversalId The ID of the transfer reversal to update. - * @param array|null $params - * @param array|string|null $opts + * @param string $id the ID of the transfer to which the transfer reversal belongs + * @param string $reversalId the ID of the transfer reversal to update + * @param null|array $params + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * diff --git a/lib/TransferReversal.php b/lib/TransferReversal.php index 003a1d74f..f2eea3860 100644 --- a/lib/TransferReversal.php +++ b/lib/TransferReversal.php @@ -3,7 +3,7 @@ namespace Stripe; /** - * Class TransferReversal + * Class TransferReversal. * * @property string $id * @property string $object @@ -15,8 +15,6 @@ * @property \Stripe\StripeObject $metadata * @property string $source_refund * @property string $transfer - * - * @package Stripe */ class TransferReversal extends ApiResource { @@ -27,7 +25,7 @@ class TransferReversal extends ApiResource } /** - * @return string The API URL for this Stripe transfer reversal. + * @return string the API URL for this Stripe transfer reversal */ public function instanceUrl() { @@ -35,7 +33,7 @@ public function instanceUrl() $transfer = $this['transfer']; if (!$id) { throw new Exception\UnexpectedValueException( - "Could not determine which URL to request: " . + 'Could not determine which URL to request: ' . "class instance has invalid ID: {$id}", null ); @@ -46,15 +44,16 @@ public function instanceUrl() $base = Transfer::classUrl(); $transferExtn = \urlencode($transfer); $extn = \urlencode($id); + return "{$base}/{$transferExtn}/reversals/{$extn}"; } /** - * @param array|string|null $opts + * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return TransferReversal The saved reversal. + * @return TransferReversal the saved reversal */ public function save($opts = null) { diff --git a/lib/UsageRecord.php b/lib/UsageRecord.php index 9ac4c8d73..34af0066b 100644 --- a/lib/UsageRecord.php +++ b/lib/UsageRecord.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class UsageRecord - * - * @package Stripe + * Class UsageRecord. * * @property string $id * @property string $object diff --git a/lib/UsageRecordSummary.php b/lib/UsageRecordSummary.php index 3292b18c7..0fba0d706 100644 --- a/lib/UsageRecordSummary.php +++ b/lib/UsageRecordSummary.php @@ -3,9 +3,7 @@ namespace Stripe; /** - * Class UsageRecord - * - * @package Stripe + * Class UsageRecord. * * @property string $id * @property string $object diff --git a/lib/Util/CaseInsensitiveArray.php b/lib/Util/CaseInsensitiveArray.php index 80781a43d..670ab0b6a 100644 --- a/lib/Util/CaseInsensitiveArray.php +++ b/lib/Util/CaseInsensitiveArray.php @@ -44,6 +44,7 @@ public function offsetSet($offset, $value) public function offsetExists($offset) { $offset = static::maybeLowercase($offset); + return isset($this->container[$offset]); } @@ -56,6 +57,7 @@ public function offsetUnset($offset) public function offsetGet($offset) { $offset = static::maybeLowercase($offset); + return isset($this->container[$offset]) ? $this->container[$offset] : null; } @@ -64,6 +66,7 @@ private static function maybeLowercase($v) if (\is_string($v)) { return \strtolower($v); } + return $v; } } diff --git a/lib/Util/RandomGenerator.php b/lib/Util/RandomGenerator.php index 490377fb4..b11e445d2 100644 --- a/lib/Util/RandomGenerator.php +++ b/lib/Util/RandomGenerator.php @@ -30,6 +30,7 @@ public function uuid() $arr = \array_values(\unpack('N1a/n4b/N1c', \openssl_random_pseudo_bytes(16))); $arr[2] = ($arr[2] & 0x0fff) | 0x4000; $arr[3] = ($arr[3] & 0x3fff) | 0x8000; + return \vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr); } } diff --git a/lib/Util/RequestOptions.php b/lib/Util/RequestOptions.php index 242eaf328..2d768b3a5 100644 --- a/lib/Util/RequestOptions.php +++ b/lib/Util/RequestOptions.php @@ -7,7 +7,7 @@ class RequestOptions { /** - * @var array A list of headers that should be persisted across requests. + * @var array a list of headers that should be persisted across requests */ public static $HEADERS_TO_PERSIST = [ 'Stripe-Account', @@ -38,7 +38,7 @@ public function __debugInfo() * Unpacks an options array and merges it into the existing RequestOptions * object. * - * @param array|string|null $options a key => value array + * @param null|array|string $options a key => value array * * @return RequestOptions */ @@ -52,6 +52,7 @@ public function merge($options) $other_options->apiBase = $this->apiBase; } $other_options->headers = \array_merge($this->headers, $other_options->headers); + return $other_options; } @@ -68,9 +69,9 @@ public function discardNonPersistentHeaders() } /** - * Unpacks an options array into an RequestOptions object + * Unpacks an options array into an RequestOptions object. * - * @param array|string|null $options a key => value array + * @param null|array|string $options a key => value array * * @return RequestOptions */ @@ -107,6 +108,7 @@ public static function parse($options) if (\array_key_exists('api_base', $options)) { $base = $options['api_base']; } + return new RequestOptions($key, $headers, $base); } @@ -114,6 +116,7 @@ public static function parse($options) . 'optional per-request apiKey, which must be a string, or ' . 'per-request options, which must be an array. (HINT: you can set ' . 'a global apiKey by "Stripe::setApiKey()")'; + throw new Exception\InvalidArgumentException($message); } @@ -125,6 +128,7 @@ private function redactedApiKey() ? (\str_repeat('*', \strlen($last) - 4) . \substr($last, -4)) : $last; \array_push($pieces, $redactedLast); + return \implode('_', $pieces); } } diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 7f3b279a5..149b5c1fb 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -16,7 +16,7 @@ abstract class Util * * @param array|mixed $array * - * @return bool true if the given object is a list. + * @return bool true if the given object is a list */ public static function isList($array) { @@ -29,13 +29,14 @@ public static function isList($array) if (\array_keys($array) !== \range(0, \count($array) - 1)) { return false; } + return true; } /** * Converts a response from the Stripe API to the corresponding PHP object. * - * @param array $resp The response from the Stripe API. + * @param array $resp the response from the Stripe API * @param array $opts * * @return array|StripeObject @@ -132,6 +133,7 @@ public static function convertToStripeObject($resp, $opts) foreach ($resp as $i) { \array_push($mapped, self::convertToStripeObject($i, $opts)); } + return $mapped; } if (\is_array($resp)) { @@ -140,16 +142,18 @@ public static function convertToStripeObject($resp, $opts) } else { $class = \Stripe\StripeObject::class; } + return $class::constructFrom($resp, $opts); } + return $resp; } /** - * @param mixed|string $value A string to UTF8-encode. + * @param mixed|string $value a string to UTF8-encode * - * @return mixed|string The UTF8-encoded string, or the object passed in if - * it wasn't a string. + * @return mixed|string the UTF8-encoded string, or the object passed in if + * it wasn't a string */ public static function utf8($value) { @@ -157,16 +161,17 @@ public static function utf8($value) self::$isMbstringAvailable = \function_exists('mb_detect_encoding'); if (!self::$isMbstringAvailable) { - \trigger_error("It looks like the mbstring extension is not enabled. " . - "UTF-8 strings will not properly be encoded. Ask your system " . - "administrator to enable the mbstring extension, or write to " . - "support@stripe.com if you have any questions.", \E_USER_WARNING); + \trigger_error('It looks like the mbstring extension is not enabled. ' . + 'UTF-8 strings will not properly be encoded. Ask your system ' . + 'administrator to enable the mbstring extension, or write to ' . + 'support@stripe.com if you have any questions.', \E_USER_WARNING); } } - if (\is_string($value) && self::$isMbstringAvailable && "UTF-8" !== \mb_detect_encoding($value, "UTF-8", true)) { + if (\is_string($value) && self::$isMbstringAvailable && 'UTF-8' !== \mb_detect_encoding($value, 'UTF-8', true)) { return \utf8_encode($value); } + return $value; } @@ -174,10 +179,10 @@ public static function utf8($value) * Compares two strings for equality. The time taken is independent of the * number of characters that match. * - * @param string $a one of the strings to compare. - * @param string $b the other string to compare. + * @param string $a one of the strings to compare + * @param string $b the other string to compare * - * @return bool true if the strings are equal, false otherwise. + * @return bool true if the strings are equal, false otherwise */ public static function secureCompare($a, $b) { @@ -196,6 +201,7 @@ public static function secureCompare($a, $b) for ($i = 0; $i < \strlen($a); ++$i) { $result |= \ord($a[$i]) ^ \ord($b[$i]); } + return 0 === $result; } @@ -218,6 +224,7 @@ public static function objectsToIds($h) foreach ($h as $v) { \array_push($results, static::objectsToIds($v)); } + return $results; } if (\is_array($h)) { @@ -228,8 +235,10 @@ public static function objectsToIds($h) } $results[$k] = static::objectsToIds($v); } + return $results; } + return $h; } @@ -246,12 +255,13 @@ public static function encodeParameters($params) list($k, $v) = $param; \array_push($pieces, self::urlEncode($k) . '=' . self::urlEncode($v)); } + return \implode('&', $pieces); } /** * @param array $params - * @param string|null $parentKey + * @param null|string $parentKey * * @return array */ @@ -298,9 +308,9 @@ public static function flattenParamsList($value, $calculatedKey) } /** - * @param string $key A string to URL-encode. + * @param string $key a string to URL-encode * - * @return string The URL-encoded string. + * @return string the URL-encoded string */ public static function urlEncode($key) { @@ -310,6 +320,7 @@ public static function urlEncode($key) // characters back to their literals. This is fine by the server, and // makes these parameter strings easier to read. $s = \str_replace('%5B', '[', $s); + return \str_replace('%5D', ']', $s); } @@ -322,11 +333,12 @@ public static function normalizeId($id) } else { $params = []; } + return [$id, $params]; } /** - * Returns UNIX timestamp in milliseconds + * Returns UNIX timestamp in milliseconds. * * @return int current time in millis */ diff --git a/lib/Webhook.php b/lib/Webhook.php index 5130fed47..b9db2d6c0 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -12,15 +12,15 @@ abstract class Webhook * an Exception\SignatureVerificationException if the signature * verification fails for any reason. * - * @param string $payload the payload sent by Stripe. + * @param string $payload the payload sent by Stripe * @param string $sigHeader the contents of the signature header sent by - * Stripe. - * @param string $secret secret used to generate the signature. + * Stripe + * @param string $secret secret used to generate the signature * @param int $tolerance maximum difference allowed between the header's * timestamp and the current time * * @throws Exception\UnexpectedValueException if the payload is not valid JSON, - * @throws Exception\SignatureVerificationException if the verification fails. + * @throws Exception\SignatureVerificationException if the verification fails * * @return Event the Event instance */ @@ -33,8 +33,10 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance if (null === $data && \JSON_ERROR_NONE !== $jsonError) { $msg = "Invalid payload: {$payload} " . "(json_last_error() was {$jsonError})"; + throw new Exception\UnexpectedValueException($msg); } + return Event::constructFrom($data); } } diff --git a/lib/WebhookEndpoint.php b/lib/WebhookEndpoint.php index 3adfa16b6..09c796ab8 100644 --- a/lib/WebhookEndpoint.php +++ b/lib/WebhookEndpoint.php @@ -3,20 +3,18 @@ namespace Stripe; /** - * Class WebhookEndpoint + * Class WebhookEndpoint. * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property string|null $api_version The API version events are rendered as for this webhook endpoint. - * @property string|null $application The ID of the associated Connect application. + * @property null|string $api_version The API version events are rendered as for this webhook endpoint. + * @property null|string $application The ID of the associated Connect application. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string[] $enabled_events The list of events to enable for this endpoint. ['*'] indicates that all events are enabled, except those that require explicit selection. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property string $secret The endpoint's secret, used to generate webhook signatures. Only returned at creation. * @property string $status The status of the webhook. It can be enabled or disabled. * @property string $url The URL of the webhook endpoint. - * - * @package Stripe */ class WebhookEndpoint extends ApiResource { diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index ba0859b5c..88d881ba9 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -4,21 +4,21 @@ abstract class WebhookSignature { - const EXPECTED_SCHEME = "v1"; + const EXPECTED_SCHEME = 'v1'; /** * Verifies the signature header sent by Stripe. Throws an * Exception\SignatureVerificationException exception if the verification fails for * any reason. * - * @param string $payload the payload sent by Stripe. + * @param string $payload the payload sent by Stripe * @param string $header the contents of the signature header sent by - * Stripe. - * @param string $secret secret used to generate the signature. + * Stripe + * @param string $secret secret used to generate the signature * @param int $tolerance maximum difference allowed between the header's * timestamp and the current time * - * @throws Exception\SignatureVerificationException if the verification fails. + * @throws Exception\SignatureVerificationException if the verification fails * * @return bool */ @@ -29,14 +29,14 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul $signatures = self::getSignatures($header, self::EXPECTED_SCHEME); if (-1 === $timestamp) { throw Exception\SignatureVerificationException::factory( - "Unable to extract timestamp and signatures from header", + 'Unable to extract timestamp and signatures from header', $payload, $header ); } if (empty($signatures)) { throw Exception\SignatureVerificationException::factory( - "No signatures found with expected scheme", + 'No signatures found with expected scheme', $payload, $header ); @@ -50,12 +50,13 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul foreach ($signatures as $signature) { if (Util\Util::secureCompare($expectedSignature, $signature)) { $signatureFound = true; + break; } } if (!$signatureFound) { throw Exception\SignatureVerificationException::factory( - "No signatures found matching the expected signature for payload", + 'No signatures found matching the expected signature for payload', $payload, $header ); @@ -64,7 +65,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul // Check if timestamp is within tolerance if (($tolerance > 0) && (\abs(\time() - $timestamp) > $tolerance)) { throw Exception\SignatureVerificationException::factory( - "Timestamp outside the tolerance zone", + 'Timestamp outside the tolerance zone', $payload, $header ); @@ -83,14 +84,15 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul */ private static function getTimestamp($header) { - $items = \explode(",", $header); + $items = \explode(',', $header); foreach ($items as $item) { - $itemParts = \explode("=", $item, 2); - if ("t" === $itemParts[0]) { + $itemParts = \explode('=', $item, 2); + if ('t' === $itemParts[0]) { if (!\is_numeric($itemParts[1])) { return -1; } + return (int) ($itemParts[1]); } } @@ -102,17 +104,17 @@ private static function getTimestamp($header) * Extracts the signatures matching a given scheme in a signature header. * * @param string $header the signature header - * @param string $scheme the signature scheme to look for. + * @param string $scheme the signature scheme to look for * - * @return array the list of signatures matching the provided scheme. + * @return array the list of signatures matching the provided scheme */ private static function getSignatures($header, $scheme) { $signatures = []; - $items = \explode(",", $header); + $items = \explode(',', $header); foreach ($items as $item) { - $itemParts = \explode("=", $item, 2); + $itemParts = \explode('=', $item, 2); if ($itemParts[0] === $scheme) { \array_push($signatures, $itemParts[1]); } @@ -126,13 +128,13 @@ private static function getSignatures($header, $scheme) * * The current scheme used by Stripe ("v1") is HMAC/SHA-256. * - * @param string $payload the payload to sign. - * @param string $secret the secret used to generate the signature. + * @param string $payload the payload to sign + * @param string $secret the secret used to generate the signature * - * @return string the signature as a string. + * @return string the signature as a string */ private static function computeSignature($payload, $secret) { - return \hash_hmac("sha256", $payload, $secret); + return \hash_hmac('sha256', $payload, $secret); } } diff --git a/tests/Stripe/AccountLinkTest.php b/tests/Stripe/AccountLinkTest.php index a981a9053..56a3ae4a1 100644 --- a/tests/Stripe/AccountLinkTest.php +++ b/tests/Stripe/AccountLinkTest.php @@ -11,10 +11,10 @@ public function testIsCreatable() '/v1/account_links' ); $resource = AccountLink::create([ - "account" => "acct_123", - "failure_url" => "https://stripe.com/failure", - "success_url" => "https://stripe.com/success", - "type" => "custom_account_verification", + 'account' => 'acct_123', + 'failure_url' => 'https://stripe.com/failure', + 'success_url' => 'https://stripe.com/success', + 'type' => 'custom_account_verification', ]); static::assertInstanceOf(\Stripe\AccountLink::class, $resource); } diff --git a/tests/Stripe/AccountTest.php b/tests/Stripe/AccountTest.php index 1ab1da07f..99c65e3cb 100644 --- a/tests/Stripe/AccountTest.php +++ b/tests/Stripe/AccountTest.php @@ -46,14 +46,14 @@ public function testIsCreatable() 'post', '/v1/accounts' ); - $resource = Account::create(["type" => "custom"]); + $resource = Account::create(['type' => 'custom']); static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsSaveable() { $resource = Account::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/accounts/' . $resource->id @@ -69,7 +69,7 @@ public function testIsUpdatable() '/v1/accounts/' . self::TEST_RESOURCE_ID ); $resource = Account::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Account::class, $resource); } @@ -92,7 +92,7 @@ public function testIsRejectable() 'post', '/v1/accounts/' . $account->id . '/reject' ); - $resource = $account->reject(["reason" => "fraud"]); + $resource = $account->reject(['reason' => 'fraud']); static::assertInstanceOf(\Stripe\Account::class, $resource); static::assertSame($resource, $account); } @@ -147,7 +147,7 @@ public function testCanUpdateCapability() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/capabilities/' . self::TEST_CAPABILITY_ID ); $resource = Account::updateCapability(self::TEST_RESOURCE_ID, self::TEST_CAPABILITY_ID, [ - "requested" => true, + 'requested' => true, ]); static::assertInstanceOf(\Stripe\Capability::class, $resource); } @@ -169,7 +169,7 @@ public function testCanCreateExternalAccount() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/external_accounts' ); $resource = Account::createExternalAccount(self::TEST_RESOURCE_ID, [ - "external_account" => "btok_123", + 'external_account' => 'btok_123', ]); static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } @@ -191,7 +191,7 @@ public function testCanUpdateExternalAccount() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/external_accounts/' . self::TEST_EXTERNALACCOUNT_ID ); $resource = Account::updateExternalAccount(self::TEST_RESOURCE_ID, self::TEST_EXTERNALACCOUNT_ID, [ - "name" => "name", + 'name' => 'name', ]); static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } @@ -233,10 +233,10 @@ public function testCanCreatePerson() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/persons' ); $resource = Account::createPerson(self::TEST_RESOURCE_ID, [ - "dob" => [ - "day" => 1, - "month" => 1, - "year" => 1980, + 'dob' => [ + 'day' => 1, + 'month' => 1, + 'year' => 1980, ], ]); static::assertInstanceOf(\Stripe\Person::class, $resource); @@ -259,7 +259,7 @@ public function testCanUpdatePerson() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/persons/' . self::TEST_PERSON_ID ); $resource = Account::updatePerson(self::TEST_RESOURCE_ID, self::TEST_PERSON_ID, [ - "first_name" => "First name", + 'first_name' => 'First name', ]); static::assertInstanceOf(\Stripe\Person::class, $resource); } diff --git a/tests/Stripe/AlipayAccountTest.php b/tests/Stripe/AlipayAccountTest.php index a615d2689..142e16eba 100644 --- a/tests/Stripe/AlipayAccountTest.php +++ b/tests/Stripe/AlipayAccountTest.php @@ -18,6 +18,7 @@ public function createFixture($params = []) 'object' => 'card', 'metadata' => [], ]; + return AlipayAccount::constructFrom( \array_merge($params, $base), new Util\RequestOptions() @@ -28,7 +29,7 @@ public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); static::assertSame( - "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, + '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -43,7 +44,7 @@ public function testIsNotDirectlyRetrievable() public function testIsSaveable() { $resource = $this->createFixture(); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID @@ -57,7 +58,7 @@ public function testIsNotDirectlyUpdatable() $this->expectException(\Stripe\Exception\BadMethodCallException::class); AlipayAccount::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); } diff --git a/tests/Stripe/ApiRequestorTest.php b/tests/Stripe/ApiRequestorTest.php index ff01038ba..f6931e422 100644 --- a/tests/Stripe/ApiRequestorTest.php +++ b/tests/Stripe/ApiRequestorTest.php @@ -17,7 +17,7 @@ public function testEncodeObjects() static::assertSame($enc, ['customer' => 'abcd']); // Preserves UTF-8 - $v = ['customer' => "☃"]; + $v = ['customer' => '☃']; $enc = $method->invoke(null, $v); static::assertSame($enc, $v); @@ -108,14 +108,14 @@ public function testRaisesInvalidRequestErrorOn400() try { Charge::create(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\InvalidRequestException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame('Missing id', $e->getMessage()); static::assertSame('id', $e->getStripeParam()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -138,13 +138,13 @@ public function testRaisesIdempotencyErrorOn400AndTypeIdempotencyError() try { Charge::create(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\IdempotencyException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame("Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'abc' if you meant to execute a different request.", $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -167,13 +167,13 @@ public function testRaisesAuthenticationErrorOn401() try { Charge::create(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\AuthenticationException $e) { static::assertSame(401, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame('You did not provide an API key.', $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -200,7 +200,7 @@ public function testRaisesCardErrorOn402() try { Charge::create(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\CardException $e) { static::assertSame(402, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); @@ -209,7 +209,7 @@ public function testRaisesCardErrorOn402() static::assertSame('generic_decline', $e->getDeclineCode()); static::assertSame('exp_month', $e->getStripeParam()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -232,13 +232,13 @@ public function testRaisesPermissionErrorOn403() try { Account::retrieve('foo'); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\PermissionException $e) { static::assertSame(403, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame("The provided key 'sk_test_********************1234' does not have access to account 'foo' (or that account does not exist). Application access may have been revoked.", $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -262,14 +262,14 @@ public function testRaisesInvalidRequestErrorOn404() try { Charge::retrieve('foo'); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\InvalidRequestException $e) { static::assertSame(404, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame('No such charge: foo', $e->getMessage()); static::assertSame('id', $e->getStripeParam()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -291,14 +291,14 @@ public function testRaisesRateLimitErrorOn429() try { Charge::create(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\RateLimitException $e) { static::assertSame(429, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame('Too many requests', $e->getMessage()); } catch (\Exception $e) { \var_dump($e); - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -321,13 +321,13 @@ public function testRaisesRateLimitErrorOn400AndCodeRateLimit() try { Charge::create(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\RateLimitException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertInternalType('array', $e->getJsonBody()); static::assertSame('Too many requests', $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -349,13 +349,13 @@ public function testRaisesOAuthInvalidRequestError() try { OAuth::token(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\OAuth\InvalidRequestException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertSame('invalid_request', $e->getStripeCode()); static::assertSame('No grant type specified', $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -377,13 +377,13 @@ public function testRaisesOAuthInvalidClientError() try { OAuth::token(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\OAuth\InvalidClientException $e) { static::assertSame(401, $e->getHttpStatus()); static::assertSame('invalid_client', $e->getStripeCode()); static::assertSame('No authentication was provided. Send your secret API key using the Authorization header, or as a client_secret POST parameter.', $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -405,13 +405,13 @@ public function testRaisesOAuthInvalidGrantError() try { OAuth::token(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\OAuth\InvalidGrantException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertSame('invalid_grant', $e->getStripeCode()); static::assertSame('This authorization code has already been used. All tokens issued with this code have been revoked.', $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -433,13 +433,13 @@ public function testRaisesOAuthInvalidScopeError() try { OAuth::token(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\OAuth\InvalidScopeException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertSame('invalid_scope', $e->getStripeCode()); static::assertSame('Invalid scope provided: invalid_scope.', $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -460,12 +460,12 @@ public function testRaisesOAuthUnsupportedGrantTypeError() try { OAuth::token(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\OAuth\UnsupportedGrantTypeException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertSame('unsupported_grant_type', $e->getStripeCode()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -487,13 +487,13 @@ public function testRaisesOAuthUnsupportedResponseTypeError() try { OAuth::token(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (Exception\OAuth\UnsupportedResponseTypeException $e) { static::assertSame(400, $e->getHttpStatus()); static::assertSame('unsupported_response_type', $e->getStripeCode()); static::assertSame("Only 'code' response_type is supported, but 'unsupported_response_type' was provided", $e->getMessage()); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } diff --git a/tests/Stripe/ApplePayDomainTest.php b/tests/Stripe/ApplePayDomainTest.php index 9e5a23fb4..31cfc9f0b 100644 --- a/tests/Stripe/ApplePayDomainTest.php +++ b/tests/Stripe/ApplePayDomainTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/apple_pay/domains' ); $resource = ApplePayDomain::create([ - "domain_name" => "domain", + 'domain_name' => 'domain', ]); static::assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); } diff --git a/tests/Stripe/ApplicationFeeRefundTest.php b/tests/Stripe/ApplicationFeeRefundTest.php index 1f51f6e7a..f2fe64943 100644 --- a/tests/Stripe/ApplicationFeeRefundTest.php +++ b/tests/Stripe/ApplicationFeeRefundTest.php @@ -10,7 +10,7 @@ class ApplicationFeeRefundTest extends TestCase public function testIsSaveable() { $resource = ApplicationFee::retrieveRefund(self::TEST_FEE_ID, self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/application_fees/' . $resource->fee . '/refunds/' . $resource->id diff --git a/tests/Stripe/BankAccountTest.php b/tests/Stripe/BankAccountTest.php index dceb41111..c020e059f 100644 --- a/tests/Stripe/BankAccountTest.php +++ b/tests/Stripe/BankAccountTest.php @@ -18,6 +18,7 @@ public function createFixture($params = []) 'object' => 'bank_account', 'metadata' => [], ]; + return BankAccount::constructFrom( \array_merge($params, $base), new Util\RequestOptions() @@ -28,7 +29,7 @@ public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); static::assertSame( - "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, + '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -37,7 +38,7 @@ public function testHasCorrectUrlForAccount() { $resource = $this->createFixture(['account' => 'acct_123']); static::assertSame( - "/v1/accounts/acct_123/external_accounts/" . self::TEST_RESOURCE_ID, + '/v1/accounts/acct_123/external_accounts/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -52,7 +53,7 @@ public function testIsNotDirectlyRetrievable() public function testIsSaveable() { $resource = $this->createFixture(); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID @@ -66,7 +67,7 @@ public function testIsNotDirectlyUpdatable() $this->expectException(\Stripe\Exception\BadMethodCallException::class); BankAccount::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); } @@ -86,12 +87,12 @@ public function testIsVerifiable() $resource = $this->createFixture(); $this->expectsRequest( 'post', - '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID . "/verify", + '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID . '/verify', [ - "amounts" => [1, 2], + 'amounts' => [1, 2], ] ); - $resource->verify(["amounts" => [1, 2]]); + $resource->verify(['amounts' => [1, 2]]); static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } } diff --git a/tests/Stripe/BitcoinReceiverTest.php b/tests/Stripe/BitcoinReceiverTest.php index 9da178fc9..670bf72f6 100644 --- a/tests/Stripe/BitcoinReceiverTest.php +++ b/tests/Stripe/BitcoinReceiverTest.php @@ -15,6 +15,7 @@ public function createFixture($params = []) 'object' => 'bitcoin_receiver', 'metadata' => [], ]; + return BitcoinReceiver::constructFrom( \array_merge($params, $base), new Util\RequestOptions() @@ -25,7 +26,7 @@ public function testHasCorrectStandaloneUrl() { $resource = $this->createFixture(); static::assertSame( - "/v1/bitcoin/receivers/" . self::TEST_RESOURCE_ID, + '/v1/bitcoin/receivers/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -34,7 +35,7 @@ public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); static::assertSame( - "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, + '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } diff --git a/tests/Stripe/CapabilityTest.php b/tests/Stripe/CapabilityTest.php index 5c4de3e47..be4890191 100644 --- a/tests/Stripe/CapabilityTest.php +++ b/tests/Stripe/CapabilityTest.php @@ -11,7 +11,7 @@ public function testHasCorrectUrl() { $resource = \Stripe\Account::retrieveCapability(self::TEST_ACCOUNT_ID, self::TEST_RESOURCE_ID); static::assertSame( - "/v1/accounts/" . self::TEST_ACCOUNT_ID . "/capabilities/" . self::TEST_RESOURCE_ID, + '/v1/accounts/' . self::TEST_ACCOUNT_ID . '/capabilities/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -39,6 +39,6 @@ public function testIsNotDirectlyUpdatable() { $this->expectException(\Stripe\Exception\BadMethodCallException::class); - Capability::update(self::TEST_RESOURCE_ID, ["requested" => true]); + Capability::update(self::TEST_RESOURCE_ID, ['requested' => true]); } } diff --git a/tests/Stripe/CardTest.php b/tests/Stripe/CardTest.php index dffe8ec65..80d9d0a2a 100644 --- a/tests/Stripe/CardTest.php +++ b/tests/Stripe/CardTest.php @@ -18,6 +18,7 @@ public function createFixture($params = []) 'object' => 'card', 'metadata' => [], ]; + return Card::constructFrom( \array_merge($params, $base), new Util\RequestOptions() @@ -28,7 +29,7 @@ public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); static::assertSame( - "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, + '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -37,7 +38,7 @@ public function testHasCorrectUrlForAccount() { $resource = $this->createFixture(['account' => 'acct_123']); static::assertSame( - "/v1/accounts/acct_123/external_accounts/" . self::TEST_RESOURCE_ID, + '/v1/accounts/acct_123/external_accounts/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -46,7 +47,7 @@ public function testHasCorrectUrlForRecipient() { $resource = $this->createFixture(['recipient' => 'rp_123']); static::assertSame( - "/v1/recipients/rp_123/cards/" . self::TEST_RESOURCE_ID, + '/v1/recipients/rp_123/cards/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -61,7 +62,7 @@ public function testIsNotDirectlyRetrievable() public function testIsSaveable() { $resource = $this->createFixture(); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID @@ -75,7 +76,7 @@ public function testIsNotDirectlyUpdatable() $this->expectException(\Stripe\Exception\BadMethodCallException::class); Card::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); } diff --git a/tests/Stripe/ChargeTest.php b/tests/Stripe/ChargeTest.php index 6cc7169c8..825a452d9 100644 --- a/tests/Stripe/ChargeTest.php +++ b/tests/Stripe/ChargeTest.php @@ -34,9 +34,9 @@ public function testIsCreatable() '/v1/charges' ); $resource = Charge::create([ - "amount" => 100, - "currency" => "usd", - "source" => "tok_123", + 'amount' => 100, + 'currency' => 'usd', + 'source' => 'tok_123', ]); static::assertInstanceOf(\Stripe\Charge::class, $resource); } @@ -44,7 +44,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Charge::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/charges/' . $resource->id @@ -60,7 +60,7 @@ public function testIsUpdatable() '/v1/charges/' . self::TEST_RESOURCE_ID ); $resource = Charge::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Charge::class, $resource); } diff --git a/tests/Stripe/CollectionTest.php b/tests/Stripe/CollectionTest.php index c0b7fb6a0..1b2049e06 100644 --- a/tests/Stripe/CollectionTest.php +++ b/tests/Stripe/CollectionTest.php @@ -236,7 +236,7 @@ public function testHeaders() public function testEmptyCollection() { $emptyCollection = Collection::emptyCollection(); - static::assertEquals([], $emptyCollection->data); + static::assertSame([], $emptyCollection->data); } public function testIsEmpty() @@ -270,7 +270,7 @@ public function testNextPage() foreach ($nextPage->data as $element) { \array_push($ids, $element['id']); } - static::assertEquals([2, 3], $ids); + static::assertSame([2, 3], $ids); } public function testPreviousPage() @@ -291,6 +291,6 @@ public function testPreviousPage() ); $previousPage = $this->fixture->previousPage(); - static::assertEquals([], $previousPage->data); + static::assertSame([], $previousPage->data); } } diff --git a/tests/Stripe/CouponTest.php b/tests/Stripe/CouponTest.php index c75f0b79f..af07ae258 100644 --- a/tests/Stripe/CouponTest.php +++ b/tests/Stripe/CouponTest.php @@ -34,10 +34,10 @@ public function testIsCreatable() '/v1/coupons' ); $resource = Coupon::create([ - "percent_off" => 25, - "duration" => "repeating", - "duration_in_months" => 3, - "id" => self::TEST_RESOURCE_ID, + 'percent_off' => 25, + 'duration' => 'repeating', + 'duration_in_months' => 3, + 'id' => self::TEST_RESOURCE_ID, ]); static::assertInstanceOf(\Stripe\Coupon::class, $resource); } @@ -45,7 +45,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Coupon::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/coupons/' . self::TEST_RESOURCE_ID @@ -61,7 +61,7 @@ public function testIsUpdatable() '/v1/coupons/' . self::TEST_RESOURCE_ID ); $resource = Coupon::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Coupon::class, $resource); } diff --git a/tests/Stripe/CreditNoteTest.php b/tests/Stripe/CreditNoteTest.php index a15d5749a..4b9bd7be4 100644 --- a/tests/Stripe/CreditNoteTest.php +++ b/tests/Stripe/CreditNoteTest.php @@ -34,9 +34,9 @@ public function testIsCreatable() '/v1/credit_notes' ); $resource = CreditNote::create([ - "amount" => 100, - "invoice" => "in_132", - "reason" => "duplicate", + 'amount' => 100, + 'invoice' => 'in_132', + 'reason' => 'duplicate', ]); static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } @@ -44,7 +44,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = CreditNote::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/credit_notes/' . $resource->id @@ -60,7 +60,7 @@ public function testIsUpdatable() '/v1/credit_notes/' . self::TEST_RESOURCE_ID ); $resource = CreditNote::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } diff --git a/tests/Stripe/CustomerBalanceTransactionTest.php b/tests/Stripe/CustomerBalanceTransactionTest.php index f71adcd84..bc9fdd6f4 100644 --- a/tests/Stripe/CustomerBalanceTransactionTest.php +++ b/tests/Stripe/CustomerBalanceTransactionTest.php @@ -11,7 +11,7 @@ public function testHasCorrectUrl() { $resource = \Stripe\Customer::retrieveBalanceTransaction(self::TEST_CUSTOMER_ID, self::TEST_RESOURCE_ID); static::assertSame( - "/v1/customers/" . self::TEST_CUSTOMER_ID . "/balance_transactions/" . self::TEST_RESOURCE_ID, + '/v1/customers/' . self::TEST_CUSTOMER_ID . '/balance_transactions/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } diff --git a/tests/Stripe/CustomerTest.php b/tests/Stripe/CustomerTest.php index d5b018895..6c8f2efc2 100644 --- a/tests/Stripe/CustomerTest.php +++ b/tests/Stripe/CustomerTest.php @@ -43,7 +43,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Customer::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/customers/' . $resource->id @@ -59,7 +59,7 @@ public function testIsUpdatable() '/v1/customers/' . self::TEST_RESOURCE_ID ); $resource = Customer::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Customer::class, $resource); } @@ -92,7 +92,7 @@ public function testCanCreateSource() 'post', '/v1/customers/' . self::TEST_RESOURCE_ID . '/sources' ); - $resource = Customer::createSource(self::TEST_RESOURCE_ID, ["source" => "btok_123"]); + $resource = Customer::createSource(self::TEST_RESOURCE_ID, ['source' => 'btok_123']); } public function testCanRetrieveSource() @@ -110,7 +110,7 @@ public function testCanUpdateSource() 'post', '/v1/customers/' . self::TEST_RESOURCE_ID . '/sources/' . self::TEST_SOURCE_ID ); - $resource = Customer::updateSource(self::TEST_RESOURCE_ID, self::TEST_SOURCE_ID, ["name" => "name"]); + $resource = Customer::updateSource(self::TEST_RESOURCE_ID, self::TEST_SOURCE_ID, ['name' => 'name']); // stripe-mock returns a Card on this method and not a bank account static::assertInstanceOf(\Stripe\Card::class, $resource); } @@ -177,8 +177,8 @@ public function testCanCreateTaxId() '/v1/customers/' . self::TEST_RESOURCE_ID . '/tax_ids' ); $resource = Customer::createTaxId(self::TEST_RESOURCE_ID, [ - "type" => TaxId::TYPE_EU_VAT, - "value" => "11111", + 'type' => TaxId::TYPE_EU_VAT, + 'value' => '11111', ]); } @@ -217,8 +217,8 @@ public function testCanCreateBalanceTransaction() '/v1/customers/' . self::TEST_RESOURCE_ID . '/balance_transactions' ); $resource = Customer::createBalanceTransaction(self::TEST_RESOURCE_ID, [ - "amount" => 1234, - "currency" => "usd", + 'amount' => 1234, + 'currency' => 'usd', ]); } @@ -237,7 +237,7 @@ public function testCanUpdateBalanceTransaction() 'post', '/v1/customers/' . self::TEST_RESOURCE_ID . '/balance_transactions/' . self::TEST_CUSTOMER_BALANCE_TRANSACTION_ID ); - $resource = Customer::updateBalanceTransaction(self::TEST_RESOURCE_ID, self::TEST_CUSTOMER_BALANCE_TRANSACTION_ID, ["description" => "new"]); + $resource = Customer::updateBalanceTransaction(self::TEST_RESOURCE_ID, self::TEST_CUSTOMER_BALANCE_TRANSACTION_ID, ['description' => 'new']); } public function testCanListCustomerBalanceTransactions() diff --git a/tests/Stripe/DisputeTest.php b/tests/Stripe/DisputeTest.php index 81a5e1964..5fb2af9cb 100644 --- a/tests/Stripe/DisputeTest.php +++ b/tests/Stripe/DisputeTest.php @@ -30,7 +30,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Dispute::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/disputes/' . $resource->id @@ -46,7 +46,7 @@ public function testIsUpdatable() '/v1/disputes/' . self::TEST_RESOURCE_ID ); $resource = Dispute::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Dispute::class, $resource); } diff --git a/tests/Stripe/EphemeralKeyTest.php b/tests/Stripe/EphemeralKeyTest.php index 684ca1ae0..57556d615 100644 --- a/tests/Stripe/EphemeralKeyTest.php +++ b/tests/Stripe/EphemeralKeyTest.php @@ -10,11 +10,11 @@ public function testIsCreatable() 'post', '/v1/ephemeral_keys', null, - ["Stripe-Version: 2017-05-25"] + ['Stripe-Version: 2017-05-25'] ); $resource = EphemeralKey::create([ - "customer" => "cus_123", - ], ["stripe_version" => "2017-05-25"]); + 'customer' => 'cus_123', + ], ['stripe_version' => '2017-05-25']); static::assertInstanceOf(\Stripe\EphemeralKey::class, $resource); } @@ -23,15 +23,15 @@ public function testIsNotCreatableWithoutAnExplicitApiVersion() $this->expectException(\InvalidArgumentException::class); $resource = EphemeralKey::create([ - "customer" => "cus_123", + 'customer' => 'cus_123', ]); } public function testIsDeletable() { $key = EphemeralKey::create([ - "customer" => "cus_123", - ], ["stripe_version" => "2017-05-25"]); + 'customer' => 'cus_123', + ], ['stripe_version' => '2017-05-25']); $this->expectsRequest( 'delete', '/v1/ephemeral_keys/' . $key->id diff --git a/tests/Stripe/Exception/ApiErrorExceptionTest.php b/tests/Stripe/Exception/ApiErrorExceptionTest.php index 222f8695e..ea0634bca 100644 --- a/tests/Stripe/Exception/ApiErrorExceptionTest.php +++ b/tests/Stripe/Exception/ApiErrorExceptionTest.php @@ -7,6 +7,7 @@ class ApiErrorExceptionTest extends \Stripe\TestCase public function createFixture() { $mock = $this->getMockForAbstractClass(ApiErrorException::class); + return $mock::factory( 'message', 200, @@ -36,6 +37,6 @@ public function testGetters() public function testToString() { $e = $this->createFixture(); - static::assertContains("(Request req_test)", (string) $e); + static::assertContains('(Request req_test)', (string) $e); } } diff --git a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php index 76000d1a2..baade6ae9 100644 --- a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php +++ b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php @@ -7,6 +7,7 @@ class OAuthErrorExceptionTest extends \Stripe\TestCase public function createFixture() { $mock = $this->getMockForAbstractClass(OAuthErrorException::class); + return $mock::factory( 'description', 200, @@ -37,6 +38,6 @@ public function testGetters() public function testToString() { $e = $this->createFixture(); - static::assertContains("(Request req_test)", (string) $e); + static::assertContains('(Request req_test)', (string) $e); } } diff --git a/tests/Stripe/ExchangeRateTest.php b/tests/Stripe/ExchangeRateTest.php index 2baaed70d..b396faf28 100644 --- a/tests/Stripe/ExchangeRateTest.php +++ b/tests/Stripe/ExchangeRateTest.php @@ -31,7 +31,7 @@ public function testIsListable() $listRates = ExchangeRate::all(); static::assertInternalType('array', $listRates->data); - static::assertEquals('exchange_rate', $listRates->data[0]->object); + static::assertSame('exchange_rate', $listRates->data[0]->object); } public function testIsRetrievable() @@ -48,7 +48,7 @@ public function testIsRetrievable() 'rates' => ['eur' => 0.845876], ] ); - $rates = ExchangeRate::retrieve("usd"); - static::assertEquals('exchange_rate', $rates->object); + $rates = ExchangeRate::retrieve('usd'); + static::assertSame('exchange_rate', $rates->object); } } diff --git a/tests/Stripe/FileCreationTest.php b/tests/Stripe/FileCreationTest.php index 1176c6fff..e594521d9 100644 --- a/tests/Stripe/FileCreationTest.php +++ b/tests/Stripe/FileCreationTest.php @@ -36,11 +36,11 @@ public function testIsCreatableWithFileHandle() true, Stripe::$apiUploadBase ); - $fp = \fopen(\dirname(__FILE__) . '/../data/test.png', 'rb'); + $fp = \fopen(__DIR__ . '/../data/test.png', 'rb'); $resource = File::create([ - "purpose" => "dispute_evidence", - "file" => $fp, - "file_link_data" => ["create" => true], + 'purpose' => 'dispute_evidence', + 'file' => $fp, + 'file_link_data' => ['create' => true], ]); static::assertInstanceOf(\Stripe\File::class, $resource); } @@ -55,11 +55,11 @@ public function testIsCreatableWithCURLFile() true, Stripe::$apiUploadBase ); - $curlFile = new \CURLFile(\dirname(__FILE__) . '/../data/test.png'); + $curlFile = new \CURLFile(__DIR__ . '/../data/test.png'); $resource = File::create([ - "purpose" => "dispute_evidence", - "file" => $curlFile, - "file_link_data" => ["create" => true], + 'purpose' => 'dispute_evidence', + 'file' => $curlFile, + 'file_link_data' => ['create' => true], ]); static::assertInstanceOf(\Stripe\File::class, $resource); } diff --git a/tests/Stripe/FileLinkTest.php b/tests/Stripe/FileLinkTest.php index e16ecb5d7..2f0c4641e 100644 --- a/tests/Stripe/FileLinkTest.php +++ b/tests/Stripe/FileLinkTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/file_links' ); $resource = FileLink::create([ - "file" => "file_123", + 'file' => 'file_123', ]); static::assertInstanceOf(\Stripe\FileLink::class, $resource); } @@ -42,7 +42,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = FileLink::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/file_links/' . $resource->id @@ -58,7 +58,7 @@ public function testIsUpdatable() '/v1/file_links/' . self::TEST_RESOURCE_ID ); $resource = FileLink::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\FileLink::class, $resource); } diff --git a/tests/Stripe/HttpClient/CurlClientTest.php b/tests/Stripe/HttpClient/CurlClientTest.php index ac456c62d..1596590a9 100644 --- a/tests/Stripe/HttpClient/CurlClientTest.php +++ b/tests/Stripe/HttpClient/CurlClientTest.php @@ -81,6 +81,7 @@ private function createFakeRandomGenerator($returnValue = 1.0) { $fakeRandomGenerator = $this->createMock('\Stripe\Util\RandomGenerator'); $fakeRandomGenerator->method('randFloat')->willReturn($returnValue); + return $fakeRandomGenerator; } @@ -121,6 +122,7 @@ public function testDefaultOptions() $ref = null; $withClosure = new CurlClient(function ($method, $absUrl, $headers, $params, $hasFile) use (&$ref) { $ref = \func_get_args(); + return []; }); @@ -132,7 +134,7 @@ public function testDefaultOptions() return 'thisShouldNotWork'; }); $this->expectException('Stripe\Exception\UnexpectedValueException'); - $this->expectExceptionMessage("Non-array value returned by defaultOptions CurlClient callback"); + $this->expectExceptionMessage('Non-array value returned by defaultOptions CurlClient callback'); $withBadClosure->request('get', 'https://httpbin.org/status/200', [], [], false); } @@ -238,23 +240,23 @@ public function testShouldNotRetryOnCertValidationError() public function testSleepTimeShouldGrowExponentially() { - $this->setMaxNetworkRetryDelay(999); + $this->setMaxNetworkRetryDelay(999.0); $curlClient = new CurlClient(null, $this->createFakeRandomGenerator()); - static::assertEquals( + static::assertSame( \Stripe\Stripe::getInitialNetworkRetryDelay() * 1, $this->sleepTimeMethod->invoke($curlClient, 1, []) ); - static::assertEquals( + static::assertSame( \Stripe\Stripe::getInitialNetworkRetryDelay() * 2, $this->sleepTimeMethod->invoke($curlClient, 2, []) ); - static::assertEquals( + static::assertSame( \Stripe\Stripe::getInitialNetworkRetryDelay() * 4, $this->sleepTimeMethod->invoke($curlClient, 3, []) ); - static::assertEquals( + static::assertSame( \Stripe\Stripe::getInitialNetworkRetryDelay() * 8, $this->sleepTimeMethod->invoke($curlClient, 4, []) ); @@ -262,37 +264,37 @@ public function testSleepTimeShouldGrowExponentially() public function testSleepTimeShouldEnforceMaxNetworkRetryDelay() { - $this->setInitialNetworkRetryDelay(1); + $this->setInitialNetworkRetryDelay(1.0); $this->setMaxNetworkRetryDelay(2); $curlClient = new CurlClient(null, $this->createFakeRandomGenerator()); - static::assertEquals(1, $this->sleepTimeMethod->invoke($curlClient, 1, [])); - static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); - static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 3, [])); - static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 4, [])); + static::assertSame(1.0, $this->sleepTimeMethod->invoke($curlClient, 1, [])); + static::assertSame(2.0, $this->sleepTimeMethod->invoke($curlClient, 2, [])); + static::assertSame(2.0, $this->sleepTimeMethod->invoke($curlClient, 3, [])); + static::assertSame(2.0, $this->sleepTimeMethod->invoke($curlClient, 4, [])); } public function testSleepTimeShouldRespectRetryAfter() { - $this->setInitialNetworkRetryDelay(1); - $this->setMaxNetworkRetryDelay(2); + $this->setInitialNetworkRetryDelay(1.0); + $this->setMaxNetworkRetryDelay(2.0); $curlClient = new CurlClient(null, $this->createFakeRandomGenerator()); // Uses max of default and header. - static::assertEquals(10, $this->sleepTimeMethod->invoke($curlClient, 1, ['retry-after' => '10'])); - static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '1'])); + static::assertSame(10.0, $this->sleepTimeMethod->invoke($curlClient, 1, ['retry-after' => '10'])); + static::assertSame(2.0, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '1'])); // Ignores excessively large values. - static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '100'])); + static::assertSame(2.0, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '100'])); } public function testSleepTimeShouldAddSomeRandomness() { $randomValue = 0.8; - $this->setInitialNetworkRetryDelay(1); - $this->setMaxNetworkRetryDelay(8); + $this->setInitialNetworkRetryDelay(1.0); + $this->setMaxNetworkRetryDelay(8.0); $curlClient = new CurlClient(null, $this->createFakeRandomGenerator($randomValue)); @@ -300,12 +302,12 @@ public function testSleepTimeShouldAddSomeRandomness() // the initial value cannot be smaller than the base, // so the randomness is ignored - static::assertEquals(\Stripe\Stripe::getInitialNetworkRetryDelay(), $this->sleepTimeMethod->invoke($curlClient, 1, [])); + static::assertSame(\Stripe\Stripe::getInitialNetworkRetryDelay(), $this->sleepTimeMethod->invoke($curlClient, 1, [])); // after the first one, the randomness is applied - static::assertEquals($baseValue * 2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); - static::assertEquals($baseValue * 4, $this->sleepTimeMethod->invoke($curlClient, 3, [])); - static::assertEquals($baseValue * 8, $this->sleepTimeMethod->invoke($curlClient, 4, [])); + static::assertSame($baseValue * 2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); + static::assertSame($baseValue * 4, $this->sleepTimeMethod->invoke($curlClient, 3, [])); + static::assertSame($baseValue * 8, $this->sleepTimeMethod->invoke($curlClient, 4, [])); } public function testResponseHeadersCaseInsensitive() @@ -314,7 +316,7 @@ public function testResponseHeadersCaseInsensitive() $headers = $charge->getLastResponse()->headers; static::assertNotNull($headers['request-id']); - static::assertEquals($headers['request-id'], $headers['Request-Id']); + static::assertSame($headers['request-id'], $headers['Request-Id']); } public function testSetRequestStatusCallback() @@ -327,12 +329,12 @@ public function testSetRequestStatusCallback() $called = true; $this->assertInternalType('string', $rbody); - $this->assertEquals(200, $rcode); - $this->assertEquals('req_123', $rheaders['request-id']); - $this->assertEquals(0, $errno); + $this->assertSame(200, $rcode); + $this->assertSame('req_123', $rheaders['request-id']); + $this->assertSame(0, $errno); $this->assertNull($message); $this->assertFalse($willBeRetried); - $this->assertEquals(0, $numRetries); + $this->assertSame(0, $numRetries); }); \Stripe\ApiRequestor::setHttpClient($curl); diff --git a/tests/Stripe/InvoiceItemTest.php b/tests/Stripe/InvoiceItemTest.php index c93adcb44..e55b1bdbd 100644 --- a/tests/Stripe/InvoiceItemTest.php +++ b/tests/Stripe/InvoiceItemTest.php @@ -34,9 +34,9 @@ public function testIsCreatable() '/v1/invoiceitems' ); $resource = InvoiceItem::create([ - "amount" => 100, - "currency" => "usd", - "customer" => "cus_123", + 'amount' => 100, + 'currency' => 'usd', + 'customer' => 'cus_123', ]); static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } @@ -44,7 +44,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = InvoiceItem::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/invoiceitems/' . $resource->id @@ -60,7 +60,7 @@ public function testIsUpdatable() '/v1/invoiceitems/' . self::TEST_RESOURCE_ID ); $resource = InvoiceItem::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } diff --git a/tests/Stripe/InvoiceTest.php b/tests/Stripe/InvoiceTest.php index 13ad286d0..5d5219319 100644 --- a/tests/Stripe/InvoiceTest.php +++ b/tests/Stripe/InvoiceTest.php @@ -35,7 +35,7 @@ public function testIsCreatable() '/v1/invoices' ); $resource = Invoice::create([ - "customer" => "cus_123", + 'customer' => 'cus_123', ]); static::assertInstanceOf(\Stripe\Invoice::class, $resource); } @@ -43,7 +43,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Invoice::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/invoices/' . $resource->id @@ -59,7 +59,7 @@ public function testIsUpdatable() '/v1/invoices/' . self::TEST_RESOURCE_ID ); $resource = Invoice::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Invoice::class, $resource); } @@ -117,7 +117,7 @@ public function testCanRetrieveUpcoming() 'get', '/v1/invoices/upcoming' ); - $resource = Invoice::upcoming(["customer" => "cus_123"]); + $resource = Invoice::upcoming(['customer' => 'cus_123']); static::assertInstanceOf(\Stripe\Invoice::class, $resource); } diff --git a/tests/Stripe/Issuing/AuthorizationTest.php b/tests/Stripe/Issuing/AuthorizationTest.php index c970dfb7f..8f6aabc02 100644 --- a/tests/Stripe/Issuing/AuthorizationTest.php +++ b/tests/Stripe/Issuing/AuthorizationTest.php @@ -30,7 +30,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Authorization::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', @@ -45,10 +45,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID, - ["metadata" => ["key" => "value"]] + ['metadata' => ['key' => 'value']] ); $resource = Authorization::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); } diff --git a/tests/Stripe/Issuing/CardTest.php b/tests/Stripe/Issuing/CardTest.php index 2ab86b62d..325979f9f 100644 --- a/tests/Stripe/Issuing/CardTest.php +++ b/tests/Stripe/Issuing/CardTest.php @@ -30,7 +30,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Card::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', @@ -45,10 +45,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/issuing/cards/' . self::TEST_RESOURCE_ID, - ["metadata" => ["key" => "value"]] + ['metadata' => ['key' => 'value']] ); $resource = Card::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); } diff --git a/tests/Stripe/Issuing/CardholderTest.php b/tests/Stripe/Issuing/CardholderTest.php index 44e1ec8d1..48f492439 100644 --- a/tests/Stripe/Issuing/CardholderTest.php +++ b/tests/Stripe/Issuing/CardholderTest.php @@ -9,16 +9,16 @@ class CardholderTest extends \Stripe\TestCase public function testIsCreatable() { $params = [ - "billing" => [ - "address" => [ - "city" => "city", - "country" => "US", - "line1" => "line1", - "postal_code" => "postal_code", + 'billing' => [ + 'address' => [ + 'city' => 'city', + 'country' => 'US', + 'line1' => 'line1', + 'postal_code' => 'postal_code', ], ], - "name" => "Cardholder Name", - "type" => "individual", + 'name' => 'Cardholder Name', + 'type' => 'individual', ]; $this->expectsRequest( @@ -54,7 +54,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Cardholder::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', @@ -69,10 +69,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/issuing/cardholders/' . self::TEST_RESOURCE_ID, - ["metadata" => ["key" => "value"]] + ['metadata' => ['key' => 'value']] ); $resource = Cardholder::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); } diff --git a/tests/Stripe/Issuing/DisputeTest.php b/tests/Stripe/Issuing/DisputeTest.php index fc2e5f3d9..57b32c7fd 100644 --- a/tests/Stripe/Issuing/DisputeTest.php +++ b/tests/Stripe/Issuing/DisputeTest.php @@ -9,8 +9,8 @@ class DisputeTest extends \Stripe\TestCase public function testIsCreatable() { $params = [ - "reason" => "fraudulent", - "disputed_transaction" => "ipi_123", + 'reason' => 'fraudulent', + 'disputed_transaction' => 'ipi_123', ]; $this->expectsRequest( @@ -46,7 +46,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Dispute::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', @@ -61,10 +61,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/issuing/disputes/' . self::TEST_RESOURCE_ID, - ["metadata" => ["key" => "value"]] + ['metadata' => ['key' => 'value']] ); $resource = Dispute::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } diff --git a/tests/Stripe/Issuing/TransactionTest.php b/tests/Stripe/Issuing/TransactionTest.php index 418064b3f..effbaae59 100644 --- a/tests/Stripe/Issuing/TransactionTest.php +++ b/tests/Stripe/Issuing/TransactionTest.php @@ -30,7 +30,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Transaction::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', @@ -45,10 +45,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/issuing/transactions/' . self::TEST_RESOURCE_ID, - ["metadata" => ["key" => "value"]] + ['metadata' => ['key' => 'value']] ); $resource = Transaction::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); } diff --git a/tests/Stripe/OrderTest.php b/tests/Stripe/OrderTest.php index cd8c5582d..c22183a8f 100644 --- a/tests/Stripe/OrderTest.php +++ b/tests/Stripe/OrderTest.php @@ -42,7 +42,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Order::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/orders/' . $resource->id @@ -58,7 +58,7 @@ public function testIsUpdatable() '/v1/orders/' . self::TEST_RESOURCE_ID ); $resource = Order::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Order::class, $resource); } diff --git a/tests/Stripe/PaymentIntentTest.php b/tests/Stripe/PaymentIntentTest.php index 4fb2b8e93..3a77225a7 100644 --- a/tests/Stripe/PaymentIntentTest.php +++ b/tests/Stripe/PaymentIntentTest.php @@ -34,8 +34,8 @@ public function testIsCreatable() '/v1/payment_intents' ); $resource = PaymentIntent::create([ - "amount" => 100, - "currency" => "usd", + 'amount' => 100, + 'currency' => 'usd', 'payment_method_types' => ['card'], ]); static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); @@ -44,7 +44,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = PaymentIntent::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/payment_intents/' . self::TEST_RESOURCE_ID @@ -62,7 +62,7 @@ public function testIsUpdatable() $resource = PaymentIntent::update( self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ] ); static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); diff --git a/tests/Stripe/PaymentMethodTest.php b/tests/Stripe/PaymentMethodTest.php index 81461fb81..889cd409f 100644 --- a/tests/Stripe/PaymentMethodTest.php +++ b/tests/Stripe/PaymentMethodTest.php @@ -45,7 +45,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = PaymentMethod::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/payment_methods/' . $resource->id @@ -61,7 +61,7 @@ public function testIsUpdatable() '/v1/payment_methods/' . self::TEST_RESOURCE_ID ); $resource = PaymentMethod::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); } diff --git a/tests/Stripe/PayoutTest.php b/tests/Stripe/PayoutTest.php index bdd3e50de..1ac518622 100644 --- a/tests/Stripe/PayoutTest.php +++ b/tests/Stripe/PayoutTest.php @@ -34,8 +34,8 @@ public function testIsCreatable() '/v1/payouts' ); $resource = Payout::create([ - "amount" => 100, - "currency" => "usd", + 'amount' => 100, + 'currency' => 'usd', ]); static::assertInstanceOf(\Stripe\Payout::class, $resource); } @@ -43,7 +43,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Payout::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/payouts/' . $resource->id @@ -59,7 +59,7 @@ public function testIsUpdatable() '/v1/payouts/' . self::TEST_RESOURCE_ID ); $resource = Payout::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Payout::class, $resource); } diff --git a/tests/Stripe/PersonTest.php b/tests/Stripe/PersonTest.php index 927a659b2..fb88ddbe5 100644 --- a/tests/Stripe/PersonTest.php +++ b/tests/Stripe/PersonTest.php @@ -11,7 +11,7 @@ public function testHasCorrectUrl() { $resource = \Stripe\Account::retrievePerson(self::TEST_ACCOUNT_ID, self::TEST_RESOURCE_ID); static::assertSame( - "/v1/accounts/" . self::TEST_ACCOUNT_ID . "/persons/" . self::TEST_RESOURCE_ID, + '/v1/accounts/' . self::TEST_ACCOUNT_ID . '/persons/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } @@ -26,7 +26,7 @@ public function testIsNotDirectlyRetrievable() public function testIsSaveable() { $resource = \Stripe\Account::retrievePerson(self::TEST_ACCOUNT_ID, self::TEST_RESOURCE_ID); - $resource->first_name = "value"; + $resource->first_name = 'value'; $this->expectsRequest( 'post', '/v1/accounts/' . self::TEST_ACCOUNT_ID . '/persons/' . self::TEST_RESOURCE_ID @@ -40,7 +40,7 @@ public function testIsNotDirectlyUpdatable() $this->expectException(\Stripe\Exception\BadMethodCallException::class); Person::update(self::TEST_RESOURCE_ID, [ - "first_name" => ["John"], + 'first_name' => ['John'], ]); } diff --git a/tests/Stripe/PlanTest.php b/tests/Stripe/PlanTest.php index 027602852..783660641 100644 --- a/tests/Stripe/PlanTest.php +++ b/tests/Stripe/PlanTest.php @@ -46,7 +46,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Plan::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/plans/' . $resource->id @@ -62,7 +62,7 @@ public function testIsUpdatable() '/v1/plans/' . self::TEST_RESOURCE_ID ); $resource = Plan::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Plan::class, $resource); } diff --git a/tests/Stripe/ProductTest.php b/tests/Stripe/ProductTest.php index 9e5587466..011ab8d31 100644 --- a/tests/Stripe/ProductTest.php +++ b/tests/Stripe/ProductTest.php @@ -43,7 +43,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Product::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/products/' . $resource->id @@ -59,7 +59,7 @@ public function testIsUpdatable() '/v1/products/' . self::TEST_RESOURCE_ID ); $resource = Product::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Product::class, $resource); } diff --git a/tests/Stripe/Radar/ValueListItemTest.php b/tests/Stripe/Radar/ValueListItemTest.php index 8dd2594d8..f7295ffc9 100644 --- a/tests/Stripe/Radar/ValueListItemTest.php +++ b/tests/Stripe/Radar/ValueListItemTest.php @@ -13,7 +13,7 @@ public function testIsListable() '/v1/radar/value_list_items' ); $resources = ValueListItem::all([ - "value_list" => "rsl_123", + 'value_list' => 'rsl_123', ]); static::assertInternalType('array', $resources->data); static::assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resources->data[0]); @@ -36,8 +36,8 @@ public function testIsCreatable() '/v1/radar/value_list_items' ); $resource = ValueListItem::create([ - "value_list" => "rsl_123", - "value" => "value", + 'value_list' => 'rsl_123', + 'value' => 'value', ]); static::assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); } diff --git a/tests/Stripe/Radar/ValueListTest.php b/tests/Stripe/Radar/ValueListTest.php index c954281ab..beb997ae8 100644 --- a/tests/Stripe/Radar/ValueListTest.php +++ b/tests/Stripe/Radar/ValueListTest.php @@ -34,8 +34,8 @@ public function testIsCreatable() '/v1/radar/value_lists' ); $resource = ValueList::create([ - "alias" => "alias", - "name" => "name", + 'alias' => 'alias', + 'name' => 'name', ]); static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } @@ -43,7 +43,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = ValueList::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/radar/value_lists/' . self::TEST_RESOURCE_ID @@ -59,7 +59,7 @@ public function testIsUpdatable() '/v1/radar/value_lists/' . self::TEST_RESOURCE_ID ); $resource = ValueList::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } diff --git a/tests/Stripe/RecipientTest.php b/tests/Stripe/RecipientTest.php index 506b783de..c8657a088 100644 --- a/tests/Stripe/RecipientTest.php +++ b/tests/Stripe/RecipientTest.php @@ -34,8 +34,8 @@ public function testIsCreatable() '/v1/recipients' ); $resource = Recipient::create([ - "name" => "name", - "type" => "individual", + 'name' => 'name', + 'type' => 'individual', ]); static::assertInstanceOf(\Stripe\Recipient::class, $resource); } @@ -43,7 +43,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Recipient::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/recipients/' . $resource->id @@ -59,7 +59,7 @@ public function testIsUpdatable() '/v1/recipients/' . self::TEST_RESOURCE_ID ); $resource = Recipient::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Recipient::class, $resource); } diff --git a/tests/Stripe/RefundTest.php b/tests/Stripe/RefundTest.php index 3bb90a350..1fcf563f9 100644 --- a/tests/Stripe/RefundTest.php +++ b/tests/Stripe/RefundTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/refunds' ); $resource = Refund::create([ - "charge" => "ch_123", + 'charge' => 'ch_123', ]); static::assertInstanceOf(\Stripe\Refund::class, $resource); } @@ -42,7 +42,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Refund::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/refunds/' . $resource->id @@ -58,7 +58,7 @@ public function testIsUpdatable() '/v1/refunds/' . self::TEST_RESOURCE_ID ); $resource = Refund::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Refund::class, $resource); } diff --git a/tests/Stripe/Reporting/ReportRunTest.php b/tests/Stripe/Reporting/ReportRunTest.php index e9e8703cb..be44cc2ca 100644 --- a/tests/Stripe/Reporting/ReportRunTest.php +++ b/tests/Stripe/Reporting/ReportRunTest.php @@ -9,10 +9,10 @@ class ReportRunTest extends \Stripe\TestCase public function testIsCreatable() { $params = [ - "parameters" => [ - "connected_account" => "acct_123", + 'parameters' => [ + 'connected_account' => 'acct_123', ], - "report_type" => "activity.summary.1", + 'report_type' => 'activity.summary.1', ]; $this->expectsRequest( diff --git a/tests/Stripe/SKUTest.php b/tests/Stripe/SKUTest.php index 7d6b56664..1792ec415 100644 --- a/tests/Stripe/SKUTest.php +++ b/tests/Stripe/SKUTest.php @@ -34,13 +34,13 @@ public function testIsCreatable() '/v1/skus' ); $resource = SKU::create([ - 'currency' => 'usd', + 'currency' => 'usd', 'inventory' => [ - 'type' => 'finite', + 'type' => 'finite', 'quantity' => 1, ], - 'price' => 100, - 'product' => "prod_123", + 'price' => 100, + 'product' => 'prod_123', ]); static::assertInstanceOf(\Stripe\SKU::class, $resource); } @@ -48,7 +48,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = SKU::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/skus/' . $resource->id @@ -64,7 +64,7 @@ public function testIsUpdatable() '/v1/skus/' . self::TEST_RESOURCE_ID ); $resource = SKU::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\SKU::class, $resource); } diff --git a/tests/Stripe/SetupIntentTest.php b/tests/Stripe/SetupIntentTest.php index d0b8bb65b..daf3e5792 100644 --- a/tests/Stripe/SetupIntentTest.php +++ b/tests/Stripe/SetupIntentTest.php @@ -42,7 +42,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = SetupIntent::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/setup_intents/' . self::TEST_RESOURCE_ID @@ -60,7 +60,7 @@ public function testIsUpdatable() $resource = SetupIntent::update( self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ] ); static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); diff --git a/tests/Stripe/SourceTest.php b/tests/Stripe/SourceTest.php index e069a1b3b..b45565b53 100644 --- a/tests/Stripe/SourceTest.php +++ b/tests/Stripe/SourceTest.php @@ -23,7 +23,7 @@ public function testIsCreatable() '/v1/sources' ); $resource = Source::create([ - "type" => "card", + 'type' => 'card', ]); static::assertInstanceOf(\Stripe\Source::class, $resource); } @@ -31,7 +31,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Source::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/sources/' . $resource->id @@ -47,7 +47,7 @@ public function testIsUpdatable() '/v1/sources/' . self::TEST_RESOURCE_ID ); $resource = Source::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Source::class, $resource); } @@ -91,7 +91,7 @@ public function testCanSaveCardExpiryDate() public function testIsDetachableWhenAttached() { $resource = Source::retrieve(self::TEST_RESOURCE_ID); - $resource->customer = "cus_123"; + $resource->customer = 'cus_123'; $this->expectsRequest( 'delete', '/v1/customers/cus_123/sources/' . $resource->id @@ -113,7 +113,7 @@ public function testCanListSourceTransactionsDeprecated() $source = Source::retrieve(self::TEST_RESOURCE_ID); $this->expectsRequest( 'get', - '/v1/sources/' . $source->id . "/source_transactions" + '/v1/sources/' . $source->id . '/source_transactions' ); $resources = $source->sourceTransactions(); static::assertInternalType('array', $resources->data); @@ -124,7 +124,7 @@ public function testCanListSourceTransactions() { $this->expectsRequest( 'get', - '/v1/sources/' . self::TEST_RESOURCE_ID . "/source_transactions" + '/v1/sources/' . self::TEST_RESOURCE_ID . '/source_transactions' ); $resources = Source::allSourceTransactions(self::TEST_RESOURCE_ID); static::assertInternalType('array', $resources->data); @@ -136,9 +136,9 @@ public function testCanVerify() $resource = Source::retrieve(self::TEST_RESOURCE_ID); $this->expectsRequest( 'post', - '/v1/sources/' . $resource->id . "/verify" + '/v1/sources/' . $resource->id . '/verify' ); - $resource->verify(["values" => [32, 45]]); + $resource->verify(['values' => [32, 45]]); static::assertInstanceOf(\Stripe\Source::class, $resource); } } diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index 2a732904c..4033b1e67 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -98,7 +98,7 @@ public function testToArray() $converted = $s->toArray(); static::assertInternalType('array', $converted); - static::assertEquals($array, $converted); + static::assertSame($array, $converted); } public function testToArrayRecursive() @@ -122,7 +122,7 @@ public function testToArrayRecursive() 'list' => [$nestedArray], ]; - static::assertEquals($expected, $obj->toArray()); + static::assertSame($expected, $obj->toArray()); } public function testNonexistentProperty() @@ -135,7 +135,7 @@ public function testNonexistentProperty() static::assertNull($s->nonexistent); static::assertRegExp( - "/Stripe Notice: Undefined property of Stripe\\\\StripeObject instance: nonexistent/", + '/Stripe Notice: Undefined property of Stripe\\\\StripeObject instance: nonexistent/', \stream_get_contents($capture) ); } finally { @@ -155,7 +155,7 @@ public function testJsonEncode() $s = new StripeObject(); $s->foo = 'a'; - static::assertEquals('{"foo":"a"}', \json_encode($s)); + static::assertSame('{"foo":"a"}', \json_encode($s)); } public function testToString() @@ -169,7 +169,7 @@ public function testToString() "foo": "a" } EOS; - static::assertEquals($expected, $string); + static::assertSame($expected, $string); } public function testReplaceNewNestedUpdatable() @@ -372,15 +372,15 @@ public function testSerializeParametersRaisesExceotionOnOtherEmbeddedApiResource try { $serialized = $obj->serializeParameters(); - static::fail("Did not raise error"); + static::fail('Did not raise error'); } catch (\InvalidArgumentException $e) { static::assertSame( - "Cannot save property `customer` containing an API resource of type Stripe\\Customer. " . + 'Cannot save property `customer` containing an API resource of type Stripe\\Customer. ' . "It doesn't appear to be persisted and is not marked as `saveWithParent`.", $e->getMessage() ); } catch (\Exception $e) { - static::fail("Unexpected exception: " . \get_class($e)); + static::fail('Unexpected exception: ' . \get_class($e)); } } @@ -417,21 +417,21 @@ public function testDirty() public function testDeepCopy() { $opts = [ - "api_base" => Stripe::$apiBase, - "api_key" => "apikey", + 'api_base' => Stripe::$apiBase, + 'api_key' => 'apikey', ]; $values = [ - "id" => 1, - "name" => "Stripe", - "arr" => [ - StripeObject::constructFrom(["id" => "index0"], $opts), - "index1", + 'id' => 1, + 'name' => 'Stripe', + 'arr' => [ + StripeObject::constructFrom(['id' => 'index0'], $opts), + 'index1', 2, ], - "map" => [ - "0" => StripeObject::constructFrom(["id" => "index0"], $opts), - "1" => "index1", - "2" => 2, + 'map' => [ + '0' => StripeObject::constructFrom(['id' => 'index0'], $opts), + '1' => 'index1', + '2' => 2, ], ]; @@ -439,54 +439,54 @@ public function testDeepCopy() // we can't compare the hashes directly because they have embedded // objects which are different from each other - static::assertEquals($values["id"], $copyValues["id"]); - static::assertEquals($values["name"], $copyValues["name"]); - static::assertEquals(\count($values["arr"]), \count($copyValues["arr"])); + static::assertSame($values['id'], $copyValues['id']); + static::assertSame($values['name'], $copyValues['name']); + static::assertSame(\count($values['arr']), \count($copyValues['arr'])); // internal values of the copied StripeObject should be the same, // but the object itself should be new (hence the assertNotSame) - static::assertEquals($values["arr"][0]["id"], $copyValues["arr"][0]["id"]); - static::assertNotSame($values["arr"][0], $copyValues["arr"][0]); + static::assertSame($values['arr'][0]['id'], $copyValues['arr'][0]['id']); + static::assertNotSame($values['arr'][0], $copyValues['arr'][0]); // likewise, the Util\RequestOptions instance in _opts should have // copied values but be a new instance - static::assertEquals( - $this->optsReflector->getValue($values["arr"][0]), - $this->optsReflector->getValue($copyValues["arr"][0]) + static::assertSame( + $this->optsReflector->getValue($values['arr'][0])->apiKey, + $this->optsReflector->getValue($copyValues['arr'][0])->apiKey ); static::assertNotSame( - $this->optsReflector->getValue($values["arr"][0]), - $this->optsReflector->getValue($copyValues["arr"][0]) + $this->optsReflector->getValue($values['arr'][0]), + $this->optsReflector->getValue($copyValues['arr'][0]) ); // scalars however, can be compared - static::assertEquals($values["arr"][1], $copyValues["arr"][1]); - static::assertEquals($values["arr"][2], $copyValues["arr"][2]); + static::assertSame($values['arr'][1], $copyValues['arr'][1]); + static::assertSame($values['arr'][2], $copyValues['arr'][2]); // and a similar story with the hash - static::assertEquals($values["map"]["0"]["id"], $copyValues["map"]["0"]["id"]); - static::assertNotSame($values["map"]["0"], $copyValues["map"]["0"]); + static::assertSame($values['map']['0']['id'], $copyValues['map']['0']['id']); + static::assertNotSame($values['map']['0'], $copyValues['map']['0']); static::assertNotSame( - $this->optsReflector->getValue($values["arr"][0]), - $this->optsReflector->getValue($copyValues["arr"][0]) + $this->optsReflector->getValue($values['arr'][0]), + $this->optsReflector->getValue($copyValues['arr'][0]) ); - static::assertEquals( - $this->optsReflector->getValue($values["map"]["0"]), - $this->optsReflector->getValue($copyValues["map"]["0"]) + static::assertSame( + $this->optsReflector->getValue($values['map']['0'])->apiKey, + $this->optsReflector->getValue($copyValues['map']['0'])->apiKey ); static::assertNotSame( - $this->optsReflector->getValue($values["map"]["0"]), - $this->optsReflector->getValue($copyValues["map"]["0"]) + $this->optsReflector->getValue($values['map']['0']), + $this->optsReflector->getValue($copyValues['map']['0']) ); - static::assertEquals($values["map"]["1"], $copyValues["map"]["1"]); - static::assertEquals($values["map"]["2"], $copyValues["map"]["2"]); + static::assertSame($values['map']['1'], $copyValues['map']['1']); + static::assertSame($values['map']['2'], $copyValues['map']['2']); } public function testDeepCopyMaintainClass() { - $charge = Charge::constructFrom(["id" => 1], null); + $charge = Charge::constructFrom(['id' => 1], null); $copyCharge = $this->deepCopyReflector->invoke(null, $charge); - static::assertEquals(\get_class($charge), \get_class($copyCharge)); + static::assertSame(\get_class($charge), \get_class($copyCharge)); } public function testIsDeleted() @@ -517,6 +517,6 @@ public function testDeserializeMetadataWithKeyNamedMetadata() ]); static::assertInstanceOf(\Stripe\StripeObject::class, $obj->metadata); - static::assertEquals("value", $obj->metadata->metadata); + static::assertSame('value', $obj->metadata->metadata); } } diff --git a/tests/Stripe/StripeTelemetryTest.php b/tests/Stripe/StripeTelemetryTest.php index 665ed4e94..ec64aa4a1 100644 --- a/tests/Stripe/StripeTelemetryTest.php +++ b/tests/Stripe/StripeTelemetryTest.php @@ -28,19 +28,19 @@ public function testNoTelemetrySentIfNotEnabled() $requestheaders = null; $stub = $this - ->getMockBuilder("HttpClient\\ClientInterface") + ->getMockBuilder('HttpClient\\ClientInterface') ->setMethods(['request']) ->getMock(); $stub->expects(static::any()) - ->method("request") + ->method('request') ->with( static::anything(), static::anything(), static::callback(function ($headers) use (&$requestheaders) { foreach ($headers as $index => $header) { // capture the requested headers and format back to into an assoc array - $components = \explode(": ", $header, 2); + $components = \explode(': ', $header, 2); $requestheaders[$components[0]] = $components[1]; } @@ -48,7 +48,7 @@ public function testNoTelemetrySentIfNotEnabled() }), static::anything(), static::anything() - )->willReturn([self::FAKE_VALID_RESPONSE, 200, ["request-id" => "123"]]); + )->willReturn([self::FAKE_VALID_RESPONSE, 200, ['request-id' => '123']]); ApiRequestor::setHttpClient($stub); @@ -70,19 +70,19 @@ public function testTelemetrySetIfEnabled() $requestheaders = null; $stub = $this - ->getMockBuilder("HttpClient\\ClientInterface") + ->getMockBuilder('HttpClient\\ClientInterface') ->setMethods(['request']) ->getMock(); $stub->expects(static::any()) - ->method("request") + ->method('request') ->with( static::anything(), static::anything(), static::callback(function ($headers) use (&$requestheaders) { // capture the requested headers and format back to into an assoc array foreach ($headers as $index => $header) { - $components = \explode(": ", $header, 2); + $components = \explode(': ', $header, 2); $requestheaders[$components[0]] = $components[1]; } @@ -90,7 +90,7 @@ public function testTelemetrySetIfEnabled() }), static::anything(), static::anything() - )->willReturn([self::FAKE_VALID_RESPONSE, 200, ["request-id" => ["req_123"]]]); + )->willReturn([self::FAKE_VALID_RESPONSE, 200, ['request-id' => ['req_123']]]); ApiRequestor::setHttpClient($stub); @@ -103,7 +103,7 @@ public function testTelemetrySetIfEnabled() static::assertArrayHasKey('X-Stripe-Client-Telemetry', $requestheaders); $data = \json_decode($requestheaders['X-Stripe-Client-Telemetry'], true); - static::assertEquals('req_123', $data['last_request_metrics']['request_id']); + static::assertSame('req_123', $data['last_request_metrics']['request_id']); static::assertNotNull($data['last_request_metrics']['request_duration_ms']); ApiRequestor::setHttpClient(null); diff --git a/tests/Stripe/StripeTest.php b/tests/Stripe/StripeTest.php index cafa2a32a..8d5c0d83c 100644 --- a/tests/Stripe/StripeTest.php +++ b/tests/Stripe/StripeTest.php @@ -28,6 +28,6 @@ public function restoreOriginalValues() public function testCABundlePathAccessors() { Stripe::setCABundlePath('path/to/ca/bundle'); - static::assertEquals('path/to/ca/bundle', Stripe::getCABundlePath()); + static::assertSame('path/to/ca/bundle', Stripe::getCABundlePath()); } } diff --git a/tests/Stripe/SubscriptionItemTest.php b/tests/Stripe/SubscriptionItemTest.php index b10d54226..7505881d0 100644 --- a/tests/Stripe/SubscriptionItemTest.php +++ b/tests/Stripe/SubscriptionItemTest.php @@ -12,11 +12,11 @@ public function testIsListable() 'get', '/v1/subscription_items', [ - "subscription" => "sub_123", + 'subscription' => 'sub_123', ] ); $resources = SubscriptionItem::all([ - "subscription" => "sub_123", + 'subscription' => 'sub_123', ]); static::assertInternalType('array', $resources->data); static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resources->data[0]); @@ -39,8 +39,8 @@ public function testIsCreatable() '/v1/subscription_items' ); $resource = SubscriptionItem::create([ - "plan" => "plan", - "subscription" => "sub_123", + 'plan' => 'plan', + 'subscription' => 'sub_123', ]); static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } @@ -48,7 +48,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = SubscriptionItem::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/subscription_items/' . $resource->id @@ -64,7 +64,7 @@ public function testIsUpdatable() '/v1/subscription_items/' . self::TEST_RESOURCE_ID ); $resource = SubscriptionItem::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } @@ -98,7 +98,7 @@ public function testCanListUsageRecordSummariesDeprecated() $resource = SubscriptionItem::retrieve(self::TEST_RESOURCE_ID); $this->expectsRequest( 'get', - '/v1/subscription_items/' . $resource->id . "/usage_record_summaries" + '/v1/subscription_items/' . $resource->id . '/usage_record_summaries' ); $resources = $resource->usageRecordSummaries(); static::assertInternalType('array', $resources->data); @@ -109,9 +109,9 @@ public function testCanListUsageRecordSummaries() { $this->expectsRequest( 'get', - '/v1/subscription_items/' . self::TEST_RESOURCE_ID . "/usage_record_summaries" + '/v1/subscription_items/' . self::TEST_RESOURCE_ID . '/usage_record_summaries' ); - $resources =SubscriptionItem::allUsageRecordSummaries(self::TEST_RESOURCE_ID); + $resources = SubscriptionItem::allUsageRecordSummaries(self::TEST_RESOURCE_ID); static::assertInternalType('array', $resources->data); static::assertInstanceOf(\Stripe\UsageRecordSummary::class, $resources->data[0]); } diff --git a/tests/Stripe/SubscriptionScheduleTest.php b/tests/Stripe/SubscriptionScheduleTest.php index 37c2ba932..fafa88d3a 100644 --- a/tests/Stripe/SubscriptionScheduleTest.php +++ b/tests/Stripe/SubscriptionScheduleTest.php @@ -35,10 +35,10 @@ public function testIsCreatable() '/v1/subscription_schedules' ); $resource = SubscriptionSchedule::create([ - "phases" => [ + 'phases' => [ [ - "plans" => [ - ["plan" => "plan_123", "quantity" => 2], + 'plans' => [ + ['plan' => 'plan_123', 'quantity' => 2], ], ], ], @@ -49,7 +49,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = SubscriptionSchedule::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/subscription_schedules/' . $resource->id @@ -65,7 +65,7 @@ public function testIsUpdatable() '/v1/subscription_schedules/' . self::TEST_RESOURCE_ID ); $resource = SubscriptionSchedule::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } diff --git a/tests/Stripe/SubscriptionTest.php b/tests/Stripe/SubscriptionTest.php index 1a00316a8..4bd8ffee5 100644 --- a/tests/Stripe/SubscriptionTest.php +++ b/tests/Stripe/SubscriptionTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/subscriptions' ); $resource = Subscription::create([ - "customer" => "cus_123", + 'customer' => 'cus_123', ]); static::assertInstanceOf(\Stripe\Subscription::class, $resource); } @@ -42,7 +42,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Subscription::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/subscriptions/' . $resource->id @@ -58,7 +58,7 @@ public function testIsUpdatable() '/v1/subscriptions/' . self::TEST_RESOURCE_ID ); $resource = Subscription::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Subscription::class, $resource); } diff --git a/tests/Stripe/TaxIdTest.php b/tests/Stripe/TaxIdTest.php index 39adf7ece..607f870f1 100644 --- a/tests/Stripe/TaxIdTest.php +++ b/tests/Stripe/TaxIdTest.php @@ -11,7 +11,7 @@ public function testHasCorrectUrl() { $resource = \Stripe\Customer::retrieveTaxId(self::TEST_CUSTOMER_ID, self::TEST_RESOURCE_ID); static::assertSame( - "/v1/customers/" . self::TEST_CUSTOMER_ID . "/tax_ids/" . self::TEST_RESOURCE_ID, + '/v1/customers/' . self::TEST_CUSTOMER_ID . '/tax_ids/' . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); } diff --git a/tests/Stripe/TaxRateTest.php b/tests/Stripe/TaxRateTest.php index 85e5c4f3b..fe45f2cb7 100644 --- a/tests/Stripe/TaxRateTest.php +++ b/tests/Stripe/TaxRateTest.php @@ -34,9 +34,9 @@ public function testIsCreatable() '/v1/tax_rates' ); $resource = TaxRate::create([ - "display_name" => "name", - "inclusive" => false, - "percentage" => 10.15, + 'display_name' => 'name', + 'inclusive' => false, + 'percentage' => 10.15, ]); static::assertInstanceOf(\Stripe\TaxRate::class, $resource); } @@ -44,7 +44,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = TaxRate::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/tax_rates/' . self::TEST_RESOURCE_ID @@ -60,7 +60,7 @@ public function testIsUpdatable() '/v1/tax_rates/' . self::TEST_RESOURCE_ID ); $resource = TaxRate::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\TaxRate::class, $resource); } diff --git a/tests/Stripe/Terminal/LocationTest.php b/tests/Stripe/Terminal/LocationTest.php index 383839fcc..bdbaf63f9 100644 --- a/tests/Stripe/Terminal/LocationTest.php +++ b/tests/Stripe/Terminal/LocationTest.php @@ -30,7 +30,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Location::retrieve(self::TEST_RESOURCE_ID); - $resource->display_name = "new-name"; + $resource->display_name = 'new-name'; $this->expectsRequest( 'post', @@ -45,10 +45,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/terminal/locations/' . self::TEST_RESOURCE_ID, - ["display_name" => "new-name"] + ['display_name' => 'new-name'] ); $resource = Location::update(self::TEST_RESOURCE_ID, [ - "display_name" => "new-name", + 'display_name' => 'new-name', ]); static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } @@ -59,24 +59,24 @@ public function testIsCreatable() 'post', '/v1/terminal/locations', [ - "display_name" => "name", - "address" => [ - "line1" => "line1", - "country" => "US", - "state" => "CA", - "postal_code" => "12345", - "city" => "San Francisco", + 'display_name' => 'name', + 'address' => [ + 'line1' => 'line1', + 'country' => 'US', + 'state' => 'CA', + 'postal_code' => '12345', + 'city' => 'San Francisco', ], ] ); $resource = Location::create([ - "display_name" => "name", - "address" => [ - "line1" => "line1", - "country" => "US", - "state" => "CA", - "postal_code" => "12345", - "city" => "San Francisco", + 'display_name' => 'name', + 'address' => [ + 'line1' => 'line1', + 'country' => 'US', + 'state' => 'CA', + 'postal_code' => '12345', + 'city' => 'San Francisco', ], ]); static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); diff --git a/tests/Stripe/Terminal/ReaderTest.php b/tests/Stripe/Terminal/ReaderTest.php index 00b4e97ec..01b1f7ca3 100644 --- a/tests/Stripe/Terminal/ReaderTest.php +++ b/tests/Stripe/Terminal/ReaderTest.php @@ -30,7 +30,7 @@ public function testIsRetrievable() public function testIsSaveable() { $resource = Reader::retrieve(self::TEST_RESOURCE_ID); - $resource->label = "new-name"; + $resource->label = 'new-name'; $this->expectsRequest( 'post', @@ -45,10 +45,10 @@ public function testIsUpdatable() $this->expectsRequest( 'post', '/v1/terminal/readers/' . self::TEST_RESOURCE_ID, - ["label" => "new-name"] + ['label' => 'new-name'] ); $resource = Reader::update(self::TEST_RESOURCE_ID, [ - "label" => "new-name", + 'label' => 'new-name', ]); static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); } @@ -58,7 +58,7 @@ public function testIsCreatable() $this->expectsRequest( 'post', '/v1/terminal/readers', - ["registration_code" => "a-b-c"] + ['registration_code' => 'a-b-c'] ); $resource = Reader::create(['registration_code' => 'a-b-c']); static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); diff --git a/tests/Stripe/ThreeDSecureTest.php b/tests/Stripe/ThreeDSecureTest.php index 8cc7fc69f..0d4cdd683 100644 --- a/tests/Stripe/ThreeDSecureTest.php +++ b/tests/Stripe/ThreeDSecureTest.php @@ -23,9 +23,9 @@ public function testIsCreatable() '/v1/3d_secure' ); $resource = ThreeDSecure::create([ - "amount" => 100, - "currency" => "usd", - "return_url" => "url", + 'amount' => 100, + 'currency' => 'usd', + 'return_url' => 'url', ]); static::assertInstanceOf(\Stripe\ThreeDSecure::class, $resource); } diff --git a/tests/Stripe/TokenTest.php b/tests/Stripe/TokenTest.php index 90f92d3f6..02c4b698b 100644 --- a/tests/Stripe/TokenTest.php +++ b/tests/Stripe/TokenTest.php @@ -22,7 +22,7 @@ public function testIsCreatable() 'post', '/v1/tokens' ); - $resource = Token::create(["card" => "tok_visa"]); + $resource = Token::create(['card' => 'tok_visa']); static::assertInstanceOf(\Stripe\Token::class, $resource); } } diff --git a/tests/Stripe/TopupTest.php b/tests/Stripe/TopupTest.php index b92752e78..7a813001b 100644 --- a/tests/Stripe/TopupTest.php +++ b/tests/Stripe/TopupTest.php @@ -34,11 +34,11 @@ public function testIsCreatable() '/v1/topups' ); $resource = Topup::create([ - "amount" => 100, - "currency" => "usd", - "source" => "tok_123", - "description" => "description", - "statement_descriptor" => "statement descriptor", + 'amount' => 100, + 'currency' => 'usd', + 'source' => 'tok_123', + 'description' => 'description', + 'statement_descriptor' => 'statement descriptor', ]); static::assertInstanceOf(\Stripe\Topup::class, $resource); } @@ -46,7 +46,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Topup::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/topups/' . $resource->id @@ -62,7 +62,7 @@ public function testIsUpdatable() '/v1/topups/' . self::TEST_RESOURCE_ID ); $resource = Topup::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Topup::class, $resource); } diff --git a/tests/Stripe/TransferReversalTest.php b/tests/Stripe/TransferReversalTest.php index 1788fdf14..b509b5630 100644 --- a/tests/Stripe/TransferReversalTest.php +++ b/tests/Stripe/TransferReversalTest.php @@ -10,7 +10,7 @@ class TransferReversalTest extends TestCase public function testIsSaveable() { $resource = Transfer::retrieveReversal(self::TEST_TRANSFER_ID, self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/transfers/' . $resource->transfer . '/reversals/' . $resource->id diff --git a/tests/Stripe/TransferTest.php b/tests/Stripe/TransferTest.php index 2bed136a0..e9d5ee054 100644 --- a/tests/Stripe/TransferTest.php +++ b/tests/Stripe/TransferTest.php @@ -35,9 +35,9 @@ public function testIsCreatable() '/v1/transfers' ); $resource = Transfer::create([ - "amount" => 100, - "currency" => "usd", - "destination" => "acct_123", + 'amount' => 100, + 'currency' => 'usd', + 'destination' => 'acct_123', ]); static::assertInstanceOf(\Stripe\Transfer::class, $resource); } @@ -45,7 +45,7 @@ public function testIsCreatable() public function testIsSaveable() { $resource = Transfer::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata["key"] = "value"; + $resource->metadata['key'] = 'value'; $this->expectsRequest( 'post', '/v1/transfers/' . $resource->id @@ -61,7 +61,7 @@ public function testIsUpdatable() '/v1/transfers/' . self::TEST_RESOURCE_ID ); $resource = Transfer::update(self::TEST_RESOURCE_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ]); static::assertInstanceOf(\Stripe\Transfer::class, $resource); } @@ -110,7 +110,7 @@ public function testCanUpdateReversal() self::TEST_RESOURCE_ID, self::TEST_REVERSAL_ID, [ - "metadata" => ["key" => "value"], + 'metadata' => ['key' => 'value'], ] ); static::assertInstanceOf(\Stripe\TransferReversal::class, $resource); diff --git a/tests/Stripe/Util/CaseInsensitiveArrayTest.php b/tests/Stripe/Util/CaseInsensitiveArrayTest.php index eef88ded5..3984c0f63 100644 --- a/tests/Stripe/Util/CaseInsensitiveArrayTest.php +++ b/tests/Stripe/Util/CaseInsensitiveArrayTest.php @@ -6,33 +6,33 @@ class CaseInsensitiveArrayTest extends \Stripe\TestCase { public function testArrayAccess() { - $arr = new CaseInsensitiveArray(["One" => "1", "TWO" => "2"]); + $arr = new CaseInsensitiveArray(['One' => '1', 'TWO' => '2']); - $arr["thrEE"] = "3"; + $arr['thrEE'] = '3'; - static::assertSame("1", $arr["one"]); - static::assertSame("1", $arr["One"]); - static::assertSame("1", $arr["ONE"]); + static::assertSame('1', $arr['one']); + static::assertSame('1', $arr['One']); + static::assertSame('1', $arr['ONE']); - static::assertSame("2", $arr["two"]); - static::assertSame("2", $arr["twO"]); - static::assertSame("2", $arr["TWO"]); + static::assertSame('2', $arr['two']); + static::assertSame('2', $arr['twO']); + static::assertSame('2', $arr['TWO']); - static::assertSame("3", $arr["three"]); - static::assertSame("3", $arr["ThReE"]); - static::assertSame("3", $arr["THREE"]); + static::assertSame('3', $arr['three']); + static::assertSame('3', $arr['ThReE']); + static::assertSame('3', $arr['THREE']); } public function testCount() { - $arr = new CaseInsensitiveArray(["One" => "1", "TWO" => "2"]); + $arr = new CaseInsensitiveArray(['One' => '1', 'TWO' => '2']); static::assertCount(2, $arr); } public function testIterable() { - $arr = new CaseInsensitiveArray(["One" => "1", "TWO" => "2"]); + $arr = new CaseInsensitiveArray(['One' => '1', 'TWO' => '2']); $seen = []; @@ -40,7 +40,7 @@ public function testIterable() $seen[$k] = $v; } - static::assertSame("1", $seen["one"]); - static::assertSame("2", $seen["two"]); + static::assertSame('1', $seen['one']); + static::assertSame('2', $seen['two']); } } diff --git a/tests/Stripe/Util/DefaultLoggerTest.php b/tests/Stripe/Util/DefaultLoggerTest.php index a66755fc6..4877eb816 100644 --- a/tests/Stripe/Util/DefaultLoggerTest.php +++ b/tests/Stripe/Util/DefaultLoggerTest.php @@ -14,9 +14,9 @@ public function testDefaultLogger() try { $logger = new DefaultLogger(); - $logger->error("This is a test message"); + $logger->error('This is a test message'); - static::assertRegExp("/This is a test message/", \stream_get_contents($capture)); + static::assertRegExp('/This is a test message/', \stream_get_contents($capture)); } finally { \ini_set('error_log', $origErrorLog); \fclose($capture); diff --git a/tests/Stripe/Util/RequestOptionsTest.php b/tests/Stripe/Util/RequestOptionsTest.php index 5eb020f4d..2be2298ff 100644 --- a/tests/Stripe/Util/RequestOptionsTest.php +++ b/tests/Stripe/Util/RequestOptionsTest.php @@ -6,8 +6,8 @@ class RequestOptionsTest extends \Stripe\TestCase { public function testStringAPIKey() { - $opts = RequestOptions::parse("foo"); - static::assertSame("foo", $opts->apiKey); + $opts = RequestOptions::parse('foo'); + static::assertSame('foo', $opts->apiKey); static::assertSame([], $opts->headers); } @@ -82,14 +82,14 @@ public function testDebugInfo() { $opts = RequestOptions::parse(['api_key' => 'sk_test_1234567890abcdefghijklmn']); $debugInfo = \print_r($opts, true); - static::assertContains("[apiKey] => sk_test_********************klmn", $debugInfo); + static::assertContains('[apiKey] => sk_test_********************klmn', $debugInfo); $opts = RequestOptions::parse(['api_key' => 'sk_1234567890abcdefghijklmn']); $debugInfo = \print_r($opts, true); - static::assertContains("[apiKey] => sk_********************klmn", $debugInfo); + static::assertContains('[apiKey] => sk_********************klmn', $debugInfo); $opts = RequestOptions::parse(['api_key' => '1234567890abcdefghijklmn']); $debugInfo = \print_r($opts, true); - static::assertContains("[apiKey] => ********************klmn", $debugInfo); + static::assertContains('[apiKey] => ********************klmn', $debugInfo); } } diff --git a/tests/Stripe/Util/UtilTest.php b/tests/Stripe/Util/UtilTest.php index 74f209b2d..daad330d1 100644 --- a/tests/Stripe/Util/UtilTest.php +++ b/tests/Stripe/Util/UtilTest.php @@ -31,7 +31,7 @@ public function testConvertStripeObjectToArrayIncludesId() ], null ); - static::assertArrayHasKey("id", $customer->toArray()); + static::assertArrayHasKey('id', $customer->toArray()); } public function testUtf8() @@ -87,17 +87,17 @@ public function testEncodeParameters() ]; static::assertSame( - "a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[0]=0&e[1]=1&f=", + 'a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[0]=0&e[1]=1&f=', Util::encodeParameters($params) ); } public function testUrlEncode() { - static::assertSame("foo", Util::urlEncode("foo")); - static::assertSame("foo%2B", Util::urlEncode("foo+")); - static::assertSame("foo%26", Util::urlEncode("foo&")); - static::assertSame("foo[bar]", Util::urlEncode("foo[bar]")); + static::assertSame('foo', Util::urlEncode('foo')); + static::assertSame('foo%2B', Util::urlEncode('foo+')); + static::assertSame('foo%26', Util::urlEncode('foo&')); + static::assertSame('foo[bar]', Util::urlEncode('foo[bar]')); } public function testFlattenParams() diff --git a/tests/Stripe/WebhookTest.php b/tests/Stripe/WebhookTest.php index f330c0ebc..6c91d0229 100644 --- a/tests/Stripe/WebhookTest.php +++ b/tests/Stripe/WebhookTest.php @@ -4,11 +4,11 @@ class WebhookTest extends TestCase { - const EVENT_PAYLOAD = "{ - \"id\": \"evt_test_webhook\", - \"object\": \"event\" -}"; - const SECRET = "whsec_test_secret"; + const EVENT_PAYLOAD = '{ + "id": "evt_test_webhook", + "object": "event" +}'; + const SECRET = 'whsec_test_secret'; private function generateHeader($opts = []) { @@ -19,8 +19,9 @@ private function generateHeader($opts = []) $signature = \array_key_exists('signature', $opts) ? $opts['signature'] : null; if (null === $signature) { $signedPayload = "{$timestamp}.{$payload}"; - $signature = \hash_hmac("sha256", $signedPayload, $secret); + $signature = \hash_hmac('sha256', $signedPayload, $secret); } + return "t={$timestamp},{$scheme}={$signature}"; } @@ -28,15 +29,15 @@ public function testValidJsonAndHeader() { $sigHeader = $this->generateHeader(); $event = Webhook::constructEvent(self::EVENT_PAYLOAD, $sigHeader, self::SECRET); - static::assertEquals("evt_test_webhook", $event->id); + static::assertSame('evt_test_webhook', $event->id); } public function testInvalidJson() { $this->expectException(\Stripe\Exception\UnexpectedValueException::class); - $payload = "this is not valid JSON"; - $sigHeader = $this->generateHeader(["payload" => $payload]); + $payload = 'this is not valid JSON'; + $sigHeader = $this->generateHeader(['payload' => $payload]); Webhook::constructEvent($payload, $sigHeader, self::SECRET); } @@ -44,7 +45,7 @@ public function testValidJsonAndInvalidHeader() { $this->expectException(\Stripe\Exception\SignatureVerificationException::class); - $sigHeader = "bad_header"; + $sigHeader = 'bad_header'; Webhook::constructEvent(self::EVENT_PAYLOAD, $sigHeader, self::SECRET); } @@ -62,7 +63,7 @@ public function testNoSignaturesWithExpectedScheme() $this->expectException(\Stripe\Exception\SignatureVerificationException::class); $this->expectExceptionMessage('No signatures found with expected scheme'); - $sigHeader = $this->generateHeader(["scheme" => "v0"]); + $sigHeader = $this->generateHeader(['scheme' => 'v0']); WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET); } @@ -71,7 +72,7 @@ public function testNoValidSignatureForPayload() $this->expectException(\Stripe\Exception\SignatureVerificationException::class); $this->expectExceptionMessage('No signatures found matching the expected signature for payload'); - $sigHeader = $this->generateHeader(["signature" => "bad_signature"]); + $sigHeader = $this->generateHeader(['signature' => 'bad_signature']); WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET); } @@ -80,7 +81,7 @@ public function testTimestampTooOld() $this->expectException(\Stripe\Exception\SignatureVerificationException::class); $this->expectExceptionMessage('Timestamp outside the tolerance zone'); - $sigHeader = $this->generateHeader(["timestamp" => \time() - 15]); + $sigHeader = $this->generateHeader(['timestamp' => \time() - 15]); WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10); } @@ -89,7 +90,7 @@ public function testTimestampTooRecent() $this->expectException(\Stripe\Exception\SignatureVerificationException::class); $this->expectExceptionMessage('Timestamp outside the tolerance zone'); - $sigHeader = $this->generateHeader(["timestamp" => \time() + 15]); + $sigHeader = $this->generateHeader(['timestamp' => \time() + 15]); WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10); } @@ -101,13 +102,13 @@ public function testValidHeaderAndSignature() public function testHeaderContainsValidSignature() { - $sigHeader = $this->generateHeader() . ",v1=bad_signature"; + $sigHeader = $this->generateHeader() . ',v1=bad_signature'; static::assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10)); } public function testTimestampOffButNoTolerance() { - $sigHeader = $this->generateHeader(["timestamp" => 12345]); + $sigHeader = $this->generateHeader(['timestamp' => 12345]); static::assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET)); } } diff --git a/tests/StripeMock.php b/tests/StripeMock.php index 23078007d..0efcaba4a 100644 --- a/tests/StripeMock.php +++ b/tests/StripeMock.php @@ -15,7 +15,7 @@ class StripeMock /** * Starts a stripe-mock process with custom OpenAPI spec and fixtures files, if they exist. * - * @return bool true if a stripe-mock process was started, false otherwise. + * @return bool true if a stripe-mock process was started, false otherwise */ public static function start() { @@ -24,13 +24,14 @@ public static function start() } if (null !== static::$process && static::$process->isRunning()) { - echo "stripe-mock already running on port " . static::$port . "\n"; + echo 'stripe-mock already running on port ' . static::$port . "\n"; + return true; } static::$port = static::findAvailablePort(); - echo "Starting stripe-mock on port " . static::$port . "...\n"; + echo 'Starting stripe-mock on port ' . static::$port . "...\n"; static::$process = new Process(\implode(' ', [ 'stripe-mock', @@ -45,9 +46,9 @@ public static function start() \sleep(1); if (static::$process->isRunning()) { - echo "Started stripe-mock, PID = " . static::$process->getPid() . "\n"; + echo 'Started stripe-mock, PID = ' . static::$process->getPid() . "\n"; } else { - die("stripe-mock terminated early, exit code = " . static::$process->wait()); + die('stripe-mock terminated early, exit code = ' . static::$process->wait()); } return true; @@ -88,11 +89,12 @@ public static function getPort() private static function findAvailablePort() { $sock = \socket_create(\AF_INET, \SOCK_STREAM, \SOL_TCP); - \socket_bind($sock, "localhost", 0); + \socket_bind($sock, 'localhost', 0); $addr = null; $port = -1; \socket_getsockname($sock, $addr, $port); \socket_close($sock); + return $port; } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 983d7d963..442d6d902 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -36,8 +36,8 @@ protected function setUp() // Set up host and credentials for stripe-mock Stripe::$apiBase = \defined('MOCK_URL') ? MOCK_URL : 'http://localhost:12111'; - Stripe::setApiKey("sk_test_123"); - Stripe::setClientId("ca_123"); + Stripe::setApiKey('sk_test_123'); + Stripe::setClientId('ca_123'); Stripe::setApiVersion(null); Stripe::setAccountId(null); @@ -65,13 +65,13 @@ protected function tearDown() * * @param string $method HTTP method (e.g. 'post', 'get', etc.) * @param string $path relative path (e.g. '/v1/charges') - * @param array|null $params array of parameters. If null, parameters will + * @param null|array $params array of parameters. If null, parameters will * not be checked. - * @param string[]|null $headers array of headers. Does not need to be + * @param null|string[] $headers array of headers. Does not need to be * exhaustive. If null, headers are not checked. * @param bool $hasFile Whether the request parameters contains a file. * Defaults to false. - * @param string|null $base base URL (e.g. 'https://api.stripe.com') + * @param null|string $base base URL (e.g. 'https://api.stripe.com') */ protected function expectsRequest( $method, @@ -86,6 +86,7 @@ protected function expectsRequest( function ($method, $absUrl, $headers, $params, $hasFile) { $curlClient = HttpClient\CurlClient::instance(); ApiRequestor::setHttpClient($curlClient); + return $curlClient->request($method, $absUrl, $headers, $params, $hasFile); } ); @@ -98,15 +99,15 @@ function ($method, $absUrl, $headers, $params, $hasFile) { * * @param string $method HTTP method (e.g. 'post', 'get', etc.) * @param string $path relative path (e.g. '/v1/charges') - * @param array|null $params array of parameters. If null, parameters will + * @param null|array $params array of parameters. If null, parameters will * not be checked. - * @param string[]|null $headers array of headers. Does not need to be + * @param null|string[] $headers array of headers. Does not need to be * exhaustive. If null, headers are not checked. * @param bool $hasFile Whether the request parameters contains a file. * Defaults to false. * @param array $response * @param int $rcode - * @param string|null $base + * @param null|string $base * * @return array */ @@ -132,13 +133,13 @@ protected function stubRequest( * * @param string $method HTTP method (e.g. 'post', 'get', etc.) * @param string $path relative path (e.g. '/v1/charges') - * @param array|null $params array of parameters. If null, parameters will + * @param null|array $params array of parameters. If null, parameters will * not be checked. - * @param string[]|null $headers array of headers. Does not need to be + * @param null|string[] $headers array of headers. Does not need to be * exhaustive. If null, headers are not checked. * @param bool $hasFile Whether the request parameters contains a file. * Defaults to false. - * @param string|null $base base URL (e.g. 'https://api.stripe.com') + * @param null|string $base base URL (e.g. 'https://api.stripe.com') * * @return \PHPUnit_Framework_MockObject_Builder_InvocationMocker */ @@ -171,6 +172,7 @@ private function prepareRequestMock( return false; } } + return true; }), null === $params ? static::anything() : static::identicalTo($params), diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a5fb00ee2..2f05295c6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,20 +1,20 @@ $fp, - \CURLOPT_TIMEOUT => 3600, - \CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem', + \CURLOPT_FILE => $fp, + \CURLOPT_TIMEOUT => 3600, + \CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem', ]; $ch = \curl_init();