From a7f0840ba1fad680d6951cfc15a3587e95a97b15 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 26 Sep 2026 00:11:16 +1200 Subject: [PATCH 1/3] (fix): build Stripe's default client from utopia-php/client 0.5's Client utopia-php/client 0.5 moved Utopia\Client to Utopia\Client\Client and keeps the old name only as a class_alias that its next release drops. The Stripe adapter still imported the old name, so constructing it without a client fails with 'Class "Utopia\Client" not found' wherever the alias is absent: under appwrite's server-ce, which replaces utopia-php/client with its own alias-free copy, and with the client's next release. Import the new name and require ^0.5, the first releases that declare it. The regression test constructs the adapter without a client, offline. On the locked client 0.5.1 the alias hides the old import, so the test fails first only against an alias-free client (client main). Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- composer.lock | 19 +++++++++++-------- src/Pay/Adapter/Stripe.php | 2 +- tests/Pay/Adapter/StripeTest.php | 8 ++++++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 66a9010..3db186a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": ">=8.5", "psr/http-client": "^1.0", "psr/http-message": "^2.0", - "utopia-php/client": "^0.4", + "utopia-php/client": "^0.5", "utopia-php/psr7": "^0.2" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 9d75785..80e342f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dd6b6d68534faf4fd36a21db56a4dceb", + "content-hash": "8350530fff342c96993f6ecb51b51848", "packages": [ { "name": "brick/math", @@ -1879,16 +1879,16 @@ }, { "name": "utopia-php/client", - "version": "0.4.3", + "version": "0.5.1", "source": { "type": "git", "url": "https://github.com/utopia-php/client.git", - "reference": "d68a5890afa6002b44691cb3f265123a6331e03e" + "reference": "7cea773be6c2c7ba2d25625a61f17278b00ee01c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/client/zipball/d68a5890afa6002b44691cb3f265123a6331e03e", - "reference": "d68a5890afa6002b44691cb3f265123a6331e03e", + "url": "https://api.github.com/repos/utopia-php/client/zipball/7cea773be6c2c7ba2d25625a61f17278b00ee01c", + "reference": "7cea773be6c2c7ba2d25625a61f17278b00ee01c", "shasum": "" }, "require": { @@ -1910,8 +1910,11 @@ }, "type": "library", "autoload": { + "files": [ + "src/compat.php" + ], "psr-4": { - "Utopia\\": "src/" + "Utopia\\Client\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1930,9 +1933,9 @@ ], "support": { "issues": "https://github.com/utopia-php/client/issues", - "source": "https://github.com/utopia-php/client/tree/0.4.3" + "source": "https://github.com/utopia-php/client/tree/0.5.1" }, - "time": "2026-09-05T15:25:56+00:00" + "time": "2026-09-23T14:09:54+00:00" }, { "name": "utopia-php/pools", diff --git a/src/Pay/Adapter/Stripe.php b/src/Pay/Adapter/Stripe.php index 7cd5f1a..c374b1b 100644 --- a/src/Pay/Adapter/Stripe.php +++ b/src/Pay/Adapter/Stripe.php @@ -4,8 +4,8 @@ use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; -use Utopia\Client; use Utopia\Client\Adapter\Curl\Client as Curl; +use Utopia\Client\Client; use Utopia\Pay\Adapter; use Utopia\Pay\Address; use Utopia\Pay\Exception; diff --git a/tests/Pay/Adapter/StripeTest.php b/tests/Pay/Adapter/StripeTest.php index 2d87a61..ef7db15 100644 --- a/tests/Pay/Adapter/StripeTest.php +++ b/tests/Pay/Adapter/StripeTest.php @@ -23,6 +23,14 @@ public function testName(): void $this->assertEquals($this->stripe->getName(), 'Stripe'); } + public function testConstructsWithoutAClient(): void + { + $stripe = new Stripe('sk_test_probe'); + + $this->assertSame('Stripe', $stripe->getName()); + $this->assertSame('USD', $stripe->getCurrency()); + } + /** * Test create customer * From fb8b4e54e20b9ba2350d16d779e380df7813b568 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 26 Sep 2026 00:18:29 +1200 Subject: [PATCH 2/3] (test): read the Stripe secret with ?: and pass assertEquals its expected value first getenv() returns string|false, never null, so ?: covers an unset or empty variable in one call. The ternary called getenv() twice, and PHPStan could not narrow the second call, so it reported the constructor argument as string|false. assertEquals takes the expected value first; with the arguments swapped, a failure would report 'Stripe' as the actual value. Co-Authored-By: Claude Opus 5.5 --- tests/Pay/Adapter/StripeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Pay/Adapter/StripeTest.php b/tests/Pay/Adapter/StripeTest.php index ef7db15..73dd88e 100644 --- a/tests/Pay/Adapter/StripeTest.php +++ b/tests/Pay/Adapter/StripeTest.php @@ -12,7 +12,7 @@ class StripeTest extends TestCase protected function setUp(): void { - $secretKey = getenv('STRIPE_SECRET') ? getenv('STRIPE_SECRET') : ''; + $secretKey = getenv('STRIPE_SECRET') ?: ''; $this->stripe = new Stripe( $secretKey ); @@ -20,7 +20,7 @@ protected function setUp(): void public function testName(): void { - $this->assertEquals($this->stripe->getName(), 'Stripe'); + $this->assertEquals('Stripe', $this->stripe->getName()); } public function testConstructsWithoutAClient(): void From 9494ffdbefe814adf578011bfcb1ff7fe47697e5 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 26 Sep 2026 02:05:24 +1200 Subject: [PATCH 3/3] (test): assert only that Stripe constructs without a client The getName() and getCurrency() checks repeated fixed values (testName already covers the name) and never touched the HTTP client. Stripe exposes nothing about its default client short of a request: the client is private, and every API method sends to api.stripe.com. So the test now pins only the regression, that construction without a client does not throw, and declares that it performs no assertions. CI's live suite already sends requests through the default client. Co-Authored-By: Claude Opus 5.5 --- tests/Pay/Adapter/StripeTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Pay/Adapter/StripeTest.php b/tests/Pay/Adapter/StripeTest.php index 73dd88e..4d01432 100644 --- a/tests/Pay/Adapter/StripeTest.php +++ b/tests/Pay/Adapter/StripeTest.php @@ -25,10 +25,9 @@ public function testName(): void public function testConstructsWithoutAClient(): void { - $stripe = new Stripe('sk_test_probe'); + $this->expectNotToPerformAssertions(); - $this->assertSame('Stripe', $stripe->getName()); - $this->assertSame('USD', $stripe->getCurrency()); + new Stripe('sk_test_probe'); } /**