diff --git a/CHANGELOG.md b/CHANGELOG.md index 79dc0c0ac..0a4dea743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 13.3.0 - 2023-11-09 +* [#1603](https://github.com/stripe/stripe-php/pull/1603) Update generated code + * Add support for new value `terminal_reader_hardware_fault` on enum `StripeError.code` + ## 13.3.0-beta.1 - 2023-11-02 * [#1598](https://github.com/stripe/stripe-php/pull/1598) Update generated code for beta * Add support for `attach_payment_intent` method on resource `Invoice` @@ -8,6 +12,9 @@ * Add support for `amounts_due` and `payments` on `Invoice` * Add support for `created` on `Issuing.PersonalizationDesign` +## 13.2.1 - 2023-11-06 +* [#1602](https://github.com/stripe/stripe-php/pull/1602) Fix error when "id" is not a string. + ## 13.2.0 - 2023-11-02 * [#1599](https://github.com/stripe/stripe-php/pull/1599) Update generated code * Add support for new resource `Tax.Registration` diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 39c58a743..341fbefcb 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v645 \ No newline at end of file +v655 \ No newline at end of file diff --git a/lib/ErrorObject.php b/lib/ErrorObject.php index a8b005663..561710ca8 100644 --- a/lib/ErrorObject.php +++ b/lib/ErrorObject.php @@ -196,6 +196,7 @@ class ErrorObject extends StripeObject const CODE_TAXES_CALCULATION_FAILED = 'taxes_calculation_failed'; const CODE_TERMINAL_LOCATION_COUNTRY_UNSUPPORTED = 'terminal_location_country_unsupported'; const CODE_TERMINAL_READER_BUSY = 'terminal_reader_busy'; + const CODE_TERMINAL_READER_HARDWARE_FAULT = 'terminal_reader_hardware_fault'; const CODE_TERMINAL_READER_OFFLINE = 'terminal_reader_offline'; const CODE_TERMINAL_READER_TIMEOUT = 'terminal_reader_timeout'; const CODE_TESTMODE_CHARGES_ONLY = 'testmode_charges_only'; diff --git a/lib/Event.php b/lib/Event.php index 5f7bedd24..264bf0a8a 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -229,6 +229,7 @@ class Event extends ApiResource const QUOTE_DRAFT = 'quote.draft'; const QUOTE_FINALIZED = 'quote.finalized'; const QUOTE_REESTIMATED = 'quote.reestimated'; + const QUOTE_REESTIMATE_FAILED = 'quote.reestimate_failed'; const QUOTE_STALE = 'quote.stale'; const RADAR_EARLY_FRAUD_WARNING_CREATED = 'radar.early_fraud_warning.created'; const RADAR_EARLY_FRAUD_WARNING_UPDATED = 'radar.early_fraud_warning.updated'; @@ -485,6 +486,7 @@ class Event extends ApiResource const TYPE_QUOTE_DRAFT = 'quote.draft'; const TYPE_QUOTE_FINALIZED = 'quote.finalized'; const TYPE_QUOTE_REESTIMATED = 'quote.reestimated'; + const TYPE_QUOTE_REESTIMATE_FAILED = 'quote.reestimate_failed'; const TYPE_QUOTE_STALE = 'quote.stale'; const TYPE_RADAR_EARLY_FRAUD_WARNING_CREATED = 'radar.early_fraud_warning.created'; const TYPE_RADAR_EARLY_FRAUD_WARNING_UPDATED = 'radar.early_fraud_warning.updated'; diff --git a/lib/QuotePhase.php b/lib/QuotePhase.php index 97c2a26fb..8176a6e9a 100644 --- a/lib/QuotePhase.php +++ b/lib/QuotePhase.php @@ -19,6 +19,7 @@ * @property null|\Stripe\StripeObject $invoice_settings The invoice settings applicable during this phase. * @property null|int $iterations Integer representing the multiplier applied to the price interval. For example, iterations=2 applied to a price with interval=month and interval_count=3 results in a phase of duration 2 * 3 months = 6 months. * @property null|\Stripe\Collection<\Stripe\LineItem> $line_items A list of items the customer is being quoted for. + * @property null|\Stripe\StripeObject $metadata Set of key-value pairs that will declaratively set metadata on the subscription schedule's phases when the quote is accepted. * @property string $proration_behavior If the quote will prorate when transitioning to this phase. Possible values are create_prorations and none. * @property \Stripe\StripeObject $total_details * @property null|bool $trial If set to true the entire phase is counted as a trial and the customer will not be charged for any recurring fees. diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 9ebc413ca..cc7a8a48f 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -243,6 +243,10 @@ public static function urlEncode($key) public static function normalizeId($id) { if (\is_array($id)) { + // see https://github.com/stripe/stripe-php/pull/1602 + if (!isset($id['id'])) { + return [null, $id]; + } $params = $id; $id = $params['id']; unset($params['id']); diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index c8e0903dd..a50e581bf 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -16,6 +16,9 @@ final class StripeObjectTest extends \Stripe\TestCase /** @var \ReflectionProperty */ private $optsReflector; + /** @var \ReflectionProperty */ + private $retrieveOptionsReflector; + /** * @before */ @@ -31,6 +34,10 @@ public function setUpReflectors() // This is used to access the `_opts` protected variable $this->optsReflector = new \ReflectionProperty(\Stripe\StripeObject::class, '_opts'); $this->optsReflector->setAccessible(true); + + // This is used to access the `_retrieveOptions` protected variable + $this->retrieveOptionsReflector = new \ReflectionProperty(\Stripe\StripeObject::class, '_retrieveOptions'); + $this->retrieveOptionsReflector->setAccessible(true); } public function testArrayAccessorsSemantics() @@ -540,6 +547,33 @@ public function testIsDeleted() static::assertTrue($obj->isDeleted()); } + public function testConstructorIdPassing() + { + $obj = new StripeObject(['id' => 'id_foo', 'other' => 'bar']); + static::assertSame('id_foo', $obj->id); + static::assertSame(['other' => 'bar'], $this->retrieveOptionsReflector->getValue($obj)); + + $obj = new StripeObject('id_foo'); + static::assertSame('id_foo', $obj->id); + static::assertSame([], $this->retrieveOptionsReflector->getValue($obj)); + + $obj = new StripeObject(['id' => 'id_foo']); + static::assertSame('id_foo', $obj->id); + static::assertSame([], $this->retrieveOptionsReflector->getValue($obj)); + + $obj = new StripeObject(['id' => ['foo' => 'bar']]); + static::assertSame(['foo' => 'bar'], $obj->id); + static::assertSame([], $this->retrieveOptionsReflector->getValue($obj)); + } + + public function testConstructFromIdPassing() + { + $obj = StripeObject::constructFrom(['inner' => ['id' => ['foo' => 'bar']]]); + + static::assertSame(['foo' => 'bar'], $obj['inner']->id->toArray()); + static::assertSame([], $this->retrieveOptionsReflector->getValue($obj)); + } + public function testDeserializeEmptyMetadata() { /** @var mixed $obj */