diff --git a/.hark/changes/2026-11-03_stripe-openapi_ddc95e66.change.md b/.hark/changes/2026-11-03_stripe-openapi_ddc95e66.change.md new file mode 100644 index 000000000..931a87715 --- /dev/null +++ b/.hark/changes/2026-11-03_stripe-openapi_ddc95e66.change.md @@ -0,0 +1,8 @@ +--- +title: Update generated code +pr_url: https://github.com/stripe/stripe-php/pull/2188 +semver_level: minor +is_stripe_api_change: true +--- + +* Add support for `business_profile_management` on `V2.Core.AccountSession.components` and `V2\Core\AccountSession.create().$params.component` diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index f99af06cd..a22905938 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -305a4cda5bfda341d0099795803d0af4637923c0 \ No newline at end of file +fcd36ef9298b7a9e8a2a18bc4f6162b100aa8bbc \ No newline at end of file diff --git a/lib/BaseStripeClient.php b/lib/BaseStripeClient.php index 8e0bf1835..6d7c7fac7 100644 --- a/lib/BaseStripeClient.php +++ b/lib/BaseStripeClient.php @@ -388,9 +388,9 @@ public function requestCollection($method, $path, $params, $opts) */ public function requestSearchResult($method, $path, $params, $opts) { - $obj = $this->request($method, $path, $params, $opts); $apiMode = Util::getApiMode($path); if ('v1' === $apiMode) { + $obj = $this->request($method, $path, $params, $opts); if (!$obj instanceof SearchResult) { $received_class = \get_class($obj); $msg = "Expected to receive `Stripe\\SearchResult` object from Stripe API. Instead received `{$received_class}`."; @@ -401,9 +401,9 @@ public function requestSearchResult($method, $path, $params, $opts) } else { $params = null === $params ? [] : $params; $filters = $params; + $path = \explode('?', $path, 2)[0]; if (\array_key_exists('limit', $params)) { - $separator = false === \strpos($path, '?') ? '?' : '&'; - $path .= $separator . 'limit=' . \rawurlencode((string) $params['limit']); + $path .= '?limit=' . \rawurlencode((string) $params['limit']); unset($params['limit']); } $obj = $this->request($method, $path, $params, $opts); diff --git a/lib/Service/V2/Core/AccountSessionService.php b/lib/Service/V2/Core/AccountSessionService.php index 3bd4f55d1..cd0fd4a64 100644 --- a/lib/Service/V2/Core/AccountSessionService.php +++ b/lib/Service/V2/Core/AccountSessionService.php @@ -14,7 +14,7 @@ class AccountSessionService extends \Stripe\Service\AbstractService /** * Create an Account Session. * - * @param null|array{account: string, components: array{account_management?: array{enabled: bool}, account_onboarding?: array{enabled: bool}, agentic_commerce_settings?: array{enabled: bool}, app_install?: array{enabled: bool}, app_viewport?: array{enabled: bool}, balance_report?: array{enabled: bool}, balances?: array{enabled: bool}, bills?: array{enabled: bool}, capital_financing?: array{enabled: bool}, capital_financing_application?: array{enabled: bool}, capital_financing_promotion?: array{enabled: bool}, check_scanning?: array{enabled: bool}, disputes_list?: array{enabled: bool}, documents?: array{enabled: bool}, export_tax_transactions?: array{enabled: bool}, financial_account_rewards?: array{enabled: bool}, financial_accounts?: array{enabled: bool}, financial_accounts_transactions?: array{enabled: bool}, instant_payouts_promotion?: array{enabled: bool}, invoice_history?: array{enabled: bool}, issuing_card?: array{enabled: bool}, issuing_cards_list?: array{enabled: bool}, network_cost_passthrough_report?: array{enabled: bool}, notification_banner?: array{enabled: bool}, payment_details?: array{enabled: bool}, payment_disputes?: array{enabled: bool}, payment_method_settings?: array{enabled: bool}, payments?: array{enabled: bool}, payout_details?: array{enabled: bool}, payout_reconciliation_report?: array{enabled: bool}, payouts?: array{enabled: bool}, payouts_list?: array{enabled: bool}, product_tax_code_selector?: array{enabled: bool}, reporting_chart?: array{enabled: bool}, tax_registrations?: array{enabled: bool}, tax_settings?: array{enabled: bool}, tax_threshold_monitoring?: array{enabled: bool}, terminal_hardware_orders?: array{enabled: bool}, terminal_hardware_shop?: array{enabled: bool}}, scopes?: array{allowed_stripe_app_ids?: string[], capture_payments?: string, create_instant_payouts?: string, create_outbound_payments?: string, create_payout_schedule?: string, create_standard_payouts?: string, create_us_paper_check_on_application?: string, disable_stripe_user_authentication?: string, manage_bills?: string, manage_destination_on_behalf_of_charges?: string, manage_issuing_cardholders?: string, manage_issuing_cards?: string, manage_issuing_disputes?: string, manage_issuing_spending_controls?: string, manage_payment_disputes?: string, manage_payout_methods?: string, manage_refund_payments?: string, manage_smart_disputes?: string}} $params + * @param null|array{account: string, components: array{account_management?: array{enabled: bool}, account_onboarding?: array{enabled: bool}, agentic_commerce_settings?: array{enabled: bool}, app_install?: array{enabled: bool}, app_viewport?: array{enabled: bool}, balance_report?: array{enabled: bool}, balances?: array{enabled: bool}, bills?: array{enabled: bool}, business_profile_management?: array{enabled: bool}, capital_financing?: array{enabled: bool}, capital_financing_application?: array{enabled: bool}, capital_financing_promotion?: array{enabled: bool}, check_scanning?: array{enabled: bool}, disputes_list?: array{enabled: bool}, documents?: array{enabled: bool}, export_tax_transactions?: array{enabled: bool}, financial_account_rewards?: array{enabled: bool}, financial_accounts?: array{enabled: bool}, financial_accounts_transactions?: array{enabled: bool}, instant_payouts_promotion?: array{enabled: bool}, invoice_history?: array{enabled: bool}, issuing_card?: array{enabled: bool}, issuing_cards_list?: array{enabled: bool}, network_cost_passthrough_report?: array{enabled: bool}, notification_banner?: array{enabled: bool}, payment_details?: array{enabled: bool}, payment_disputes?: array{enabled: bool}, payment_method_settings?: array{enabled: bool}, payments?: array{enabled: bool}, payout_details?: array{enabled: bool}, payout_reconciliation_report?: array{enabled: bool}, payouts?: array{enabled: bool}, payouts_list?: array{enabled: bool}, product_tax_code_selector?: array{enabled: bool}, reporting_chart?: array{enabled: bool}, tax_registrations?: array{enabled: bool}, tax_settings?: array{enabled: bool}, tax_threshold_monitoring?: array{enabled: bool}, terminal_hardware_orders?: array{enabled: bool}, terminal_hardware_shop?: array{enabled: bool}}, scopes?: array{allowed_stripe_app_ids?: string[], capture_payments?: string, create_instant_payouts?: string, create_outbound_payments?: string, create_payout_schedule?: string, create_standard_payouts?: string, create_us_paper_check_on_application?: string, disable_stripe_user_authentication?: string, manage_bills?: string, manage_destination_on_behalf_of_charges?: string, manage_issuing_cardholders?: string, manage_issuing_cards?: string, manage_issuing_disputes?: string, manage_issuing_spending_controls?: string, manage_payment_disputes?: string, manage_payout_methods?: string, manage_refund_payments?: string, manage_smart_disputes?: string}} $params * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts * * @return \Stripe\V2\Core\AccountSession diff --git a/lib/V2/Core/AccountSession.php b/lib/V2/Core/AccountSession.php index 769f642e3..963b207a6 100644 --- a/lib/V2/Core/AccountSession.php +++ b/lib/V2/Core/AccountSession.php @@ -11,7 +11,7 @@ * @property string $object String representing the object's type. Objects of the same type share the same value of the object field. * @property string $account The ID of the account this Account Session grants access to. * @property string $client_secret The client secret used to initialize Connect embedded components. Do not log it or expose it to anyone other than the intended user. - * @property (object{account_management: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), account_onboarding: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), agentic_commerce_settings: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), app_install: (object{enabled: bool, scopes: (object{allowed_stripe_app_ids: string[]}&\Stripe\StripeObject)}&\Stripe\StripeObject), app_viewport: (object{enabled: bool, scopes: (object{allowed_stripe_app_ids: string[]}&\Stripe\StripeObject)}&\Stripe\StripeObject), balance_report: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), balances: (object{enabled: bool, scopes: (object{create_instant_payouts?: string, create_payout_schedule: string, create_standard_payouts: string, disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), bills: (object{enabled: bool, scopes: (object{create_outbound_payments: string, disable_stripe_user_authentication: string, manage_bills: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), capital_financing: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), capital_financing_application: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), capital_financing_promotion: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), check_scanning: (object{enabled: bool, scopes: (object{create_us_paper_check_on_application: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), disputes_list: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), documents: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), export_tax_transactions: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), financial_account_rewards: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), financial_accounts: (object{enabled: bool, scopes: (object{create_outbound_payments: string, create_payout_schedule: string, disable_stripe_user_authentication: string, manage_bills: string, manage_issuing_cards: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), financial_accounts_transactions: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_issuing_cards: string, manage_issuing_disputes: string, manage_payment_disputes: string, manage_refund_payments: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), instant_payouts_promotion: (object{enabled: bool, scopes: (object{create_instant_payouts?: string, disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), invoice_history: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), issuing_card: (object{enabled: bool, scopes: (object{manage_issuing_cardholders: string, manage_issuing_cards: string, manage_issuing_disputes: string, manage_issuing_spending_controls: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), issuing_cards_list: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_issuing_cardholders: string, manage_issuing_cards: string, manage_issuing_disputes: string, manage_issuing_spending_controls: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), network_cost_passthrough_report: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), notification_banner: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payment_details: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payment_disputes: (object{enabled: bool, scopes: (object{manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payment_method_settings: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payments: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payout_details: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), payout_reconciliation_report: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), payouts: (object{enabled: bool, scopes: (object{create_instant_payouts?: string, create_payout_schedule: string, create_standard_payouts: string, disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payouts_list: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), product_tax_code_selector: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), reporting_chart: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), tax_registrations: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), tax_settings: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), tax_threshold_monitoring: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), terminal_hardware_orders: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), terminal_hardware_shop: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject)}&\Stripe\StripeObject) $components Settings and scopes for each embedded component in this Account Session. + * @property (object{account_management: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), account_onboarding: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), agentic_commerce_settings: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), app_install: (object{enabled: bool, scopes: (object{allowed_stripe_app_ids: string[]}&\Stripe\StripeObject)}&\Stripe\StripeObject), app_viewport: (object{enabled: bool, scopes: (object{allowed_stripe_app_ids: string[]}&\Stripe\StripeObject)}&\Stripe\StripeObject), balance_report: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), balances: (object{enabled: bool, scopes: (object{create_instant_payouts?: string, create_payout_schedule: string, create_standard_payouts: string, disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), bills: (object{enabled: bool, scopes: (object{create_outbound_payments: string, disable_stripe_user_authentication: string, manage_bills: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), business_profile_management: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), capital_financing: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), capital_financing_application: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), capital_financing_promotion: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), check_scanning: (object{enabled: bool, scopes: (object{create_us_paper_check_on_application: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), disputes_list: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), documents: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), export_tax_transactions: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), financial_account_rewards: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), financial_accounts: (object{enabled: bool, scopes: (object{create_outbound_payments: string, create_payout_schedule: string, disable_stripe_user_authentication: string, manage_bills: string, manage_issuing_cards: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), financial_accounts_transactions: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_issuing_cards: string, manage_issuing_disputes: string, manage_payment_disputes: string, manage_refund_payments: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), instant_payouts_promotion: (object{enabled: bool, scopes: (object{create_instant_payouts?: string, disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), invoice_history: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), issuing_card: (object{enabled: bool, scopes: (object{manage_issuing_cardholders: string, manage_issuing_cards: string, manage_issuing_disputes: string, manage_issuing_spending_controls: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), issuing_cards_list: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_issuing_cardholders: string, manage_issuing_cards: string, manage_issuing_disputes: string, manage_issuing_spending_controls: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), network_cost_passthrough_report: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), notification_banner: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payment_details: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payment_disputes: (object{enabled: bool, scopes: (object{manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payment_method_settings: (object{enabled: bool, scopes: (object{disable_stripe_user_authentication: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payments: (object{enabled: bool, scopes: (object{capture_payments: string, manage_destination_on_behalf_of_charges: string, manage_payment_disputes: string, manage_refund_payments: string, manage_smart_disputes: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payout_details: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), payout_reconciliation_report: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), payouts: (object{enabled: bool, scopes: (object{create_instant_payouts?: string, create_payout_schedule: string, create_standard_payouts: string, disable_stripe_user_authentication: string, manage_payout_methods: string}&\Stripe\StripeObject)}&\Stripe\StripeObject), payouts_list: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), product_tax_code_selector: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), reporting_chart: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), tax_registrations: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), tax_settings: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), tax_threshold_monitoring: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), terminal_hardware_orders: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject), terminal_hardware_shop: (object{enabled: bool, scopes: (object{}&\Stripe\StripeObject)}&\Stripe\StripeObject)}&\Stripe\StripeObject) $components Settings and scopes for each embedded component in this Account Session. * @property string $created The time at which the Account Session was created. * @property string $expires_at The time at which the Account Session expires. * @property bool $livemode Has the value true if the object exists in live mode or false if the object exists in test mode. diff --git a/lib/V2/Data/SearchResultList.php b/lib/V2/Data/SearchResultList.php index dee737ad0..ea6241c16 100644 --- a/lib/V2/Data/SearchResultList.php +++ b/lib/V2/Data/SearchResultList.php @@ -14,7 +14,7 @@ * @property null|string $next_page_url Token for the next page. * @property null|string $previous_page_url Token for the previous page. */ -class SearchResultList extends \Stripe\ApiResource +class SearchResultList extends \Stripe\StripeObject { const OBJECT_NAME = 'v2.data.search_result_list'; diff --git a/lib/V2/Tax/OperationsResolveAddressResult.php b/lib/V2/Tax/OperationsResolveAddressResult.php index 20db348e3..e4b8eeb99 100644 --- a/lib/V2/Tax/OperationsResolveAddressResult.php +++ b/lib/V2/Tax/OperationsResolveAddressResult.php @@ -13,7 +13,7 @@ * @property string $precision The precision level of the resolved address. * @property (object{issues: (object{code: string, field: string}&\Stripe\StripeObject)[]}&\Stripe\StripeObject) $precision_details Details about the precision, including any issues. */ -class OperationsResolveAddressResult extends \Stripe\SingletonApiResource +class OperationsResolveAddressResult extends \Stripe\StripeObject { const OBJECT_NAME = 'v2.tax.operations_resolve_address_result'; diff --git a/tests/Stripe/BaseStripeClientTest.php b/tests/Stripe/BaseStripeClientTest.php index db75be237..718126d9d 100644 --- a/tests/Stripe/BaseStripeClientTest.php +++ b/tests/Stripe/BaseStripeClientTest.php @@ -51,6 +51,61 @@ protected function setUpCurlClientStub() ; } + /** + * @dataProvider provideSearchDispatchesOnceCases + * + * @param mixed $method + * @param mixed $path + * @param mixed $params + * @param mixed $expectedPath + * @param mixed $body + * @param mixed $v2 + */ + public function testSearchDispatchesOnce($method, $path, $params, $expectedPath, $body, $v2) + { + $client = $this->getMockBuilder(BaseStripeClient::class)->setMethods(['request'])->getMock(); + $result = $v2 ? new V2\SearchResult() : new SearchResult(); + $opts = ['stripe_account' => 'acct_123']; + $original = $params; + $client->expects(self::once())->method('request') + ->with($method, $expectedPath, $body, $opts)->willReturn($result) + ; + self::assertSame($result, $client->requestSearchResult($method, $path, $params, $opts)); + self::assertSame($original, $params); + if ($v2) { + $filters = new \ReflectionProperty(V2\SearchResult::class, 'filters'); + $filters->setAccessible(true); + self::assertSame(null === $params ? [] : $params, $filters->getValue($result)); + } else { + self::assertSame($params, $result->getFilters()); + } + } + + public static function provideSearchDispatchesOnceCases(): iterable + { + return [ + ['get', '/v1/widgets/search', ['limit' => 2], '/v1/widgets/search', ['limit' => 2], false], + ['post', '/v2/widgets/search', ['query' => 'widgets', 'limit' => 2], '/v2/widgets/search?limit=2', ['query' => 'widgets'], true], + ['post', '/v2/widgets/search', ['query' => 'widgets'], '/v2/widgets/search', ['query' => 'widgets'], true], + ['post', '/v2/widgets/search', null, '/v2/widgets/search', [], true], + ['post', '/v2/widgets/search?page=2&limit=2', ['query' => 'widgets', 'limit' => 9], '/v2/widgets/search?limit=9', ['query' => 'widgets'], true], + ['post', '/v2/widgets/search?page=2', ['query' => 'widgets', 'limit' => 9], '/v2/widgets/search?limit=9', ['query' => 'widgets'], true], + ['post', '/v2/widgets/search?limit=2&unused=value', ['query' => 'widgets'], '/v2/widgets/search', ['query' => 'widgets'], true], + ['post', '/v2/widgets/search?limit=2', null, '/v2/widgets/search', [], true], + ]; + } + + public function testSearchPropagatesErrorWithoutAnotherDispatch() + { + $client = $this->getMockBuilder(BaseStripeClient::class)->setMethods(['request'])->getMock(); + $client->expects(self::once())->method('request') + ->with('post', '/v2/widgets/search?limit=2', ['query' => 'widgets'], []) + ->willThrowException(new Exception\InvalidRequestException('search failed')) + ; + $this->expectException(Exception\InvalidRequestException::class); + $client->requestSearchResult('post', '/v2/widgets/search', ['limit' => 2, 'query' => 'widgets'], []); + } + public function testCtorDoesNotThrowWhenNoParams() { $client = new BaseStripeClient(); diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index 19cbf17aa..2a5b3746a 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -9203,6 +9203,7 @@ public function testV2CoreAccountSessionPost() 'balance_report' => ['enabled' => true], 'balances' => ['enabled' => true], 'bills' => ['enabled' => true], + 'business_profile_management' => ['enabled' => true], 'capital_financing' => ['enabled' => true], 'capital_financing_application' => ['enabled' => true], 'capital_financing_promotion' => ['enabled' => true], @@ -9298,6 +9299,10 @@ public function testV2CoreAccountSessionPost() 'manage_bills' => 'disabled', ], ], + 'business_profile_management' => [ + 'enabled' => [], + 'scopes' => [], + ], 'capital_financing' => [ 'enabled' => [], 'scopes' => [], @@ -9505,6 +9510,7 @@ public function testV2CoreAccountSessionPost() 'balance_report' => ['enabled' => true], 'balances' => ['enabled' => true], 'bills' => ['enabled' => true], + 'business_profile_management' => ['enabled' => true], 'capital_financing' => ['enabled' => true], 'capital_financing_application' => ['enabled' => true], 'capital_financing_promotion' => ['enabled' => true], @@ -11155,7 +11161,7 @@ public function testV2DataAnalyticsMetricQueryPost() self::assertInstanceOf(V2\Data\Analytics\MetricQueryResult::class, $result); } - public function testV2DataOperationPost() + public function testV2DataOperationSearchPostRequired() { $this->stubRequest( 'post', @@ -11165,6 +11171,16 @@ public function testV2DataOperationPost() false, [ 'object' => 'v2.data.search_result_list', + 'context' => [ + 'business_concepts' => [ + '0' => [ + 'definition' => 'definition', + 'term' => 'term', + ], + ], + 'domain' => 'domain', + 'guidance' => 'guidance', + ], 'data' => [ '0' => [ 'description' => 'description', @@ -11173,6 +11189,7 @@ public function testV2DataOperationPost() 'http_method' => 'GET', 'id' => 'obj_123', ], + 'extended_description' => 'extended_description', 'id' => 'obj_123', 'name' => 'name', 'object_type' => 'object_type', @@ -11182,6 +11199,8 @@ public function testV2DataOperationPost() ], ], 'livemode' => [], + 'next_page_url' => 'next_page_url', + 'previous_page_url' => 'previous_page_url', ], 200, BaseStripeClient::DEFAULT_API_BASE @@ -11192,6 +11211,64 @@ public function testV2DataOperationPost() self::assertInstanceOf(V2\Data\SearchResultList::class, $result); } + public function testV2DataOperationSearchPostAll() + { + $this->stubRequest( + 'post', + '/v2/data/operations/search', + [ + 'catalogs' => ['schemas'], + 'limit' => 102976443, + 'page' => 'page', + 'query' => 'query', + ], + [], + false, + [ + 'object' => 'v2.data.search_result_list', + 'context' => [ + 'business_concepts' => [ + '0' => [ + 'definition' => 'definition', + 'term' => 'term', + ], + ], + 'domain' => 'domain', + 'guidance' => 'guidance', + ], + 'data' => [ + '0' => [ + 'description' => 'description', + 'execution_spec' => [ + 'execution_url' => 'execution_url', + 'http_method' => 'GET', + 'id' => 'obj_123', + ], + 'extended_description' => 'extended_description', + 'id' => 'obj_123', + 'name' => 'name', + 'object_type' => 'object_type', + 'reference_url' => 'reference_url', + 'refreshed_at' => '1970-01-01T11:25:45.896Z', + 'relevance_score' => '1104594632', + ], + ], + 'livemode' => [], + 'next_page_url' => 'next_page_url', + 'previous_page_url' => 'previous_page_url', + ], + 200, + BaseStripeClient::DEFAULT_API_BASE + ); + $result = $this->v2Client->v2->data->operations->search([ + 'catalogs' => ['schemas'], + 'limit' => 102976443, + 'page' => 'page', + 'query' => 'query', + ]); + self::assertInstanceOf(V2\Data\SearchResultList::class, $result); + } + public function testV2DataQueryRunPost() { $this->stubRequest( @@ -18520,7 +18597,44 @@ public function testV2TaxManualRulePost3() self::assertInstanceOf(V2\Tax\ManualRule::class, $result); } - public function testV2TaxOperationPost() + public function testV2TaxOperationResolveAddressPostRequired() + { + $this->stubRequest( + 'post', + '/v2/tax/operations/resolve_address', + ['address' => ['country' => 'country']], + [], + false, + [ + 'object' => 'v2.tax.operations_resolve_address_result', + 'address' => [ + 'city' => 'city', + 'country' => 'country', + 'line1' => 'line1', + 'postal_code' => 'postal_code', + 'state' => 'state', + ], + 'livemode' => [], + 'precision' => 'none', + 'precision_details' => [ + 'issues' => [ + '0' => [ + 'code' => 'required_for_improved_precision', + 'field' => 'country', + ], + ], + ], + ], + 200, + BaseStripeClient::DEFAULT_API_BASE + ); + $result = $this->v2Client->v2->tax->operations->resolveAddress([ + 'address' => ['country' => 'country'], + ]); + self::assertInstanceOf(V2\Tax\OperationsResolveAddressResult::class, $result); + } + + public function testV2TaxOperationResolveAddressPostAll() { $this->stubRequest( 'post', @@ -18538,7 +18652,13 @@ public function testV2TaxOperationPost() false, [ 'object' => 'v2.tax.operations_resolve_address_result', - 'address' => [], + 'address' => [ + 'city' => 'city', + 'country' => 'country', + 'line1' => 'line1', + 'postal_code' => 'postal_code', + 'state' => 'state', + ], 'livemode' => [], 'precision' => 'none', 'precision_details' => [