diff --git a/lib/Error/Base.php b/lib/Error/Base.php index 44106ecca..c0051e6a4 100644 --- a/lib/Error/Base.php +++ b/lib/Error/Base.php @@ -20,11 +20,20 @@ public function __construct( $this->httpHeaders = $httpHeaders; $this->requestId = null; + // TODO: make this a proper constructor argument in the next major + // release. + $this->stripeCode = isset($jsonBody["error"]["code"]) ? $jsonBody["error"]["code"] : null; + if ($httpHeaders && isset($httpHeaders['Request-Id'])) { $this->requestId = $httpHeaders['Request-Id']; } } + public function getStripeCode() + { + return $this->stripeCode; + } + public function getHttpStatus() { return $this->httpStatus; diff --git a/lib/Error/Card.php b/lib/Error/Card.php index 9004db271..f3ff343d8 100644 --- a/lib/Error/Card.php +++ b/lib/Error/Card.php @@ -15,12 +15,16 @@ public function __construct( ) { parent::__construct($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders); $this->stripeParam = $stripeParam; + + // TODO: once Error\Base accepts the error code as an argument, pass it + // in the call to parent::__construct() and stop setting it here. $this->stripeCode = $stripeCode; // This one is not like the others because it was added later and we're // trying to do our best not to change the public interface of this class' - // constructor. We should consider changing its implementation on the - // next major version bump of this library. + // constructor. + // TODO: make this a proper constructor argument in the next major + // release. $this->declineCode = isset($jsonBody["error"]["decline_code"]) ? $jsonBody["error"]["decline_code"] : null; } @@ -29,11 +33,6 @@ public function getDeclineCode() return $this->declineCode; } - public function getStripeCode() - { - return $this->stripeCode; - } - public function getStripeParam() { return $this->stripeParam;