From 44f67901964e80b31566a639105d21e0423dc07a Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Fri, 7 Jul 2023 15:09:19 -0700 Subject: [PATCH 1/6] Pin to latest API version --- lib/BaseStripeClient.php | 1 + lib/Stripe.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/BaseStripeClient.php b/lib/BaseStripeClient.php index aa6a59a37..60c7c5a5f 100644 --- a/lib/BaseStripeClient.php +++ b/lib/BaseStripeClient.php @@ -18,6 +18,7 @@ class BaseStripeClient implements StripeClientInterface, StripeStreamingClientIn 'api_key' => null, 'client_id' => null, 'stripe_account' => null, + // Note, even if null, ApiRequestor will default this to Stripe::$apiVersion 'stripe_version' => null, 'api_base' => self::DEFAULT_API_BASE, 'connect_base' => self::DEFAULT_CONNECT_BASE, diff --git a/lib/Stripe.php b/lib/Stripe.php index 504b13ec8..2b4dc5535 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -23,7 +23,7 @@ class Stripe public static $apiUploadBase = 'https://files.stripe.com'; /** @var null|string The version of the Stripe API to use for requests. */ - public static $apiVersion = null; + public static $apiVersion = \Stripe\Util\ApiVersion::CURRENT; /** @var null|string The account ID for connected accounts requests. */ public static $accountId = null; From 16abe517c726d5cf553b975f527dcce12feb6827 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Mon, 14 Aug 2023 12:36:26 -0700 Subject: [PATCH 2/6] Add a test --- lib/ApiRequestor.php | 4 +--- lib/Stripe.php | 5 ++--- tests/Stripe/ApiRequestorTest.php | 5 +++++ tests/TestHelper.php | 2 -- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index e8f653438..2672ef35e 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -348,6 +348,7 @@ private static function _defaultHeaders($apiKey, $clientInfo = null) 'X-Stripe-Client-User-Agent' => \json_encode($ua), 'User-Agent' => $uaString, 'Authorization' => 'Bearer ' . $apiKey, + 'Stripe-Version' => Stripe::getApiVersion(), ]; } @@ -393,9 +394,6 @@ function ($key) use ($params) { $absUrl = $this->_apiBase . $url; $params = self::_encodeObjects($params); $defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo); - if (Stripe::$apiVersion) { - $defaultHeaders['Stripe-Version'] = Stripe::$apiVersion; - } if (Stripe::$accountId) { $defaultHeaders['Stripe-Account'] = Stripe::$accountId; diff --git a/lib/Stripe.php b/lib/Stripe.php index 2b4dc5535..d53e0592d 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -22,7 +22,7 @@ class Stripe /** @var string The base URL for the Stripe API uploads endpoint. */ public static $apiUploadBase = 'https://files.stripe.com'; - /** @var null|string The version of the Stripe API to use for requests. */ + /** @var string The version of the Stripe API to use for requests. */ public static $apiVersion = \Stripe\Util\ApiVersion::CURRENT; /** @var null|string The account ID for connected accounts requests. */ @@ -119,8 +119,7 @@ public static function setClientId($clientId) } /** - * @return string The API version used for requests. null if we're using the - * latest version. + * @return string The API version used for requests. */ public static function getApiVersion() { diff --git a/tests/Stripe/ApiRequestorTest.php b/tests/Stripe/ApiRequestorTest.php index 6615b12a6..5fbdfa945 100644 --- a/tests/Stripe/ApiRequestorTest.php +++ b/tests/Stripe/ApiRequestorTest.php @@ -82,6 +82,11 @@ public function testDefaultHeaders() 'Stripe/v1 PhpBindings/' . Stripe::VERSION . ' MyTestApp/1.2.34 (https://mytestapp.example)' ); + static::assertSame( + $headers['Stripe-Version'], + Stripe::getApiVersion() + ); + static::assertSame($headers['Authorization'], 'Bearer ' . $apiKey); } diff --git a/tests/TestHelper.php b/tests/TestHelper.php index 95e4ec64b..06319c7c0 100644 --- a/tests/TestHelper.php +++ b/tests/TestHelper.php @@ -43,7 +43,6 @@ protected function setUpConfig() Stripe::$apiUploadBase = \defined('MOCK_URL') ? MOCK_URL : 'http://localhost:12111'; Stripe::setApiKey('sk_test_123'); Stripe::setClientId('ca_123'); - Stripe::setApiVersion(null); Stripe::setAccountId(null); // Set up the HTTP client mocker @@ -63,7 +62,6 @@ protected function tearDownConfig() Stripe::setEnableTelemetry(false); Stripe::setApiKey($this->origApiKey); Stripe::setClientId($this->origClientId); - Stripe::setApiVersion($this->origApiVersion); Stripe::setAccountId($this->origAccountId); } From 9dc3d91471ff5128d83b16263c878ccc65104897 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Mon, 14 Aug 2023 13:26:40 -0700 Subject: [PATCH 3/6] lint --- lib/Stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stripe.php b/lib/Stripe.php index d53e0592d..335f9316e 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -119,7 +119,7 @@ public static function setClientId($clientId) } /** - * @return string The API version used for requests. + * @return string the API version used for requests */ public static function getApiVersion() { From f6a3aa06e3781a43eab8ac5a14335e112536f0bf Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 1 Aug 2023 14:29:17 -0700 Subject: [PATCH 4/6] Empty commit From 14865da94a3bdd5b457f8e452c807f134a700d74 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 1 Aug 2023 14:29:25 -0700 Subject: [PATCH 5/6] Empty commit From 5e2cc2626975a07fc3e023ccec1cd4289cc0bc0b Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 15 Aug 2023 14:46:30 -0700 Subject: [PATCH 6/6] Remove Invoice.STATUS_DELETE --- lib/Invoice.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Invoice.php b/lib/Invoice.php index e9511b69a..1b77457c9 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -158,9 +158,6 @@ class Invoice extends ApiResource const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically'; const BILLING_SEND_INVOICE = 'send_invoice'; - /** @deprecated */ - const STATUS_DELETED = 'deleted'; - /** * @param null|array $params * @param null|array|string $opts