Stripe · sdk · fg-0147

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

If you see TypeError: Object of type Decimal is not JSON serializable, the cause and the fix for Stripe are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
TypeError: Object of type Decimal is not JSON serializableprice.unit_amount_decimal == '9.99' is now FalseType checker rejects a str passed as unit_amount_decimal
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"): ...
Affected
stripe-python 15.0.0 and later
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun