-
Notifications
You must be signed in to change notification settings - Fork 355
/
Invoice.java
2723 lines (2417 loc) · 113 KB
/
Invoice.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec
package com.stripe.model;
import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.testhelpers.TestClock;
import com.stripe.net.ApiMode;
import com.stripe.net.ApiRequest;
import com.stripe.net.ApiRequestParams;
import com.stripe.net.ApiResource;
import com.stripe.net.BaseAddress;
import com.stripe.net.RequestOptions;
import com.stripe.net.StripeResponseGetter;
import com.stripe.param.InvoiceCreateParams;
import com.stripe.param.InvoiceCreatePreviewParams;
import com.stripe.param.InvoiceFinalizeInvoiceParams;
import com.stripe.param.InvoiceListParams;
import com.stripe.param.InvoiceMarkUncollectibleParams;
import com.stripe.param.InvoicePayParams;
import com.stripe.param.InvoiceRetrieveParams;
import com.stripe.param.InvoiceSearchParams;
import com.stripe.param.InvoiceSendInvoiceParams;
import com.stripe.param.InvoiceUpcomingLinesParams;
import com.stripe.param.InvoiceUpcomingParams;
import com.stripe.param.InvoiceUpdateParams;
import com.stripe.param.InvoiceVoidInvoiceParams;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* Invoices are statements of amounts owed by a customer, and are either generated one-off, or
* generated periodically from a subscription.
*
* <p>They contain <a href="https://stripe.com/docs/api#invoiceitems">invoice items</a>, and
* proration adjustments that may be caused by subscription upgrades/downgrades (if necessary).
*
* <p>If your invoice is configured to be billed through automatic charges, Stripe automatically
* finalizes your invoice and attempts payment. Note that finalizing the invoice, <a
* href="https://stripe.com/docs/invoicing/integration/automatic-advancement-collection">when
* automatic</a>, does not happen immediately as the invoice is created. Stripe waits until one hour
* after the last webhook was successfully sent (or the last webhook timed out after failing). If
* you (and the platforms you may have connected to) have no webhooks configured, Stripe waits one
* hour after creation to finalize the invoice.
*
* <p>If your invoice is configured to be billed by sending an email, then based on your <a
* href="https://dashboard.stripe.com/account/billing/automatic">email settings</a>, Stripe will
* email the invoice to your customer and await payment. These emails can contain a link to a hosted
* page to pay the invoice.
*
* <p>Stripe applies any customer credit on the account before determining the amount due for the
* invoice (i.e., the amount that will be actually charged). If the amount due for the invoice is
* less than Stripe's <a
* href="https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts">minimum allowed
* charge per currency</a>, the invoice is automatically marked paid, and we add the amount due to
* the customer's credit balance which is applied to the next invoice.
*
* <p>More details on the customer's credit balance are <a
* href="https://stripe.com/docs/billing/customer/balance">here</a>.
*
* <p>Related guide: <a href="https://stripe.com/docs/billing/invoices/sending">Send invoices to
* customers</a>
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Invoice extends ApiResource implements HasId, MetadataStore<Invoice> {
/**
* The country of the business associated with this invoice, most often the business creating the
* invoice.
*/
@SerializedName("account_country")
String accountCountry;
/**
* The public name of the business associated with this invoice, most often the business creating
* the invoice.
*/
@SerializedName("account_name")
String accountName;
/** The account tax IDs associated with the invoice. Only editable when the invoice is a draft. */
@SerializedName("account_tax_ids")
List<ExpandableField<TaxId>> accountTaxIds;
/**
* Final amount due at this time for this invoice. If the invoice's total is smaller than the
* minimum charge amount, for example, or if there is account credit that can be applied to the
* invoice, the {@code amount_due} may be 0. If there is a positive {@code starting_balance} for
* the invoice (the customer owes money), the {@code amount_due} will also take that into account.
* The charge that gets generated for the invoice will be for the amount specified in {@code
* amount_due}.
*/
@SerializedName("amount_due")
Long amountDue;
/** The amount, in cents (or local equivalent), that was paid. */
@SerializedName("amount_paid")
Long amountPaid;
/** The difference between amount_due and amount_paid, in cents (or local equivalent). */
@SerializedName("amount_remaining")
Long amountRemaining;
/** This is the sum of all the shipping amounts. */
@SerializedName("amount_shipping")
Long amountShipping;
/** ID of the Connect Application that created the invoice. */
@SerializedName("application")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Application> application;
/**
* The fee in cents (or local equivalent) that will be applied to the invoice and transferred to
* the application owner's Stripe account when the invoice is paid.
*/
@SerializedName("application_fee_amount")
Long applicationFeeAmount;
/**
* Number of payment attempts made for this invoice, from the perspective of the payment retry
* schedule. Any payment attempt counts as the first attempt, and subsequently only automatic
* retries increment the attempt count. In other words, manual payment attempts after the first
* attempt do not affect the retry schedule.
*/
@SerializedName("attempt_count")
Long attemptCount;
/**
* Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour
* after the {@code invoice.created} webhook, for example, so you might not want to display that
* invoice as unpaid to your users.
*/
@SerializedName("attempted")
Boolean attempted;
/**
* Controls whether Stripe performs <a
* href="https://stripe.com/docs/invoicing/integration/automatic-advancement-collection">automatic
* collection</a> of the invoice. If {@code false}, the invoice's state doesn't automatically
* advance without an explicit action.
*/
@SerializedName("auto_advance")
Boolean autoAdvance;
@SerializedName("automatic_tax")
AutomaticTax automaticTax;
/**
* Indicates the reason why the invoice was created.
*
* <p>* {@code manual}: Unrelated to a subscription, for example, created via the invoice editor.
* * {@code subscription}: No longer in use. Applies to subscriptions from before May 2018 where
* no distinction was made between updates, cycles, and thresholds. * {@code subscription_create}:
* A new subscription was created. * {@code subscription_cycle}: A subscription advanced into a
* new period. * {@code subscription_threshold}: A subscription reached a billing threshold. *
* {@code subscription_update}: A subscription was updated. * {@code upcoming}: Reserved for
* simulated invoices, per the upcoming invoice endpoint.
*
* <p>One of {@code automatic_pending_invoice_item_invoice}, {@code manual}, {@code quote_accept},
* {@code subscription}, {@code subscription_create}, {@code subscription_cycle}, {@code
* subscription_threshold}, {@code subscription_update}, or {@code upcoming}.
*/
@SerializedName("billing_reason")
String billingReason;
/** ID of the latest charge generated for this invoice, if any. */
@SerializedName("charge")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Charge> charge;
/**
* Either {@code charge_automatically}, or {@code send_invoice}. When charging automatically,
* Stripe will attempt to pay this invoice using the default source attached to the customer. When
* sending an invoice, Stripe will email this invoice to the customer with payment instructions.
*
* <p>One of {@code charge_automatically}, or {@code send_invoice}.
*/
@SerializedName("collection_method")
String collectionMethod;
/** Time at which the object was created. Measured in seconds since the Unix epoch. */
@SerializedName("created")
Long created;
/**
* Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
* in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
*/
@SerializedName("currency")
String currency;
/** Custom fields displayed on the invoice. */
@SerializedName("custom_fields")
List<Invoice.CustomField> customFields;
/** The ID of the customer who will be billed. */
@SerializedName("customer")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Customer> customer;
/**
* The customer's address. Until the invoice is finalized, this field will equal {@code
* customer.address}. Once the invoice is finalized, this field will no longer be updated.
*/
@SerializedName("customer_address")
Address customerAddress;
/**
* The customer's email. Until the invoice is finalized, this field will equal {@code
* customer.email}. Once the invoice is finalized, this field will no longer be updated.
*/
@SerializedName("customer_email")
String customerEmail;
/**
* The customer's name. Until the invoice is finalized, this field will equal {@code
* customer.name}. Once the invoice is finalized, this field will no longer be updated.
*/
@SerializedName("customer_name")
String customerName;
/**
* The customer's phone number. Until the invoice is finalized, this field will equal {@code
* customer.phone}. Once the invoice is finalized, this field will no longer be updated.
*/
@SerializedName("customer_phone")
String customerPhone;
/**
* The customer's shipping information. Until the invoice is finalized, this field will equal
* {@code customer.shipping}. Once the invoice is finalized, this field will no longer be updated.
*/
@SerializedName("customer_shipping")
ShippingDetails customerShipping;
/**
* The customer's tax exempt status. Until the invoice is finalized, this field will equal {@code
* customer.tax_exempt}. Once the invoice is finalized, this field will no longer be updated.
*
* <p>One of {@code exempt}, {@code none}, or {@code reverse}.
*/
@SerializedName("customer_tax_exempt")
String customerTaxExempt;
/**
* The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax
* IDs as {@code customer.tax_ids}. Once the invoice is finalized, this field will no longer be
* updated.
*/
@SerializedName("customer_tax_ids")
List<Invoice.CustomerTaxId> customerTaxIds;
/**
* ID of the default payment method for the invoice. It must belong to the customer associated
* with the invoice. If not set, defaults to the subscription's default payment method, if any, or
* to the default payment method in the customer's invoice settings.
*/
@SerializedName("default_payment_method")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<PaymentMethod> defaultPaymentMethod;
/**
* ID of the default payment source for the invoice. It must belong to the customer associated
* with the invoice and be in a chargeable state. If not set, defaults to the subscription's
* default source, if any, or to the customer's default source.
*/
@SerializedName("default_source")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<PaymentSource> defaultSource;
/** The tax rates applied to this invoice, if any. */
@SerializedName("default_tax_rates")
List<TaxRate> defaultTaxRates;
/** Always true for a deleted object. */
@SerializedName("deleted")
Boolean deleted;
/**
* An arbitrary string attached to the object. Often useful for displaying to users. Referenced as
* 'memo' in the Dashboard.
*/
@SerializedName("description")
String description;
/**
* Describes the current discount applied to this invoice, if there is one. Not populated if there
* are multiple discounts.
*/
@SerializedName("discount")
Discount discount;
/**
* The discounts applied to the invoice. Line item discounts are applied before invoice discounts.
* Use {@code expand[]=discounts} to expand each discount.
*/
@SerializedName("discounts")
List<ExpandableField<Discount>> discounts;
/**
* The date on which payment for this invoice is due. This value will be {@code null} for invoices
* where {@code collection_method=charge_automatically}.
*/
@SerializedName("due_date")
Long dueDate;
/**
* The date when this invoice is in effect. Same as {@code finalized_at} unless overwritten. When
* defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF
* and receipt.
*/
@SerializedName("effective_at")
Long effectiveAt;
/**
* Ending customer balance after the invoice is finalized. Invoices are finalized approximately an
* hour after successful webhook delivery or when payment collection is attempted for the invoice.
* If the invoice has not been finalized yet, this will be null.
*/
@SerializedName("ending_balance")
Long endingBalance;
/** Footer displayed on the invoice. */
@SerializedName("footer")
String footer;
/**
* Details of the invoice that was cloned. See the <a
* href="https://stripe.com/docs/invoicing/invoice-revisions">revision documentation</a> for more
* details.
*/
@SerializedName("from_invoice")
FromInvoice fromInvoice;
/**
* The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the
* invoice has not been finalized yet, this will be null.
*/
@SerializedName("hosted_invoice_url")
String hostedInvoiceUrl;
/**
* Unique identifier for the object. This property is always present unless the invoice is an
* upcoming invoice. See <a href="https://stripe.com/docs/api/invoices/upcoming">Retrieve an
* upcoming invoice</a> for more details.
*/
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;
/**
* The link to download the PDF for the invoice. If the invoice has not been finalized yet, this
* will be null.
*/
@SerializedName("invoice_pdf")
String invoicePdf;
@SerializedName("issuer")
Issuer issuer;
/**
* The error encountered during the previous attempt to finalize the invoice. This field is
* cleared when the invoice is successfully finalized.
*/
@SerializedName("last_finalization_error")
StripeError lastFinalizationError;
/** The ID of the most recent non-draft revision of this invoice. */
@SerializedName("latest_revision")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Invoice> latestRevision;
/**
* The individual line items that make up the invoice. {@code lines} is sorted as follows: (1)
* pending invoice items (including prorations) in reverse chronological order, (2) subscription
* items in reverse chronological order, and (3) invoice items added after invoice creation in
* chronological order.
*/
@SerializedName("lines")
InvoiceLineItemCollection lines;
/**
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
* object exists in test mode.
*/
@SerializedName("livemode")
Boolean livemode;
/**
* Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
* to an object. This can be useful for storing additional information about the object in a
* structured format.
*/
@Getter(onMethod_ = {@Override})
@SerializedName("metadata")
Map<String, String> metadata;
/**
* The time at which payment will next be attempted. This value will be {@code null} for invoices
* where {@code collection_method=send_invoice}.
*/
@SerializedName("next_payment_attempt")
Long nextPaymentAttempt;
/**
* A unique, identifying string that appears on emails sent to the customer for this invoice. This
* starts with the customer's unique invoice_prefix if it is specified.
*/
@SerializedName("number")
String number;
/**
* String representing the object's type. Objects of the same type share the same value.
*
* <p>Equal to {@code invoice}.
*/
@SerializedName("object")
String object;
/**
* The account (if any) for which the funds of the invoice payment are intended. If set, the
* invoice will be presented with the branding and support information of the specified account.
* See the <a href="https://stripe.com/docs/billing/invoices/connect">Invoices with Connect</a>
* documentation for details.
*/
@SerializedName("on_behalf_of")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Account> onBehalfOf;
/**
* Whether payment was successfully collected for this invoice. An invoice can be paid (most
* commonly) with a charge or with credit from the customer's account balance.
*/
@SerializedName("paid")
Boolean paid;
/**
* Returns true if the invoice was manually marked paid, returns false if the invoice hasn't been
* paid yet or was paid on Stripe.
*/
@SerializedName("paid_out_of_band")
Boolean paidOutOfBand;
/**
* The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice
* is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel
* the PaymentIntent.
*/
@SerializedName("payment_intent")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<PaymentIntent> paymentIntent;
@SerializedName("payment_settings")
PaymentSettings paymentSettings;
/** End of the usage period during which invoice items were added to this invoice. */
@SerializedName("period_end")
Long periodEnd;
/** Start of the usage period during which invoice items were added to this invoice. */
@SerializedName("period_start")
Long periodStart;
/** Total amount of all post-payment credit notes issued for this invoice. */
@SerializedName("post_payment_credit_notes_amount")
Long postPaymentCreditNotesAmount;
/** Total amount of all pre-payment credit notes issued for this invoice. */
@SerializedName("pre_payment_credit_notes_amount")
Long prePaymentCreditNotesAmount;
/** The quote this invoice was generated from. */
@SerializedName("quote")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Quote> quote;
/** This is the transaction number that appears on email receipts sent for this invoice. */
@SerializedName("receipt_number")
String receiptNumber;
/**
* The rendering-related settings that control how the invoice is displayed on customer-facing
* surfaces such as PDF and Hosted Invoice Page.
*/
@SerializedName("rendering")
Rendering rendering;
/** The details of the cost of shipping, including the ShippingRate applied on the invoice. */
@SerializedName("shipping_cost")
ShippingCost shippingCost;
/**
* Shipping details for the invoice. The Invoice PDF will use the {@code shipping_details} value
* if it is set, otherwise the PDF will render the shipping address from the customer.
*/
@SerializedName("shipping_details")
ShippingDetails shippingDetails;
/**
* Starting customer balance before the invoice is finalized. If the invoice has not been
* finalized yet, this will be the current customer balance. For revision invoices, this also
* includes any customer balance that was applied to the original invoice.
*/
@SerializedName("starting_balance")
Long startingBalance;
/** Extra information about an invoice for the customer's credit card statement. */
@SerializedName("statement_descriptor")
String statementDescriptor;
/**
* The status of the invoice, one of {@code draft}, {@code open}, {@code paid}, {@code
* uncollectible}, or {@code void}. <a
* href="https://stripe.com/docs/billing/invoices/workflow#workflow-overview">Learn more</a>
*/
@SerializedName("status")
String status;
@SerializedName("status_transitions")
StatusTransitions statusTransitions;
/** The subscription that this invoice was prepared for, if any. */
@SerializedName("subscription")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Subscription> subscription;
/** Details about the subscription that created this invoice. */
@SerializedName("subscription_details")
SubscriptionDetails subscriptionDetails;
/**
* Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
*/
@SerializedName("subscription_proration_date")
Long subscriptionProrationDate;
/**
* Total of all subscriptions, invoice items, and prorations on the invoice before any invoice
* level discount or exclusive tax is applied. Item discounts are already incorporated
*/
@SerializedName("subtotal")
Long subtotal;
/**
* The integer amount in cents (or local equivalent) representing the subtotal of the invoice
* before any invoice level discount or tax is applied. Item discounts are already incorporated
*/
@SerializedName("subtotal_excluding_tax")
Long subtotalExcludingTax;
/** The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice. */
@SerializedName("tax")
Long tax;
/** ID of the test clock this invoice belongs to. */
@SerializedName("test_clock")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<TestClock> testClock;
@SerializedName("threshold_reason")
ThresholdReason thresholdReason;
/** Total after discounts and taxes. */
@SerializedName("total")
Long total;
/** The aggregate amounts calculated per discount across all line items. */
@SerializedName("total_discount_amounts")
List<Invoice.TotalDiscountAmount> totalDiscountAmounts;
/**
* The integer amount in cents (or local equivalent) representing the total amount of the invoice
* including all discounts but excluding all tax.
*/
@SerializedName("total_excluding_tax")
Long totalExcludingTax;
/** The aggregate amounts calculated per tax rate for all line items. */
@SerializedName("total_tax_amounts")
List<Invoice.TotalTaxAmount> totalTaxAmounts;
/**
* The account (if any) the payment will be attributed to for tax reporting, and where funds from
* the payment will be transferred to for the invoice.
*/
@SerializedName("transfer_data")
TransferData transferData;
/**
* Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all
* webhook delivery attempts have <a
* href="https://stripe.com/docs/billing/webhooks#understand">been exhausted</a>. This field
* tracks the time when webhooks for this invoice were successfully delivered. If the invoice had
* no webhooks to deliver, this will be set while the invoice is being created.
*/
@SerializedName("webhooks_delivered_at")
Long webhooksDeliveredAt;
/** Get ID of expandable {@code application} object. */
public String getApplication() {
return (this.application != null) ? this.application.getId() : null;
}
public void setApplication(String id) {
this.application = ApiResource.setExpandableFieldId(id, this.application);
}
/** Get expanded {@code application}. */
public Application getApplicationObject() {
return (this.application != null) ? this.application.getExpanded() : null;
}
public void setApplicationObject(Application expandableObject) {
this.application = new ExpandableField<Application>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code charge} object. */
public String getCharge() {
return (this.charge != null) ? this.charge.getId() : null;
}
public void setCharge(String id) {
this.charge = ApiResource.setExpandableFieldId(id, this.charge);
}
/** Get expanded {@code charge}. */
public Charge getChargeObject() {
return (this.charge != null) ? this.charge.getExpanded() : null;
}
public void setChargeObject(Charge expandableObject) {
this.charge = new ExpandableField<Charge>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code customer} object. */
public String getCustomer() {
return (this.customer != null) ? this.customer.getId() : null;
}
public void setCustomer(String id) {
this.customer = ApiResource.setExpandableFieldId(id, this.customer);
}
/** Get expanded {@code customer}. */
public Customer getCustomerObject() {
return (this.customer != null) ? this.customer.getExpanded() : null;
}
public void setCustomerObject(Customer expandableObject) {
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code defaultPaymentMethod} object. */
public String getDefaultPaymentMethod() {
return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getId() : null;
}
public void setDefaultPaymentMethod(String id) {
this.defaultPaymentMethod = ApiResource.setExpandableFieldId(id, this.defaultPaymentMethod);
}
/** Get expanded {@code defaultPaymentMethod}. */
public PaymentMethod getDefaultPaymentMethodObject() {
return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getExpanded() : null;
}
public void setDefaultPaymentMethodObject(PaymentMethod expandableObject) {
this.defaultPaymentMethod =
new ExpandableField<PaymentMethod>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code defaultSource} object. */
public String getDefaultSource() {
return (this.defaultSource != null) ? this.defaultSource.getId() : null;
}
public void setDefaultSource(String id) {
this.defaultSource = ApiResource.setExpandableFieldId(id, this.defaultSource);
}
/** Get expanded {@code defaultSource}. */
public PaymentSource getDefaultSourceObject() {
return (this.defaultSource != null) ? this.defaultSource.getExpanded() : null;
}
public void setDefaultSourceObject(PaymentSource expandableObject) {
this.defaultSource =
new ExpandableField<PaymentSource>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code latestRevision} object. */
public String getLatestRevision() {
return (this.latestRevision != null) ? this.latestRevision.getId() : null;
}
public void setLatestRevision(String id) {
this.latestRevision = ApiResource.setExpandableFieldId(id, this.latestRevision);
}
/** Get expanded {@code latestRevision}. */
public Invoice getLatestRevisionObject() {
return (this.latestRevision != null) ? this.latestRevision.getExpanded() : null;
}
public void setLatestRevisionObject(Invoice expandableObject) {
this.latestRevision = new ExpandableField<Invoice>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code onBehalfOf} object. */
public String getOnBehalfOf() {
return (this.onBehalfOf != null) ? this.onBehalfOf.getId() : null;
}
public void setOnBehalfOf(String id) {
this.onBehalfOf = ApiResource.setExpandableFieldId(id, this.onBehalfOf);
}
/** Get expanded {@code onBehalfOf}. */
public Account getOnBehalfOfObject() {
return (this.onBehalfOf != null) ? this.onBehalfOf.getExpanded() : null;
}
public void setOnBehalfOfObject(Account expandableObject) {
this.onBehalfOf = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code paymentIntent} object. */
public String getPaymentIntent() {
return (this.paymentIntent != null) ? this.paymentIntent.getId() : null;
}
public void setPaymentIntent(String id) {
this.paymentIntent = ApiResource.setExpandableFieldId(id, this.paymentIntent);
}
/** Get expanded {@code paymentIntent}. */
public PaymentIntent getPaymentIntentObject() {
return (this.paymentIntent != null) ? this.paymentIntent.getExpanded() : null;
}
public void setPaymentIntentObject(PaymentIntent expandableObject) {
this.paymentIntent =
new ExpandableField<PaymentIntent>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code quote} object. */
public String getQuote() {
return (this.quote != null) ? this.quote.getId() : null;
}
public void setQuote(String id) {
this.quote = ApiResource.setExpandableFieldId(id, this.quote);
}
/** Get expanded {@code quote}. */
public Quote getQuoteObject() {
return (this.quote != null) ? this.quote.getExpanded() : null;
}
public void setQuoteObject(Quote expandableObject) {
this.quote = new ExpandableField<Quote>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code subscription} object. */
public String getSubscription() {
return (this.subscription != null) ? this.subscription.getId() : null;
}
public void setSubscription(String id) {
this.subscription = ApiResource.setExpandableFieldId(id, this.subscription);
}
/** Get expanded {@code subscription}. */
public Subscription getSubscriptionObject() {
return (this.subscription != null) ? this.subscription.getExpanded() : null;
}
public void setSubscriptionObject(Subscription expandableObject) {
this.subscription =
new ExpandableField<Subscription>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code testClock} object. */
public String getTestClock() {
return (this.testClock != null) ? this.testClock.getId() : null;
}
public void setTestClock(String id) {
this.testClock = ApiResource.setExpandableFieldId(id, this.testClock);
}
/** Get expanded {@code testClock}. */
public TestClock getTestClockObject() {
return (this.testClock != null) ? this.testClock.getExpanded() : null;
}
public void setTestClockObject(TestClock expandableObject) {
this.testClock = new ExpandableField<TestClock>(expandableObject.getId(), expandableObject);
}
/** Get IDs of expandable {@code accountTaxIds} object list. */
public List<String> getAccountTaxIds() {
return (this.accountTaxIds != null)
? this.accountTaxIds.stream().map(x -> x.getId()).collect(Collectors.toList())
: null;
}
public void setAccountTaxIds(List<String> ids) {
if (ids == null) {
this.accountTaxIds = null;
return;
}
if (this.accountTaxIds != null
&& this.accountTaxIds.stream()
.map(x -> x.getId())
.collect(Collectors.toList())
.equals(ids)) {
// noop if the ids are equal to what are already present
return;
}
this.accountTaxIds =
(ids != null)
? ids.stream()
.map(id -> new ExpandableField<TaxId>(id, null))
.collect(Collectors.toList())
: null;
}
/** Get expanded {@code accountTaxIds}. */
public List<TaxId> getAccountTaxIdObjects() {
return (this.accountTaxIds != null)
? this.accountTaxIds.stream().map(x -> x.getExpanded()).collect(Collectors.toList())
: null;
}
public void setAccountTaxIdObjects(List<TaxId> objs) {
this.accountTaxIds =
objs != null
? objs.stream()
.map(x -> new ExpandableField<TaxId>(x.getId(), x))
.collect(Collectors.toList())
: null;
}
/** Get IDs of expandable {@code discounts} object list. */
public List<String> getDiscounts() {
return (this.discounts != null)
? this.discounts.stream().map(x -> x.getId()).collect(Collectors.toList())
: null;
}
public void setDiscounts(List<String> ids) {
if (ids == null) {
this.discounts = null;
return;
}
if (this.discounts != null
&& this.discounts.stream().map(x -> x.getId()).collect(Collectors.toList()).equals(ids)) {
// noop if the ids are equal to what are already present
return;
}
this.discounts =
(ids != null)
? ids.stream()
.map(id -> new ExpandableField<Discount>(id, null))
.collect(Collectors.toList())
: null;
}
/** Get expanded {@code discounts}. */
public List<Discount> getDiscountObjects() {
return (this.discounts != null)
? this.discounts.stream().map(x -> x.getExpanded()).collect(Collectors.toList())
: null;
}
public void setDiscountObjects(List<Discount> objs) {
this.discounts =
objs != null
? objs.stream()
.map(x -> new ExpandableField<Discount>(x.getId(), x))
.collect(Collectors.toList())
: null;
}
/**
* This endpoint creates a draft invoice for a given customer. The invoice remains a draft until
* you <a href="https://stripe.com/docs/api#finalize_invoice">finalize</a> the invoice, which
* allows you to <a href="https://stripe.com/docs/api#pay_invoice">pay</a> or <a
* href="https://stripe.com/docs/api#send_invoice">send</a> the invoice to your customers.
*/
public static Invoice create(Map<String, Object> params) throws StripeException {
return create(params, (RequestOptions) null);
}
/**
* This endpoint creates a draft invoice for a given customer. The invoice remains a draft until
* you <a href="https://stripe.com/docs/api#finalize_invoice">finalize</a> the invoice, which
* allows you to <a href="https://stripe.com/docs/api#pay_invoice">pay</a> or <a
* href="https://stripe.com/docs/api#send_invoice">send</a> the invoice to your customers.
*/
public static Invoice create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String path = "/v1/invoices";
ApiRequest request =
new ApiRequest(
BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options, ApiMode.V1);
return getGlobalResponseGetter().request(request, Invoice.class);
}
/**
* This endpoint creates a draft invoice for a given customer. The invoice remains a draft until
* you <a href="https://stripe.com/docs/api#finalize_invoice">finalize</a> the invoice, which
* allows you to <a href="https://stripe.com/docs/api#pay_invoice">pay</a> or <a
* href="https://stripe.com/docs/api#send_invoice">send</a> the invoice to your customers.
*/
public static Invoice create(InvoiceCreateParams params) throws StripeException {
return create(params, (RequestOptions) null);
}
/**
* This endpoint creates a draft invoice for a given customer. The invoice remains a draft until
* you <a href="https://stripe.com/docs/api#finalize_invoice">finalize</a> the invoice, which
* allows you to <a href="https://stripe.com/docs/api#pay_invoice">pay</a> or <a
* href="https://stripe.com/docs/api#send_invoice">send</a> the invoice to your customers.
*/
public static Invoice create(InvoiceCreateParams params, RequestOptions options)
throws StripeException {
String path = "/v1/invoices";
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.POST,
path,
ApiRequestParams.paramsToMap(params),
options,
ApiMode.V1);
return getGlobalResponseGetter().request(request, Invoice.class);
}
/**
* At any time, you can preview the upcoming invoice for a customer. This will show you all the
* charges that are pending, including subscription renewal charges, invoice item charges, etc. It
* will also show you any discounts that are applicable to the invoice.
*
* <p>Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the
* invoice has not yet been created. As such, the upcoming invoice will not show up in invoice
* listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the
* amount that your customer will be billed, you can add, remove, or update pending invoice items,
* or update the customer’s discount.
*
* <p>You can preview the effects of updating a subscription, including a preview of what
* proration will take place. To ensure that the actual proration is calculated exactly the same
* as the previewed proration, you should pass the {@code subscription_details.proration_date}
* parameter when doing the actual subscription update. The recommended way to get only the
* prorations being previewed is to consider only proration line items where {@code period[start]}
* is equal to the {@code subscription_details.proration_date} value passed in the request.
*/
public static Invoice createPreview() throws StripeException {
return createPreview((Map<String, Object>) null, (RequestOptions) null);
}
/**
* At any time, you can preview the upcoming invoice for a customer. This will show you all the
* charges that are pending, including subscription renewal charges, invoice item charges, etc. It
* will also show you any discounts that are applicable to the invoice.
*
* <p>Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the
* invoice has not yet been created. As such, the upcoming invoice will not show up in invoice
* listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the
* amount that your customer will be billed, you can add, remove, or update pending invoice items,
* or update the customer’s discount.
*
* <p>You can preview the effects of updating a subscription, including a preview of what
* proration will take place. To ensure that the actual proration is calculated exactly the same
* as the previewed proration, you should pass the {@code subscription_details.proration_date}
* parameter when doing the actual subscription update. The recommended way to get only the
* prorations being previewed is to consider only proration line items where {@code period[start]}
* is equal to the {@code subscription_details.proration_date} value passed in the request.
*/
public static Invoice createPreview(RequestOptions options) throws StripeException {
return createPreview((Map<String, Object>) null, options);
}