From e9f0e8593d90e1a579364d168208f8475cf575ec Mon Sep 17 00:00:00 2001 From: jar-stripe Date: Fri, 6 Nov 2026 16:44:31 -0800 Subject: [PATCH 1/5] Fix stale Stripe-Account header on directly-retrieved Event related objects (#1968) * Fix stale Stripe-Account header on directly-retrieved Event related objects A directly-retrieved v2 Event keeps the requestor of whatever account fetched it, so Event.fetch_related_object() could send a stale Stripe-Account header alongside the event's own Stripe-Context. EventNotification already avoids this in its own construction via StripeClient.with_stripe_context; give Event the same treatment where it's deserialized in _convert_to_stripe_object. Fixes RUN_DEVSDK-3694. Co-Authored-By: Claude Sonnet 5 Committed-By-Agent: claude * Update requestor context handling in _util.py Refactor handling of requestor context for v2 events. --------- Co-authored-by: Claude Sonnet 5 --- ...t-related-object-account-scoping.change.md | 6 ++ stripe/_api_requestor.py | 19 ++++++ stripe/_util.py | 13 ++++ tests/test_api_requestor.py | 31 ++++++++++ tests/test_v2_event.py | 60 +++++++++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 .hark/changes/2026-11-06_jar_fix-event-related-object-account-scoping.change.md diff --git a/.hark/changes/2026-11-06_jar_fix-event-related-object-account-scoping.change.md b/.hark/changes/2026-11-06_jar_fix-event-related-object-account-scoping.change.md new file mode 100644 index 000000000..027e2fb54 --- /dev/null +++ b/.hark/changes/2026-11-06_jar_fix-event-related-object-account-scoping.change.md @@ -0,0 +1,6 @@ +--- +title: Fix stale Stripe-Account header when fetching an object related to a directly-retrieved Event +semver_level: patch +jira_tickets_closed: +- RUN_DEVSDK-3694 +--- diff --git a/stripe/_api_requestor.py b/stripe/_api_requestor.py index 6224c5e6d..a9a52c09d 100644 --- a/stripe/_api_requestor.py +++ b/stripe/_api_requestor.py @@ -65,6 +65,7 @@ if TYPE_CHECKING: from stripe._app_info import AppInfo from stripe._stripe_object import StripeObject + from stripe._stripe_context import StripeContext HttpVerb = Literal["get", "post", "delete"] @@ -174,6 +175,24 @@ def _new_requestor_with_options( options=RequestorOptions(**new_options), client=self._client ) + def with_stripe_context( + self, stripe_context: "Optional[Union[str, StripeContext]]" + ) -> "_APIRequestor": + """ + Returns a new _APIRequestor with the same configuration as this one, but + scoped to a different stripe_context. Unlike _new_requestor_with_options, + this always replaces stripe_context (even with None) and clears + stripe_account, since a context is self-contained and a stripe_account + inherited from whatever request produced this requestor should not leak + into requests scoped by it. + """ + new_options = self._options.to_dict() + new_options["stripe_context"] = stripe_context + new_options["stripe_account"] = None + return _APIRequestor( + options=RequestorOptions(**new_options), client=self._client + ) + @property def api_key(self): return self._options.api_key diff --git a/stripe/_util.py b/stripe/_util.py index e034b209f..995967aa5 100644 --- a/stripe/_util.py +++ b/stripe/_util.py @@ -243,6 +243,7 @@ def _convert_to_stripe_object( elif isinstance(resp, dict): resp = resp.copy() klass_name = resp.get("object") + requestor_uses_response_context = False if isinstance(klass_name, str): if is_v2_deleted_object: # circular import @@ -254,6 +255,7 @@ def _convert_to_stripe_object( event_type = resp.get("type", "") klass = get_v2_event_class(event_type) + requestor_uses_response_context = True else: from stripe._object_classes import get_object_class @@ -279,6 +281,17 @@ def _convert_to_stripe_object( api_mode=api_mode, ) + if requestor_uses_response_context: + # A directly-retrieved object carries the requestor of whatever + # account fetched it (e.g. a platform account), but its `context` + # field is the self-contained auth context for its own account. + # Rescope the requestor the same way EventNotification.__init__ + # scopes its client so fetch_related_object() uses the correct + # headers. + obj._requestor = obj._requestor.with_stripe_context( + getattr(obj, "context", None) + ) + # We only need to update _retrieve_params when special params were # actually passed. Otherwise, leave it as is as the list / search result # constructors will instantiate their own params. diff --git a/tests/test_api_requestor.py b/tests/test_api_requestor.py index 744930ed9..b8adae3a3 100644 --- a/tests/test_api_requestor.py +++ b/tests/test_api_requestor.py @@ -669,6 +669,37 @@ def test_uses_instance_context(self, http_client_mock): stripe_context=context, ) + def test_with_stripe_context_clears_stripe_account( + self, requestor, http_client_mock: HTTPClientMock + ): + """ + with_stripe_context is used to scope a requestor to a v2 Event's own + context (see Event's construction in _util._convert_to_stripe_object). + Unlike _new_requestor_with_options, it must always clear stripe_account, + even though one was already set, so a stale account from whatever + request produced the original requestor can't leak into requests made + with the new one. + """ + requestor = requestor._new_requestor_with_options( + RequestOptions(stripe_account="acct_original") + ) + + requestor = requestor.with_stripe_context("acct_context") + + http_client_mock.stub_request( + "get", path=self.v1_path, rbody="{}", rcode=200 + ) + + requestor.request("get", self.v1_path, {}, base_address="api") + + http_client_mock.assert_requested( + "get", + stripe_context="acct_context", + ) + call = http_client_mock.get_last_call() + assert call.headers is not None + assert "Stripe-Account" not in call.headers + def test_sets_default_http_client(self, mocker): assert not stripe.default_http_client diff --git a/tests/test_v2_event.py b/tests/test_v2_event.py index 7f59ca3d5..ea7c46c95 100644 --- a/tests/test_v2_event.py +++ b/tests/test_v2_event.py @@ -15,6 +15,7 @@ V1BillingMeterErrorReportTriggeredEvent, ) from stripe.events._v1_product_updated_event import ( + V1ProductUpdatedEvent, V1ProductUpdatedEventNotification, ) from stripe.v2.core._event import ( @@ -515,3 +516,62 @@ async def test_related_object_retains_event_context_async( http_client_mock.assert_requested( "delete", path=path, stripe_context="acct_child" ) + + def test_direct_retrieve_related_object_retains_event_context( + self, http_client_mock: HTTPClientMock + ): + """ + Unlike EventNotification (built from a webhook), a directly-retrieved + Event doesn't go through StripeClient.with_stripe_context in its own + construction, so historically it kept whatever stripe_account retrieved + it. Make sure fetch_related_object() only ever uses the event's own + context, with no stale account from the retrieving client leaking in. + """ + event_path = "/v2/core/events/evt_123" + related_path = "/v1/products/prod_shared" + + http_client_mock.stub_request( + "get", + path=event_path, + rbody=json.dumps( + { + "id": "evt_123", + "object": "v2.core.event", + "type": "v1.product.updated", + "created": "2022-02-15T00:27:45.330Z", + "livemode": False, + "context": "acct_child", + "related_object": { + "id": "prod_shared", + "type": "product", + "url": related_path, + }, + } + ), + ) + http_client_mock.stub_request( + "get", + path=related_path, + rbody=json.dumps({"id": "prod_shared", "object": "product"}), + ) + + client = StripeClient( + api_key="sk_test_1234", + stripe_account="acct_platform", + http_client=http_client_mock.get_mock_http_client(), + ) + + event = client.v2.core.events.retrieve("evt_123") + assert isinstance(event, V1ProductUpdatedEvent) + + product = event.fetch_related_object() + assert product.id == "prod_shared" + + http_client_mock.assert_requested( + "get", path=related_path, stripe_context="acct_child" + ) + + assert len(http_client_mock.get_all_calls()) == 2 + related_call = http_client_mock.get_last_call() + assert related_call.headers is not None + assert "Stripe-Account" not in related_call.headers From ee9db3377090cd2eb7c9a338b943c1fdf97a67f8 Mon Sep 17 00:00:00 2001 From: jar-stripe Date: Mon, 9 Nov 2026 10:05:09 -0800 Subject: [PATCH 2/5] Reject CR/LF/NUL in header values before passing them to pycurl (#1971) PycurlClient built the HTTPHEADER list via raw "%s: %s" string interpolation with no validation, so a header value containing CR or LF could inject an additional header line (e.g. via Stripe-Request- Trigger, built from an unverified webhook event id). Other HTTP client backends in this file are already protected by their own underlying library (stdlib http.client, h11, aiohttp); pycurl has no such check built in, so it needs one here. Committed-By-Agent: claude Co-authored-by: Claude Sonnet 5 --- ...ar_reject-pycurl-header-injection.change.md | 6 ++++++ stripe/_http_client.py | 18 ++++++++++++++++++ tests/test_http_client.py | 17 +++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .hark/changes/2026-11-06_jar_reject-pycurl-header-injection.change.md diff --git a/.hark/changes/2026-11-06_jar_reject-pycurl-header-injection.change.md b/.hark/changes/2026-11-06_jar_reject-pycurl-header-injection.change.md new file mode 100644 index 000000000..401ef8606 --- /dev/null +++ b/.hark/changes/2026-11-06_jar_reject-pycurl-header-injection.change.md @@ -0,0 +1,6 @@ +--- +title: "Reject header values containing CR, LF or NUL in the pycurl HTTP client" +semver_level: patch +jira_tickets_closed: +- RUN_DEVSDK-3683 +--- diff --git a/stripe/_http_client.py b/stripe/_http_client.py index 65c3ed684..6f0815e91 100644 --- a/stripe/_http_client.py +++ b/stripe/_http_client.py @@ -827,6 +827,23 @@ def close(self): pass +def _assert_no_header_injection(headers: Mapping[str, str]) -> None: + """Rejects CR, LF and NUL in a header name or value. + + pycurl's HTTPHEADER option takes raw "name: value" strings, assembled + here by string formatting rather than passed to a validating library + call. A CR or LF in either half would let the remainder be parsed as an + additional header line. + """ + for key, value in headers.items(): + for part in (key, value): + if "\r" in part or "\n" in part or "\0" in part: + raise ValueError( + "Header names and values may not contain CR, LF or " + "NUL characters." + ) + + class PycurlClient(HTTPClient): class _ParsedProxy(TypedDict, total=False): http: Optional["ParseResult"] @@ -957,6 +974,7 @@ def _request_internal( self._curl.setopt(self.pycurl.NOSIGNAL, 1) self._curl.setopt(self.pycurl.CONNECTTIMEOUT, 30) self._curl.setopt(self.pycurl.TIMEOUT, 80) + _assert_no_header_injection(headers) self._curl.setopt( self.pycurl.HTTPHEADER, ["%s: %s" % (k, v) for k, v in dict(headers).items()], diff --git a/tests/test_http_client.py b/tests/test_http_client.py index 8b3ab71fb..0c6eaa557 100644 --- a/tests/test_http_client.py +++ b/tests/test_http_client.py @@ -1149,6 +1149,23 @@ def _check_call( return _check_call + def test_request_rejects_header_injection( + self, mocked_request_lib, make_request: MakeReqFunc, mock_response + ): + mock_response(mocked_request_lib, '{"foo": "baz"}', 200) + + hostile_headers = [ + {"Stripe-Context": "acct_123\r\nX-Injected: 1"}, + {"Stripe-Request-Trigger": "event=evt_1\nX-Injected: 1"}, + {"Authorization": "Bearer sk_test_123\r\n"}, + {"Authorization": "Bearer sk_test_123\0"}, + {"X-Injected\r\nEvil": "value"}, + ] + + for headers in hostile_headers: + with pytest.raises(ValueError): + make_request("get", self.valid_url, headers, None) + class TestPycurlClientHttpProxy(TestPycurlClient): PROXY = "http://user:withPwd@slap:8888/" From 0291a9a4023f21473c2d30daa3560eb55eb5b53d Mon Sep 17 00:00:00 2001 From: Christopher Orr Date: Mon, 9 Nov 2026 21:59:48 +0100 Subject: [PATCH 3/5] Add error messages to help users debug signature verification failures. (#1958) The stripe-signature header may now include additional metadata about the event destination and the event being sent. These can help narrow down the reason why signature verification failed. No changes are made to the verification process; this just updates how error messages are generated, if the metadata is present in the header. --- ...rc_webhook-signature-diagnostics.change.md | 6 + stripe/_webhook.py | 100 +++++++++- tests/test_webhook.py | 172 +++++++++++++++++- 3 files changed, 274 insertions(+), 4 deletions(-) create mode 100644 .hark/changes/2026-10-12_orrc_webhook-signature-diagnostics.change.md diff --git a/.hark/changes/2026-10-12_orrc_webhook-signature-diagnostics.change.md b/.hark/changes/2026-10-12_orrc_webhook-signature-diagnostics.change.md new file mode 100644 index 000000000..af73a3475 --- /dev/null +++ b/.hark/changes/2026-10-12_orrc_webhook-signature-diagnostics.change.md @@ -0,0 +1,6 @@ +--- +title: Improve webhook signature verification error messages +semver_level: patch +--- + +- When diagnostic metadata is present in the `Stripe-Signature` header, error messages help identify an incorrect signing secret or altered request body. diff --git a/stripe/_webhook.py b/stripe/_webhook.py index a9a041454..9c39d59a7 100644 --- a/stripe/_webhook.py +++ b/stripe/_webhook.py @@ -2,8 +2,10 @@ import json import time from collections import OrderedDict +from dataclasses import dataclass from hashlib import sha256 from typing import Any, Dict, Optional, Union +from urllib.parse import quote # Used for global variables import stripe # noqa: IMP101 @@ -19,6 +21,13 @@ """ +@dataclass +class _DebugMetadata: + secret: Optional[str] = None + destination: Optional[str] = None + payload: Optional[str] = None + + def build_v1_event(values: Dict[str, Any], requestor: _APIRequestor) -> Event: """ Internal helper for centralizing v1 event creation @@ -180,8 +189,7 @@ def verify_header( expected_sig = cls._compute_signature(signed_payload, secret) if not any(secure_compare(expected_sig, s) for s in signatures): raise SignatureVerificationError( - "No signatures found matching the expected signature for " - "payload", + cls._signature_error_message(header, str(payload), secret), header, payload, ) @@ -194,3 +202,91 @@ def verify_header( ) return True + + @classmethod + def _signature_error_message( + cls, header: str, payload: str, secret: str + ) -> str: + """Build an HMAC-mismatch message using optional header metadata.""" + metadata = cls._signature_debug_metadata(header) + + # If metadata has an asterisk-masked secret, compare against its length and last four characters + masked_secret = metadata.secret or "" + secret_suffix = secret[-4:] + if "*" in masked_secret and ( + len(secret) != len(masked_secret) + or secret_suffix != masked_secret[-4:] + ): + dashboard_url = "https://dashboard.stripe.com/webhooks" + if metadata.destination is not None: + dashboard_url += "/" + quote(metadata.destination, safe="") + return ( + "Webhook signature verification failed. This request may not " + "have originated from Stripe.\n\n" + f"The signing secret you provided is {len(secret)} characters " + f"long and ends in `{secret_suffix}`. However, the signing " + "secret for this destination is " + f"{len(masked_secret)} characters long and looks like " + f"`{masked_secret}`. Ensure you're using the signing secret " + "for this destination, as shown on the Dashboard: " + f"{dashboard_url}\n\n" + "Learn more: https://docs.stripe.com/webhooks/signature" + ) + + # If metadata includes the truncated payload hash, compare with the payload passed in + expected_hash = (metadata.payload or "").lower() + if len(expected_hash) == 8 and all( + character in "0123456789abcdef" for character in expected_hash + ): + actual_hash = sha256(payload.encode("utf-8")).hexdigest()[-8:] + if expected_hash != actual_hash: + return ( + "Webhook signature verification failed.\n\n" + "The request body you passed to this function differs " + "from the request body sent by Stripe to this webhook " + "destination.\n" + "The SHA-256 hash of the body should end in " + f"`{expected_hash}`. However, the SHA-256 hash of the body " + f"you provided ends in `{actual_hash}`.\n\n" + "Make sure your code does not reformat or otherwise alter " + "the raw HTTP request body before passing it to this " + "function.\n\n" + "Learn more: https://docs.stripe.com/webhooks/signature" + ) + + # Fall back to the generic message if no debug metadata available + return ( + "No signatures found matching the expected signature for payload" + ) + + @classmethod + def _signature_debug_metadata(cls, header: str) -> _DebugMetadata: + """Extract metadata from the stripe-signature header value to help debug verification failures.""" + # For each metadata key, extract the first value found in the header + metadata: Dict[str, Optional[str]] = {} + for item in header.split(","): + key, separator, value = item.lstrip().partition("=") + if ( + key in ("secret", "destination", "payload") + and key not in metadata + ): + metadata[key] = ( + cls._safe_metadata_value(value) if separator else None + ) + return _DebugMetadata( + metadata.get("secret"), + metadata.get("destination"), + metadata.get("payload"), + ) + + @staticmethod + def _safe_metadata_value(value: str) -> Optional[str]: + """Return a bounded UTF-8 metadata value, or None if unusable.""" + # Ignore overly long, potentially attacker-provided metadata values + if len(value) > 100: + return None + try: + value.encode("utf-8") + except UnicodeEncodeError: + return None + return value.strip() or None diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 2a884ef0a..7248ef01e 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -1,4 +1,5 @@ import time +from hashlib import sha256 import pytest @@ -35,12 +36,19 @@ def generate_header( - payload=DUMMY_WEBHOOK_PAYLOAD, secret=DUMMY_WEBHOOK_SECRET, timestamp=None + payload=DUMMY_WEBHOOK_PAYLOAD, + secret=DUMMY_WEBHOOK_SECRET, + timestamp=None, + debug_metadata=None, ): """Thin wrapper around WebhookSignature.generate_signature_header for tests.""" - return WebhookSignature.generate_signature_header( + header = WebhookSignature.generate_signature_header( payload, secret, timestamp ) + for key, value in (debug_metadata or {}).items(): + if value is not None: + header += f",{key}={value}" + return header def _build_header_with_scheme( @@ -214,6 +222,166 @@ def test_raise_on_no_valid_signatures_for_payload(self): DUMMY_WEBHOOK_PAYLOAD, header, DUMMY_WEBHOOK_SECRET ) + def test_diagnose_secret_mismatch(self): + dashboard_url_base = "https://dashboard.stripe.com/webhooks" + cases = [ + # Secret and masket secret don't match; show URL with endpoint + { + "masked_secret": "whsec_******************1q84", + "destination": "we_example", + "url": dashboard_url_base + "/we_example", + }, + # Missing and blank destinations use the bare Dashboard URL + { + "masked_secret": "whsec_******************1q84", + "destination": "", + "url": dashboard_url_base, + }, + # Length mismatch + {"masked_secret": "whsec_******************cret"}, + # An attacker-selected mask must not expose more than the last four characters + {"masked_secret": "whsec_*bcdefghijklmnopqrstuvwxyZ"}, + ] + for case in cases: + secret = case.get("secret", DUMMY_WEBHOOK_SECRET) + secret_suffix = case.get("secret_suffix", secret[-4:]) + masked_secret = case.get("masked_secret", "whsec_*******cret") + url = case.get("url", dashboard_url_base) + header = generate_header( + secret="whsec_other_secret", + debug_metadata={ + "secret": masked_secret, + "destination": case.get("destination"), + "payload": "00000000", + }, + ) + with pytest.raises(SignatureVerificationError) as error: + WebhookSignature.verify_header( + DUMMY_WEBHOOK_PAYLOAD, header, secret + ) + assert str(error.value) == ( + "Webhook signature verification failed. This request may not have originated from Stripe.\n\n" + f"The signing secret you provided is {len(secret)} characters long and ends in `{secret_suffix}`. " + f"However, the signing secret for this destination is {len(masked_secret)} characters long " + f"and looks like `{masked_secret}`. Ensure you're using the signing secret for this " + f"destination, as shown on the Dashboard: {url}\n\n" + "Learn more: https://docs.stripe.com/webhooks/signature" + ) + + def test_diagnose_payload_mismatch(self): + # User supplies the original body with an extra trailing space. + payload = DUMMY_WEBHOOK_PAYLOAD + " " + expected_hash = sha256( + DUMMY_WEBHOOK_PAYLOAD.encode("utf-8") + ).hexdigest()[-8:] + actual_hash = sha256(payload.encode("utf-8")).hexdigest()[-8:] + header = generate_header( + debug_metadata={ + "secret": "whsec_*******cret", + "payload": expected_hash.upper(), + } + ) + with pytest.raises(SignatureVerificationError) as error: + WebhookSignature.verify_header( + payload, header, DUMMY_WEBHOOK_SECRET + ) + assert str(error.value) == ( + "Webhook signature verification failed.\n\n" + "The request body you passed to this function differs from the request body sent by Stripe to this webhook destination.\n" + f"The SHA-256 hash of the body should end in `{expected_hash}`. However, the SHA-256 hash of the body you provided ends in `{actual_hash}`.\n\n" + "Make sure your code does not reformat or otherwise alter the raw HTTP request body before passing it to this function.\n\n" + "Learn more: https://docs.stripe.com/webhooks/signature" + ) + + def test_matching_metadata_falls_back_to_generic_error(self): + for masked_secret, secret in [ + ("whsec_*******cret", DUMMY_WEBHOOK_SECRET), + # Prefixes and mask widths do not change the fixed four-character comparison. + ("other_*******cret", DUMMY_WEBHOOK_SECRET), + ( + "whsec_*bcdefghijklmnopqrstuvwxyz", + "whsec_abcdefghijklmnopqrstuvwxyz", + ), + ("*", "*"), + ]: + header = generate_header( + secret="whsec_other_secret", + debug_metadata={"secret": masked_secret}, + ) + with pytest.raises(SignatureVerificationError) as error: + WebhookSignature.verify_header( + DUMMY_WEBHOOK_PAYLOAD, header, secret + ) + assert ( + str(error.value) + == "No signatures found matching the expected signature for payload" + ) + + def test_invalid_secret_metadata_falls_back_to_generic_error(self): + payload_hash = sha256( + DUMMY_WEBHOOK_PAYLOAD.encode("utf-8") + ).hexdigest()[-8:] + for masked_secret in [ + "unmasked", + "*" * 101, + "*\ud800", + # A blank first secret must not be replaced by a later value. + ",secret=whsec_*******abcd", + ]: + header = generate_header( + secret="whsec_other_secret", + debug_metadata={ + "secret": masked_secret, + "payload": payload_hash, + }, + ) + with pytest.raises(SignatureVerificationError) as error: + WebhookSignature.verify_header( + DUMMY_WEBHOOK_PAYLOAD, header, DUMMY_WEBHOOK_SECRET + ) + assert ( + str(error.value) + == "No signatures found matching the expected signature for payload" + ) + + def test_invalid_payload_metadata_falls_back_to_generic_error(self): + for payload_hash in [ + "1234567", + "123456789", + "not-hex!", + "a" * 101, + "1234567\ud800", + # A blank first hash must not be replaced by a later value. + ",payload=00000000", + ]: + header = generate_header( + secret="whsec_other_secret", + debug_metadata={ + "secret": "whsec_*******cret", + "payload": payload_hash, + }, + ) + with pytest.raises(SignatureVerificationError) as error: + WebhookSignature.verify_header( + DUMMY_WEBHOOK_PAYLOAD, header, DUMMY_WEBHOOK_SECRET + ) + assert ( + str(error.value) + == "No signatures found matching the expected signature for payload" + ) + + def test_valid_signature_ignores_conflicting_metadata(self): + header = generate_header( + debug_metadata={ + "secret": "*abcd", + "destination": "clidev_example", + "payload": "00000000", + } + ) + assert WebhookSignature.verify_header( + DUMMY_WEBHOOK_PAYLOAD, header, DUMMY_WEBHOOK_SECRET + ) + def test_raise_on_timestamp_outside_tolerance(self): header = generate_header(timestamp=int(time.time()) - 15) with pytest.raises( From e881f4ad3d63df52c2adb4111fe2ee0a1fe986f4 Mon Sep 17 00:00:00 2001 From: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:53:20 -0800 Subject: [PATCH 4/5] Remove obsolete guidance for updating CA bunle (#1973) * Remove update-certs task from justfile Removed the update-certs task from the justfile. * Remove CA certificates update instructions from README Removed instructions for updating bundled CA certificates. --- README.md | 6 ------ justfile | 3 --- 2 files changed, 9 deletions(-) diff --git a/README.md b/README.md index f851cec19..c40ed3e96 100644 --- a/README.md +++ b/README.md @@ -471,12 +471,6 @@ just format # or: venv/bin/ruff format . --quiet ``` -Update bundled CA certificates from the [Mozilla cURL release][curl]: - -```sh -just update-certs -``` - [api-keys]: https://dashboard.stripe.com/account/apikeys [ruff]: https://github.com/astral-sh/ruff [connect]: https://stripe.com/connect diff --git a/justfile b/justfile index b156e797c..5e38fb99d 100644 --- a/justfile +++ b/justfile @@ -75,9 +75,6 @@ install group: venv # always log deps in CI, but don't do it locally python -I -m pip install -r deps/{{ group }}-requirements.txt --disable-pip-version-check {{ if env("CI", "") == "true" {""} else if is_dependency() == "true" {"--quiet"} else {""} }} -update-certs: - curl -o stripe/data/ca-certificates.crt https://curl.se/ca/cacert.pem - # create a virtualenv if it doesn't exist; always installs the local package [private] venv: From d643367e621ada1f0823ce52da211f21b9ca2c14 Mon Sep 17 00:00:00 2001 From: Zachary Chua Date: Wed, 11 Nov 2026 09:24:07 -0800 Subject: [PATCH 5/5] Restore 2026-11-09 changefile The unified-spec regen diffed against a stale base (stripe/openapi@v2598's unified private preview spec, last refreshed 2026-10-29), so its changefile re-reported entries that already shipped. Generated code is unchanged since the v2599 regen, so the v2599 changefile is the accurate one for this release. --- ...26-11-09_stripe-openapi_67eb12fb.change.md | 29 +++++++ ...26-11-11_stripe-openapi_20cbdbca.change.md | 80 ------------------- 2 files changed, 29 insertions(+), 80 deletions(-) create mode 100644 .hark/changes/2026-11-09_stripe-openapi_67eb12fb.change.md delete mode 100644 .hark/changes/2026-11-11_stripe-openapi_20cbdbca.change.md diff --git a/.hark/changes/2026-11-09_stripe-openapi_67eb12fb.change.md b/.hark/changes/2026-11-09_stripe-openapi_67eb12fb.change.md new file mode 100644 index 000000000..6546d09ab --- /dev/null +++ b/.hark/changes/2026-11-09_stripe-openapi_67eb12fb.change.md @@ -0,0 +1,29 @@ +--- +title: Update generated code +pr_url: https://github.com/stripe/stripe-python/pull/1969 +semver_level: major +is_stripe_api_change: true +--- + +* Add support for new resource `v2.money_management.SpendingMandate` +* Add support for `cancel`, `list`, and `retrieve` methods on resource `v2.money_management.SpendingMandate` +* Add support for `cardholder_message` on `Charge.PaymentMethodDetail.CardPresent.Receipt`, `ConfirmationToken.PaymentMethodPreview.Card.GeneratedFrom.PaymentMethodDetail.CardPresent.Receipt`, `PaymentAttemptRecord.PaymentMethodDetail.CardPresent.Receipt`, `PaymentMethod.Card.GeneratedFrom.PaymentMethodDetail.CardPresent.Receipt`, and `PaymentRecord.PaymentMethodDetail.CardPresent.Receipt` +* Add support for `pricing_token` on `checkout.SessionCreateParams` +* Add support for `marketing_attributions` on `CustomerModifyParams` +* Add support for `fraudulent_selfie` on `Identity.VerificationReport.Signal` +* Add support for `toss_pay` on `Mandate.PaymentMethodDetail`, `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationModifyParams`, `PaymentMethodConfiguration`, and `SetupAttempt.PaymentMethodDetail` +* Add support for `payment_evaluations` on `PaymentAttemptRecordReportAuthenticatedParams` +* Add support for `three_d_secure` on `PaymentAttemptRecordReportAuthorizedParamsPaymentMethodDetailCard`, `PaymentAttemptRecordReportGuaranteedParamsPaymentMethodDetailCard`, `PaymentRecordReportPaymentAttemptGuaranteedParamsPaymentMethodDetailCard`, `PaymentRecordReportPaymentAttemptParamsPaymentMethodDetailCard`, and `PaymentRecordReportPaymentParamsPaymentMethodDetailCard` +* Add support for `wechat_pay_redirect_to_mini_program` on `PaymentIntent.NextAction` +* Add support for `customer_presence` and `payment_type` on `Radar.PaymentEvaluation.PaymentDetail.MoneyMovementDetail.SepaDebit` and `radar.PaymentEvaluationCreateParamsPaymentDetailMoneyMovementDetailSepaDebit` +* Add support for `financial_connections` on `SetupIntent.PaymentMethodOption.BacsDebit`, `SetupIntentConfirmParamsPaymentMethodOptionBacsDebit`, `SetupIntentCreateParamsPaymentMethodOptionBacsDebit`, and `SetupIntentModifyParamsPaymentMethodOptionBacsDebit` +* Add support for `referral_fee_details` on `SharedPayment.GrantedToken`, `SharedPayment.IssuedToken`, and `shared_payment.IssuedTokenCreateParams` +* Add support for new values `stripe_s700_devkit`, `stripe_s710_devkit`, `stripe_t600_devkit`, `verifone_ux700_devkit`, and `verifone_v660p_devkit` on enum `terminal.ReaderListParams.device_type` +* Add support for `device_health_details` and `device_health` on `Terminal.Reader` +* Add support for new values `check_attachment_too_large`, `check_expired`, and `check_undeliverable` on enum `V2.MoneyManagement.OutboundPayment.StatusDetail.Failed.reason` +* Add support for `check_send` on `V2.MoneyManagement.OutboundPayment.To.PayoutMethodOption`, `V2.MoneyManagement.OutboundPayment.TrackingDetail`, `V2.MoneyManagement.PayoutIntent.To.PayoutMethodOption`, `V2.MoneyManagement.PayoutMethod`, `v2.money_management.OutboundPaymentCreateParamsToPayoutMethodOption`, `v2.money_management.OutboundSetupIntentCreateParamsPayoutMethodDatum`, `v2.money_management.PayoutIntentCreateParamsToPayoutMethodOption`, and `v2.money_management.PayoutIntentModifyParamsToPayoutMethodOption` +* Add support for new values `check_attachment_too_large`, `check_expired`, and `check_undeliverable` on enum `V2.MoneyManagement.PayoutIntent.NextAction.HandleFailure.failure_reason` +* Add support for new value `check_send` on enums `V2.MoneyManagement.PayoutMethod.type`, `v2.money_management.OutboundSetupIntentCreateParamsPayoutMethodDatum.type`, and `v2.money_management.OutboundSetupIntentModifyParamsPayoutMethodDatum.type` +* Add support for `spending_mandate` on `V2.MoneyManagement.ReceivedDebit.BankTransfer` and `v2.money_management.ReceivedDebitListParams` +* Add support for event notifications `V2MoneyManagementSpendingMandateCanceledEvent`, `V2MoneyManagementSpendingMandateCreatedEvent`, `V2MoneyManagementSpendingMandateExpiredEvent`, `V2MoneyManagementSpendingMandatePendingCancellationEvent`, and `V2MoneyManagementSpendingMandateUpdatedEvent` with related object `v2.money_management.SpendingMandate` +* ⚠️ Add error type `MerchantNotGatedError` on `v2.core.vault.NetworkToken#create_from_credential` diff --git a/.hark/changes/2026-11-11_stripe-openapi_20cbdbca.change.md b/.hark/changes/2026-11-11_stripe-openapi_20cbdbca.change.md deleted file mode 100644 index eb2eb68bc..000000000 --- a/.hark/changes/2026-11-11_stripe-openapi_20cbdbca.change.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: Update generated code -pr_url: https://github.com/stripe/stripe-python/pull/1969 -semver_level: major -is_stripe_api_change: true ---- - -* Add support for new resources `tax.Certificate`, `tax.FormCorrection`, `v2.core.AccountSession`, `v2.extend.ObjectDefinitionVersion`, `v2.extend.ObjectDefinition`, and `v2.money_management.SpendingMandate` -* ⚠️ Remove support for resource `v2.core.AccountSessionResource` -* Add support for `create`, `delete`, `list`, and `retrieve` methods on resource `tax.Certificate` -* Add support for `create` method on resource `tax.Form` -* Add support for `cancel`, `list`, and `retrieve` methods on resource `v2.money_management.SpendingMandate` -* Add support for `list` and `retrieve` methods on resources `v2.extend.ObjectDefinitionVersion` and `v2.extend.ObjectDefinition` -* Add support for `bills`, `financial_account_rewards`, `financial_accounts_transactions`, `financial_accounts`, `network_cost_passthrough_report`, and `recipients_list` on `AccountSessionCreateParamsComponent` -* Add support for `business_profile_management` on `AccountSessionCreateParamsComponent` and `v2.core.AccountSessionResourceCreateParamsComponent` -* Add support for `export_tax_transactions`, `product_tax_code_selector`, and `tax_threshold_monitoring` on `AccountSession.Component` -* Add support for `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on `Charge.PaymentMethodDetail`, `ConfirmationToken.PaymentMethodPreview`, `ConfirmationTokenCreateParamsPaymentMethodDatum`, `PaymentAttemptRecord.PaymentMethodDetail`, `PaymentIntentConfirmParamsPaymentMethodDatum`, `PaymentIntentCreateParamsPaymentMethodDatum`, `PaymentIntentModifyParamsPaymentMethodDatum`, `PaymentMethodCreateParams`, `PaymentMethod`, `PaymentRecord.PaymentMethodDetail`, `SetupIntentConfirmParamsPaymentMethodDatum`, `SetupIntentCreateParamsPaymentMethodDatum`, and `SetupIntentModifyParamsPaymentMethodDatum` -* Add support for `funding_sources` on `Charge.PaymentMethodDetail.Card.Wallet.Link` and `Charge.PaymentMethodDetail.Link` -* Add support for `fleet` on `Charge.PaymentMethodDetail.CardPresent`, `ConfirmationToken.PaymentMethodPreview.Card.GeneratedFrom.PaymentMethodDetail.CardPresent`, `PaymentAttemptRecord.PaymentMethodDetail.CardPresent`, `PaymentMethod.Card.GeneratedFrom.PaymentMethodDetail.CardPresent`, and `PaymentRecord.PaymentMethodDetail.CardPresent` -* Add support for `cardholder_message` on `Charge.PaymentMethodDetail.CardPresent.Receipt`, `ConfirmationToken.PaymentMethodPreview.Card.GeneratedFrom.PaymentMethodDetail.CardPresent.Receipt`, `PaymentAttemptRecord.PaymentMethodDetail.CardPresent.Receipt`, `PaymentMethod.Card.GeneratedFrom.PaymentMethodDetail.CardPresent.Receipt`, and `PaymentRecord.PaymentMethodDetail.CardPresent.Receipt` -* Add support for `fingerprint` on `Charge.PaymentMethodDetail.Paypay`, `PaymentAttemptRecord.PaymentMethodDetail.Paypay`, `PaymentRecord.PaymentMethodDetail.Paypay`, and `SetupAttempt.PaymentMethodDetail.Paypay` -* Add support for `custom_payment_method_options` and `pricing_token` on `checkout.SessionCreateParams` -* Add support for new value `tamara` on enum `checkout.SessionCreateParams.allowed_payment_method_types` -* Add support for new value `tamara` on enum `checkout.SessionCreateParams.excluded_payment_method_types` -* Add support for `stripe_balance` on `Checkout.Session.PaymentMethodOption` and `checkout.SessionCreateParamsPaymentMethodOption` -* Add support for new value `buyer_choice` on enums `Checkout.Session.PaymentMethodOption.AcssDebit.MandateOption.transaction_type` and `checkout.SessionCreateParamsPaymentMethodOptionAcssDebitMandateOption.transaction_type` -* Add support for new value `instant` on enums `Checkout.Session.PaymentMethodOption.BacsDebit.verification_method`, `Invoice.PaymentSetting.PaymentMethodOption.BacsDebit.verification_method`, `InvoiceCreateParamsPaymentSettingPaymentMethodOptionBacsDebit.verification_method`, `InvoiceModifyParamsPaymentSettingPaymentMethodOptionBacsDebit.verification_method`, `PaymentIntent.PaymentMethodOption.BacsDebit.verification_method`, `PaymentIntentConfirmParamsPaymentMethodOptionBacsDebit.verification_method`, `PaymentIntentCreateParamsPaymentMethodOptionBacsDebit.verification_method`, `PaymentIntentModifyParamsPaymentMethodOptionBacsDebit.verification_method`, `QuotePreviewInvoice.PaymentSetting.PaymentMethodOption.BacsDebit.verification_method`, `SetupIntent.PaymentMethodOption.BacsDebit.verification_method`, `SetupIntentConfirmParamsPaymentMethodOptionBacsDebit.verification_method`, `SetupIntentCreateParamsPaymentMethodOptionBacsDebit.verification_method`, `SetupIntentModifyParamsPaymentMethodOptionBacsDebit.verification_method`, `Subscription.PaymentSetting.PaymentMethodOption.BacsDebit.verification_method`, `SubscriptionCreateParamsPaymentSettingPaymentMethodOptionBacsDebit.verification_method`, `SubscriptionModifyParamsPaymentSettingPaymentMethodOptionBacsDebit.verification_method`, and `checkout.SessionCreateParamsPaymentMethodOptionBacsDebit.verification_method` -* Add support for `setup_future_usage` on `Checkout.Session.PaymentMethodOption.Paypay` and `checkout.SessionCreateParamsPaymentMethodOptionPaypay` -* Add support for new values `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on enums `ConfirmationTokenCreateParamsPaymentMethodDatum.type`, `PaymentIntentConfirmParamsPaymentMethodDatum.type`, `PaymentIntentCreateParamsPaymentMethodDatum.type`, `PaymentIntentModifyParamsPaymentMethodDatum.type`, `SetupIntentConfirmParamsPaymentMethodDatum.type`, `SetupIntentCreateParamsPaymentMethodDatum.type`, and `SetupIntentModifyParamsPaymentMethodDatum.type` -* Add support for new values `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on enums `ConfirmationToken.PaymentMethodPreview.type` and `PaymentMethod.type` -* Add support for `marketing_attributions` on `CustomerModifyParams` -* Add support for new values `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on enums `CustomerListPaymentMethodsParams.type`, `PaymentMethodCreateParams.type`, and `PaymentMethodListParams.type` -* Add support for `reason_details` and `reason` on `CustomerCreateCustomerTaxExemptionParams` and `CustomerTaxExemption` -* Add support for `tax_code_group` on `CustomerCreateCustomerTaxExemptionParamsMe` and `CustomerTaxExemption.Me` -* Change `Dispute.Evidence.appeal` to be required -* Add support for `fraudulent_selfie` on `Identity.VerificationReport.Signal` -* Add support for `target_date` on `Invoice.PaymentSetting.PaymentMethodOption.SepaDebit`, `InvoiceCreateParamsPaymentSettingPaymentMethodOptionSepaDebit`, and `InvoiceModifyParamsPaymentSettingPaymentMethodOptionSepaDebit` -* Change `Issuing.Card.Shipping.delivered_at` to be required -* Change `Issuing.Card.Shipping.shipped_at` to be required -* Add support for `toss_pay` on `Mandate.PaymentMethodDetail`, `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationModifyParams`, `PaymentMethodConfiguration`, and `SetupAttempt.PaymentMethodDetail` -* Add support for `payment_evaluations` and `payment_method_details` on `PaymentAttemptRecordReportAuthenticatedParams` -* Add support for `three_d_secure` on `PaymentAttemptRecordReportAuthorizedParamsPaymentMethodDetailCard`, `PaymentAttemptRecordReportGuaranteedParamsPaymentMethodDetailCard`, `PaymentRecordReportPaymentAttemptGuaranteedParamsPaymentMethodDetailCard`, `PaymentRecordReportPaymentAttemptParamsPaymentMethodDetailCard`, and `PaymentRecordReportPaymentParamsPaymentMethodDetailCard` -* Change type of `PaymentAttemptRecordReportGuaranteedParamsPaymentMethodDetail.type` and `PaymentRecordReportPaymentAttemptGuaranteedParamsPaymentMethodDetail.type` from `literal('card')` to `enum('card'|'us_bank_account')` -* Add support for `dispute_details` on `PaymentAttemptRecord` and `PaymentRecord` -* Add support for new values `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on enums `PaymentIntent.allowed_payment_method_types`, `PaymentIntentConfirmParams.allowed_payment_method_types`, `PaymentIntentCreateParams.allowed_payment_method_types`, `PaymentIntentModifyParams.allowed_payment_method_types`, `SetupIntent.allowed_payment_method_types`, `SetupIntentConfirmParams.allowed_payment_method_types`, `SetupIntentCreateParams.allowed_payment_method_types`, and `SetupIntentModifyParams.allowed_payment_method_types` -* Add support for `ev_charging` and `fleet_data` on `PaymentIntentAmountDetailsLineItem.PaymentMethodOption.CardPresent`, `PaymentIntentCaptureParamsAmountDetailLineItemPaymentMethodOptionCardPresent`, `PaymentIntentConfirmParamsAmountDetailLineItemPaymentMethodOptionCardPresent`, `PaymentIntentCreateParamsAmountDetailLineItemPaymentMethodOptionCardPresent`, `PaymentIntentDecrementAuthorizationParamsAmountDetailLineItemPaymentMethodOptionCardPresent`, `PaymentIntentIncrementAuthorizationParamsAmountDetailLineItemPaymentMethodOptionCardPresent`, and `PaymentIntentModifyParamsAmountDetailLineItemPaymentMethodOptionCardPresent` -* Add support for new values `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on enums `PaymentIntent.excluded_payment_method_types`, `PaymentIntentConfirmParams.excluded_payment_method_types`, `PaymentIntentCreateParams.excluded_payment_method_types`, `PaymentIntentModifyParams.excluded_payment_method_types`, `SetupIntent.excluded_payment_method_types`, `SetupIntentCreateParams.excluded_payment_method_types`, and `SetupIntentModifyParams.excluded_payment_method_types` -* Add support for `financial_connections` on `PaymentIntent.PaymentMethodOption.BacsDebit`, `PaymentIntentConfirmParamsPaymentMethodOptionBacsDebit`, `PaymentIntentCreateParamsPaymentMethodOptionBacsDebit`, `PaymentIntentModifyParamsPaymentMethodOptionBacsDebit`, `SetupIntent.PaymentMethodOption.BacsDebit`, `SetupIntentConfirmParamsPaymentMethodOptionBacsDebit`, `SetupIntentCreateParamsPaymentMethodOptionBacsDebit`, and `SetupIntentModifyParamsPaymentMethodOptionBacsDebit` -* ⚠️ Remove support for value `on_session` from enums `PaymentIntent.PaymentMethodOption.Paypay.setup_future_usage`, `PaymentIntentConfirmParamsPaymentMethodOptionPaypay.setup_future_usage`, `PaymentIntentCreateParamsPaymentMethodOptionPaypay.setup_future_usage`, and `PaymentIntentModifyParamsPaymentMethodOptionPaypay.setup_future_usage` -* Add support for `wechat_pay_redirect_to_mini_program` on `PaymentIntent.NextAction` -* Add support for `payment_details` on `PaymentIntent.PaymentMethodOption.CardPresent` and `PaymentIntent.PaymentMethodOption.Card` -* Add support for new value `tamara` on enums `PaymentLink.payment_method_types`, `PaymentLinkCreateParams.payment_method_types`, and `PaymentLinkModifyParams.payment_method_types` -* Add support for `rakuten_pay` on `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationModifyParams`, and `PaymentMethodConfiguration` -* Add support for `sepa_debit` on `Radar.PaymentEvaluation.PaymentDetail.MoneyMovementDetail` and `radar.PaymentEvaluationCreateParamsPaymentDetailMoneyMovementDetail` -* Add support for new value `sepa_debit` on enums `Radar.PaymentEvaluation.PaymentDetail.MoneyMovementDetail.money_movement_type` and `radar.PaymentEvaluationCreateParamsPaymentDetailMoneyMovementDetail.money_movement_type` -* Add support for new value `continue_with_manual_review` on enum `Radar.PaymentEvaluation.recommended_action` -* Add support for `card_testing` on `Radar.PaymentEvaluation.Signal` -* Add support for `payment_method` on `RefundCreateParams` -* Add support for new values `aeon_pay`, `au_pay`, `dbarai`, and `merpay` on enum `RefundCreateParamsPaymentMethodDatum.type` -* Add support for `payment_record` on `Refund` -* Add support for `bizum` and `upi` on `Refund.DestinationDetail` -* Add support for `tax_invoice_month` on `Reporting.ReportRun.Parameter` -* Add support for `radar_options` on `SetupIntentConfirmParams`, `SetupIntentCreateParams`, and `SetupIntent` -* Add support for `referral_fee_details` on `SharedPayment.GrantedToken`, `SharedPayment.IssuedToken`, and `shared_payment.IssuedTokenCreateParams` -* Add support for `billing_group` on `SubscriptionCreateParams`, `SubscriptionListParams`, `SubscriptionModifyParams`, and `Subscription` -* Add support for new values `stripe_s700_devkit`, `stripe_s710_devkit`, `stripe_t600_devkit`, `verifone_ux700_devkit`, and `verifone_v660p_devkit` on enum `terminal.ReaderListParams.device_type` -* Add support for `device_health_details` and `device_health` on `Terminal.Reader` -* Add support for `network_details` on `Treasury.InboundTransfer.FailureDetail`, `Treasury.OutboundPayment.ReturnedDetail`, and `Treasury.OutboundTransfer.ReturnedDetail` -* Add support for `reference` on `V2.MoneyManagement.FinancialAddress.BankAccount.Iban` -* Add support for new values `check_attachment_too_large`, `check_expired`, and `check_undeliverable` on enum `V2.MoneyManagement.OutboundPayment.StatusDetail.Failed.reason` -* Add support for `check_send` on `V2.MoneyManagement.OutboundPayment.To.PayoutMethodOption`, `V2.MoneyManagement.OutboundPayment.TrackingDetail`, `V2.MoneyManagement.PayoutIntent.To.PayoutMethodOption`, `V2.MoneyManagement.PayoutMethod`, `v2.money_management.OutboundPaymentCreateParamsToPayoutMethodOption`, `v2.money_management.OutboundSetupIntentCreateParamsPayoutMethodDatum`, `v2.money_management.PayoutIntentCreateParamsToPayoutMethodOption`, and `v2.money_management.PayoutIntentModifyParamsToPayoutMethodOption` -* Add support for new values `check_attachment_too_large`, `check_expired`, and `check_undeliverable` on enum `V2.MoneyManagement.PayoutIntent.NextAction.HandleFailure.failure_reason` -* Add support for new value `check_send` on enums `V2.MoneyManagement.PayoutMethod.type`, `v2.money_management.OutboundSetupIntentCreateParamsPayoutMethodDatum.type`, and `v2.money_management.OutboundSetupIntentModifyParamsPayoutMethodDatum.type` -* Add support for `spending_mandate` on `V2.MoneyManagement.ReceivedDebit.BankTransfer` and `v2.money_management.ReceivedDebitListParams` -* Add support for `additional_details` on `V2.Signals.AccountSignal.CustomerRisk` -* Add support for new value `pln` on enum `v2.money_management.FinancialAddressCreateParamsBankAccount.currency` -* Add support for event notification `V2ExtendObjectDefinitionCreatedEvent` with related object `v2.extend.ObjectDefinition` -* Add support for event notification `V2ExtendObjectDefinitionVersionCreatedEvent` with related object `v2.extend.ObjectDefinitionVersion` -* Add support for event notifications `V2MoneyManagementSpendingMandateCanceledEvent`, `V2MoneyManagementSpendingMandateCreatedEvent`, `V2MoneyManagementSpendingMandateExpiredEvent`, `V2MoneyManagementSpendingMandatePendingCancellationEvent`, and `V2MoneyManagementSpendingMandateUpdatedEvent` with related object `v2.money_management.SpendingMandate` -* ⚠️ Add error type `MerchantNotGatedError` on `v2.core.vault.NetworkToken#create_from_credential`