Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ List out the key changes made in this PR, e.g.

### See Also
<!-- Include any links or additional information that help explain this change. -->

## Changelog
<!-- Heads up! This section should include entries for any user-facing changes.
Either fill it out or remove it if there are no entries to report.
List changes that affect end users, e.g.
- Fixes crash when calling `foo.bar()` with null argument
- Adds support for new `baz` parameter on `PaymentIntent` creation
List breaking changes first with a ⚠️ prefix, e.g.
- ⚠️ Removes deprecated `legacy_method` function
-->
16 changes: 7 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: check examples w/ mypy (against python@3.10)
python-version: "3.13"
- name: check examples w/ mypy (against python@3.13)
run: just typecheck-examples
# skip deps on all these since mypy installed everything
- name: check linting
Expand All @@ -42,13 +42,11 @@ jobs:
run: just --no-deps format-check
# pyright depends on node, which it handles and installs for itself as needed
# we _could_ run setup-node to make it available for it if we're having reliability problems
- name: check types (all Python versions)
run: |
set -eox

for minor in {6..12}; do
just --no-deps typecheck $minor
done
- name: check types
# only check against a modern version- unit tests will catch syntax errors on older versions
# this isn't user facing, this is just checking that our code is internally consistent
# e.g. a bug here wouldn't cause user CI to fail since the issue is internal to our codebase
run: just --no-deps typecheck

build:
name: Build
Expand Down
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,61 @@ This release changes the pinned API version to 2026-05-27.private.
* Add support for new value `chaps` on enum `v2.FinancialAddressCreditSimulationCreditParams.network`
* Add support for error codes `payment_method_microdeposit_processing_error` and `siret_invalid` on `QuotePreviewInvoice.LastFinalizationError`

## 15.2.0 - 2026-05-27
This release changes the pinned API version to 2026-05-27.dahlia.

* [#1816](https://github.com/stripe/stripe-python/pull/1816) Update generated code
* Add support for new resource `v2.commerce.ProductCatalogImport`
* Add support for `create` and `retrieve` methods on resource `v2.commerce.ProductCatalogImport`
* Add support for `bizum_payments` and `scalapay_payments` on `Account.Capability`, `AccountCreateParamsCapability`, and `AccountModifyParamsCapability`
* Add support for `automatic_transfer_rules_by_currency` on `BalanceSettings.Payment.Payout` and `BalanceSettingsModifyParamsPaymentPayout`
* Add support for `start_of_day` on `BalanceSettings.Payment.SettlementTiming` and `BalanceSettingsModifyParamsPaymentSettlementTiming`
* Add support for `description` on `ChargeCreateParamsTransferDatum`, `PaymentIntent.TransferDatum`, `PaymentIntentCreateParamsTransferDatum`, and `PaymentIntentModifyParamsTransferDatum`
* Add support for `bizum` on `Charge.PaymentMethodDetail`, `ConfirmationToken.PaymentMethodPreview`, `ConfirmationTokenCreateParamsPaymentMethodDatum`, `PaymentAttemptRecord.PaymentMethodDetail`, `PaymentIntent.PaymentMethodOption`, `PaymentIntentConfirmParamsPaymentMethodDatum`, `PaymentIntentConfirmParamsPaymentMethodOption`, `PaymentIntentCreateParamsPaymentMethodDatum`, `PaymentIntentCreateParamsPaymentMethodOption`, `PaymentIntentModifyParamsPaymentMethodDatum`, `PaymentIntentModifyParamsPaymentMethodOption`, `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationModifyParams`, `PaymentMethodConfiguration`, `PaymentMethodCreateParams`, `PaymentMethod`, `PaymentRecord.PaymentMethodDetail`, `SetupIntent.PaymentMethodOption`, `SetupIntentConfirmParamsPaymentMethodDatum`, `SetupIntentConfirmParamsPaymentMethodOption`, `SetupIntentCreateParamsPaymentMethodDatum`, `SetupIntentCreateParamsPaymentMethodOption`, `SetupIntentModifyParamsPaymentMethodDatum`, and `SetupIntentModifyParamsPaymentMethodOption`
* Add support for `scalapay` on `Charge.PaymentMethodDetail`, `Checkout.Session.PaymentMethodOption`, `ConfirmationToken.PaymentMethodPreview`, `ConfirmationTokenCreateParamsPaymentMethodDatum`, `PaymentAttemptRecord.PaymentMethodDetail`, `PaymentIntent.PaymentMethodOption`, `PaymentIntentConfirmParamsPaymentMethodDatum`, `PaymentIntentConfirmParamsPaymentMethodOption`, `PaymentIntentCreateParamsPaymentMethodDatum`, `PaymentIntentCreateParamsPaymentMethodOption`, `PaymentIntentModifyParamsPaymentMethodDatum`, `PaymentIntentModifyParamsPaymentMethodOption`, `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationModifyParams`, `PaymentMethodConfiguration`, `PaymentMethodCreateParams`, `PaymentMethod`, `PaymentRecord.PaymentMethodDetail`, `Refund.DestinationDetail`, `SetupIntentConfirmParamsPaymentMethodDatum`, `SetupIntentCreateParamsPaymentMethodDatum`, `SetupIntentModifyParamsPaymentMethodDatum`, and `checkout.SessionCreateParamsPaymentMethodOption`
* Add support for `mandate` on `Charge.PaymentMethodDetail.Twint`, `PaymentAttemptRecord.PaymentMethodDetail.Twint`, and `PaymentRecord.PaymentMethodDetail.Twint`
* Add support for new values `bizum` and `scalapay` on enums `PaymentIntentConfirmParams.excluded_payment_method_types`, `PaymentIntentCreateParams.excluded_payment_method_types`, `PaymentIntentModifyParams.excluded_payment_method_types`, `SetupIntentCreateParams.excluded_payment_method_types`, `SetupIntentModifyParams.excluded_payment_method_types`, and `checkout.SessionCreateParams.excluded_payment_method_types`
* Change type of `PaymentIntentConfirmParamsPaymentMethodOptionTwint.setup_future_usage`, `PaymentIntentCreateParamsPaymentMethodOptionTwint.setup_future_usage`, `PaymentIntentModifyParamsPaymentMethodOptionTwint.setup_future_usage`, and `checkout.SessionCreateParamsPaymentMethodOptionTwint.setup_future_usage` from `literal('none')` to `enum('none'|'off_session')`
* Add support for new values `bizum` and `scalapay` on enum `checkout.SessionCreateParams.payment_method_types`
* ⚠️ Change type of `Checkout.Session.PaymentMethodOption.Twint.setup_future_usage` and `PaymentIntent.PaymentMethodOption.Twint.setup_future_usage` from `literal('none')` to `enum('none'|'off_session')`
* Add support for new values `bizum` and `scalapay` on enums `ConfirmationTokenCreateParamsPaymentMethodDatum.type`, `PaymentIntentConfirmParamsPaymentMethodDatum.type`, `PaymentIntentCreateParamsPaymentMethodDatum.type`, `PaymentIntentModifyParamsPaymentMethodDatum.type`, `SetupIntentConfirmParamsPaymentMethodDatum.type`, `SetupIntentCreateParamsPaymentMethodDatum.type`, and `SetupIntentModifyParamsPaymentMethodDatum.type`
* ⚠️ Add support for new values `bizum` and `scalapay` on enums `ConfirmationToken.PaymentMethodPreview.type` and `PaymentMethod.type`
* Add support for new values `bizum` and `scalapay` on enums `CustomerListPaymentMethodsParams.type`, `PaymentMethodCreateParams.type`, and `PaymentMethodListParams.type`
* Add support for `credited_items` on `InvoiceItem.ProrationDetail`
* Add support for new value `twint` on enums `InvoiceCreateParamsPaymentSetting.payment_method_types`, `InvoiceModifyParamsPaymentSetting.payment_method_types`, `SubscriptionCreateParamsPaymentSetting.payment_method_types`, and `SubscriptionModifyParamsPaymentSetting.payment_method_types`
* Add support for `discountable` on `InvoiceCreatePreviewParamsScheduleDetailPhaseAddInvoiceItem`, `SubscriptionCreateParamsAddInvoiceItem`, `SubscriptionModifyParamsAddInvoiceItem`, `SubscriptionSchedule.Phase.AddInvoiceItem`, `SubscriptionScheduleCreateParamsPhaseAddInvoiceItem`, and `SubscriptionScheduleModifyParamsPhaseAddInvoiceItem`
* Add support for `billing_schedules` on `InvoiceCreatePreviewParamsSubscriptionDetail`, `SubscriptionCreateParams`, `SubscriptionModifyParams`, and `Subscription`
* Add support for new value `max_billed_until` on enums `InvoiceCreatePreviewParamsSubscriptionDetail.cancel_at`, `SubscriptionCreateParams.cancel_at`, and `SubscriptionModifyParams.cancel_at`
* Add support for `amount_paid_off_stripe` on `Invoice`
* ⚠️ Add support for new value `twint` on enums `Invoice.PaymentSetting.payment_method_types` and `Subscription.PaymentSetting.payment_method_types`
* Add support for `twint` on `Mandate.PaymentMethodDetail` and `SetupAttempt.PaymentMethodDetail`
* Add support for `metadata` on `PaymentIntent.TransferDatum`, `PaymentIntentCreateParamsTransferDatum`, `PaymentIntentModifyParamsTransferDatum`, and `Subscription.PendingUpdate`
* Add support for `payment_data` on `PaymentIntent.TransferDatum`, `PaymentIntentCreateParamsTransferDatum`, and `PaymentIntentModifyParamsTransferDatum`
* ⚠️ Add support for new values `bizum` and `scalapay` on enums `PaymentIntent.excluded_payment_method_types` and `SetupIntent.excluded_payment_method_types`
* Add support for `blik_authorize` on `PaymentIntent.NextAction` and `SetupIntent.NextAction`
* Add support for `payment_method_options` on `PaymentLinkCreateParams`, `PaymentLinkModifyParams`, and `PaymentLink`
* Add support for new value `bizum` on enums `PaymentLinkCreateParams.payment_method_types` and `PaymentLinkModifyParams.payment_method_types`
* ⚠️ Add support for new value `bizum` on enum `PaymentLink.payment_method_types`
* Add support for `active` on `PaymentMethodConfigurationListParams`
* Add support for `billed_until` on `SubscriptionItem`
* Add support for `discount` and `discounts` on `Subscription.PendingUpdate`
* Add support for `verifone_m425`, `verifone_p630`, `verifone_ux700`, and `verifone_v660p` on `Terminal.Configuration`, `terminal.ConfigurationCreateParams`, and `terminal.ConfigurationModifyParams`
* Add support for new values `simulated_verifone_m425`, `simulated_verifone_p630`, `simulated_verifone_ux700`, `simulated_verifone_v660p`, `verifone_m425`, `verifone_p630`, `verifone_ux700`, and `verifone_v660p` on enum `terminal.ReaderListParams.device_type`
* Add support for `api_error` and `print_content` on `Terminal.Reader.Action`
* ⚠️ Add support for new value `print_content` on enum `Terminal.Reader.Action.type`
* ⚠️ Add support for new values `simulated_verifone_m425`, `simulated_verifone_p630`, `simulated_verifone_ux700`, `simulated_verifone_v660p`, `verifone_m425`, `verifone_p630`, `verifone_ux700`, and `verifone_v660p` on enum `Terminal.Reader.device_type`
* Add support for `customer` on `test_helpers.TestClockCreateParams`
* Add support for new value `2026-05-27.dahlia` on enum `WebhookEndpointCreateParams.api_version`
* Add support for `signer` on `V2.Core.Account.Identity.BusinessDetail.Document.ProofOfRegistration`, `V2.Core.Account.Identity.BusinessDetail.Document.ProofOfUltimateBeneficialOwnership`, `v2.core.AccountCreateParamsIdentityBusinessDetailDocumentProofOfRegistration`, `v2.core.AccountCreateParamsIdentityBusinessDetailDocumentProofOfUltimateBeneficialOwnership`, `v2.core.AccountModifyParamsIdentityBusinessDetailDocumentProofOfRegistration`, `v2.core.AccountModifyParamsIdentityBusinessDetailDocumentProofOfUltimateBeneficialOwnership`, `v2.core.AccountTokenCreateParamsIdentityBusinessDetailDocumentProofOfRegistration`, and `v2.core.AccountTokenCreateParamsIdentityBusinessDetailDocumentProofOfUltimateBeneficialOwnership`
* Add support for `azure_event_grid` on `V2.Core.EventDestination` and `v2.core.EventDestinationCreateParams`
* ⚠️ Add support for new value `no_azure_partner_topic_exists` on enum `V2.Core.EventDestination.StatusDetail.Disabled.reason`
* ⚠️ Add support for new value `azure_event_grid` on enum `V2.Core.EventDestination.type`
* Add support for new value `azure_event_grid` on enum `v2.core.EventDestinationCreateParams.type`
* ⚠️ Add support for new value `meter_event_value_too_many_digits` on enums `EventsV1BillingMeterErrorReportTriggeredEvent.Reason.ErrorType.code` and `EventsV1BillingMeterNoMeterFoundEvent.Reason.ErrorType.code`
* Add support for event notifications `V2CommerceProductCatalogImportsFailedEvent`, `V2CommerceProductCatalogImportsProcessingEvent`, `V2CommerceProductCatalogImportsSucceededEvent`, and `V2CommerceProductCatalogImportsSucceededWithErrorsEvent` with related object `v2.commerce.ProductCatalogImport`
* Add support for error codes `payment_method_microdeposit_processing_error` and `siret_invalid` on `Invoice.LastFinalizationError`, `PaymentIntent.LastPaymentError`, `SetupAttempt.SetupError`, `SetupIntent.LastSetupError`, and `StripeError`
* [#1813](https://github.com/stripe/stripe-python/pull/1813) Emit warning when `stripe-notify` header is present in response

## 15.2.0b2 - 2026-04-24
* [#1797](https://github.com/stripe/stripe-python/pull/1797) Update generated code for beta
* Add support for new resources `v2.commerce.ProductCatalogImport`, `v2.data.reporting.QueryRun`, `v2.extend.WorkflowRun`, `v2.extend.Workflow`, `v2.iam.ActivityLog`, `v2.network.BusinessProfile`, and `v2.orchestrated_commerce.Agreement`
Expand Down
2 changes: 1 addition & 1 deletion CODEGEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d59a1f4bdea3032b8e282d40badc032cb021fc60
64505e82d8e31da4bf9d8fe129ff75c1a94e359b
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2277
v2290
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ stripe.add_beta_version("feature_beta", "v3")

### Private Preview SDKs

Stripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `aX` suffix like `12.2.0a2`. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-python?tab=readme-ov-file#public-preview-sdks) above and replacing the suffix `b` with `a` in package versions.
Stripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `aX` suffix like `12.2.0a2`. You can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-python?tab=readme-ov-file#public-preview-sdks) above and replacing the suffix `b` with `a` in package versions. Note that access to specific private preview API features may require separate approval.

### Custom requests

Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ test-one test_name: install-test-deps
lint: install-dev-deps
python -m flake8 --show-source stripe tests

# verify types. optional argument to test as of a specific minor python version (e.g. `8` to test `python 3.8`); otherwise uses current version
typecheck minor_py_version="": install-test-deps install-dev-deps
# verify types using current python version
typecheck: install-test-deps install-dev-deps
# suppress version update warnings
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 pyright {{ if minor_py_version == "" { "" } else { "--pythonversion 3." + minor_py_version } }}
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 pyright

# ⭐ format all code
format: install-dev-deps
Expand Down
19 changes: 19 additions & 0 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from io import BytesIO, IOBase
import functools
import hashlib
import json
import os
import platform
import socket
from typing import (
Any,
AsyncIterable,
Expand Down Expand Up @@ -72,6 +75,19 @@
_default_proxy: Optional[str] = None


@functools.lru_cache(maxsize=None)
def _get_uname_hash() -> Optional[str]:
try:
parts: List[str] = list(platform.uname())
try:
parts.append(socket.gethostname())
except Exception:
pass
return hashlib.md5(" ".join(parts).encode()).hexdigest()
except Exception:
return None


def _maybe_emit_stripe_notice(rheaders: Mapping[str, str]) -> None:
notice = rheaders.get("Stripe-Notice")
if notice:
Expand Down Expand Up @@ -561,6 +577,9 @@ def request_headers(
"lang": "python",
"httplib": self._get_http_client().name,
}
uname_hash = _get_uname_hash()
if uname_hash is not None:
ua["source"] = uname_hash
attr_funcs: List[Tuple[str, Callable[[], str]]] = [
("lang_version", platform.python_version),
]
Expand Down
7 changes: 1 addition & 6 deletions stripe/_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(
self._verify_ssl_certs = verify_ssl_certs
if proxy:
if isinstance(proxy, str):
proxy = {"http": proxy, "https": proxy}
proxy = HTTPClient._Proxy(http=proxy, https=proxy)
if not isinstance(proxy, dict): # pyright: ignore[reportUnnecessaryIsInstance]
raise ValueError(
"Proxy(ies) must be specified as either a string "
Expand Down Expand Up @@ -899,11 +899,6 @@ def close(self):
pass


class _Proxy(TypedDict):
http: Optional["ParseResult"]
https: Optional["ParseResult"]


class PycurlClient(HTTPClient):
class _ParsedProxy(TypedDict, total=False):
http: Optional["ParseResult"]
Expand Down
31 changes: 31 additions & 0 deletions tests/test_api_requestor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import json
import re
import tempfile
import uuid
from collections import OrderedDict
Expand Down Expand Up @@ -812,6 +813,36 @@ def fail():
last_call.get_raw_header("X-Stripe-Client-User-Agent")
)

def test_source_field_is_md5_hex(self, requestor, http_client_mock):
http_client_mock.stub_request(
"get", path=self.v1_path, rbody="{}", rcode=200
)
requestor.request("get", self.v1_path, {}, base_address="api")

last_call = http_client_mock.get_last_call()
client_ua = json.loads(
last_call.get_raw_header("X-Stripe-Client-User-Agent")
)
assert "source" in client_ua
assert re.fullmatch(r"[0-9a-f]{32}", client_ua["source"])

def test_source_field_absent_when_uname_fails(
self, requestor, mocker, http_client_mock
):
http_client_mock.stub_request(
"get", path=self.v1_path, rbody="{}", rcode=200
)
mocker.patch(
"stripe._api_requestor._get_uname_hash", return_value=None
)
requestor.request("get", self.v1_path, {}, base_address="api")

last_call = http_client_mock.get_last_call()
client_ua = json.loads(
last_call.get_raw_header("X-Stripe-Client-User-Agent")
)
assert "source" not in client_ua

def test_uses_given_idempotency_key(self, requestor, http_client_mock):
method = "post"
http_client_mock.stub_request(
Expand Down
Loading