Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+2 -1
View File
@@ -6,5 +6,6 @@ namespace Stripe\Util;
class ApiVersion
{
const CURRENT = '2025-05-28.basil';
const CURRENT = '2026-02-25.clover';
const CURRENT_MAJOR = 'clover';
}
+18 -1
View File
@@ -4,10 +4,27 @@ namespace Stripe\Util;
class EventTypes
{
const thinEventMapping = [
const v2EventMapping = [
// The beginning of the section generated from our OpenAPI spec
\Stripe\Events\V1BillingMeterErrorReportTriggeredEvent::LOOKUP_TYPE => \Stripe\Events\V1BillingMeterErrorReportTriggeredEvent::class,
\Stripe\Events\V1BillingMeterNoMeterFoundEvent::LOOKUP_TYPE => \Stripe\Events\V1BillingMeterNoMeterFoundEvent::class,
\Stripe\Events\V2CoreAccountClosedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountClosedEvent::class,
\Stripe\Events\V2CoreAccountCreatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountCreatedEvent::class,
\Stripe\Events\V2CoreAccountUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingConfigurationCustomerUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingConfigurationCustomerUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingConfigurationMerchantUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingConfigurationMerchantUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingConfigurationRecipientUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingConfigurationRecipientUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingDefaultsUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingDefaultsUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingFutureRequirementsUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingFutureRequirementsUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingIdentityUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingIdentityUpdatedEvent::class,
\Stripe\Events\V2CoreAccountIncludingRequirementsUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountIncludingRequirementsUpdatedEvent::class,
\Stripe\Events\V2CoreAccountLinkReturnedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountLinkReturnedEvent::class,
\Stripe\Events\V2CoreAccountPersonCreatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountPersonCreatedEvent::class,
\Stripe\Events\V2CoreAccountPersonDeletedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountPersonDeletedEvent::class,
\Stripe\Events\V2CoreAccountPersonUpdatedEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreAccountPersonUpdatedEvent::class,
\Stripe\Events\V2CoreEventDestinationPingEvent::LOOKUP_TYPE => \Stripe\Events\V2CoreEventDestinationPingEvent::class,
// The end of the section generated from our OpenAPI spec
];
+17 -2
View File
@@ -23,6 +23,7 @@ class ObjectTypes
\Stripe\ApplicationFeeRefund::OBJECT_NAME => \Stripe\ApplicationFeeRefund::class,
\Stripe\Apps\Secret::OBJECT_NAME => \Stripe\Apps\Secret::class,
\Stripe\Balance::OBJECT_NAME => \Stripe\Balance::class,
\Stripe\BalanceSettings::OBJECT_NAME => \Stripe\BalanceSettings::class,
\Stripe\BalanceTransaction::OBJECT_NAME => \Stripe\BalanceTransaction::class,
\Stripe\BankAccount::OBJECT_NAME => \Stripe\BankAccount::class,
\Stripe\Billing\Alert::OBJECT_NAME => \Stripe\Billing\Alert::class,
@@ -89,11 +90,14 @@ class ObjectTypes
\Stripe\LineItem::OBJECT_NAME => \Stripe\LineItem::class,
\Stripe\LoginLink::OBJECT_NAME => \Stripe\LoginLink::class,
\Stripe\Mandate::OBJECT_NAME => \Stripe\Mandate::class,
\Stripe\PaymentAttemptRecord::OBJECT_NAME => \Stripe\PaymentAttemptRecord::class,
\Stripe\PaymentIntent::OBJECT_NAME => \Stripe\PaymentIntent::class,
\Stripe\PaymentIntentAmountDetailsLineItem::OBJECT_NAME => \Stripe\PaymentIntentAmountDetailsLineItem::class,
\Stripe\PaymentLink::OBJECT_NAME => \Stripe\PaymentLink::class,
\Stripe\PaymentMethod::OBJECT_NAME => \Stripe\PaymentMethod::class,
\Stripe\PaymentMethodConfiguration::OBJECT_NAME => \Stripe\PaymentMethodConfiguration::class,
\Stripe\PaymentMethodDomain::OBJECT_NAME => \Stripe\PaymentMethodDomain::class,
\Stripe\PaymentRecord::OBJECT_NAME => \Stripe\PaymentRecord::class,
\Stripe\Payout::OBJECT_NAME => \Stripe\Payout::class,
\Stripe\Person::OBJECT_NAME => \Stripe\Person::class,
\Stripe\Plan::OBJECT_NAME => \Stripe\Plan::class,
@@ -103,11 +107,15 @@ class ObjectTypes
\Stripe\PromotionCode::OBJECT_NAME => \Stripe\PromotionCode::class,
\Stripe\Quote::OBJECT_NAME => \Stripe\Quote::class,
\Stripe\Radar\EarlyFraudWarning::OBJECT_NAME => \Stripe\Radar\EarlyFraudWarning::class,
\Stripe\Radar\PaymentEvaluation::OBJECT_NAME => \Stripe\Radar\PaymentEvaluation::class,
\Stripe\Radar\ValueList::OBJECT_NAME => \Stripe\Radar\ValueList::class,
\Stripe\Radar\ValueListItem::OBJECT_NAME => \Stripe\Radar\ValueListItem::class,
\Stripe\Refund::OBJECT_NAME => \Stripe\Refund::class,
\Stripe\Reporting\ReportRun::OBJECT_NAME => \Stripe\Reporting\ReportRun::class,
\Stripe\Reporting\ReportType::OBJECT_NAME => \Stripe\Reporting\ReportType::class,
\Stripe\Reserve\Hold::OBJECT_NAME => \Stripe\Reserve\Hold::class,
\Stripe\Reserve\Plan::OBJECT_NAME => \Stripe\Reserve\Plan::class,
\Stripe\Reserve\Release::OBJECT_NAME => \Stripe\Reserve\Release::class,
\Stripe\ReserveTransaction::OBJECT_NAME => \Stripe\ReserveTransaction::class,
\Stripe\Review::OBJECT_NAME => \Stripe\Review::class,
\Stripe\SetupAttempt::OBJECT_NAME => \Stripe\SetupAttempt::class,
@@ -120,6 +128,7 @@ class ObjectTypes
\Stripe\Subscription::OBJECT_NAME => \Stripe\Subscription::class,
\Stripe\SubscriptionItem::OBJECT_NAME => \Stripe\SubscriptionItem::class,
\Stripe\SubscriptionSchedule::OBJECT_NAME => \Stripe\SubscriptionSchedule::class,
\Stripe\Tax\Association::OBJECT_NAME => \Stripe\Tax\Association::class,
\Stripe\Tax\Calculation::OBJECT_NAME => \Stripe\Tax\Calculation::class,
\Stripe\Tax\CalculationLineItem::OBJECT_NAME => \Stripe\Tax\CalculationLineItem::class,
\Stripe\Tax\Registration::OBJECT_NAME => \Stripe\Tax\Registration::class,
@@ -133,6 +142,7 @@ class ObjectTypes
\Stripe\Terminal\Configuration::OBJECT_NAME => \Stripe\Terminal\Configuration::class,
\Stripe\Terminal\ConnectionToken::OBJECT_NAME => \Stripe\Terminal\ConnectionToken::class,
\Stripe\Terminal\Location::OBJECT_NAME => \Stripe\Terminal\Location::class,
\Stripe\Terminal\OnboardingLink::OBJECT_NAME => \Stripe\Terminal\OnboardingLink::class,
\Stripe\Terminal\Reader::OBJECT_NAME => \Stripe\Terminal\Reader::class,
\Stripe\TestHelpers\TestClock::OBJECT_NAME => \Stripe\TestHelpers\TestClock::class,
\Stripe\Token::OBJECT_NAME => \Stripe\Token::class,
@@ -162,8 +172,13 @@ class ObjectTypes
\Stripe\V2\Billing\MeterEvent::OBJECT_NAME => \Stripe\V2\Billing\MeterEvent::class,
\Stripe\V2\Billing\MeterEventAdjustment::OBJECT_NAME => \Stripe\V2\Billing\MeterEventAdjustment::class,
\Stripe\V2\Billing\MeterEventSession::OBJECT_NAME => \Stripe\V2\Billing\MeterEventSession::class,
\Stripe\V2\Event::OBJECT_NAME => \Stripe\V2\Event::class,
\Stripe\V2\EventDestination::OBJECT_NAME => \Stripe\V2\EventDestination::class,
\Stripe\V2\Core\Account::OBJECT_NAME => \Stripe\V2\Core\Account::class,
\Stripe\V2\Core\AccountLink::OBJECT_NAME => \Stripe\V2\Core\AccountLink::class,
\Stripe\V2\Core\AccountPerson::OBJECT_NAME => \Stripe\V2\Core\AccountPerson::class,
\Stripe\V2\Core\AccountPersonToken::OBJECT_NAME => \Stripe\V2\Core\AccountPersonToken::class,
\Stripe\V2\Core\AccountToken::OBJECT_NAME => \Stripe\V2\Core\AccountToken::class,
\Stripe\V2\Core\Event::OBJECT_NAME => \Stripe\V2\Core\Event::class,
\Stripe\V2\Core\EventDestination::OBJECT_NAME => \Stripe\V2\Core\EventDestination::class,
// v2 object classes: The end of the section generated from our OpenAPI spec
];
}
+14 -3
View File
@@ -3,9 +3,9 @@
namespace Stripe\Util;
/**
* @phpstan-type RequestOptionsArray array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string, stripe_version?: string, api_base?: string, max_network_retries?: int }
* @phpstan-type RequestOptionsArray array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string|\Stripe\StripeContext, stripe_version?: string, api_base?: string, max_network_retries?: int, headers?: Array }
*
* @psalm-type RequestOptionsArray = array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string, stripe_version?: string, api_base?: string, max_network_retries?: int }
* @psalm-type RequestOptionsArray = array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string|\Stripe\StripeContext, stripe_version?: string, api_base?: string, max_network_retries?: int, headers?: Array }
*/
class RequestOptions
{
@@ -14,6 +14,7 @@ class RequestOptions
*/
public static $HEADERS_TO_PERSIST = [
'Stripe-Account',
'Stripe-Context',
'Stripe-Version',
];
@@ -79,6 +80,12 @@ class RequestOptions
}
$other_options->headers = \array_merge($this->headers, $other_options->headers);
// special handling for stripe_context
// if other sent an empty string, then we should unset
if (\array_key_exists('Stripe-Context', $other_options->headers) && '' === $other_options->headers['Stripe-Context']) {
unset($other_options->headers['Stripe-Context']);
}
return $other_options;
}
@@ -147,7 +154,7 @@ class RequestOptions
}
if (\array_key_exists('stripe_context', $options)) {
if (null !== $options['stripe_context']) {
$headers['Stripe-Context'] = $options['stripe_context'];
$headers['Stripe-Context'] = (string) $options['stripe_context'];
}
unset($options['stripe_context']);
}
@@ -167,6 +174,10 @@ class RequestOptions
$base = $options['api_base'];
unset($options['api_base']);
}
if (\array_key_exists('headers', $options)) {
$headers = \array_merge($headers, $options['headers']);
unset($options['headers']);
}
if ($strict && !empty($options)) {
$message = 'Got unexpected keys in options array: ' . \implode(', ', \array_keys($options));
+29 -48
View File
@@ -3,6 +3,7 @@
namespace Stripe\Util;
use Stripe\StripeObject;
use Stripe\V2\DeletedObject;
abstract class Util
{
@@ -39,10 +40,11 @@ abstract class Util
* @param array $resp the response from the Stripe API
* @param array|RequestOptions $opts
* @param 'v1'|'v2' $apiMode whether the response is from a v1 or v2 API
* @param bool $isV2DeletedObject whether we should ignore the `object` field and treat the response as a v2 deleted object
*
* @return array|StripeObject
*/
public static function convertToStripeObject($resp, $opts, $apiMode = 'v1')
public static function convertToStripeObject($resp, $opts, $apiMode = 'v1', $isV2DeletedObject = false)
{
$types = 'v1' === $apiMode ? ObjectTypes::mapping
: ObjectTypes::v2Mapping;
@@ -55,16 +57,19 @@ abstract class Util
return $mapped;
}
if (\is_array($resp)) {
if (isset($resp['object']) && \is_string($resp['object'])
if ($isV2DeletedObject) {
$class = DeletedObject::class;
} elseif (
isset($resp['object']) && \is_string($resp['object'])
&& isset($types[$resp['object']])
) {
$class = $types[$resp['object']];
if ('v2' === $apiMode && ('v2.core.event' === $resp['object'])) {
$eventTypes = EventTypes::thinEventMapping;
$eventTypes = EventTypes::v2EventMapping;
if (\array_key_exists('type', $resp) && \array_key_exists($resp['type'], $eventTypes)) {
$class = $eventTypes[$resp['type']];
} else {
$class = \Stripe\V2\Event::class;
$class = \Stripe\V2\Core\Event::class;
}
}
} elseif (\array_key_exists('data', $resp) && \array_key_exists('next_page_url', $resp)) {
@@ -81,41 +86,6 @@ abstract class Util
return $resp;
}
/**
* @param mixed $json
* @param mixed $class
*
* @throws \ReflectionException
*/
public static function json_decode_thin_event_object($json, $class)
{
$reflection = new \ReflectionClass($class);
$instance = $reflection->newInstanceWithoutConstructor();
$json = json_decode($json, true);
$properties = $reflection->getProperties();
foreach ($properties as $key => $property) {
if (\array_key_exists($property->getName(), $json)) {
if ('related_object' === $property->getName()) {
$related_object = new \Stripe\RelatedObject();
$related_object->id = $json['related_object']['id'];
$related_object->url = $json['related_object']['url'];
$related_object->type = $json['related_object']['type'];
$property->setValue($instance, $related_object);
} elseif ('reason' === $property->getName()) {
$reason = new \Stripe\Reason();
$reason->id = $json['reason']['id'];
$reason->idempotency_key = $json['reason']['idempotency_key'];
$property->setValue($instance, $reason);
} else {
$property->setAccessible(true);
$property->setValue($instance, $json[$property->getName()]);
}
}
}
return $instance;
}
/**
* @param mixed|string $value a string to UTF8-encode
*
@@ -131,15 +101,16 @@ abstract class Util
if (!self::$isMbstringAvailable) {
\trigger_error(
'It looks like the mbstring extension is not enabled. '
. 'UTF-8 strings will not properly be encoded. Ask your system '
. 'administrator to enable the mbstring extension, or write to '
. 'support@stripe.com if you have any questions.',
. 'UTF-8 strings will not properly be encoded. Ask your system '
. 'administrator to enable the mbstring extension, or write to '
. 'support@stripe.com if you have any questions.',
\E_USER_WARNING
);
}
}
if (\is_string($value) && self::$isMbstringAvailable
if (
\is_string($value) && self::$isMbstringAvailable
&& 'UTF-8' !== \mb_detect_encoding($value, 'UTF-8', true)
) {
return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
@@ -293,11 +264,8 @@ abstract class Util
self::flattenParams($elem, "{$calculatedKey}[{$i}]")
);
} else {
if ('v2' === $apiMode) {
$result[] = ["{$calculatedKey}", $elem];
} else {
$result[] = ["{$calculatedKey}[{$i}]", $elem];
}
// Always use indexed format for arrays
$result[] = ["{$calculatedKey}[{$i}]", $elem];
}
}
@@ -357,4 +325,17 @@ abstract class Util
return $apiMode;
}
/**
* Useful for determining if we should trust the object type when turning a response into a StripeObject.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param 'v1'|'v2' $apiMode the API version
*
* @return bool true if the method is a DELETE request for v2 API, false otherwise
*/
public static function isV2DeleteRequest($method, $apiMode)
{
return 'delete' === $method && 'v2' === $apiMode;
}
}