diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
commit | 19985dbb8c0aa66dc4bf7905abc1148de909097d (patch) | |
tree | 2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /vendor/stripe/stripe-php/lib/Exception | |
download | 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip |
Diffstat (limited to 'vendor/stripe/stripe-php/lib/Exception')
23 files changed, 658 insertions, 0 deletions
diff --git a/vendor/stripe/stripe-php/lib/Exception/ApiConnectionException.php b/vendor/stripe/stripe-php/lib/Exception/ApiConnectionException.php new file mode 100644 index 0000000..33f2ede --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/ApiConnectionException.php @@ -0,0 +1,12 @@ +<?php + +namespace Stripe\Exception; + +/** + * 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. + */ +class ApiConnectionException extends ApiErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php b/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php new file mode 100644 index 0000000..995a42e --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php @@ -0,0 +1,219 @@ +<?php + +namespace Stripe\Exception; + +/** + * Implements properties and methods common to all (non-SPL) Stripe exceptions. + */ +abstract class ApiErrorException extends \Exception implements ExceptionInterface +{ + protected $error; + protected $httpBody; + protected $httpHeaders; + protected $httpStatus; + protected $jsonBody; + protected $requestId; + protected $stripeCode; + + /** + * Creates a new API error exception. + * + * @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 + */ + public static function factory( + $message, + $httpStatus = null, + $httpBody = null, + $jsonBody = null, + $httpHeaders = null, + $stripeCode = null + ) { + $instance = new static($message); + $instance->setHttpStatus($httpStatus); + $instance->setHttpBody($httpBody); + $instance->setJsonBody($jsonBody); + $instance->setHttpHeaders($httpHeaders); + $instance->setStripeCode($stripeCode); + + $instance->setRequestId(null); + if ($httpHeaders && isset($httpHeaders['Request-Id'])) { + $instance->setRequestId($httpHeaders['Request-Id']); + } + + $instance->setError($instance->constructErrorObject()); + + return $instance; + } + + /** + * Gets the Stripe error object. + * + * @return null|\Stripe\ErrorObject + */ + public function getError() + { + return $this->error; + } + + /** + * Sets the Stripe error object. + * + * @param null|\Stripe\ErrorObject $error + */ + public function setError($error) + { + $this->error = $error; + } + + /** + * Gets the HTTP body as a string. + * + * @return null|string + */ + public function getHttpBody() + { + return $this->httpBody; + } + + /** + * Sets the HTTP body as a string. + * + * @param null|string $httpBody + */ + public function setHttpBody($httpBody) + { + $this->httpBody = $httpBody; + } + + /** + * Gets the HTTP headers array. + * + * @return null|array|\Stripe\Util\CaseInsensitiveArray + */ + public function getHttpHeaders() + { + return $this->httpHeaders; + } + + /** + * Sets the HTTP headers array. + * + * @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders + */ + public function setHttpHeaders($httpHeaders) + { + $this->httpHeaders = $httpHeaders; + } + + /** + * Gets the HTTP status code. + * + * @return null|int + */ + public function getHttpStatus() + { + return $this->httpStatus; + } + + /** + * Sets the HTTP status code. + * + * @param null|int $httpStatus + */ + public function setHttpStatus($httpStatus) + { + $this->httpStatus = $httpStatus; + } + + /** + * Gets the JSON deserialized body. + * + * @return null|array<string, mixed> + */ + public function getJsonBody() + { + return $this->jsonBody; + } + + /** + * Sets the JSON deserialized body. + * + * @param null|array<string, mixed> $jsonBody + */ + public function setJsonBody($jsonBody) + { + $this->jsonBody = $jsonBody; + } + + /** + * Gets the Stripe request ID. + * + * @return null|string + */ + public function getRequestId() + { + return $this->requestId; + } + + /** + * Sets the Stripe request ID. + * + * @param null|string $requestId + */ + public function setRequestId($requestId) + { + $this->requestId = $requestId; + } + + /** + * Gets the Stripe error code. + * + * Cf. the `CODE_*` constants on {@see \Stripe\ErrorObject} for possible + * values. + * + * @return null|string + */ + public function getStripeCode() + { + return $this->stripeCode; + } + + /** + * Sets the Stripe error code. + * + * @param null|string $stripeCode + */ + public function setStripeCode($stripeCode) + { + $this->stripeCode = $stripeCode; + } + + /** + * Returns the string representation of the exception. + * + * @return string + */ + public function __toString() + { + $statusStr = (null === $this->getHttpStatus()) ? '' : "(Status {$this->getHttpStatus()}) "; + $idStr = (null === $this->getRequestId()) ? '' : "(Request {$this->getRequestId()}) "; + + return "{$statusStr}{$idStr}{$this->getMessage()}"; + } + + protected function constructErrorObject() + { + if (null === $this->jsonBody || !\array_key_exists('error', $this->jsonBody)) { + return null; + } + + return \Stripe\ErrorObject::constructFrom($this->jsonBody['error']); + } +} diff --git a/vendor/stripe/stripe-php/lib/Exception/AuthenticationException.php b/vendor/stripe/stripe-php/lib/Exception/AuthenticationException.php new file mode 100644 index 0000000..9e5c718 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/AuthenticationException.php @@ -0,0 +1,11 @@ +<?php + +namespace Stripe\Exception; + +/** + * AuthenticationException is thrown when invalid credentials are used to + * connect to Stripe's servers. + */ +class AuthenticationException extends ApiErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/BadMethodCallException.php b/vendor/stripe/stripe-php/lib/Exception/BadMethodCallException.php new file mode 100644 index 0000000..96bdf66 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/BadMethodCallException.php @@ -0,0 +1,7 @@ +<?php + +namespace Stripe\Exception; + +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/CardException.php b/vendor/stripe/stripe-php/lib/Exception/CardException.php new file mode 100644 index 0000000..43df9c7 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/CardException.php @@ -0,0 +1,84 @@ +<?php + +namespace Stripe\Exception; + +/** + * CardException is thrown when a user enters a card that can't be charged for + * some reason. + */ +class CardException extends ApiErrorException +{ + protected $declineCode; + protected $stripeParam; + + /** + * Creates a new CardException exception. + * + * @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 + */ + public static function factory( + $message, + $httpStatus = null, + $httpBody = null, + $jsonBody = null, + $httpHeaders = null, + $stripeCode = null, + $declineCode = null, + $stripeParam = null + ) { + $instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders, $stripeCode); + $instance->setDeclineCode($declineCode); + $instance->setStripeParam($stripeParam); + + return $instance; + } + + /** + * Gets the decline code. + * + * @return null|string + */ + public function getDeclineCode() + { + return $this->declineCode; + } + + /** + * Sets the decline code. + * + * @param null|string $declineCode + */ + public function setDeclineCode($declineCode) + { + $this->declineCode = $declineCode; + } + + /** + * Gets the parameter related to the error. + * + * @return null|string + */ + public function getStripeParam() + { + return $this->stripeParam; + } + + /** + * Sets the parameter related to the error. + * + * @param null|string $stripeParam + */ + public function setStripeParam($stripeParam) + { + $this->stripeParam = $stripeParam; + } +} diff --git a/vendor/stripe/stripe-php/lib/Exception/ExceptionInterface.php b/vendor/stripe/stripe-php/lib/Exception/ExceptionInterface.php new file mode 100644 index 0000000..c84f37d --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/ExceptionInterface.php @@ -0,0 +1,22 @@ +<?php + +namespace Stripe\Exception; + +// TODO: remove this check once we drop support for PHP 5 +if (\interface_exists(\Throwable::class, false)) { + /** + * The base interface for all Stripe exceptions. + */ + interface ExceptionInterface extends \Throwable + { + } +} else { + /** + * The base interface for all Stripe exceptions. + */ + // phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses + interface ExceptionInterface + { + } + // phpcs:enable +} diff --git a/vendor/stripe/stripe-php/lib/Exception/IdempotencyException.php b/vendor/stripe/stripe-php/lib/Exception/IdempotencyException.php new file mode 100644 index 0000000..09dbf07 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/IdempotencyException.php @@ -0,0 +1,11 @@ +<?php + +namespace Stripe\Exception; + +/** + * IdempotencyException is thrown in cases where an idempotency key was used + * improperly. + */ +class IdempotencyException extends ApiErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/InvalidArgumentException.php b/vendor/stripe/stripe-php/lib/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..7aa3ca3 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/InvalidArgumentException.php @@ -0,0 +1,7 @@ +<?php + +namespace Stripe\Exception; + +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/InvalidRequestException.php b/vendor/stripe/stripe-php/lib/Exception/InvalidRequestException.php new file mode 100644 index 0000000..ed4f8d0 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/InvalidRequestException.php @@ -0,0 +1,60 @@ +<?php + +namespace Stripe\Exception; + +/** + * InvalidRequestException is thrown when a request is initiated with invalid + * parameters. + */ +class InvalidRequestException extends ApiErrorException +{ + protected $stripeParam; + + /** + * Creates a new InvalidRequestException exception. + * + * @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 + */ + public static function factory( + $message, + $httpStatus = null, + $httpBody = null, + $jsonBody = null, + $httpHeaders = null, + $stripeCode = null, + $stripeParam = null + ) { + $instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders, $stripeCode); + $instance->setStripeParam($stripeParam); + + return $instance; + } + + /** + * Gets the parameter related to the error. + * + * @return null|string + */ + public function getStripeParam() + { + return $this->stripeParam; + } + + /** + * Sets the parameter related to the error. + * + * @param null|string $stripeParam + */ + public function setStripeParam($stripeParam) + { + $this->stripeParam = $stripeParam; + } +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/ExceptionInterface.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/ExceptionInterface.php new file mode 100644 index 0000000..dd42662 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/ExceptionInterface.php @@ -0,0 +1,10 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * The base interface for all Stripe OAuth exceptions. + */ +interface ExceptionInterface extends \Stripe\Exception\ExceptionInterface +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidClientException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidClientException.php new file mode 100644 index 0000000..1393451 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidClientException.php @@ -0,0 +1,12 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * 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. + */ +class InvalidClientException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidGrantException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidGrantException.php new file mode 100644 index 0000000..898b3a7 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidGrantException.php @@ -0,0 +1,13 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * InvalidGrantException is thrown when a specified code doesn't exist, is + * 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. + */ +class InvalidGrantException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidRequestException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidRequestException.php new file mode 100644 index 0000000..59dac7c --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidRequestException.php @@ -0,0 +1,11 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * InvalidRequestException is thrown when a code, refresh token, or grant + * type parameter is not provided, but was required. + */ +class InvalidRequestException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidScopeException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidScopeException.php new file mode 100644 index 0000000..091729d --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/InvalidScopeException.php @@ -0,0 +1,10 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * InvalidScopeException is thrown when an invalid scope parameter is provided. + */ +class InvalidScopeException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/OAuthErrorException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/OAuthErrorException.php new file mode 100644 index 0000000..bded3c8 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/OAuthErrorException.php @@ -0,0 +1,19 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * Implements properties and methods common to all (non-SPL) Stripe OAuth + * exceptions. + */ +abstract class OAuthErrorException extends \Stripe\Exception\ApiErrorException +{ + protected function constructErrorObject() + { + if (null === $this->jsonBody) { + return null; + } + + return \Stripe\OAuthErrorObject::constructFrom($this->jsonBody); + } +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/UnknownOAuthErrorException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/UnknownOAuthErrorException.php new file mode 100644 index 0000000..c8dba29 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/UnknownOAuthErrorException.php @@ -0,0 +1,12 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * 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. + */ +class UnknownOAuthErrorException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/UnsupportedGrantTypeException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/UnsupportedGrantTypeException.php new file mode 100644 index 0000000..418635d --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/UnsupportedGrantTypeException.php @@ -0,0 +1,11 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * UnsupportedGrantTypeException is thrown when an unuspported grant type + * parameter is specified. + */ +class UnsupportedGrantTypeException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/OAuth/UnsupportedResponseTypeException.php b/vendor/stripe/stripe-php/lib/Exception/OAuth/UnsupportedResponseTypeException.php new file mode 100644 index 0000000..26742a8 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/OAuth/UnsupportedResponseTypeException.php @@ -0,0 +1,11 @@ +<?php + +namespace Stripe\Exception\OAuth; + +/** + * UnsupportedResponseTypeException is thrown when an unsupported response type + * parameter is specified. + */ +class UnsupportedResponseTypeException extends OAuthErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/PermissionException.php b/vendor/stripe/stripe-php/lib/Exception/PermissionException.php new file mode 100644 index 0000000..5cf5154 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/PermissionException.php @@ -0,0 +1,11 @@ +<?php + +namespace Stripe\Exception; + +/** + * PermissionException is thrown in cases where access was attempted on a + * resource that wasn't allowed. + */ +class PermissionException extends ApiErrorException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/RateLimitException.php b/vendor/stripe/stripe-php/lib/Exception/RateLimitException.php new file mode 100644 index 0000000..f28f450 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/RateLimitException.php @@ -0,0 +1,12 @@ +<?php + +namespace Stripe\Exception; + +/** + * 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. + */ +class RateLimitException extends InvalidRequestException +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/SignatureVerificationException.php b/vendor/stripe/stripe-php/lib/Exception/SignatureVerificationException.php new file mode 100644 index 0000000..b08534a --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/SignatureVerificationException.php @@ -0,0 +1,74 @@ +<?php + +namespace Stripe\Exception; + +/** + * SignatureVerificationException is thrown when the signature verification for + * a webhook fails. + */ +class SignatureVerificationException extends \Exception implements ExceptionInterface +{ + protected $httpBody; + protected $sigHeader; + + /** + * Creates a new SignatureVerificationException exception. + * + * @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 + */ + public static function factory( + $message, + $httpBody = null, + $sigHeader = null + ) { + $instance = new static($message); + $instance->setHttpBody($httpBody); + $instance->setSigHeader($sigHeader); + + return $instance; + } + + /** + * Gets the HTTP body as a string. + * + * @return null|string + */ + public function getHttpBody() + { + return $this->httpBody; + } + + /** + * Sets the HTTP body as a string. + * + * @param null|string $httpBody + */ + public function setHttpBody($httpBody) + { + $this->httpBody = $httpBody; + } + + /** + * Gets the `Stripe-Signature` HTTP header. + * + * @return null|string + */ + public function getSigHeader() + { + return $this->sigHeader; + } + + /** + * Sets the `Stripe-Signature` HTTP header. + * + * @param null|string $sigHeader + */ + public function setSigHeader($sigHeader) + { + $this->sigHeader = $sigHeader; + } +} diff --git a/vendor/stripe/stripe-php/lib/Exception/UnexpectedValueException.php b/vendor/stripe/stripe-php/lib/Exception/UnexpectedValueException.php new file mode 100644 index 0000000..0a629ed --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/UnexpectedValueException.php @@ -0,0 +1,7 @@ +<?php + +namespace Stripe\Exception; + +class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface +{ +} diff --git a/vendor/stripe/stripe-php/lib/Exception/UnknownApiErrorException.php b/vendor/stripe/stripe-php/lib/Exception/UnknownApiErrorException.php new file mode 100644 index 0000000..7873bf8 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/Exception/UnknownApiErrorException.php @@ -0,0 +1,12 @@ +<?php + +namespace Stripe\Exception; + +/** + * 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. + */ +class UnknownApiErrorException extends ApiErrorException +{ +} |