• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-java / #16517

08 Oct 2024 06:27PM UTC coverage: 12.74% (-0.2%) from 12.899%
#16517

push

github

web-flow
Merge pull request #1872 from stripe/latest-codegen-beta

Update generated code for beta

53 of 2404 new or added lines in 50 files covered. (2.2%)

91 existing lines in 27 files now uncovered.

18753 of 147196 relevant lines covered (12.74%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.78
/src/main/java/com/stripe/model/TaxRate.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.net.ApiRequest;
7
import com.stripe.net.ApiRequestParams;
8
import com.stripe.net.ApiResource;
9
import com.stripe.net.BaseAddress;
10
import com.stripe.net.RequestOptions;
11
import com.stripe.net.StripeResponseGetter;
12
import com.stripe.param.TaxRateCreateParams;
13
import com.stripe.param.TaxRateListParams;
14
import com.stripe.param.TaxRateRetrieveParams;
15
import com.stripe.param.TaxRateUpdateParams;
16
import java.math.BigDecimal;
17
import java.util.Map;
18
import lombok.EqualsAndHashCode;
19
import lombok.Getter;
20
import lombok.Setter;
21

22
/**
23
 * Tax rates can be applied to <a
24
 * href="https://stripe.com/docs/billing/invoices/tax-rates">invoices</a>, <a
25
 * href="https://stripe.com/docs/billing/subscriptions/taxes">subscriptions</a> and <a
26
 * href="https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates">Checkout
27
 * Sessions</a> to collect tax.
28
 *
29
 * <p>Related guide: <a href="https://stripe.com/docs/billing/taxes/tax-rates">Tax rates</a>
30
 */
31
@Getter
32
@Setter
33
@EqualsAndHashCode(callSuper = false)
34
public class TaxRate extends ApiResource implements HasId, MetadataStore<TaxRate> {
1✔
35
  /**
36
   * Defaults to {@code true}. When set to {@code false}, this tax rate cannot be used with new
37
   * applications or Checkout Sessions, but will still work for subscriptions and invoices that
38
   * already have it set.
39
   */
40
  @SerializedName("active")
41
  Boolean active;
42

43
  /**
44
   * Two-letter country code (<a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1
45
   * alpha-2</a>).
46
   */
47
  @SerializedName("country")
48
  String country;
49

50
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
51
  @SerializedName("created")
52
  Long created;
53

54
  /**
55
   * An arbitrary string attached to the tax rate for your internal use only. It will not be visible
56
   * to your customers.
57
   */
58
  @SerializedName("description")
59
  String description;
60

61
  /**
62
   * The display name of the tax rates as it will appear to your customer on their receipt email,
63
   * PDF, and the hosted invoice page.
64
   */
65
  @SerializedName("display_name")
66
  String displayName;
67

68
  /**
69
   * Actual/effective tax rate percentage out of 100. For tax calculations with
70
   * automatic_tax[enabled]=true, this percentage reflects the rate actually used to calculate tax
71
   * based on the product's taxability and whether the user is registered to collect taxes in the
72
   * corresponding jurisdiction.
73
   */
74
  @SerializedName("effective_percentage")
75
  BigDecimal effectivePercentage;
76

77
  /**
78
   * The amount of the tax rate when the {@code rate_type} is {@code flat_amount}. Tax rates with
79
   * {@code rate_type} {@code percentage} can vary based on the transaction, resulting in this field
80
   * being {@code null}. This field exposes the amount and currency of the flat tax rate.
81
   */
82
  @SerializedName("flat_amount")
83
  FlatAmount flatAmount;
84

85
  /** Unique identifier for the object. */
86
  @Getter(onMethod_ = {@Override})
87
  @SerializedName("id")
88
  String id;
89

90
  /** This specifies if the tax rate is inclusive or exclusive. */
91
  @SerializedName("inclusive")
92
  Boolean inclusive;
93

94
  /**
95
   * The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It
96
   * also appears on your customer’s invoice.
97
   */
98
  @SerializedName("jurisdiction")
99
  String jurisdiction;
100

101
  /**
102
   * The level of the jurisdiction that imposes this tax rate. Will be {@code null} for manually
103
   * defined tax rates.
104
   *
105
   * <p>One of {@code city}, {@code country}, {@code county}, {@code district}, {@code multiple}, or
106
   * {@code state}.
107
   */
108
  @SerializedName("jurisdiction_level")
109
  String jurisdictionLevel;
110

111
  /**
112
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
113
   * object exists in test mode.
114
   */
115
  @SerializedName("livemode")
116
  Boolean livemode;
117

118
  /**
119
   * Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
120
   * to an object. This can be useful for storing additional information about the object in a
121
   * structured format.
122
   */
123
  @Getter(onMethod_ = {@Override})
124
  @SerializedName("metadata")
125
  Map<String, String> metadata;
126

127
  /**
128
   * String representing the object's type. Objects of the same type share the same value.
129
   *
130
   * <p>Equal to {@code tax_rate}.
131
   */
132
  @SerializedName("object")
133
  String object;
134

135
  /**
136
   * Tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this
137
   * percentage includes the statutory tax rate of non-taxable jurisdictions.
138
   */
139
  @SerializedName("percentage")
140
  BigDecimal percentage;
141

142
  /**
143
   * Indicates the type of tax rate applied to the taxable amount. This value can be {@code null}
144
   * when no tax applies to the location.
145
   *
146
   * <p>One of {@code flat_amount}, or {@code percentage}.
147
   */
148
  @SerializedName("rate_type")
149
  String rateType;
150

151
  /**
152
   * <a href="https://en.wikipedia.org/wiki/ISO_3166-2:US">ISO 3166-2 subdivision code</a>, without
153
   * country prefix. For example, &quot;NY&quot; for New York, United States.
154
   */
155
  @SerializedName("state")
156
  String state;
157

158
  /**
159
   * The high-level tax type, such as {@code vat} or {@code sales_tax}.
160
   *
161
   * <p>One of {@code amusement_tax}, {@code communications_tax}, {@code gst}, {@code hst}, {@code
162
   * igst}, {@code jct}, {@code lease_tax}, {@code pst}, {@code qst}, {@code retail_delivery_fee},
163
   * {@code rst}, {@code sales_tax}, or {@code vat}.
164
   */
165
  @SerializedName("tax_type")
166
  String taxType;
167

168
  /** Creates a new tax rate. */
169
  public static TaxRate create(Map<String, Object> params) throws StripeException {
170
    return create(params, (RequestOptions) null);
×
171
  }
172

173
  /** Creates a new tax rate. */
174
  public static TaxRate create(Map<String, Object> params, RequestOptions options)
175
      throws StripeException {
176
    String path = "/v1/tax_rates";
×
177
    ApiRequest request =
×
178
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
179
    return getGlobalResponseGetter().request(request, TaxRate.class);
×
180
  }
181

182
  /** Creates a new tax rate. */
183
  public static TaxRate create(TaxRateCreateParams params) throws StripeException {
184
    return create(params, (RequestOptions) null);
1✔
185
  }
186

187
  /** Creates a new tax rate. */
188
  public static TaxRate create(TaxRateCreateParams params, RequestOptions options)
189
      throws StripeException {
190
    String path = "/v1/tax_rates";
1✔
191
    ApiResource.checkNullTypedParams(path, params);
1✔
192
    ApiRequest request =
1✔
193
        new ApiRequest(
194
            BaseAddress.API,
195
            ApiResource.RequestMethod.POST,
196
            path,
197
            ApiRequestParams.paramsToMap(params),
1✔
198
            options);
199
    return getGlobalResponseGetter().request(request, TaxRate.class);
1✔
200
  }
201

202
  /**
203
   * Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most
204
   * recently created tax rates appearing first.
205
   */
206
  public static TaxRateCollection list(Map<String, Object> params) throws StripeException {
207
    return list(params, (RequestOptions) null);
×
208
  }
209

210
  /**
211
   * Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most
212
   * recently created tax rates appearing first.
213
   */
214
  public static TaxRateCollection list(Map<String, Object> params, RequestOptions options)
215
      throws StripeException {
216
    String path = "/v1/tax_rates";
×
217
    ApiRequest request =
×
218
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
219
    return getGlobalResponseGetter().request(request, TaxRateCollection.class);
×
220
  }
221

222
  /**
223
   * Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most
224
   * recently created tax rates appearing first.
225
   */
226
  public static TaxRateCollection list(TaxRateListParams params) throws StripeException {
227
    return list(params, (RequestOptions) null);
1✔
228
  }
229

230
  /**
231
   * Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most
232
   * recently created tax rates appearing first.
233
   */
234
  public static TaxRateCollection list(TaxRateListParams params, RequestOptions options)
235
      throws StripeException {
236
    String path = "/v1/tax_rates";
1✔
237
    ApiResource.checkNullTypedParams(path, params);
1✔
238
    ApiRequest request =
1✔
239
        new ApiRequest(
240
            BaseAddress.API,
241
            ApiResource.RequestMethod.GET,
242
            path,
243
            ApiRequestParams.paramsToMap(params),
1✔
244
            options);
245
    return getGlobalResponseGetter().request(request, TaxRateCollection.class);
1✔
246
  }
247

248
  /** Retrieves a tax rate with the given ID. */
249
  public static TaxRate retrieve(String taxRate) throws StripeException {
250
    return retrieve(taxRate, (Map<String, Object>) null, (RequestOptions) null);
1✔
251
  }
252

253
  /** Retrieves a tax rate with the given ID. */
254
  public static TaxRate retrieve(String taxRate, RequestOptions options) throws StripeException {
255
    return retrieve(taxRate, (Map<String, Object>) null, options);
×
256
  }
257

258
  /** Retrieves a tax rate with the given ID. */
259
  public static TaxRate retrieve(String taxRate, Map<String, Object> params, RequestOptions options)
260
      throws StripeException {
261
    String path = String.format("/v1/tax_rates/%s", ApiResource.urlEncodeId(taxRate));
1✔
262
    ApiRequest request =
1✔
263
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
264
    return getGlobalResponseGetter().request(request, TaxRate.class);
1✔
265
  }
266

267
  /** Retrieves a tax rate with the given ID. */
268
  public static TaxRate retrieve(
269
      String taxRate, TaxRateRetrieveParams params, RequestOptions options) throws StripeException {
270
    String path = String.format("/v1/tax_rates/%s", ApiResource.urlEncodeId(taxRate));
×
271
    ApiResource.checkNullTypedParams(path, params);
×
272
    ApiRequest request =
×
273
        new ApiRequest(
274
            BaseAddress.API,
275
            ApiResource.RequestMethod.GET,
276
            path,
277
            ApiRequestParams.paramsToMap(params),
×
278
            options);
279
    return getGlobalResponseGetter().request(request, TaxRate.class);
×
280
  }
281

282
  /** Updates an existing tax rate. */
283
  @Override
284
  public TaxRate update(Map<String, Object> params) throws StripeException {
285
    return update(params, (RequestOptions) null);
×
286
  }
287

288
  /** Updates an existing tax rate. */
289
  @Override
290
  public TaxRate update(Map<String, Object> params, RequestOptions options) throws StripeException {
291
    String path = String.format("/v1/tax_rates/%s", ApiResource.urlEncodeId(this.getId()));
×
292
    ApiRequest request =
×
293
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
294
    return getResponseGetter().request(request, TaxRate.class);
×
295
  }
296

297
  /** Updates an existing tax rate. */
298
  public TaxRate update(TaxRateUpdateParams params) throws StripeException {
299
    return update(params, (RequestOptions) null);
1✔
300
  }
301

302
  /** Updates an existing tax rate. */
303
  public TaxRate update(TaxRateUpdateParams params, RequestOptions options) throws StripeException {
304
    String path = String.format("/v1/tax_rates/%s", ApiResource.urlEncodeId(this.getId()));
1✔
305
    ApiResource.checkNullTypedParams(path, params);
1✔
306
    ApiRequest request =
1✔
307
        new ApiRequest(
308
            BaseAddress.API,
309
            ApiResource.RequestMethod.POST,
310
            path,
311
            ApiRequestParams.paramsToMap(params),
1✔
312
            options);
313
    return getResponseGetter().request(request, TaxRate.class);
1✔
314
  }
315

316
  /**
317
   * The amount of the tax rate when the {@code rate_type`` is }flat_amount{@code . Tax rates with
318
   * }rate_type{@code }percentage{@code can vary based on the transaction, resulting in this field
319
   * being}null`. This field exposes the amount and currency of the flat tax rate.
320
   */
321
  @Getter
322
  @Setter
323
  @EqualsAndHashCode(callSuper = false)
NEW
324
  public static class FlatAmount extends StripeObject {
×
325
    /**
326
     * Amount of the tax when the {@code rate_type} is {@code flat_amount}. This positive integer
327
     * represents how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00
328
     * or 100 to charge ¥100, a zero-decimal currency). The amount value supports up to eight digits
329
     * (e.g., a value of 99999999 for a USD charge of $999,999.99).
330
     */
331
    @SerializedName("amount")
332
    Long amount;
333

334
    /** Three-letter ISO currency code, in lowercase. */
335
    @SerializedName("currency")
336
    String currency;
337
  }
338

339
  @Override
340
  public void setResponseGetter(StripeResponseGetter responseGetter) {
341
    super.setResponseGetter(responseGetter);
1✔
342
    trySetResponseGetter(flatAmount, responseGetter);
1✔
343
  }
1✔
344
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc