Stripe · sdk · fg-0147

json.dumps fails and price comparisons stop matching after stripe-python v15 returns Decimal

TypeError: Object of type Decimal is not JSON serializable

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

Cause

v15 maps every decimal formatted field, in responses and in request params, to Python Decimal instead of str.

Fix

Serialize with to_dict(for_json=True), compare against Decimal values, and pass Decimal when setting these fields.

Apply

from decimal import Decimal
payload = json.dumps(price.to_dict(for_json=True))
if price.unit_amount_decimal == Decimal("9.99"):
    ...

Affects: stripe-python 15.0.0 and later

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp