Skip to content

Add runtime support for V2 int64 string-encoded fields#1756

Open
mbroshi-stripe wants to merge 3 commits intomasterfrom
mbroshi/v2-int64-as-string
Open

Add runtime support for V2 int64 string-encoded fields#1756
mbroshi-stripe wants to merge 3 commits intomasterfrom
mbroshi/v2-int64-as-string

Conversation

@mbroshi-stripe
Copy link
Contributor

@mbroshi-stripe mbroshi-stripe commented Mar 12, 2026

Why?

V2 APIs represent int64 fields as JSON strings on the wire (e.g. "12345" instead of 12345) to avoid precision loss. The SDK should transparently convert between native Python int and this wire format so users don't need to handle string encoding themselves.

What?

  • Added _coerce_v2_params() and _coerce_value() to stripe/_encode.py for request-side coercion (int → str), handling scalars, nested objects, and arrays
  • Added _field_encodings class variable and _coerce_field_value() method to StripeObject for response-side coercion (str → int) during _refresh_from
  • Added tests covering top-level, nested, array, nullable, and mixed-field scenarios for both request and response paths

@mbroshi-stripe mbroshi-stripe force-pushed the mbroshi/v2-int64-as-string branch from d8449b2 to 054338e Compare March 15, 2026 18:45
@mbroshi-stripe mbroshi-stripe changed the base branch from master to private-preview March 15, 2026 19:44
@mbroshi-stripe mbroshi-stripe changed the title WIP Mbroshi/v2 int64 as string Mar 15, 2026
@mbroshi-stripe mbroshi-stripe force-pushed the mbroshi/v2-int64-as-string branch from 3176f76 to cb5ea24 Compare March 15, 2026 22:03
@mbroshi-stripe mbroshi-stripe changed the title Mbroshi/v2 int64 as string Add runtime support for V2 int64 string-encoded fields Mar 15, 2026
@mbroshi-stripe mbroshi-stripe changed the base branch from private-preview to master March 15, 2026 22:32
@mbroshi-stripe mbroshi-stripe marked this pull request as ready for review March 16, 2026 00:47
@mbroshi-stripe mbroshi-stripe requested a review from a team as a code owner March 16, 2026 00:47
@mbroshi-stripe mbroshi-stripe requested review from prathmesh-stripe and removed request for a team March 16, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant