/
InvoiceLineItems.d.ts
671 lines (556 loc) · 23.6 KB
/
InvoiceLineItems.d.ts
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
// File generated from our OpenAPI spec
declare module 'stripe' {
namespace Stripe {
/**
* The InvoiceLineItem object.
*/
interface InvoiceLineItem {
/**
* Unique identifier for the object.
*/
id: string;
/**
* String representing the object's type. Objects of the same type share the same value.
*/
object: 'line_item';
/**
* The amount, in %s.
*/
amount: number;
/**
* Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
*/
currency: string;
/**
* An arbitrary string attached to the object. Often useful for displaying to users.
*/
description: string | null;
/**
* The amount of discount calculated per discount for this line item.
*/
discount_amounts: Array<InvoiceLineItem.DiscountAmount> | null;
/**
* If true, discounts will apply to this line item. Always false for prorations.
*/
discountable: boolean;
/**
* The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.
*/
discounts: Array<string | Stripe.Discount> | null;
/**
* The ID of the [invoice item](https://stripe.com/docs/api/invoiceitems) associated with this line item if any.
*/
invoice_item?: string;
/**
* Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
*/
livemode: boolean;
/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with `type=subscription` this will reflect the metadata of the subscription that caused the line item to be created.
*/
metadata: Stripe.Metadata;
period: InvoiceLineItem.Period;
/**
* The plan of the subscription, if the line item is a subscription or a proration.
*/
plan: Stripe.Plan | null;
/**
* The price of the line item.
*/
price: Stripe.Price | null;
/**
* Whether this is a proration.
*/
proration: boolean;
/**
* The quantity of the subscription, if the line item is a subscription or a proration.
*/
quantity: number | null;
/**
* The subscription that the invoice item pertains to, if any.
*/
subscription: string | null;
/**
* The subscription item that generated this invoice item. Left empty if the line item is not an explicit result of a subscription.
*/
subscription_item?: string;
/**
* The amount of tax calculated per tax rate for this line item
*/
tax_amounts?: Array<InvoiceLineItem.TaxAmount>;
/**
* The tax rates which apply to the line item.
*/
tax_rates?: Array<Stripe.TaxRate>;
/**
* A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`.
*/
type: InvoiceLineItem.Type;
}
namespace InvoiceLineItem {
interface DiscountAmount {
/**
* The amount, in %s, of the discount.
*/
amount: number;
/**
* The discount that was applied to get this discount amount.
*/
discount: string | Stripe.Discount | Stripe.DeletedDiscount;
}
interface Period {
/**
* End of the line item's billing period
*/
end: number;
/**
* Start of the line item's billing period
*/
start: number;
}
interface TaxAmount {
/**
* The amount, in %s, of the tax.
*/
amount: number;
/**
* Whether this tax amount is inclusive or exclusive.
*/
inclusive: boolean;
/**
* The tax rate that was applied to get this tax amount.
*/
tax_rate: string | Stripe.TaxRate;
}
type Type = 'invoiceitem' | 'subscription';
}
interface InvoiceLineItemListParams extends PaginationParams {
/**
* Specifies which fields in the response should be expanded.
*/
expand?: Array<string>;
}
interface InvoiceLineItemListUpcomingParams extends PaginationParams {
/**
* Settings for automatic tax lookup for this invoice preview.
*/
automatic_tax?: InvoiceLineItemListUpcomingParams.AutomaticTax;
/**
* The code of the coupon to apply. If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. The invoice can be previewed without a coupon by passing this value as an empty string.
*/
coupon?: string;
/**
* The identifier of the customer whose upcoming invoice you'd like to retrieve.
*/
customer?: string;
/**
* Details about the customer you want to invoice or overrides for an existing customer.
*/
customer_details?: InvoiceLineItemListUpcomingParams.CustomerDetails;
/**
* The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the customer or subscription. This only works for coupons directly applied to the invoice. To apply a coupon to a subscription, you must use the `coupon` parameter instead. Pass an empty string to avoid inheriting any discounts. To preview the upcoming invoice for a subscription that hasn't been created, use `coupon` instead.
*/
discounts?: Stripe.Emptyable<
Array<InvoiceLineItemListUpcomingParams.Discount>
>;
/**
* Specifies which fields in the response should be expanded.
*/
expand?: Array<string>;
/**
* List of invoice items to add or update in the upcoming invoice preview.
*/
invoice_items?: Array<InvoiceLineItemListUpcomingParams.InvoiceItem>;
/**
* The identifier of the unstarted schedule whose upcoming invoice you'd like to retrieve. Cannot be used with subscription or subscription fields.
*/
schedule?: string;
/**
* The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions.
*/
subscription?: string;
/**
* For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`.
*/
subscription_billing_cycle_anchor?:
| InvoiceLineItemListUpcomingParams.SubscriptionBillingCycleAnchor
| number;
/**
* Timestamp indicating when the subscription should be scheduled to cancel. Will prorate if within the current period and prorations have been enabled using `proration_behavior`.
*/
subscription_cancel_at?: Stripe.Emptyable<number>;
/**
* Boolean indicating whether this subscription should cancel at the end of the current period.
*/
subscription_cancel_at_period_end?: boolean;
/**
* This simulates the subscription being canceled or expired immediately.
*/
subscription_cancel_now?: boolean;
/**
* If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set.
*/
subscription_default_tax_rates?: Stripe.Emptyable<Array<string>>;
/**
* A list of up to 20 subscription items, each with an attached price.
*/
subscription_items?: Array<
InvoiceLineItemListUpcomingParams.SubscriptionItem
>;
/**
* Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. Valid values are `create_prorations`, `none`, or `always_invoice`.
*
* Passing `create_prorations` will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under [certain conditions](https://stripe.com/docs/subscriptions/upgrading-downgrading#immediate-payment). In order to always invoice immediately for prorations, pass `always_invoice`.
*
* Prorations can be disabled by passing `none`.
*/
subscription_proration_behavior?: InvoiceLineItemListUpcomingParams.SubscriptionProrationBehavior;
/**
* If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period, and cannot be before the subscription was on its current plan. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to 'none'.
*/
subscription_proration_date?: number;
/**
* Date a subscription is intended to start (can be future or past)
*/
subscription_start_date?: number;
/**
* If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of `subscription_items` or `subscription` is required.
*/
subscription_trial_end?: 'now' | number;
/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
*/
subscription_trial_from_plan?: boolean;
}
namespace InvoiceLineItemListUpcomingParams {
interface AutomaticTax {
/**
* Controls whether Stripe will automatically compute tax on this invoice.
*/
enabled: boolean;
}
interface CustomerDetails {
/**
* The customer's address.
*/
address?: Stripe.Emptyable<CustomerDetails.Address>;
/**
* The customer's shipping information. Appears on invoices emailed to this customer.
*/
shipping?: Stripe.Emptyable<CustomerDetails.Shipping>;
/**
* Tax details about the customer.
*/
tax?: CustomerDetails.Tax;
/**
* The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
*/
tax_exempt?: Stripe.Emptyable<CustomerDetails.TaxExempt>;
/**
* The customer's tax IDs.
*/
tax_ids?: Array<CustomerDetails.TaxId>;
}
namespace CustomerDetails {
interface Address extends Omit<Stripe.AddressParam, 'line1'> {
line1?: string;
}
interface Shipping {
/**
* Customer shipping address.
*/
address: Shipping.Address;
/**
* Customer name.
*/
name: string;
/**
* Customer phone (including extension).
*/
phone?: string;
}
namespace Shipping {
interface Address extends Omit<Stripe.AddressParam, 'line1'> {
line1?: string;
}
}
interface Tax {
/**
* A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
*/
ip_address?: Stripe.Emptyable<string>;
}
type TaxExempt = 'exempt' | 'none' | 'reverse';
interface TaxId {
/**
* Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat`
*/
type: TaxId.Type;
/**
* Value of the tax ID.
*/
value: string;
}
namespace TaxId {
type Type =
| 'ae_trn'
| 'au_abn'
| 'au_arn'
| 'br_cnpj'
| 'br_cpf'
| 'ca_bn'
| 'ca_gst_hst'
| 'ca_pst_bc'
| 'ca_pst_mb'
| 'ca_pst_sk'
| 'ca_qst'
| 'ch_vat'
| 'cl_tin'
| 'es_cif'
| 'eu_vat'
| 'gb_vat'
| 'ge_vat'
| 'hk_br'
| 'id_npwp'
| 'il_vat'
| 'in_gst'
| 'is_vat'
| 'jp_cn'
| 'jp_rn'
| 'kr_brn'
| 'li_uid'
| 'mx_rfc'
| 'my_frp'
| 'my_itn'
| 'my_sst'
| 'no_vat'
| 'nz_gst'
| 'ru_inn'
| 'ru_kpp'
| 'sa_vat'
| 'sg_gst'
| 'sg_uen'
| 'th_vat'
| 'tw_vat'
| 'ua_vat'
| 'us_ein'
| 'za_vat';
}
}
interface Discount {
/**
* ID of the coupon to create a new discount for.
*/
coupon?: string;
/**
* ID of an existing discount on the object (or one of its ancestors) to reuse.
*/
discount?: string;
}
interface InvoiceItem {
/**
* The integer amount in %s of previewed invoice item.
*/
amount?: number;
/**
* Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Only applicable to new invoice items.
*/
currency?: string;
/**
* An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.
*/
description?: string;
/**
* Explicitly controls whether discounts apply to this invoice item. Defaults to true, except for negative invoice items.
*/
discountable?: boolean;
/**
* The coupons to redeem into discounts for the invoice item in the preview.
*/
discounts?: Stripe.Emptyable<Array<InvoiceItem.Discount>>;
/**
* The ID of the invoice item to update in preview. If not specified, a new invoice item will be added to the preview of the upcoming invoice.
*/
invoiceitem?: string;
/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: Stripe.Emptyable<Stripe.MetadataParam>;
/**
* The period associated with this invoice item.
*/
period?: InvoiceItem.Period;
/**
* The ID of the price object.
*/
price?: string;
/**
* Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
*/
price_data?: InvoiceItem.PriceData;
/**
* Non-negative integer. The quantity of units for the invoice item.
*/
quantity?: number;
/**
* The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item.
*/
tax_rates?: Stripe.Emptyable<Array<string>>;
/**
* The integer unit amount in %s of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount.
*/
unit_amount?: number;
/**
* Same as `unit_amount`, but accepts a decimal value in %s with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
*/
unit_amount_decimal?: string;
}
namespace InvoiceItem {
interface Discount {
/**
* ID of the coupon to create a new discount for.
*/
coupon?: string;
/**
* ID of an existing discount on the object (or one of its ancestors) to reuse.
*/
discount?: string;
}
interface Period {
/**
* The end of the period, which must be greater than or equal to the start.
*/
end: number;
/**
* The start of the period.
*/
start: number;
}
interface PriceData {
/**
* Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
*/
currency: string;
/**
* The ID of the product that this price will belong to.
*/
product: string;
/**
* Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
*/
tax_behavior?: PriceData.TaxBehavior;
/**
* A positive integer in %s (or 0 for a free price) representing how much to charge.
*/
unit_amount?: number;
/**
* Same as `unit_amount`, but accepts a decimal value in %s with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
*/
unit_amount_decimal?: string;
}
namespace PriceData {
type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified';
}
}
type SubscriptionBillingCycleAnchor = 'now' | 'unchanged';
interface SubscriptionItem {
/**
* Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.
*/
billing_thresholds?: Stripe.Emptyable<
SubscriptionItem.BillingThresholds
>;
/**
* Delete all usage for a given subscription item. Allowed only when `deleted` is set to `true` and the current plan's `usage_type` is `metered`.
*/
clear_usage?: boolean;
/**
* A flag that, if set to `true`, will delete the specified item.
*/
deleted?: boolean;
/**
* Subscription item to update.
*/
id?: string;
/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: Stripe.Emptyable<Stripe.MetadataParam>;
/**
* Plan ID for this item, as a string.
*/
plan?: string;
/**
* The ID of the price object. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided.
*/
price?: string;
/**
* Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
*/
price_data?: SubscriptionItem.PriceData;
/**
* Quantity for this item.
*/
quantity?: number;
/**
* A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
*/
tax_rates?: Stripe.Emptyable<Array<string>>;
}
namespace SubscriptionItem {
interface BillingThresholds {
/**
* Usage threshold that triggers the subscription to advance to a new billing period
*/
usage_gte: number;
}
interface PriceData {
/**
* Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
*/
currency: string;
/**
* The ID of the product that this price will belong to.
*/
product: string;
/**
* The recurring components of a price such as `interval` and `usage_type`.
*/
recurring: PriceData.Recurring;
/**
* Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
*/
tax_behavior?: PriceData.TaxBehavior;
/**
* A positive integer in %s (or 0 for a free price) representing how much to charge.
*/
unit_amount?: number;
/**
* Same as `unit_amount`, but accepts a decimal value in %s with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
*/
unit_amount_decimal?: string;
}
namespace PriceData {
interface Recurring {
/**
* Specifies billing frequency. Either `day`, `week`, `month` or `year`.
*/
interval: Recurring.Interval;
/**
* The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
*/
interval_count?: number;
}
namespace Recurring {
type Interval = 'day' | 'month' | 'week' | 'year';
}
type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified';
}
}
type SubscriptionProrationBehavior =
| 'always_invoice'
| 'create_prorations'
| 'none';
}
}
}