diff --git a/lib/BaseStripeClient.php b/lib/BaseStripeClient.php index 60c7c5a5f..9fa2264f7 100644 --- a/lib/BaseStripeClient.php +++ b/lib/BaseStripeClient.php @@ -18,8 +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, + 'stripe_version' => \Stripe\Util\ApiVersion::CURRENT, 'api_base' => self::DEFAULT_API_BASE, 'connect_base' => self::DEFAULT_CONNECT_BASE, 'files_base' => self::DEFAULT_FILES_BASE, diff --git a/tests/Stripe/BaseStripeClientTest.php b/tests/Stripe/BaseStripeClientTest.php index 561af37d0..36a059794 100644 --- a/tests/Stripe/BaseStripeClientTest.php +++ b/tests/Stripe/BaseStripeClientTest.php @@ -8,6 +8,7 @@ */ final class BaseStripeClientTest extends \Stripe\TestCase { + use TestHelper; /** @var \ReflectionProperty */ private $optsReflector; @@ -202,4 +203,21 @@ public function testRequestWithOptsInParamsWarns() static::assertNotNull($charge); static::assertSame('acct_456', $this->optsReflector->getValue($charge)->headers['Stripe-Account']); } + + public function testRequestWithNoVersionDefaultsToPinnedVersion() + { + $client = new BaseStripeClient([ + 'api_key' => 'sk_test_client', + 'api_base' => MOCK_URL, + ]); + $this->expectsRequest('get', '/v1/charges/ch_123', null, [ + 'Stripe-Version: ' . \Stripe\Util\ApiVersion::CURRENT, + ]); + $charge = $client->request( + 'get', + '/v1/charges/ch_123', + [], + [] + ); + } }