From a2edf2b3f3296721321ece8daae1978ede98d876 Mon Sep 17 00:00:00 2001 From: David Brownman Date: Wed, 1 Oct 2025 12:31:08 -0700 Subject: [PATCH 1/3] update doc link --- CHANGELOG.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 757a177d2..36a49f018 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ This release changes the pinned API version to `2025-09-30.clover` and contains - If you parse an event the SDK doesn't have types for (e.g. it's newer than the SDK you're using), you'll get an instance of `Stripe\Events\UnknownEventNotification` instead of a more specific type. It has both the `relatedObject` property and the `FetchRelatedObject()` function (but they may be/return `null`) - ⚠️ removed the `Util::json_decode_thin_event_object`. Its functionality was folded into the new `\Stripe\V2\EventNotification::fromJson` method. * [#1925](https://github.com/stripe/stripe-php/pull/1925) add version deprecation note to README - - NOTE: we'll be dropping support for PHP 5.6, 7.0, and 7.1 in the next major version (March 2026). The README has been updated with a link to our new [language version support policy](https://docs.stripe.com/sdks/versioning?server=php#stripe-sdk-language-version-support-policy) + - NOTE: we'll be dropping support for PHP 5.6, 7.0, and 7.1 in the next major version (March 2026). The README has been updated with a link to our new [language version support policy](https://docs.stripe.com/sdks/versioning?lang=php#stripe-sdk-language-version-support-policy) * [#1921](https://github.com/stripe/stripe-php/pull/1921) Update generated code * Change `Invoice.id` to be required. * [#1923](https://github.com/stripe/stripe-php/pull/1923) Update generated code diff --git a/README.md b/README.md index 0a72d157c..c346df11e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ API. PHP 5.6.0 and later. -Note that per our [language version support policy](https://docs.stripe.com/sdks/versioning?server=php#stripe-sdk-language-version-support-policy), support for PHP 5.6, 7.0, and 7.1 will be removed in the March 2026 major version. +Note that per our [language version support policy](https://docs.stripe.com/sdks/versioning?lang=php#stripe-sdk-language-version-support-policy), support for PHP 5.6, 7.0, and 7.1 will be removed in the March 2026 major version. Additional PHP versions will be dropped in future major versions, so upgrade to supported versions if possible. From 63c4e461aafe99d6bf43a2cd6b348f8519e6ee98 Mon Sep 17 00:00:00 2001 From: jar-stripe Date: Wed, 1 Oct 2025 15:38:01 -0700 Subject: [PATCH 2/3] Remove manual promotion code test (#1931) * removed manually maintained promotion code test (will be convered by generated example tests) * regenerated GeneratedExamplesTest --- tests/Stripe/GeneratedExamplesTest.php | 12 +++ tests/Stripe/PromotionCodeTest.php | 73 ------------------ .../Service/PromotionCodeServiceTest.php | 76 ------------------- 3 files changed, 12 insertions(+), 149 deletions(-) delete mode 100644 tests/Stripe/PromotionCodeTest.php delete mode 100644 tests/Stripe/Service/PromotionCodeServiceTest.php diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index cd52e0ccd..66e24ec86 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -2415,6 +2415,18 @@ public function testPromotionCodesGet2() } public function testPromotionCodesPost() + { + $this->expectsRequest('post', '/v1/promotion_codes'); + $result = $this->client->promotionCodes->create([ + 'promotion' => [ + 'type' => 'coupon', + 'coupon' => 'Z4OV52SU', + ], + ]); + self::assertInstanceOf(PromotionCode::class, $result); + } + + public function testPromotionCodesPost2() { $this->expectsRequest( 'post', diff --git a/tests/Stripe/PromotionCodeTest.php b/tests/Stripe/PromotionCodeTest.php deleted file mode 100644 index b0dfb5a01..000000000 --- a/tests/Stripe/PromotionCodeTest.php +++ /dev/null @@ -1,73 +0,0 @@ -expectsRequest( - 'get', - '/v1/promotion_codes' - ); - $resources = PromotionCode::all(); - self::compatAssertIsArray($resources->data); - self::assertInstanceOf(PromotionCode::class, $resources->data[0]); - } - - public function testIsRetrievable() - { - $this->expectsRequest( - 'get', - '/v1/promotion_codes/' . self::TEST_RESOURCE_ID - ); - $resource = PromotionCode::retrieve(self::TEST_RESOURCE_ID); - self::assertInstanceOf(PromotionCode::class, $resource); - } - - public function testIsCreatable() - { - $this->expectsRequest( - 'post', - '/v1/promotion_codes' - ); - $resource = PromotionCode::create([ - 'coupon' => 'co_123', - 'code' => 'MYCODE', - ]); - self::assertInstanceOf(PromotionCode::class, $resource); - } - - public function testIsSaveable() - { - $resource = PromotionCode::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata['key'] = 'value'; - $this->expectsRequest( - 'post', - '/v1/promotion_codes/' . self::TEST_RESOURCE_ID - ); - $resource->save(); - self::assertInstanceOf(PromotionCode::class, $resource); - } - - public function testIsUpdatable() - { - $this->expectsRequest( - 'post', - '/v1/promotion_codes/' . self::TEST_RESOURCE_ID - ); - $resource = PromotionCode::update(self::TEST_RESOURCE_ID, [ - 'metadata' => ['key' => 'value'], - ]); - self::assertInstanceOf(PromotionCode::class, $resource); - } -} diff --git a/tests/Stripe/Service/PromotionCodeServiceTest.php b/tests/Stripe/Service/PromotionCodeServiceTest.php deleted file mode 100644 index cb94559f5..000000000 --- a/tests/Stripe/Service/PromotionCodeServiceTest.php +++ /dev/null @@ -1,76 +0,0 @@ -client = new \Stripe\StripeClient(['api_key' => 'sk_test_123', 'api_base' => MOCK_URL]); - $this->service = new PromotionCodeService($this->client); - } - - public function testAll() - { - $this->expectsRequest( - 'get', - '/v1/promotion_codes' - ); - $resources = $this->service->all(); - self::compatAssertIsArray($resources->data); - self::assertInstanceOf(\Stripe\PromotionCode::class, $resources->data[0]); - } - - public function testCreate() - { - $this->expectsRequest( - 'post', - '/v1/promotion_codes' - ); - $resource = $this->service->create([ - 'coupon' => 'co_123', - 'code' => 'MYCODE', - ]); - self::assertInstanceOf(\Stripe\PromotionCode::class, $resource); - } - - public function testRetrieve() - { - $this->expectsRequest( - 'get', - '/v1/promotion_codes/' . self::TEST_RESOURCE_ID - ); - $resource = $this->service->retrieve(self::TEST_RESOURCE_ID); - self::assertInstanceOf(\Stripe\PromotionCode::class, $resource); - } - - public function testUpdate() - { - $this->expectsRequest( - 'post', - '/v1/promotion_codes/' . self::TEST_RESOURCE_ID - ); - $resource = $this->service->update(self::TEST_RESOURCE_ID, [ - 'metadata' => ['key' => 'value'], - ]); - self::assertInstanceOf(\Stripe\PromotionCode::class, $resource); - } -} From 98b345bd1fd30e75034d195db5e88a0b62b90ec6 Mon Sep 17 00:00:00 2001 From: David Brownman <109395161+xavdid-stripe@users.noreply.github.com> Date: Mon, 6 Oct 2025 12:10:50 -0700 Subject: [PATCH 3/3] Improve event notification example (#1934) * update webhook example * Fix comments * update docs * linting --- examples/EventNotificationWebhookHandler.php | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/examples/EventNotificationWebhookHandler.php b/examples/EventNotificationWebhookHandler.php index 6eb828381..41070d60e 100644 --- a/examples/EventNotificationWebhookHandler.php +++ b/examples/EventNotificationWebhookHandler.php @@ -26,16 +26,24 @@ // check what type of event notification we have if ($event_notification instanceof Stripe\Events\V1BillingMeterErrorReportTriggeredEventNotification) { - $meter = $event_notification->fetchRelatedObject(); - $meter_id = $meter->id; + // there's basic info about the related object in the notification + echo "Meter with id {$event_notification->related_object->id} reported an error\n"; - // Record the failures and alert your team - // Add your logic here + // or you can fetch the full object form the API for more details + $meter = $event_notification->fetchRelatedObject(); + echo "Meter {$meter->display_name} ({$meter->id}) had a problem\n"; - // can fetch full event w/ data + // And you can always fetch the full event: $event = $event_notification->fetchEvent(); - // data is fully typed - $event->data->developer_message_summary; + echo "More info: {$event->data->developer_message_summary}\n"; + } elseif ($event_notification instanceof Stripe\Events\UnknownEventNotification) { + // Events that were introduced after this SDK version release are + // represented as `UnknownEventNotification`s. + // They're valid, the SDK just doesn't have corresponding classes for them. + // You must match on the "type" property instead. + if ('some.new.event' === $event_notification->type) { + // handle it the same way as above + } } return $response->withStatus(200);