diff --git a/src/main/java/com/stripe/model/v2/core/Account.java b/src/main/java/com/stripe/model/v2/core/Account.java index 269497a1f2d..4af8544f7f8 100644 --- a/src/main/java/com/stripe/model/v2/core/Account.java +++ b/src/main/java/com/stripe/model/v2/core/Account.java @@ -5,6 +5,7 @@ import com.stripe.model.HasId; import com.stripe.model.StripeObject; import com.stripe.v2.Amount; +import java.math.BigDecimal; import java.time.Instant; import java.util.List; import java.util.Map; @@ -5345,7 +5346,7 @@ public static class Relationship extends StripeObject { /** The percentage of the Account's identity that the individual owns. */ @SerializedName("percent_ownership") - String percentOwnership; + BigDecimal percentOwnership; /** * Whether the individual is authorized as the primary representative of the Account. This diff --git a/src/main/java/com/stripe/model/v2/core/AccountPerson.java b/src/main/java/com/stripe/model/v2/core/AccountPerson.java index f3ce221205d..25eed6ceaab 100644 --- a/src/main/java/com/stripe/model/v2/core/AccountPerson.java +++ b/src/main/java/com/stripe/model/v2/core/AccountPerson.java @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName; import com.stripe.model.HasId; import com.stripe.model.StripeObject; +import java.math.BigDecimal; import java.time.Instant; import java.util.List; import java.util.Map; @@ -584,7 +585,7 @@ public static class Relationship extends StripeObject { /** The percentage of the Account's identity that the individual owns. */ @SerializedName("percent_ownership") - String percentOwnership; + BigDecimal percentOwnership; /** * Whether the individual is authorized as the primary representative of the Account. This is diff --git a/src/main/java/com/stripe/net/JsonEncoder.java b/src/main/java/com/stripe/net/JsonEncoder.java index 35de33bc6a2..898a7d6f5e3 100644 --- a/src/main/java/com/stripe/net/JsonEncoder.java +++ b/src/main/java/com/stripe/net/JsonEncoder.java @@ -3,15 +3,42 @@ import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; import java.io.IOException; +import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; final class JsonEncoder { + /** + * Serializes BigDecimal as a JSON string (e.g., "25.5") rather than a JSON number (25.5). All + * BigDecimal fields in the Stripe API use format: decimal, and the V2 API expects them as strings + * on the wire. + */ + private static final TypeAdapter BIG_DECIMAL_STRING_ADAPTER = + new TypeAdapter() { + @Override + public void write(JsonWriter out, BigDecimal value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(value.toPlainString()); + } + } + + @Override + public BigDecimal read(JsonReader in) throws IOException { + return new BigDecimal(in.nextString()); + } + }; + private static final Gson BODY_GSON = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .serializeNulls() + .registerTypeAdapter(BigDecimal.class, BIG_DECIMAL_STRING_ADAPTER) .create(); public static HttpContent createHttpContent(Map params) throws IOException { diff --git a/src/main/java/com/stripe/param/v2/core/AccountCreateParams.java b/src/main/java/com/stripe/param/v2/core/AccountCreateParams.java index 48026ef7d63..f804f21010d 100644 --- a/src/main/java/com/stripe/param/v2/core/AccountCreateParams.java +++ b/src/main/java/com/stripe/param/v2/core/AccountCreateParams.java @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName; import com.stripe.net.ApiRequestParams; import com.stripe.v2.Amount; +import java.math.BigDecimal; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; @@ -15655,7 +15656,7 @@ public static class Relationship { /** The percent owned by the person of the account's legal entity. */ @SerializedName("percent_ownership") - String percentOwnership; + BigDecimal percentOwnership; /** The person's title (e.g., CEO, Support Engineer). */ @SerializedName("title") @@ -15666,7 +15667,7 @@ private Relationship( Boolean executive, Map extraParams, Boolean owner, - String percentOwnership, + BigDecimal percentOwnership, String title) { this.director = director; this.executive = executive; @@ -15689,7 +15690,7 @@ public static class Builder { private Boolean owner; - private String percentOwnership; + private BigDecimal percentOwnership; private String title; @@ -15758,7 +15759,7 @@ public Builder setOwner(Boolean owner) { } /** The percent owned by the person of the account's legal entity. */ - public Builder setPercentOwnership(String percentOwnership) { + public Builder setPercentOwnership(BigDecimal percentOwnership) { this.percentOwnership = percentOwnership; return this; } diff --git a/src/main/java/com/stripe/param/v2/core/AccountTokenCreateParams.java b/src/main/java/com/stripe/param/v2/core/AccountTokenCreateParams.java index f2dec5cc6e3..4057ecb4dd6 100644 --- a/src/main/java/com/stripe/param/v2/core/AccountTokenCreateParams.java +++ b/src/main/java/com/stripe/param/v2/core/AccountTokenCreateParams.java @@ -5,6 +5,7 @@ import com.stripe.net.ApiRequestParams; import com.stripe.param.common.EmptyParam; import com.stripe.v2.Amount; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -7123,7 +7124,7 @@ public static class Relationship { /** The percent owned by the person of the account's legal entity. */ @SerializedName("percent_ownership") - String percentOwnership; + BigDecimal percentOwnership; /** The person's title (e.g., CEO, Support Engineer). */ @SerializedName("title") @@ -7134,7 +7135,7 @@ private Relationship( Boolean executive, Map extraParams, Boolean owner, - String percentOwnership, + BigDecimal percentOwnership, String title) { this.director = director; this.executive = executive; @@ -7157,7 +7158,7 @@ public static class Builder { private Boolean owner; - private String percentOwnership; + private BigDecimal percentOwnership; private String title; @@ -7226,7 +7227,7 @@ public Builder setOwner(Boolean owner) { } /** The percent owned by the person of the account's legal entity. */ - public Builder setPercentOwnership(String percentOwnership) { + public Builder setPercentOwnership(BigDecimal percentOwnership) { this.percentOwnership = percentOwnership; return this; } diff --git a/src/main/java/com/stripe/param/v2/core/AccountUpdateParams.java b/src/main/java/com/stripe/param/v2/core/AccountUpdateParams.java index 7bbc94507b1..63db37871ad 100644 --- a/src/main/java/com/stripe/param/v2/core/AccountUpdateParams.java +++ b/src/main/java/com/stripe/param/v2/core/AccountUpdateParams.java @@ -5,6 +5,7 @@ import com.stripe.net.ApiRequestParams; import com.stripe.param.common.EmptyParam; import com.stripe.v2.Amount; +import java.math.BigDecimal; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; @@ -17078,7 +17079,7 @@ public Builder setOwner(Boolean owner) { } /** The percent owned by the person of the account's legal entity. */ - public Builder setPercentOwnership(String percentOwnership) { + public Builder setPercentOwnership(BigDecimal percentOwnership) { this.percentOwnership = percentOwnership; return this; } diff --git a/src/main/java/com/stripe/param/v2/core/accounts/PersonCreateParams.java b/src/main/java/com/stripe/param/v2/core/accounts/PersonCreateParams.java index cb190454762..23964e137e1 100644 --- a/src/main/java/com/stripe/param/v2/core/accounts/PersonCreateParams.java +++ b/src/main/java/com/stripe/param/v2/core/accounts/PersonCreateParams.java @@ -3,6 +3,7 @@ import com.google.gson.annotations.SerializedName; import com.stripe.net.ApiRequestParams; +import java.math.BigDecimal; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; @@ -2575,7 +2576,7 @@ public static class Relationship { /** The percentage of ownership the person has in the associated legal entity. */ @SerializedName("percent_ownership") - String percentOwnership; + BigDecimal percentOwnership; /** Indicates whether the person is a representative of the associated legal entity. */ @SerializedName("representative") @@ -2592,7 +2593,7 @@ private Relationship( Map extraParams, Boolean legalGuardian, Boolean owner, - String percentOwnership, + BigDecimal percentOwnership, Boolean representative, String title) { this.authorizer = authorizer; @@ -2623,7 +2624,7 @@ public static class Builder { private Boolean owner; - private String percentOwnership; + private BigDecimal percentOwnership; private Boolean representative; @@ -2700,7 +2701,7 @@ public Builder setOwner(Boolean owner) { } /** The percentage of ownership the person has in the associated legal entity. */ - public Builder setPercentOwnership(String percentOwnership) { + public Builder setPercentOwnership(BigDecimal percentOwnership) { this.percentOwnership = percentOwnership; return this; } diff --git a/src/main/java/com/stripe/param/v2/core/accounts/PersonTokenCreateParams.java b/src/main/java/com/stripe/param/v2/core/accounts/PersonTokenCreateParams.java index 5d4fae4ceb8..47d2c7f0f15 100644 --- a/src/main/java/com/stripe/param/v2/core/accounts/PersonTokenCreateParams.java +++ b/src/main/java/com/stripe/param/v2/core/accounts/PersonTokenCreateParams.java @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName; import com.stripe.net.ApiRequestParams; import com.stripe.param.common.EmptyParam; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -2545,7 +2546,7 @@ public static class Relationship { /** The percentage of ownership the person has in the associated legal entity. */ @SerializedName("percent_ownership") - String percentOwnership; + BigDecimal percentOwnership; /** Indicates whether the person is a representative of the associated legal entity. */ @SerializedName("representative") @@ -2562,7 +2563,7 @@ private Relationship( Map extraParams, Boolean legalGuardian, Boolean owner, - String percentOwnership, + BigDecimal percentOwnership, Boolean representative, String title) { this.authorizer = authorizer; @@ -2593,7 +2594,7 @@ public static class Builder { private Boolean owner; - private String percentOwnership; + private BigDecimal percentOwnership; private Boolean representative; @@ -2670,7 +2671,7 @@ public Builder setOwner(Boolean owner) { } /** The percentage of ownership the person has in the associated legal entity. */ - public Builder setPercentOwnership(String percentOwnership) { + public Builder setPercentOwnership(BigDecimal percentOwnership) { this.percentOwnership = percentOwnership; return this; } diff --git a/src/main/java/com/stripe/param/v2/core/accounts/PersonUpdateParams.java b/src/main/java/com/stripe/param/v2/core/accounts/PersonUpdateParams.java index c886d483511..001c826555a 100644 --- a/src/main/java/com/stripe/param/v2/core/accounts/PersonUpdateParams.java +++ b/src/main/java/com/stripe/param/v2/core/accounts/PersonUpdateParams.java @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName; import com.stripe.net.ApiRequestParams; import com.stripe.param.common.EmptyParam; +import java.math.BigDecimal; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; @@ -2918,7 +2919,7 @@ public Builder setOwner(Boolean owner) { } /** The percentage of ownership the person has in the associated legal entity. */ - public Builder setPercentOwnership(String percentOwnership) { + public Builder setPercentOwnership(BigDecimal percentOwnership) { this.percentOwnership = percentOwnership; return this; }