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

stripe / stripe-java / #16493

03 Oct 2024 07:15PM UTC coverage: 12.942% (+0.08%) from 12.864%
#16493

push

github

web-flow
Merge Stripe-java v27.0.0 to beta branch (#1888)

409 of 1651 new or added lines in 88 files covered. (24.77%)

31 existing lines in 7 files now uncovered.

18773 of 145050 relevant lines covered (12.94%)

0.13 hits per line

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

25.33
/src/main/java/com/stripe/model/CreditNote.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.model.billing.CreditBalanceTransaction;
7
import com.stripe.net.ApiRequest;
8
import com.stripe.net.ApiRequestParams;
9
import com.stripe.net.ApiResource;
10
import com.stripe.net.BaseAddress;
11
import com.stripe.net.RequestOptions;
12
import com.stripe.net.StripeResponseGetter;
13
import com.stripe.param.CreditNoteCreateParams;
14
import com.stripe.param.CreditNoteListParams;
15
import com.stripe.param.CreditNotePreviewParams;
16
import com.stripe.param.CreditNoteRetrieveParams;
17
import com.stripe.param.CreditNoteUpdateParams;
18
import com.stripe.param.CreditNoteVoidCreditNoteParams;
19
import java.util.List;
20
import java.util.Map;
21
import lombok.EqualsAndHashCode;
22
import lombok.Getter;
23
import lombok.Setter;
24

25
/**
26
 * Issue a credit note to adjust an invoice's amount after the invoice is finalized.
27
 *
28
 * <p>Related guide: <a href="https://stripe.com/docs/billing/invoices/credit-notes">Credit
29
 * notes</a>
30
 */
31
@Getter
32
@Setter
33
@EqualsAndHashCode(callSuper = false)
34
public class CreditNote extends ApiResource implements HasId, MetadataStore<CreditNote> {
1✔
35
  /**
36
   * The integer amount in cents (or local equivalent) representing the total amount of the credit
37
   * note, including tax.
38
   */
39
  @SerializedName("amount")
40
  Long amount;
41

42
  /** This is the sum of all the shipping amounts. */
43
  @SerializedName("amount_shipping")
44
  Long amountShipping;
45

46
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
47
  @SerializedName("created")
48
  Long created;
49

50
  /**
51
   * Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
52
   * in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
53
   */
54
  @SerializedName("currency")
55
  String currency;
56

57
  /** ID of the customer. */
58
  @SerializedName("customer")
59
  @Getter(lombok.AccessLevel.NONE)
60
  @Setter(lombok.AccessLevel.NONE)
61
  ExpandableField<Customer> customer;
62

63
  /** Customer balance transaction related to this credit note. */
64
  @SerializedName("customer_balance_transaction")
65
  @Getter(lombok.AccessLevel.NONE)
66
  @Setter(lombok.AccessLevel.NONE)
67
  ExpandableField<CustomerBalanceTransaction> customerBalanceTransaction;
68

69
  /**
70
   * The integer amount in cents (or local equivalent) representing the total amount of discount
71
   * that was credited.
72
   */
73
  @SerializedName("discount_amount")
74
  Long discountAmount;
75

76
  /** The aggregate amounts calculated per discount for all line items. */
77
  @SerializedName("discount_amounts")
78
  List<CreditNote.DiscountAmount> discountAmounts;
79

80
  /**
81
   * The date when this credit note is in effect. Same as {@code created} unless overwritten. When
82
   * defined, this value replaces the system-generated 'Date of issue' printed on the credit note
83
   * PDF.
84
   */
85
  @SerializedName("effective_at")
86
  Long effectiveAt;
87

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

93
  /** ID of the invoice. */
94
  @SerializedName("invoice")
95
  @Getter(lombok.AccessLevel.NONE)
96
  @Setter(lombok.AccessLevel.NONE)
97
  ExpandableField<Invoice> invoice;
98

99
  /** Line items that make up the credit note. */
100
  @SerializedName("lines")
101
  CreditNoteLineItemCollection lines;
102

103
  /**
104
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
105
   * object exists in test mode.
106
   */
107
  @SerializedName("livemode")
108
  Boolean livemode;
109

110
  /** Customer-facing text that appears on the credit note PDF. */
111
  @SerializedName("memo")
112
  String memo;
113

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

123
  /**
124
   * A unique number that identifies this particular credit note and appears on the PDF of the
125
   * credit note and its associated invoice.
126
   */
127
  @SerializedName("number")
128
  String number;
129

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

138
  /** Amount that was credited outside of Stripe. */
139
  @SerializedName("out_of_band_amount")
140
  Long outOfBandAmount;
141

142
  /** The link to download the PDF of the credit note. */
143
  @SerializedName("pdf")
144
  String pdf;
145

146
  @SerializedName("post_payment_amount")
147
  Long postPaymentAmount;
148

149
  @SerializedName("pre_payment_amount")
150
  Long prePaymentAmount;
151

152
  @SerializedName("pretax_credit_amounts")
153
  List<CreditNote.PretaxCreditAmount> pretaxCreditAmounts;
154

155
  /**
156
   * Reason for issuing this credit note, one of {@code duplicate}, {@code fraudulent}, {@code
157
   * order_change}, or {@code product_unsatisfactory}.
158
   */
159
  @SerializedName("reason")
160
  String reason;
161

162
  /** Refund related to this credit note. */
163
  @SerializedName("refund")
164
  @Getter(lombok.AccessLevel.NONE)
165
  @Setter(lombok.AccessLevel.NONE)
166
  ExpandableField<com.stripe.model.Refund> refund;
167

168
  /** Refunds related to this credit note. */
169
  @SerializedName("refunds")
170
  List<CreditNote.Refund> refunds;
171

172
  /** The details of the cost of shipping, including the ShippingRate applied to the invoice. */
173
  @SerializedName("shipping_cost")
174
  ShippingCost shippingCost;
175

176
  /**
177
   * Status of this credit note, one of {@code issued} or {@code void}. Learn more about <a
178
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
179
   */
180
  @SerializedName("status")
181
  String status;
182

183
  /**
184
   * The integer amount in cents (or local equivalent) representing the amount of the credit note,
185
   * excluding exclusive tax and invoice level discounts.
186
   */
187
  @SerializedName("subtotal")
188
  Long subtotal;
189

190
  /**
191
   * The integer amount in cents (or local equivalent) representing the amount of the credit note,
192
   * excluding all tax and invoice level discounts.
193
   */
194
  @SerializedName("subtotal_excluding_tax")
195
  Long subtotalExcludingTax;
196

197
  /** The aggregate amounts calculated per tax rate for all line items. */
198
  @SerializedName("tax_amounts")
199
  List<CreditNote.TaxAmount> taxAmounts;
200

201
  /**
202
   * The integer amount in cents (or local equivalent) representing the total amount of the credit
203
   * note, including tax and all discount.
204
   */
205
  @SerializedName("total")
206
  Long total;
207

208
  /**
209
   * The integer amount in cents (or local equivalent) representing the total amount of the credit
210
   * note, excluding tax, but including discounts.
211
   */
212
  @SerializedName("total_excluding_tax")
213
  Long totalExcludingTax;
214

215
  /**
216
   * Type of this credit note, one of {@code pre_payment} or {@code post_payment}. A {@code
217
   * pre_payment} credit note means it was issued when the invoice was open. A {@code post_payment}
218
   * credit note means it was issued when the invoice was paid.
219
   */
220
  @SerializedName("type")
221
  String type;
222

223
  /** The time that the credit note was voided. */
224
  @SerializedName("voided_at")
225
  Long voidedAt;
226

227
  /** Get ID of expandable {@code customer} object. */
228
  public String getCustomer() {
229
    return (this.customer != null) ? this.customer.getId() : null;
×
230
  }
231

232
  public void setCustomer(String id) {
233
    this.customer = ApiResource.setExpandableFieldId(id, this.customer);
×
234
  }
×
235

236
  /** Get expanded {@code customer}. */
237
  public Customer getCustomerObject() {
238
    return (this.customer != null) ? this.customer.getExpanded() : null;
×
239
  }
240

241
  public void setCustomerObject(Customer expandableObject) {
242
    this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
×
243
  }
×
244

245
  /** Get ID of expandable {@code customerBalanceTransaction} object. */
246
  public String getCustomerBalanceTransaction() {
247
    return (this.customerBalanceTransaction != null)
×
248
        ? this.customerBalanceTransaction.getId()
×
249
        : null;
×
250
  }
251

252
  public void setCustomerBalanceTransaction(String id) {
253
    this.customerBalanceTransaction =
×
254
        ApiResource.setExpandableFieldId(id, this.customerBalanceTransaction);
×
255
  }
×
256

257
  /** Get expanded {@code customerBalanceTransaction}. */
258
  public CustomerBalanceTransaction getCustomerBalanceTransactionObject() {
259
    return (this.customerBalanceTransaction != null)
×
260
        ? this.customerBalanceTransaction.getExpanded()
×
261
        : null;
×
262
  }
263

264
  public void setCustomerBalanceTransactionObject(CustomerBalanceTransaction expandableObject) {
265
    this.customerBalanceTransaction =
×
266
        new ExpandableField<CustomerBalanceTransaction>(expandableObject.getId(), expandableObject);
×
267
  }
×
268

269
  /** Get ID of expandable {@code invoice} object. */
270
  public String getInvoice() {
271
    return (this.invoice != null) ? this.invoice.getId() : null;
×
272
  }
273

274
  public void setInvoice(String id) {
275
    this.invoice = ApiResource.setExpandableFieldId(id, this.invoice);
×
276
  }
×
277

278
  /** Get expanded {@code invoice}. */
279
  public Invoice getInvoiceObject() {
280
    return (this.invoice != null) ? this.invoice.getExpanded() : null;
×
281
  }
282

283
  public void setInvoiceObject(Invoice expandableObject) {
284
    this.invoice = new ExpandableField<Invoice>(expandableObject.getId(), expandableObject);
×
285
  }
×
286

287
  /** Get ID of expandable {@code refund} object. */
288
  public String getRefund() {
289
    return (this.refund != null) ? this.refund.getId() : null;
×
290
  }
291

292
  public void setRefund(String id) {
293
    this.refund = ApiResource.setExpandableFieldId(id, this.refund);
×
294
  }
×
295

296
  /** Get expanded {@code refund}. */
297
  public com.stripe.model.Refund getRefundObject() {
298
    return (this.refund != null) ? this.refund.getExpanded() : null;
×
299
  }
300

301
  public void setRefundObject(com.stripe.model.Refund expandableObject) {
302
    this.refund =
×
303
        new ExpandableField<com.stripe.model.Refund>(expandableObject.getId(), expandableObject);
×
304
  }
×
305

306
  /**
307
   * Issue a credit note to adjust the amount of a finalized invoice. For a {@code status=open}
308
   * invoice, a credit note reduces its {@code amount_due}. For a {@code status=paid} invoice, a
309
   * credit note does not affect its {@code amount_due}. Instead, it can result in any combination
310
   * of the following:
311
   *
312
   * <p>
313
   *
314
   * <ul>
315
   *   <li>Refund: create a new refund (using {@code refund_amount}) or link an existing refund
316
   *       (using {@code refund}).
317
   *   <li>Customer balance credit: credit the customer’s balance (using {@code credit_amount})
318
   *       which will be automatically applied to their next invoice when it’s finalized.
319
   *   <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe
320
   *       (using {@code out_of_band_amount}).
321
   * </ul>
322
   *
323
   * <p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts
324
   * must equal the credit note total.
325
   *
326
   * <p>You may issue multiple credit notes for an invoice. Each credit note will increment the
327
   * invoice’s {@code pre_payment_credit_notes_amount} or {@code post_payment_credit_notes_amount}
328
   * depending on its {@code status} at the time of credit note creation.
329
   */
330
  public static CreditNote create(Map<String, Object> params) throws StripeException {
331
    return create(params, (RequestOptions) null);
×
332
  }
333

334
  /**
335
   * Issue a credit note to adjust the amount of a finalized invoice. For a {@code status=open}
336
   * invoice, a credit note reduces its {@code amount_due}. For a {@code status=paid} invoice, a
337
   * credit note does not affect its {@code amount_due}. Instead, it can result in any combination
338
   * of the following:
339
   *
340
   * <p>
341
   *
342
   * <ul>
343
   *   <li>Refund: create a new refund (using {@code refund_amount}) or link an existing refund
344
   *       (using {@code refund}).
345
   *   <li>Customer balance credit: credit the customer’s balance (using {@code credit_amount})
346
   *       which will be automatically applied to their next invoice when it’s finalized.
347
   *   <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe
348
   *       (using {@code out_of_band_amount}).
349
   * </ul>
350
   *
351
   * <p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts
352
   * must equal the credit note total.
353
   *
354
   * <p>You may issue multiple credit notes for an invoice. Each credit note will increment the
355
   * invoice’s {@code pre_payment_credit_notes_amount} or {@code post_payment_credit_notes_amount}
356
   * depending on its {@code status} at the time of credit note creation.
357
   */
358
  public static CreditNote create(Map<String, Object> params, RequestOptions options)
359
      throws StripeException {
360
    String path = "/v1/credit_notes";
×
361
    ApiRequest request =
×
362
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
363
    return getGlobalResponseGetter().request(request, CreditNote.class);
×
364
  }
365

366
  /**
367
   * Issue a credit note to adjust the amount of a finalized invoice. For a {@code status=open}
368
   * invoice, a credit note reduces its {@code amount_due}. For a {@code status=paid} invoice, a
369
   * credit note does not affect its {@code amount_due}. Instead, it can result in any combination
370
   * of the following:
371
   *
372
   * <p>
373
   *
374
   * <ul>
375
   *   <li>Refund: create a new refund (using {@code refund_amount}) or link an existing refund
376
   *       (using {@code refund}).
377
   *   <li>Customer balance credit: credit the customer’s balance (using {@code credit_amount})
378
   *       which will be automatically applied to their next invoice when it’s finalized.
379
   *   <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe
380
   *       (using {@code out_of_band_amount}).
381
   * </ul>
382
   *
383
   * <p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts
384
   * must equal the credit note total.
385
   *
386
   * <p>You may issue multiple credit notes for an invoice. Each credit note will increment the
387
   * invoice’s {@code pre_payment_credit_notes_amount} or {@code post_payment_credit_notes_amount}
388
   * depending on its {@code status} at the time of credit note creation.
389
   */
390
  public static CreditNote create(CreditNoteCreateParams params) throws StripeException {
391
    return create(params, (RequestOptions) null);
1✔
392
  }
393

394
  /**
395
   * Issue a credit note to adjust the amount of a finalized invoice. For a {@code status=open}
396
   * invoice, a credit note reduces its {@code amount_due}. For a {@code status=paid} invoice, a
397
   * credit note does not affect its {@code amount_due}. Instead, it can result in any combination
398
   * of the following:
399
   *
400
   * <p>
401
   *
402
   * <ul>
403
   *   <li>Refund: create a new refund (using {@code refund_amount}) or link an existing refund
404
   *       (using {@code refund}).
405
   *   <li>Customer balance credit: credit the customer’s balance (using {@code credit_amount})
406
   *       which will be automatically applied to their next invoice when it’s finalized.
407
   *   <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe
408
   *       (using {@code out_of_band_amount}).
409
   * </ul>
410
   *
411
   * <p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts
412
   * must equal the credit note total.
413
   *
414
   * <p>You may issue multiple credit notes for an invoice. Each credit note will increment the
415
   * invoice’s {@code pre_payment_credit_notes_amount} or {@code post_payment_credit_notes_amount}
416
   * depending on its {@code status} at the time of credit note creation.
417
   */
418
  public static CreditNote create(CreditNoteCreateParams params, RequestOptions options)
419
      throws StripeException {
420
    String path = "/v1/credit_notes";
1✔
421
    ApiResource.checkNullTypedParams(path, params);
1✔
422
    ApiRequest request =
1✔
423
        new ApiRequest(
424
            BaseAddress.API,
425
            ApiResource.RequestMethod.POST,
426
            path,
427
            ApiRequestParams.paramsToMap(params),
1✔
428
            options);
429
    return getGlobalResponseGetter().request(request, CreditNote.class);
1✔
430
  }
431

432
  /** Returns a list of credit notes. */
433
  public static CreditNoteCollection list(Map<String, Object> params) throws StripeException {
434
    return list(params, (RequestOptions) null);
×
435
  }
436

437
  /** Returns a list of credit notes. */
438
  public static CreditNoteCollection list(Map<String, Object> params, RequestOptions options)
439
      throws StripeException {
440
    String path = "/v1/credit_notes";
×
441
    ApiRequest request =
×
442
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
443
    return getGlobalResponseGetter().request(request, CreditNoteCollection.class);
×
444
  }
445

446
  /** Returns a list of credit notes. */
447
  public static CreditNoteCollection list(CreditNoteListParams params) throws StripeException {
448
    return list(params, (RequestOptions) null);
1✔
449
  }
450

451
  /** Returns a list of credit notes. */
452
  public static CreditNoteCollection list(CreditNoteListParams params, RequestOptions options)
453
      throws StripeException {
454
    String path = "/v1/credit_notes";
1✔
455
    ApiResource.checkNullTypedParams(path, params);
1✔
456
    ApiRequest request =
1✔
457
        new ApiRequest(
458
            BaseAddress.API,
459
            ApiResource.RequestMethod.GET,
460
            path,
461
            ApiRequestParams.paramsToMap(params),
1✔
462
            options);
463
    return getGlobalResponseGetter().request(request, CreditNoteCollection.class);
1✔
464
  }
465

466
  /** Get a preview of a credit note without creating it. */
467
  public static CreditNote preview(Map<String, Object> params) throws StripeException {
468
    return preview(params, (RequestOptions) null);
×
469
  }
470

471
  /** Get a preview of a credit note without creating it. */
472
  public static CreditNote preview(Map<String, Object> params, RequestOptions options)
473
      throws StripeException {
474
    String path = "/v1/credit_notes/preview";
×
475
    ApiRequest request =
×
476
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
477
    return getGlobalResponseGetter().request(request, CreditNote.class);
×
478
  }
479

480
  /** Get a preview of a credit note without creating it. */
481
  public static CreditNote preview(CreditNotePreviewParams params) throws StripeException {
482
    return preview(params, (RequestOptions) null);
1✔
483
  }
484

485
  /** Get a preview of a credit note without creating it. */
486
  public static CreditNote preview(CreditNotePreviewParams params, RequestOptions options)
487
      throws StripeException {
488
    String path = "/v1/credit_notes/preview";
1✔
489
    ApiResource.checkNullTypedParams(path, params);
1✔
490
    ApiRequest request =
1✔
491
        new ApiRequest(
492
            BaseAddress.API,
493
            ApiResource.RequestMethod.GET,
494
            path,
495
            ApiRequestParams.paramsToMap(params),
1✔
496
            options);
497
    return getGlobalResponseGetter().request(request, CreditNote.class);
1✔
498
  }
499

500
  /** Retrieves the credit note object with the given identifier. */
501
  public static CreditNote retrieve(String id) throws StripeException {
502
    return retrieve(id, (Map<String, Object>) null, (RequestOptions) null);
1✔
503
  }
504

505
  /** Retrieves the credit note object with the given identifier. */
506
  public static CreditNote retrieve(String id, RequestOptions options) throws StripeException {
507
    return retrieve(id, (Map<String, Object>) null, options);
×
508
  }
509

510
  /** Retrieves the credit note object with the given identifier. */
511
  public static CreditNote retrieve(String id, Map<String, Object> params, RequestOptions options)
512
      throws StripeException {
513
    String path = String.format("/v1/credit_notes/%s", ApiResource.urlEncodeId(id));
1✔
514
    ApiRequest request =
1✔
515
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
516
    return getGlobalResponseGetter().request(request, CreditNote.class);
1✔
517
  }
518

519
  /** Retrieves the credit note object with the given identifier. */
520
  public static CreditNote retrieve(
521
      String id, CreditNoteRetrieveParams params, RequestOptions options) throws StripeException {
522
    String path = String.format("/v1/credit_notes/%s", ApiResource.urlEncodeId(id));
×
523
    ApiResource.checkNullTypedParams(path, params);
×
524
    ApiRequest request =
×
525
        new ApiRequest(
526
            BaseAddress.API,
527
            ApiResource.RequestMethod.GET,
528
            path,
529
            ApiRequestParams.paramsToMap(params),
×
530
            options);
531
    return getGlobalResponseGetter().request(request, CreditNote.class);
×
532
  }
533

534
  /** Updates an existing credit note. */
535
  @Override
536
  public CreditNote update(Map<String, Object> params) throws StripeException {
537
    return update(params, (RequestOptions) null);
×
538
  }
539

540
  /** Updates an existing credit note. */
541
  @Override
542
  public CreditNote update(Map<String, Object> params, RequestOptions options)
543
      throws StripeException {
544
    String path = String.format("/v1/credit_notes/%s", ApiResource.urlEncodeId(this.getId()));
×
545
    ApiRequest request =
×
546
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
547
    return getResponseGetter().request(request, CreditNote.class);
×
548
  }
549

550
  /** Updates an existing credit note. */
551
  public CreditNote update(CreditNoteUpdateParams params) throws StripeException {
552
    return update(params, (RequestOptions) null);
×
553
  }
554

555
  /** Updates an existing credit note. */
556
  public CreditNote update(CreditNoteUpdateParams params, RequestOptions options)
557
      throws StripeException {
558
    String path = String.format("/v1/credit_notes/%s", ApiResource.urlEncodeId(this.getId()));
×
559
    ApiResource.checkNullTypedParams(path, params);
×
560
    ApiRequest request =
×
561
        new ApiRequest(
562
            BaseAddress.API,
563
            ApiResource.RequestMethod.POST,
564
            path,
565
            ApiRequestParams.paramsToMap(params),
×
566
            options);
567
    return getResponseGetter().request(request, CreditNote.class);
×
568
  }
569

570
  /**
571
   * Marks a credit note as void. Learn more about <a
572
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
573
   */
574
  public CreditNote voidCreditNote() throws StripeException {
575
    return voidCreditNote((Map<String, Object>) null, (RequestOptions) null);
×
576
  }
577

578
  /**
579
   * Marks a credit note as void. Learn more about <a
580
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
581
   */
582
  public CreditNote voidCreditNote(RequestOptions options) throws StripeException {
583
    return voidCreditNote((Map<String, Object>) null, options);
×
584
  }
585

586
  /**
587
   * Marks a credit note as void. Learn more about <a
588
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
589
   */
590
  public CreditNote voidCreditNote(Map<String, Object> params) throws StripeException {
591
    return voidCreditNote(params, (RequestOptions) null);
×
592
  }
593

594
  /**
595
   * Marks a credit note as void. Learn more about <a
596
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
597
   */
598
  public CreditNote voidCreditNote(Map<String, Object> params, RequestOptions options)
599
      throws StripeException {
600
    String path = String.format("/v1/credit_notes/%s/void", ApiResource.urlEncodeId(this.getId()));
×
601
    ApiRequest request =
×
602
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
603
    return getResponseGetter().request(request, CreditNote.class);
×
604
  }
605

606
  /**
607
   * Marks a credit note as void. Learn more about <a
608
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
609
   */
610
  public CreditNote voidCreditNote(CreditNoteVoidCreditNoteParams params) throws StripeException {
611
    return voidCreditNote(params, (RequestOptions) null);
1✔
612
  }
613

614
  /**
615
   * Marks a credit note as void. Learn more about <a
616
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
617
   */
618
  public CreditNote voidCreditNote(CreditNoteVoidCreditNoteParams params, RequestOptions options)
619
      throws StripeException {
620
    String path = String.format("/v1/credit_notes/%s/void", ApiResource.urlEncodeId(this.getId()));
1✔
621
    ApiResource.checkNullTypedParams(path, params);
1✔
622
    ApiRequest request =
1✔
623
        new ApiRequest(
624
            BaseAddress.API,
625
            ApiResource.RequestMethod.POST,
626
            path,
627
            ApiRequestParams.paramsToMap(params),
1✔
628
            options);
629
    return getResponseGetter().request(request, CreditNote.class);
1✔
630
  }
631

632
  @Getter
633
  @Setter
634
  @EqualsAndHashCode(callSuper = false)
635
  public static class DiscountAmount extends StripeObject {
×
636
    /** The amount, in cents (or local equivalent), of the discount. */
637
    @SerializedName("amount")
638
    Long amount;
639

640
    /** The discount that was applied to get this discount amount. */
641
    @SerializedName("discount")
642
    @Getter(lombok.AccessLevel.NONE)
643
    @Setter(lombok.AccessLevel.NONE)
644
    ExpandableField<Discount> discount;
645

646
    /** Get ID of expandable {@code discount} object. */
647
    public String getDiscount() {
648
      return (this.discount != null) ? this.discount.getId() : null;
×
649
    }
650

651
    public void setDiscount(String id) {
652
      this.discount = ApiResource.setExpandableFieldId(id, this.discount);
×
653
    }
×
654

655
    /** Get expanded {@code discount}. */
656
    public Discount getDiscountObject() {
657
      return (this.discount != null) ? this.discount.getExpanded() : null;
×
658
    }
659

660
    public void setDiscountObject(Discount expandableObject) {
661
      this.discount = new ExpandableField<Discount>(expandableObject.getId(), expandableObject);
×
662
    }
×
663
  }
664

665
  @Getter
666
  @Setter
667
  @EqualsAndHashCode(callSuper = false)
NEW
668
  public static class PretaxCreditAmount extends StripeObject {
×
669
    /** The amount, in cents (or local equivalent), of the pretax credit amount. */
670
    @SerializedName("amount")
671
    Long amount;
672

673
    /** The credit balance transaction that was applied to get this pretax credit amount. */
674
    @SerializedName("credit_balance_transaction")
675
    @Getter(lombok.AccessLevel.NONE)
676
    @Setter(lombok.AccessLevel.NONE)
677
    ExpandableField<CreditBalanceTransaction> creditBalanceTransaction;
678

679
    /** The discount that was applied to get this pretax credit amount. */
680
    @SerializedName("discount")
681
    @Getter(lombok.AccessLevel.NONE)
682
    @Setter(lombok.AccessLevel.NONE)
683
    ExpandableField<Discount> discount;
684

685
    /**
686
     * Type of the pretax credit amount referenced.
687
     *
688
     * <p>One of {@code credit_balance_transaction}, or {@code discount}.
689
     */
690
    @SerializedName("type")
691
    String type;
692

693
    /** Get ID of expandable {@code creditBalanceTransaction} object. */
694
    public String getCreditBalanceTransaction() {
NEW
695
      return (this.creditBalanceTransaction != null) ? this.creditBalanceTransaction.getId() : null;
×
696
    }
697

698
    public void setCreditBalanceTransaction(String id) {
NEW
699
      this.creditBalanceTransaction =
×
NEW
700
          ApiResource.setExpandableFieldId(id, this.creditBalanceTransaction);
×
NEW
701
    }
×
702

703
    /** Get expanded {@code creditBalanceTransaction}. */
704
    public CreditBalanceTransaction getCreditBalanceTransactionObject() {
NEW
705
      return (this.creditBalanceTransaction != null)
×
NEW
706
          ? this.creditBalanceTransaction.getExpanded()
×
NEW
707
          : null;
×
708
    }
709

710
    public void setCreditBalanceTransactionObject(CreditBalanceTransaction expandableObject) {
NEW
711
      this.creditBalanceTransaction =
×
NEW
712
          new ExpandableField<CreditBalanceTransaction>(expandableObject.getId(), expandableObject);
×
NEW
713
    }
×
714

715
    /** Get ID of expandable {@code discount} object. */
716
    public String getDiscount() {
NEW
717
      return (this.discount != null) ? this.discount.getId() : null;
×
718
    }
719

720
    public void setDiscount(String id) {
NEW
721
      this.discount = ApiResource.setExpandableFieldId(id, this.discount);
×
NEW
722
    }
×
723

724
    /** Get expanded {@code discount}. */
725
    public Discount getDiscountObject() {
NEW
726
      return (this.discount != null) ? this.discount.getExpanded() : null;
×
727
    }
728

729
    public void setDiscountObject(Discount expandableObject) {
NEW
730
      this.discount = new ExpandableField<Discount>(expandableObject.getId(), expandableObject);
×
NEW
731
    }
×
732
  }
733

734
  @Getter
735
  @Setter
736
  @EqualsAndHashCode(callSuper = false)
737
  public static class Refund extends StripeObject {
×
738
    /** Amount of the refund that applies to this credit note, in cents (or local equivalent). */
739
    @SerializedName("amount_refunded")
740
    Long amountRefunded;
741

742
    /** ID of the refund. */
743
    @SerializedName("refund")
744
    @Getter(lombok.AccessLevel.NONE)
745
    @Setter(lombok.AccessLevel.NONE)
746
    ExpandableField<com.stripe.model.Refund> refund;
747

748
    /** Get ID of expandable {@code refund} object. */
749
    public String getRefund() {
750
      return (this.refund != null) ? this.refund.getId() : null;
×
751
    }
752

753
    public void setRefund(String id) {
754
      this.refund = ApiResource.setExpandableFieldId(id, this.refund);
×
755
    }
×
756

757
    /** Get expanded {@code refund}. */
758
    public com.stripe.model.Refund getRefundObject() {
759
      return (this.refund != null) ? this.refund.getExpanded() : null;
×
760
    }
761

762
    public void setRefundObject(com.stripe.model.Refund expandableObject) {
763
      this.refund =
×
764
          new ExpandableField<com.stripe.model.Refund>(expandableObject.getId(), expandableObject);
×
765
    }
×
766
  }
767

768
  @Getter
769
  @Setter
770
  @EqualsAndHashCode(callSuper = false)
771
  public static class ShippingCost extends StripeObject {
×
772
    /** Total shipping cost before any taxes are applied. */
773
    @SerializedName("amount_subtotal")
774
    Long amountSubtotal;
775

776
    /** Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0. */
777
    @SerializedName("amount_tax")
778
    Long amountTax;
779

780
    /** Total shipping cost after taxes are applied. */
781
    @SerializedName("amount_total")
782
    Long amountTotal;
783

784
    /** The ID of the ShippingRate for this invoice. */
785
    @SerializedName("shipping_rate")
786
    @Getter(lombok.AccessLevel.NONE)
787
    @Setter(lombok.AccessLevel.NONE)
788
    ExpandableField<ShippingRate> shippingRate;
789

790
    /** The taxes applied to the shipping rate. */
791
    @SerializedName("taxes")
792
    List<CreditNote.ShippingCost.Tax> taxes;
793

794
    /** Get ID of expandable {@code shippingRate} object. */
795
    public String getShippingRate() {
796
      return (this.shippingRate != null) ? this.shippingRate.getId() : null;
×
797
    }
798

799
    public void setShippingRate(String id) {
800
      this.shippingRate = ApiResource.setExpandableFieldId(id, this.shippingRate);
×
801
    }
×
802

803
    /** Get expanded {@code shippingRate}. */
804
    public ShippingRate getShippingRateObject() {
805
      return (this.shippingRate != null) ? this.shippingRate.getExpanded() : null;
×
806
    }
807

808
    public void setShippingRateObject(ShippingRate expandableObject) {
809
      this.shippingRate =
×
810
          new ExpandableField<ShippingRate>(expandableObject.getId(), expandableObject);
×
811
    }
×
812

813
    @Getter
814
    @Setter
815
    @EqualsAndHashCode(callSuper = false)
816
    public static class Tax extends StripeObject {
×
817
      /** Amount of tax applied for this rate. */
818
      @SerializedName("amount")
819
      Long amount;
820

821
      /**
822
       * Tax rates can be applied to <a
823
       * href="https://stripe.com/docs/billing/invoices/tax-rates">invoices</a>, <a
824
       * href="https://stripe.com/docs/billing/subscriptions/taxes">subscriptions</a> and <a
825
       * href="https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates">Checkout
826
       * Sessions</a> to collect tax.
827
       *
828
       * <p>Related guide: <a href="https://stripe.com/docs/billing/taxes/tax-rates">Tax rates</a>
829
       */
830
      @SerializedName("rate")
831
      TaxRate rate;
832

833
      /**
834
       * The reasoning behind this tax, for example, if the product is tax exempt. The possible
835
       * values for this field may be extended as new tax rules are supported.
836
       *
837
       * <p>One of {@code customer_exempt}, {@code not_collecting}, {@code not_subject_to_tax},
838
       * {@code not_supported}, {@code portion_product_exempt}, {@code portion_reduced_rated},
839
       * {@code portion_standard_rated}, {@code product_exempt}, {@code product_exempt_holiday},
840
       * {@code proportionally_rated}, {@code reduced_rated}, {@code reverse_charge}, {@code
841
       * standard_rated}, {@code taxable_basis_reduced}, or {@code zero_rated}.
842
       */
843
      @SerializedName("taxability_reason")
844
      String taxabilityReason;
845

846
      /** The amount on which tax is calculated, in cents (or local equivalent). */
847
      @SerializedName("taxable_amount")
848
      Long taxableAmount;
849
    }
850
  }
851

852
  @Getter
853
  @Setter
854
  @EqualsAndHashCode(callSuper = false)
855
  public static class TaxAmount extends StripeObject {
1✔
856
    /** The amount, in cents (or local equivalent), of the tax. */
857
    @SerializedName("amount")
858
    Long amount;
859

860
    /** Whether this tax amount is inclusive or exclusive. */
861
    @SerializedName("inclusive")
862
    Boolean inclusive;
863

864
    /** The tax rate that was applied to get this tax amount. */
865
    @SerializedName("tax_rate")
866
    @Getter(lombok.AccessLevel.NONE)
867
    @Setter(lombok.AccessLevel.NONE)
868
    ExpandableField<TaxRate> taxRate;
869

870
    /**
871
     * The reasoning behind this tax, for example, if the product is tax exempt. The possible values
872
     * for this field may be extended as new tax rules are supported.
873
     *
874
     * <p>One of {@code customer_exempt}, {@code not_collecting}, {@code not_subject_to_tax}, {@code
875
     * not_supported}, {@code portion_product_exempt}, {@code portion_reduced_rated}, {@code
876
     * portion_standard_rated}, {@code product_exempt}, {@code product_exempt_holiday}, {@code
877
     * proportionally_rated}, {@code reduced_rated}, {@code reverse_charge}, {@code standard_rated},
878
     * {@code taxable_basis_reduced}, or {@code zero_rated}.
879
     */
880
    @SerializedName("taxability_reason")
881
    String taxabilityReason;
882

883
    /** The amount on which tax is calculated, in cents (or local equivalent). */
884
    @SerializedName("taxable_amount")
885
    Long taxableAmount;
886

887
    /** Get ID of expandable {@code taxRate} object. */
888
    public String getTaxRate() {
889
      return (this.taxRate != null) ? this.taxRate.getId() : null;
×
890
    }
891

892
    public void setTaxRate(String id) {
893
      this.taxRate = ApiResource.setExpandableFieldId(id, this.taxRate);
×
894
    }
×
895

896
    /** Get expanded {@code taxRate}. */
897
    public TaxRate getTaxRateObject() {
898
      return (this.taxRate != null) ? this.taxRate.getExpanded() : null;
×
899
    }
900

901
    public void setTaxRateObject(TaxRate expandableObject) {
902
      this.taxRate = new ExpandableField<TaxRate>(expandableObject.getId(), expandableObject);
×
903
    }
×
904
  }
905

906
  @Override
907
  public void setResponseGetter(StripeResponseGetter responseGetter) {
908
    super.setResponseGetter(responseGetter);
1✔
909
    trySetResponseGetter(customer, responseGetter);
1✔
910
    trySetResponseGetter(customerBalanceTransaction, responseGetter);
1✔
911
    trySetResponseGetter(invoice, responseGetter);
1✔
912
    trySetResponseGetter(lines, responseGetter);
1✔
913
    trySetResponseGetter(refund, responseGetter);
1✔
914
    trySetResponseGetter(shippingCost, responseGetter);
1✔
915
  }
1✔
916
}
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