Skip to content

Commit

Permalink
Merge pull request #1555 from stripe/richardm-fix-pinning-for-stripec…
Browse files Browse the repository at this point in the history
…lient

Pin version in StripeClient
  • Loading branch information
richardm-stripe authored Aug 18, 2023
2 parents 8860217 + 68086b4 commit 7977510
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/BaseStripeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions tests/Stripe/BaseStripeClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
final class BaseStripeClientTest extends \Stripe\TestCase
{
use TestHelper;
/** @var \ReflectionProperty */
private $optsReflector;

Expand Down Expand Up @@ -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',
[],
[]
);
}
}

0 comments on commit 7977510

Please sign in to comment.