orb-billing 4.71.6 → 4.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/index.d.mts +3 -0
  3. package/index.d.ts +3 -0
  4. package/index.d.ts.map +1 -1
  5. package/index.js +3 -0
  6. package/index.js.map +1 -1
  7. package/index.mjs +3 -0
  8. package/index.mjs.map +1 -1
  9. package/package.json +1 -1
  10. package/resources/index.d.ts +1 -0
  11. package/resources/index.d.ts.map +1 -1
  12. package/resources/index.js +3 -1
  13. package/resources/index.js.map +1 -1
  14. package/resources/index.mjs +1 -0
  15. package/resources/index.mjs.map +1 -1
  16. package/resources/invoices.d.ts +3 -2
  17. package/resources/invoices.d.ts.map +1 -1
  18. package/resources/invoices.js.map +1 -1
  19. package/resources/invoices.mjs.map +1 -1
  20. package/resources/plans/plans.d.ts +4 -4
  21. package/resources/prices/prices.d.ts +8 -8
  22. package/resources/subscription-changes.d.ts +1707 -0
  23. package/resources/subscription-changes.d.ts.map +1 -0
  24. package/resources/subscription-changes.js +38 -0
  25. package/resources/subscription-changes.js.map +1 -0
  26. package/resources/subscription-changes.mjs +34 -0
  27. package/resources/subscription-changes.mjs.map +1 -0
  28. package/resources/subscriptions.d.ts +422 -20
  29. package/resources/subscriptions.d.ts.map +1 -1
  30. package/resources/subscriptions.js.map +1 -1
  31. package/resources/subscriptions.mjs.map +1 -1
  32. package/src/index.ts +17 -0
  33. package/src/resources/index.ts +7 -0
  34. package/src/resources/invoices.ts +3 -2
  35. package/src/resources/plans/plans.ts +4 -4
  36. package/src/resources/prices/prices.ts +8 -8
  37. package/src/resources/subscription-changes.ts +2167 -0
  38. package/src/resources/subscriptions.ts +494 -20
  39. package/src/version.ts +1 -1
  40. package/version.d.ts +1 -1
  41. package/version.js +1 -1
  42. package/version.mjs +1 -1
@@ -0,0 +1,2167 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../resource';
4
+ import { isRequestOptions } from '../core';
5
+ import * as Core from '../core';
6
+ import * as CreditNotesAPI from './credit-notes';
7
+ import * as InvoicesAPI from './invoices';
8
+ import * as CustomersAPI from './customers/customers';
9
+ import * as PlansAPI from './plans/plans';
10
+ import * as PricesAPI from './prices/prices';
11
+
12
+ export class SubscriptionChanges extends APIResource {
13
+ /**
14
+ * This endpoint returns a subscription change given an identifier.
15
+ *
16
+ * A subscription change is created by including
17
+ * `Create-Pending-Subscription-Change: True` in the header of a subscription
18
+ * mutation API call (e.g.
19
+ * [create subscription endpoint](/api-reference/subscription/create-subscription),
20
+ * [schedule plan change endpoint](/api-reference/subscription/schedule-plan-change),
21
+ * ...). The subscription change will be referenced by the
22
+ * `pending_subscription_change` field in the response.
23
+ */
24
+ retrieve(
25
+ subscriptionChangeId: string,
26
+ options?: Core.RequestOptions,
27
+ ): Core.APIPromise<SubscriptionChangeRetrieveResponse> {
28
+ return this._client.get(`/subscription_changes/${subscriptionChangeId}`, options);
29
+ }
30
+
31
+ /**
32
+ * Apply a subscription change to perform the intended action. If a positive amount
33
+ * is passed with a request to this endpoint, any eligible invoices that were
34
+ * created will be issued immediately if they only contain in-advance fees.
35
+ */
36
+ apply(
37
+ subscriptionChangeId: string,
38
+ body?: SubscriptionChangeApplyParams,
39
+ options?: Core.RequestOptions,
40
+ ): Core.APIPromise<SubscriptionChangeApplyResponse>;
41
+ apply(
42
+ subscriptionChangeId: string,
43
+ options?: Core.RequestOptions,
44
+ ): Core.APIPromise<SubscriptionChangeApplyResponse>;
45
+ apply(
46
+ subscriptionChangeId: string,
47
+ body: SubscriptionChangeApplyParams | Core.RequestOptions = {},
48
+ options?: Core.RequestOptions,
49
+ ): Core.APIPromise<SubscriptionChangeApplyResponse> {
50
+ if (isRequestOptions(body)) {
51
+ return this.apply(subscriptionChangeId, {}, body);
52
+ }
53
+ return this._client.post(`/subscription_changes/${subscriptionChangeId}/apply`, { body, ...options });
54
+ }
55
+
56
+ /**
57
+ * Cancel a subscription change. The change can no longer be applied. A
58
+ * subscription can only have one "pending" change at a time - use this endpoint to
59
+ * cancel an existing change before creating a new one.
60
+ */
61
+ cancel(
62
+ subscriptionChangeId: string,
63
+ options?: Core.RequestOptions,
64
+ ): Core.APIPromise<SubscriptionChangeCancelResponse> {
65
+ return this._client.post(`/subscription_changes/${subscriptionChangeId}/cancel`, options);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * A subscription change represents a desired new subscription / pending change to
71
+ * an existing subscription. It is a way to first preview the effects on the
72
+ * subscription as well as any changes/creation of invoices (see
73
+ * `subscription.changed_resources`).
74
+ */
75
+ export interface SubscriptionChangeRetrieveResponse {
76
+ id: string;
77
+
78
+ /**
79
+ * Subscription change will be cancelled at this time and can no longer be applied.
80
+ */
81
+ expiration_time: string;
82
+
83
+ status: 'pending' | 'applied' | 'cancelled';
84
+
85
+ subscription: SubscriptionChangeRetrieveResponse.Subscription | null;
86
+
87
+ /**
88
+ * When this change was applied.
89
+ */
90
+ applied_at?: string | null;
91
+
92
+ /**
93
+ * When this change was cancelled.
94
+ */
95
+ cancelled_at?: string | null;
96
+ }
97
+
98
+ export namespace SubscriptionChangeRetrieveResponse {
99
+ export interface Subscription {
100
+ id: string;
101
+
102
+ /**
103
+ * The current plan phase that is active, only if the subscription's plan has
104
+ * phases.
105
+ */
106
+ active_plan_phase_order: number | null;
107
+
108
+ /**
109
+ * The adjustment intervals for this subscription sorted by the start_date of the
110
+ * adjustment interval.
111
+ */
112
+ adjustment_intervals: Array<Subscription.AdjustmentInterval>;
113
+
114
+ /**
115
+ * Determines whether issued invoices for this subscription will automatically be
116
+ * charged with the saved payment method on the due date. This property defaults to
117
+ * the plan's behavior. If null, defaults to the customer's setting.
118
+ */
119
+ auto_collection: boolean | null;
120
+
121
+ billing_cycle_anchor_configuration: Subscription.BillingCycleAnchorConfiguration;
122
+
123
+ /**
124
+ * The day of the month on which the billing cycle is anchored. If the maximum
125
+ * number of days in a month is greater than this value, the last day of the month
126
+ * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing
127
+ * period begins on the 30th.
128
+ */
129
+ billing_cycle_day: number;
130
+
131
+ created_at: string;
132
+
133
+ /**
134
+ * The end of the current billing period. This is an exclusive timestamp, such that
135
+ * the instant returned is not part of the billing period. Set to null for
136
+ * subscriptions that are not currently active.
137
+ */
138
+ current_billing_period_end_date: string | null;
139
+
140
+ /**
141
+ * The start date of the current billing period. This is an inclusive timestamp;
142
+ * the instant returned is exactly the beginning of the billing period. Set to null
143
+ * if the subscription is not currently active.
144
+ */
145
+ current_billing_period_start_date: string | null;
146
+
147
+ /**
148
+ * A customer is a buyer of your products, and the other party to the billing
149
+ * relationship.
150
+ *
151
+ * In Orb, customers are assigned system generated identifiers automatically, but
152
+ * it's often desirable to have these match existing identifiers in your system. To
153
+ * avoid having to denormalize Orb ID information, you can pass in an
154
+ * `external_customer_id` with your own identifier. See
155
+ * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further
156
+ * information about how these aliases work in Orb.
157
+ *
158
+ * In addition to having an identifier in your system, a customer may exist in a
159
+ * payment provider solution like Stripe. Use the `payment_provider_id` and the
160
+ * `payment_provider` enum field to express this mapping.
161
+ *
162
+ * A customer also has a timezone (from the standard
163
+ * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to
164
+ * your account's timezone. See [Timezone localization](/essentials/timezones) for
165
+ * information on what this timezone parameter influences within Orb.
166
+ */
167
+ customer: CustomersAPI.Customer;
168
+
169
+ /**
170
+ * Determines the default memo on this subscriptions' invoices. Note that if this
171
+ * is not provided, it is determined by the plan configuration.
172
+ */
173
+ default_invoice_memo: string | null;
174
+
175
+ /**
176
+ * The discount intervals for this subscription sorted by the start_date.
177
+ */
178
+ discount_intervals: Array<
179
+ | Subscription.AmountDiscountInterval
180
+ | Subscription.PercentageDiscountInterval
181
+ | Subscription.UsageDiscountInterval
182
+ >;
183
+
184
+ /**
185
+ * The date Orb stops billing for this subscription.
186
+ */
187
+ end_date: string | null;
188
+
189
+ fixed_fee_quantity_schedule: Array<Subscription.FixedFeeQuantitySchedule>;
190
+
191
+ invoicing_threshold: string | null;
192
+
193
+ /**
194
+ * The maximum intervals for this subscription sorted by the start_date.
195
+ */
196
+ maximum_intervals: Array<Subscription.MaximumInterval>;
197
+
198
+ /**
199
+ * User specified key-value pairs for the resource. If not present, this defaults
200
+ * to an empty dictionary. Individual keys can be removed by setting the value to
201
+ * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
202
+ * `null`.
203
+ */
204
+ metadata: Record<string, string>;
205
+
206
+ /**
207
+ * The minimum intervals for this subscription sorted by the start_date.
208
+ */
209
+ minimum_intervals: Array<Subscription.MinimumInterval>;
210
+
211
+ /**
212
+ * Determines the difference between the invoice issue date for subscription
213
+ * invoices as the date that they are due. A value of `0` here represents that the
214
+ * invoice is due on issue, whereas a value of `30` represents that the customer
215
+ * has a month to pay the invoice.
216
+ */
217
+ net_terms: number;
218
+
219
+ /**
220
+ * A pending subscription change if one exists on this subscription.
221
+ */
222
+ pending_subscription_change: Subscription.PendingSubscriptionChange | null;
223
+
224
+ /**
225
+ * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be
226
+ * subscribed to by a customer. Plans define the billing behavior of the
227
+ * subscription. You can see more about how to configure prices in the
228
+ * [Price resource](/reference/price).
229
+ */
230
+ plan: PlansAPI.Plan;
231
+
232
+ /**
233
+ * The price intervals for this subscription.
234
+ */
235
+ price_intervals: Array<Subscription.PriceInterval>;
236
+
237
+ redeemed_coupon: Subscription.RedeemedCoupon | null;
238
+
239
+ /**
240
+ * The date Orb starts billing for this subscription.
241
+ */
242
+ start_date: string;
243
+
244
+ status: 'active' | 'ended' | 'upcoming';
245
+
246
+ trial_info: Subscription.TrialInfo;
247
+
248
+ /**
249
+ * The resources that were changed as part of this operation. Only present when
250
+ * fetched through the subscription changes API or if the
251
+ * `include_changed_resources` parameter was passed in the request.
252
+ */
253
+ changed_resources?: Subscription.ChangedResources | null;
254
+ }
255
+
256
+ export namespace Subscription {
257
+ export interface AdjustmentInterval {
258
+ id: string;
259
+
260
+ adjustment:
261
+ | AdjustmentInterval.PlanPhaseUsageDiscountAdjustment
262
+ | AdjustmentInterval.PlanPhaseAmountDiscountAdjustment
263
+ | AdjustmentInterval.PlanPhasePercentageDiscountAdjustment
264
+ | AdjustmentInterval.PlanPhaseMinimumAdjustment
265
+ | AdjustmentInterval.PlanPhaseMaximumAdjustment;
266
+
267
+ /**
268
+ * The price interval IDs that this adjustment applies to.
269
+ */
270
+ applies_to_price_interval_ids: Array<string>;
271
+
272
+ /**
273
+ * The end date of the adjustment interval.
274
+ */
275
+ end_date: string | null;
276
+
277
+ /**
278
+ * The start date of the adjustment interval.
279
+ */
280
+ start_date: string;
281
+ }
282
+
283
+ export namespace AdjustmentInterval {
284
+ export interface PlanPhaseUsageDiscountAdjustment {
285
+ id: string;
286
+
287
+ adjustment_type: 'usage_discount';
288
+
289
+ /**
290
+ * The price IDs that this adjustment applies to.
291
+ */
292
+ applies_to_price_ids: Array<string>;
293
+
294
+ /**
295
+ * True for adjustments that apply to an entire invocice, false for adjustments
296
+ * that apply to only one price.
297
+ */
298
+ is_invoice_level: boolean;
299
+
300
+ /**
301
+ * The plan phase in which this adjustment is active.
302
+ */
303
+ plan_phase_order: number | null;
304
+
305
+ /**
306
+ * The reason for the adjustment.
307
+ */
308
+ reason: string | null;
309
+
310
+ /**
311
+ * The number of usage units by which to discount the price this adjustment applies
312
+ * to in a given billing period.
313
+ */
314
+ usage_discount: number;
315
+ }
316
+
317
+ export interface PlanPhaseAmountDiscountAdjustment {
318
+ id: string;
319
+
320
+ adjustment_type: 'amount_discount';
321
+
322
+ /**
323
+ * The amount by which to discount the prices this adjustment applies to in a given
324
+ * billing period.
325
+ */
326
+ amount_discount: string;
327
+
328
+ /**
329
+ * The price IDs that this adjustment applies to.
330
+ */
331
+ applies_to_price_ids: Array<string>;
332
+
333
+ /**
334
+ * True for adjustments that apply to an entire invocice, false for adjustments
335
+ * that apply to only one price.
336
+ */
337
+ is_invoice_level: boolean;
338
+
339
+ /**
340
+ * The plan phase in which this adjustment is active.
341
+ */
342
+ plan_phase_order: number | null;
343
+
344
+ /**
345
+ * The reason for the adjustment.
346
+ */
347
+ reason: string | null;
348
+ }
349
+
350
+ export interface PlanPhasePercentageDiscountAdjustment {
351
+ id: string;
352
+
353
+ adjustment_type: 'percentage_discount';
354
+
355
+ /**
356
+ * The price IDs that this adjustment applies to.
357
+ */
358
+ applies_to_price_ids: Array<string>;
359
+
360
+ /**
361
+ * True for adjustments that apply to an entire invocice, false for adjustments
362
+ * that apply to only one price.
363
+ */
364
+ is_invoice_level: boolean;
365
+
366
+ /**
367
+ * The percentage (as a value between 0 and 1) by which to discount the price
368
+ * intervals this adjustment applies to in a given billing period.
369
+ */
370
+ percentage_discount: number;
371
+
372
+ /**
373
+ * The plan phase in which this adjustment is active.
374
+ */
375
+ plan_phase_order: number | null;
376
+
377
+ /**
378
+ * The reason for the adjustment.
379
+ */
380
+ reason: string | null;
381
+ }
382
+
383
+ export interface PlanPhaseMinimumAdjustment {
384
+ id: string;
385
+
386
+ adjustment_type: 'minimum';
387
+
388
+ /**
389
+ * The price IDs that this adjustment applies to.
390
+ */
391
+ applies_to_price_ids: Array<string>;
392
+
393
+ /**
394
+ * True for adjustments that apply to an entire invocice, false for adjustments
395
+ * that apply to only one price.
396
+ */
397
+ is_invoice_level: boolean;
398
+
399
+ /**
400
+ * The item ID that revenue from this minimum will be attributed to.
401
+ */
402
+ item_id: string;
403
+
404
+ /**
405
+ * The minimum amount to charge in a given billing period for the prices this
406
+ * adjustment applies to.
407
+ */
408
+ minimum_amount: string;
409
+
410
+ /**
411
+ * The plan phase in which this adjustment is active.
412
+ */
413
+ plan_phase_order: number | null;
414
+
415
+ /**
416
+ * The reason for the adjustment.
417
+ */
418
+ reason: string | null;
419
+ }
420
+
421
+ export interface PlanPhaseMaximumAdjustment {
422
+ id: string;
423
+
424
+ adjustment_type: 'maximum';
425
+
426
+ /**
427
+ * The price IDs that this adjustment applies to.
428
+ */
429
+ applies_to_price_ids: Array<string>;
430
+
431
+ /**
432
+ * True for adjustments that apply to an entire invocice, false for adjustments
433
+ * that apply to only one price.
434
+ */
435
+ is_invoice_level: boolean;
436
+
437
+ /**
438
+ * The maximum amount to charge in a given billing period for the prices this
439
+ * adjustment applies to.
440
+ */
441
+ maximum_amount: string;
442
+
443
+ /**
444
+ * The plan phase in which this adjustment is active.
445
+ */
446
+ plan_phase_order: number | null;
447
+
448
+ /**
449
+ * The reason for the adjustment.
450
+ */
451
+ reason: string | null;
452
+ }
453
+ }
454
+
455
+ export interface BillingCycleAnchorConfiguration {
456
+ /**
457
+ * The day of the month on which the billing cycle is anchored. If the maximum
458
+ * number of days in a month is greater than this value, the last day of the month
459
+ * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing
460
+ * period begins on the 30th.
461
+ */
462
+ day: number;
463
+
464
+ /**
465
+ * The month on which the billing cycle is anchored (e.g. a quarterly price
466
+ * anchored in February would have cycles starting February, May, August, and
467
+ * November).
468
+ */
469
+ month?: number | null;
470
+
471
+ /**
472
+ * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle
473
+ * anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.).
474
+ */
475
+ year?: number | null;
476
+ }
477
+
478
+ export interface AmountDiscountInterval {
479
+ /**
480
+ * Only available if discount_type is `amount`.
481
+ */
482
+ amount_discount: string;
483
+
484
+ /**
485
+ * The price ids that this discount interval applies to.
486
+ */
487
+ applies_to_price_ids: Array<string>;
488
+
489
+ /**
490
+ * The price interval ids that this discount interval applies to.
491
+ */
492
+ applies_to_price_interval_ids: Array<string>;
493
+
494
+ discount_type: 'amount';
495
+
496
+ /**
497
+ * The end date of the discount interval.
498
+ */
499
+ end_date: string | null;
500
+
501
+ /**
502
+ * The start date of the discount interval.
503
+ */
504
+ start_date: string;
505
+ }
506
+
507
+ export interface PercentageDiscountInterval {
508
+ /**
509
+ * The price ids that this discount interval applies to.
510
+ */
511
+ applies_to_price_ids: Array<string>;
512
+
513
+ /**
514
+ * The price interval ids that this discount interval applies to.
515
+ */
516
+ applies_to_price_interval_ids: Array<string>;
517
+
518
+ discount_type: 'percentage';
519
+
520
+ /**
521
+ * The end date of the discount interval.
522
+ */
523
+ end_date: string | null;
524
+
525
+ /**
526
+ * Only available if discount_type is `percentage`.This is a number between 0
527
+ * and 1.
528
+ */
529
+ percentage_discount: number;
530
+
531
+ /**
532
+ * The start date of the discount interval.
533
+ */
534
+ start_date: string;
535
+ }
536
+
537
+ export interface UsageDiscountInterval {
538
+ /**
539
+ * The price ids that this discount interval applies to.
540
+ */
541
+ applies_to_price_ids: Array<string>;
542
+
543
+ /**
544
+ * The price interval ids that this discount interval applies to.
545
+ */
546
+ applies_to_price_interval_ids: Array<string>;
547
+
548
+ discount_type: 'usage';
549
+
550
+ /**
551
+ * The end date of the discount interval.
552
+ */
553
+ end_date: string | null;
554
+
555
+ /**
556
+ * The start date of the discount interval.
557
+ */
558
+ start_date: string;
559
+
560
+ /**
561
+ * Only available if discount_type is `usage`. Number of usage units that this
562
+ * discount is for
563
+ */
564
+ usage_discount: number;
565
+ }
566
+
567
+ export interface FixedFeeQuantitySchedule {
568
+ end_date: string | null;
569
+
570
+ price_id: string;
571
+
572
+ quantity: number;
573
+
574
+ start_date: string;
575
+ }
576
+
577
+ export interface MaximumInterval {
578
+ /**
579
+ * The price ids that this maximum interval applies to.
580
+ */
581
+ applies_to_price_ids: Array<string>;
582
+
583
+ /**
584
+ * The price interval ids that this maximum interval applies to.
585
+ */
586
+ applies_to_price_interval_ids: Array<string>;
587
+
588
+ /**
589
+ * The end date of the maximum interval.
590
+ */
591
+ end_date: string | null;
592
+
593
+ /**
594
+ * The maximum amount to charge in a given billing period for the price intervals
595
+ * this transform applies to.
596
+ */
597
+ maximum_amount: string;
598
+
599
+ /**
600
+ * The start date of the maximum interval.
601
+ */
602
+ start_date: string;
603
+ }
604
+
605
+ export interface MinimumInterval {
606
+ /**
607
+ * The price ids that this minimum interval applies to.
608
+ */
609
+ applies_to_price_ids: Array<string>;
610
+
611
+ /**
612
+ * The price interval ids that this minimum interval applies to.
613
+ */
614
+ applies_to_price_interval_ids: Array<string>;
615
+
616
+ /**
617
+ * The end date of the minimum interval.
618
+ */
619
+ end_date: string | null;
620
+
621
+ /**
622
+ * The minimum amount to charge in a given billing period for the price intervals
623
+ * this minimum applies to.
624
+ */
625
+ minimum_amount: string;
626
+
627
+ /**
628
+ * The start date of the minimum interval.
629
+ */
630
+ start_date: string;
631
+ }
632
+
633
+ /**
634
+ * A pending subscription change if one exists on this subscription.
635
+ */
636
+ export interface PendingSubscriptionChange {
637
+ id: string;
638
+ }
639
+
640
+ /**
641
+ * The Price Interval resource represents a period of time for which a price will
642
+ * bill on a subscription. A subscription’s price intervals define its billing
643
+ * behavior.
644
+ */
645
+ export interface PriceInterval {
646
+ id: string;
647
+
648
+ /**
649
+ * The day of the month that Orb bills for this price
650
+ */
651
+ billing_cycle_day: number;
652
+
653
+ /**
654
+ * The end of the current billing period. This is an exclusive timestamp, such that
655
+ * the instant returned is exactly the end of the billing period. Set to null if
656
+ * this price interval is not currently active.
657
+ */
658
+ current_billing_period_end_date: string | null;
659
+
660
+ /**
661
+ * The start date of the current billing period. This is an inclusive timestamp;
662
+ * the instant returned is exactly the beginning of the billing period. Set to null
663
+ * if this price interval is not currently active.
664
+ */
665
+ current_billing_period_start_date: string | null;
666
+
667
+ /**
668
+ * The end date of the price interval. This is the date that Orb stops billing for
669
+ * this price.
670
+ */
671
+ end_date: string | null;
672
+
673
+ /**
674
+ * An additional filter to apply to usage queries.
675
+ */
676
+ filter: string | null;
677
+
678
+ /**
679
+ * The fixed fee quantity transitions for this price interval. This is only
680
+ * relevant for fixed fees.
681
+ */
682
+ fixed_fee_quantity_transitions: Array<PriceInterval.FixedFeeQuantityTransition> | null;
683
+
684
+ /**
685
+ * The Price resource represents a price that can be billed on a subscription,
686
+ * resulting in a charge on an invoice in the form of an invoice line item. Prices
687
+ * take a quantity and determine an amount to bill.
688
+ *
689
+ * Orb supports a few different pricing models out of the box. Each of these models
690
+ * is serialized differently in a given Price object. The model_type field
691
+ * determines the key for the configuration object that is present.
692
+ *
693
+ * For more on the types of prices, see
694
+ * [the core concepts documentation](/core-concepts#plan-and-price)
695
+ */
696
+ price: PricesAPI.Price;
697
+
698
+ /**
699
+ * The start date of the price interval. This is the date that Orb starts billing
700
+ * for this price.
701
+ */
702
+ start_date: string;
703
+
704
+ /**
705
+ * A list of customer IDs whose usage events will be aggregated and billed under
706
+ * this price interval.
707
+ */
708
+ usage_customer_ids: Array<string> | null;
709
+ }
710
+
711
+ export namespace PriceInterval {
712
+ export interface FixedFeeQuantityTransition {
713
+ effective_date: string;
714
+
715
+ price_id: string;
716
+
717
+ quantity: number;
718
+ }
719
+ }
720
+
721
+ export interface RedeemedCoupon {
722
+ coupon_id: string;
723
+
724
+ end_date: string | null;
725
+
726
+ start_date: string;
727
+ }
728
+
729
+ export interface TrialInfo {
730
+ end_date: string | null;
731
+ }
732
+
733
+ /**
734
+ * The resources that were changed as part of this operation. Only present when
735
+ * fetched through the subscription changes API or if the
736
+ * `include_changed_resources` parameter was passed in the request.
737
+ */
738
+ export interface ChangedResources {
739
+ /**
740
+ * The credit notes that were created as part of this operation.
741
+ */
742
+ created_credit_notes: Array<CreditNotesAPI.CreditNote>;
743
+
744
+ /**
745
+ * The invoices that were created as part of this operation.
746
+ */
747
+ created_invoices: Array<InvoicesAPI.Invoice>;
748
+
749
+ /**
750
+ * The credit notes that were voided as part of this operation.
751
+ */
752
+ voided_credit_notes: Array<CreditNotesAPI.CreditNote>;
753
+
754
+ /**
755
+ * The invoices that were voided as part of this operation.
756
+ */
757
+ voided_invoices: Array<InvoicesAPI.Invoice>;
758
+ }
759
+ }
760
+ }
761
+
762
+ /**
763
+ * A subscription change represents a desired new subscription / pending change to
764
+ * an existing subscription. It is a way to first preview the effects on the
765
+ * subscription as well as any changes/creation of invoices (see
766
+ * `subscription.changed_resources`).
767
+ */
768
+ export interface SubscriptionChangeApplyResponse {
769
+ id: string;
770
+
771
+ /**
772
+ * Subscription change will be cancelled at this time and can no longer be applied.
773
+ */
774
+ expiration_time: string;
775
+
776
+ status: 'pending' | 'applied' | 'cancelled';
777
+
778
+ subscription: SubscriptionChangeApplyResponse.Subscription | null;
779
+
780
+ /**
781
+ * When this change was applied.
782
+ */
783
+ applied_at?: string | null;
784
+
785
+ /**
786
+ * When this change was cancelled.
787
+ */
788
+ cancelled_at?: string | null;
789
+ }
790
+
791
+ export namespace SubscriptionChangeApplyResponse {
792
+ export interface Subscription {
793
+ id: string;
794
+
795
+ /**
796
+ * The current plan phase that is active, only if the subscription's plan has
797
+ * phases.
798
+ */
799
+ active_plan_phase_order: number | null;
800
+
801
+ /**
802
+ * The adjustment intervals for this subscription sorted by the start_date of the
803
+ * adjustment interval.
804
+ */
805
+ adjustment_intervals: Array<Subscription.AdjustmentInterval>;
806
+
807
+ /**
808
+ * Determines whether issued invoices for this subscription will automatically be
809
+ * charged with the saved payment method on the due date. This property defaults to
810
+ * the plan's behavior. If null, defaults to the customer's setting.
811
+ */
812
+ auto_collection: boolean | null;
813
+
814
+ billing_cycle_anchor_configuration: Subscription.BillingCycleAnchorConfiguration;
815
+
816
+ /**
817
+ * The day of the month on which the billing cycle is anchored. If the maximum
818
+ * number of days in a month is greater than this value, the last day of the month
819
+ * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing
820
+ * period begins on the 30th.
821
+ */
822
+ billing_cycle_day: number;
823
+
824
+ created_at: string;
825
+
826
+ /**
827
+ * The end of the current billing period. This is an exclusive timestamp, such that
828
+ * the instant returned is not part of the billing period. Set to null for
829
+ * subscriptions that are not currently active.
830
+ */
831
+ current_billing_period_end_date: string | null;
832
+
833
+ /**
834
+ * The start date of the current billing period. This is an inclusive timestamp;
835
+ * the instant returned is exactly the beginning of the billing period. Set to null
836
+ * if the subscription is not currently active.
837
+ */
838
+ current_billing_period_start_date: string | null;
839
+
840
+ /**
841
+ * A customer is a buyer of your products, and the other party to the billing
842
+ * relationship.
843
+ *
844
+ * In Orb, customers are assigned system generated identifiers automatically, but
845
+ * it's often desirable to have these match existing identifiers in your system. To
846
+ * avoid having to denormalize Orb ID information, you can pass in an
847
+ * `external_customer_id` with your own identifier. See
848
+ * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further
849
+ * information about how these aliases work in Orb.
850
+ *
851
+ * In addition to having an identifier in your system, a customer may exist in a
852
+ * payment provider solution like Stripe. Use the `payment_provider_id` and the
853
+ * `payment_provider` enum field to express this mapping.
854
+ *
855
+ * A customer also has a timezone (from the standard
856
+ * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to
857
+ * your account's timezone. See [Timezone localization](/essentials/timezones) for
858
+ * information on what this timezone parameter influences within Orb.
859
+ */
860
+ customer: CustomersAPI.Customer;
861
+
862
+ /**
863
+ * Determines the default memo on this subscriptions' invoices. Note that if this
864
+ * is not provided, it is determined by the plan configuration.
865
+ */
866
+ default_invoice_memo: string | null;
867
+
868
+ /**
869
+ * The discount intervals for this subscription sorted by the start_date.
870
+ */
871
+ discount_intervals: Array<
872
+ | Subscription.AmountDiscountInterval
873
+ | Subscription.PercentageDiscountInterval
874
+ | Subscription.UsageDiscountInterval
875
+ >;
876
+
877
+ /**
878
+ * The date Orb stops billing for this subscription.
879
+ */
880
+ end_date: string | null;
881
+
882
+ fixed_fee_quantity_schedule: Array<Subscription.FixedFeeQuantitySchedule>;
883
+
884
+ invoicing_threshold: string | null;
885
+
886
+ /**
887
+ * The maximum intervals for this subscription sorted by the start_date.
888
+ */
889
+ maximum_intervals: Array<Subscription.MaximumInterval>;
890
+
891
+ /**
892
+ * User specified key-value pairs for the resource. If not present, this defaults
893
+ * to an empty dictionary. Individual keys can be removed by setting the value to
894
+ * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
895
+ * `null`.
896
+ */
897
+ metadata: Record<string, string>;
898
+
899
+ /**
900
+ * The minimum intervals for this subscription sorted by the start_date.
901
+ */
902
+ minimum_intervals: Array<Subscription.MinimumInterval>;
903
+
904
+ /**
905
+ * Determines the difference between the invoice issue date for subscription
906
+ * invoices as the date that they are due. A value of `0` here represents that the
907
+ * invoice is due on issue, whereas a value of `30` represents that the customer
908
+ * has a month to pay the invoice.
909
+ */
910
+ net_terms: number;
911
+
912
+ /**
913
+ * A pending subscription change if one exists on this subscription.
914
+ */
915
+ pending_subscription_change: Subscription.PendingSubscriptionChange | null;
916
+
917
+ /**
918
+ * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be
919
+ * subscribed to by a customer. Plans define the billing behavior of the
920
+ * subscription. You can see more about how to configure prices in the
921
+ * [Price resource](/reference/price).
922
+ */
923
+ plan: PlansAPI.Plan;
924
+
925
+ /**
926
+ * The price intervals for this subscription.
927
+ */
928
+ price_intervals: Array<Subscription.PriceInterval>;
929
+
930
+ redeemed_coupon: Subscription.RedeemedCoupon | null;
931
+
932
+ /**
933
+ * The date Orb starts billing for this subscription.
934
+ */
935
+ start_date: string;
936
+
937
+ status: 'active' | 'ended' | 'upcoming';
938
+
939
+ trial_info: Subscription.TrialInfo;
940
+
941
+ /**
942
+ * The resources that were changed as part of this operation. Only present when
943
+ * fetched through the subscription changes API or if the
944
+ * `include_changed_resources` parameter was passed in the request.
945
+ */
946
+ changed_resources?: Subscription.ChangedResources | null;
947
+ }
948
+
949
+ export namespace Subscription {
950
+ export interface AdjustmentInterval {
951
+ id: string;
952
+
953
+ adjustment:
954
+ | AdjustmentInterval.PlanPhaseUsageDiscountAdjustment
955
+ | AdjustmentInterval.PlanPhaseAmountDiscountAdjustment
956
+ | AdjustmentInterval.PlanPhasePercentageDiscountAdjustment
957
+ | AdjustmentInterval.PlanPhaseMinimumAdjustment
958
+ | AdjustmentInterval.PlanPhaseMaximumAdjustment;
959
+
960
+ /**
961
+ * The price interval IDs that this adjustment applies to.
962
+ */
963
+ applies_to_price_interval_ids: Array<string>;
964
+
965
+ /**
966
+ * The end date of the adjustment interval.
967
+ */
968
+ end_date: string | null;
969
+
970
+ /**
971
+ * The start date of the adjustment interval.
972
+ */
973
+ start_date: string;
974
+ }
975
+
976
+ export namespace AdjustmentInterval {
977
+ export interface PlanPhaseUsageDiscountAdjustment {
978
+ id: string;
979
+
980
+ adjustment_type: 'usage_discount';
981
+
982
+ /**
983
+ * The price IDs that this adjustment applies to.
984
+ */
985
+ applies_to_price_ids: Array<string>;
986
+
987
+ /**
988
+ * True for adjustments that apply to an entire invocice, false for adjustments
989
+ * that apply to only one price.
990
+ */
991
+ is_invoice_level: boolean;
992
+
993
+ /**
994
+ * The plan phase in which this adjustment is active.
995
+ */
996
+ plan_phase_order: number | null;
997
+
998
+ /**
999
+ * The reason for the adjustment.
1000
+ */
1001
+ reason: string | null;
1002
+
1003
+ /**
1004
+ * The number of usage units by which to discount the price this adjustment applies
1005
+ * to in a given billing period.
1006
+ */
1007
+ usage_discount: number;
1008
+ }
1009
+
1010
+ export interface PlanPhaseAmountDiscountAdjustment {
1011
+ id: string;
1012
+
1013
+ adjustment_type: 'amount_discount';
1014
+
1015
+ /**
1016
+ * The amount by which to discount the prices this adjustment applies to in a given
1017
+ * billing period.
1018
+ */
1019
+ amount_discount: string;
1020
+
1021
+ /**
1022
+ * The price IDs that this adjustment applies to.
1023
+ */
1024
+ applies_to_price_ids: Array<string>;
1025
+
1026
+ /**
1027
+ * True for adjustments that apply to an entire invocice, false for adjustments
1028
+ * that apply to only one price.
1029
+ */
1030
+ is_invoice_level: boolean;
1031
+
1032
+ /**
1033
+ * The plan phase in which this adjustment is active.
1034
+ */
1035
+ plan_phase_order: number | null;
1036
+
1037
+ /**
1038
+ * The reason for the adjustment.
1039
+ */
1040
+ reason: string | null;
1041
+ }
1042
+
1043
+ export interface PlanPhasePercentageDiscountAdjustment {
1044
+ id: string;
1045
+
1046
+ adjustment_type: 'percentage_discount';
1047
+
1048
+ /**
1049
+ * The price IDs that this adjustment applies to.
1050
+ */
1051
+ applies_to_price_ids: Array<string>;
1052
+
1053
+ /**
1054
+ * True for adjustments that apply to an entire invocice, false for adjustments
1055
+ * that apply to only one price.
1056
+ */
1057
+ is_invoice_level: boolean;
1058
+
1059
+ /**
1060
+ * The percentage (as a value between 0 and 1) by which to discount the price
1061
+ * intervals this adjustment applies to in a given billing period.
1062
+ */
1063
+ percentage_discount: number;
1064
+
1065
+ /**
1066
+ * The plan phase in which this adjustment is active.
1067
+ */
1068
+ plan_phase_order: number | null;
1069
+
1070
+ /**
1071
+ * The reason for the adjustment.
1072
+ */
1073
+ reason: string | null;
1074
+ }
1075
+
1076
+ export interface PlanPhaseMinimumAdjustment {
1077
+ id: string;
1078
+
1079
+ adjustment_type: 'minimum';
1080
+
1081
+ /**
1082
+ * The price IDs that this adjustment applies to.
1083
+ */
1084
+ applies_to_price_ids: Array<string>;
1085
+
1086
+ /**
1087
+ * True for adjustments that apply to an entire invocice, false for adjustments
1088
+ * that apply to only one price.
1089
+ */
1090
+ is_invoice_level: boolean;
1091
+
1092
+ /**
1093
+ * The item ID that revenue from this minimum will be attributed to.
1094
+ */
1095
+ item_id: string;
1096
+
1097
+ /**
1098
+ * The minimum amount to charge in a given billing period for the prices this
1099
+ * adjustment applies to.
1100
+ */
1101
+ minimum_amount: string;
1102
+
1103
+ /**
1104
+ * The plan phase in which this adjustment is active.
1105
+ */
1106
+ plan_phase_order: number | null;
1107
+
1108
+ /**
1109
+ * The reason for the adjustment.
1110
+ */
1111
+ reason: string | null;
1112
+ }
1113
+
1114
+ export interface PlanPhaseMaximumAdjustment {
1115
+ id: string;
1116
+
1117
+ adjustment_type: 'maximum';
1118
+
1119
+ /**
1120
+ * The price IDs that this adjustment applies to.
1121
+ */
1122
+ applies_to_price_ids: Array<string>;
1123
+
1124
+ /**
1125
+ * True for adjustments that apply to an entire invocice, false for adjustments
1126
+ * that apply to only one price.
1127
+ */
1128
+ is_invoice_level: boolean;
1129
+
1130
+ /**
1131
+ * The maximum amount to charge in a given billing period for the prices this
1132
+ * adjustment applies to.
1133
+ */
1134
+ maximum_amount: string;
1135
+
1136
+ /**
1137
+ * The plan phase in which this adjustment is active.
1138
+ */
1139
+ plan_phase_order: number | null;
1140
+
1141
+ /**
1142
+ * The reason for the adjustment.
1143
+ */
1144
+ reason: string | null;
1145
+ }
1146
+ }
1147
+
1148
+ export interface BillingCycleAnchorConfiguration {
1149
+ /**
1150
+ * The day of the month on which the billing cycle is anchored. If the maximum
1151
+ * number of days in a month is greater than this value, the last day of the month
1152
+ * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing
1153
+ * period begins on the 30th.
1154
+ */
1155
+ day: number;
1156
+
1157
+ /**
1158
+ * The month on which the billing cycle is anchored (e.g. a quarterly price
1159
+ * anchored in February would have cycles starting February, May, August, and
1160
+ * November).
1161
+ */
1162
+ month?: number | null;
1163
+
1164
+ /**
1165
+ * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle
1166
+ * anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.).
1167
+ */
1168
+ year?: number | null;
1169
+ }
1170
+
1171
+ export interface AmountDiscountInterval {
1172
+ /**
1173
+ * Only available if discount_type is `amount`.
1174
+ */
1175
+ amount_discount: string;
1176
+
1177
+ /**
1178
+ * The price ids that this discount interval applies to.
1179
+ */
1180
+ applies_to_price_ids: Array<string>;
1181
+
1182
+ /**
1183
+ * The price interval ids that this discount interval applies to.
1184
+ */
1185
+ applies_to_price_interval_ids: Array<string>;
1186
+
1187
+ discount_type: 'amount';
1188
+
1189
+ /**
1190
+ * The end date of the discount interval.
1191
+ */
1192
+ end_date: string | null;
1193
+
1194
+ /**
1195
+ * The start date of the discount interval.
1196
+ */
1197
+ start_date: string;
1198
+ }
1199
+
1200
+ export interface PercentageDiscountInterval {
1201
+ /**
1202
+ * The price ids that this discount interval applies to.
1203
+ */
1204
+ applies_to_price_ids: Array<string>;
1205
+
1206
+ /**
1207
+ * The price interval ids that this discount interval applies to.
1208
+ */
1209
+ applies_to_price_interval_ids: Array<string>;
1210
+
1211
+ discount_type: 'percentage';
1212
+
1213
+ /**
1214
+ * The end date of the discount interval.
1215
+ */
1216
+ end_date: string | null;
1217
+
1218
+ /**
1219
+ * Only available if discount_type is `percentage`.This is a number between 0
1220
+ * and 1.
1221
+ */
1222
+ percentage_discount: number;
1223
+
1224
+ /**
1225
+ * The start date of the discount interval.
1226
+ */
1227
+ start_date: string;
1228
+ }
1229
+
1230
+ export interface UsageDiscountInterval {
1231
+ /**
1232
+ * The price ids that this discount interval applies to.
1233
+ */
1234
+ applies_to_price_ids: Array<string>;
1235
+
1236
+ /**
1237
+ * The price interval ids that this discount interval applies to.
1238
+ */
1239
+ applies_to_price_interval_ids: Array<string>;
1240
+
1241
+ discount_type: 'usage';
1242
+
1243
+ /**
1244
+ * The end date of the discount interval.
1245
+ */
1246
+ end_date: string | null;
1247
+
1248
+ /**
1249
+ * The start date of the discount interval.
1250
+ */
1251
+ start_date: string;
1252
+
1253
+ /**
1254
+ * Only available if discount_type is `usage`. Number of usage units that this
1255
+ * discount is for
1256
+ */
1257
+ usage_discount: number;
1258
+ }
1259
+
1260
+ export interface FixedFeeQuantitySchedule {
1261
+ end_date: string | null;
1262
+
1263
+ price_id: string;
1264
+
1265
+ quantity: number;
1266
+
1267
+ start_date: string;
1268
+ }
1269
+
1270
+ export interface MaximumInterval {
1271
+ /**
1272
+ * The price ids that this maximum interval applies to.
1273
+ */
1274
+ applies_to_price_ids: Array<string>;
1275
+
1276
+ /**
1277
+ * The price interval ids that this maximum interval applies to.
1278
+ */
1279
+ applies_to_price_interval_ids: Array<string>;
1280
+
1281
+ /**
1282
+ * The end date of the maximum interval.
1283
+ */
1284
+ end_date: string | null;
1285
+
1286
+ /**
1287
+ * The maximum amount to charge in a given billing period for the price intervals
1288
+ * this transform applies to.
1289
+ */
1290
+ maximum_amount: string;
1291
+
1292
+ /**
1293
+ * The start date of the maximum interval.
1294
+ */
1295
+ start_date: string;
1296
+ }
1297
+
1298
+ export interface MinimumInterval {
1299
+ /**
1300
+ * The price ids that this minimum interval applies to.
1301
+ */
1302
+ applies_to_price_ids: Array<string>;
1303
+
1304
+ /**
1305
+ * The price interval ids that this minimum interval applies to.
1306
+ */
1307
+ applies_to_price_interval_ids: Array<string>;
1308
+
1309
+ /**
1310
+ * The end date of the minimum interval.
1311
+ */
1312
+ end_date: string | null;
1313
+
1314
+ /**
1315
+ * The minimum amount to charge in a given billing period for the price intervals
1316
+ * this minimum applies to.
1317
+ */
1318
+ minimum_amount: string;
1319
+
1320
+ /**
1321
+ * The start date of the minimum interval.
1322
+ */
1323
+ start_date: string;
1324
+ }
1325
+
1326
+ /**
1327
+ * A pending subscription change if one exists on this subscription.
1328
+ */
1329
+ export interface PendingSubscriptionChange {
1330
+ id: string;
1331
+ }
1332
+
1333
+ /**
1334
+ * The Price Interval resource represents a period of time for which a price will
1335
+ * bill on a subscription. A subscription’s price intervals define its billing
1336
+ * behavior.
1337
+ */
1338
+ export interface PriceInterval {
1339
+ id: string;
1340
+
1341
+ /**
1342
+ * The day of the month that Orb bills for this price
1343
+ */
1344
+ billing_cycle_day: number;
1345
+
1346
+ /**
1347
+ * The end of the current billing period. This is an exclusive timestamp, such that
1348
+ * the instant returned is exactly the end of the billing period. Set to null if
1349
+ * this price interval is not currently active.
1350
+ */
1351
+ current_billing_period_end_date: string | null;
1352
+
1353
+ /**
1354
+ * The start date of the current billing period. This is an inclusive timestamp;
1355
+ * the instant returned is exactly the beginning of the billing period. Set to null
1356
+ * if this price interval is not currently active.
1357
+ */
1358
+ current_billing_period_start_date: string | null;
1359
+
1360
+ /**
1361
+ * The end date of the price interval. This is the date that Orb stops billing for
1362
+ * this price.
1363
+ */
1364
+ end_date: string | null;
1365
+
1366
+ /**
1367
+ * An additional filter to apply to usage queries.
1368
+ */
1369
+ filter: string | null;
1370
+
1371
+ /**
1372
+ * The fixed fee quantity transitions for this price interval. This is only
1373
+ * relevant for fixed fees.
1374
+ */
1375
+ fixed_fee_quantity_transitions: Array<PriceInterval.FixedFeeQuantityTransition> | null;
1376
+
1377
+ /**
1378
+ * The Price resource represents a price that can be billed on a subscription,
1379
+ * resulting in a charge on an invoice in the form of an invoice line item. Prices
1380
+ * take a quantity and determine an amount to bill.
1381
+ *
1382
+ * Orb supports a few different pricing models out of the box. Each of these models
1383
+ * is serialized differently in a given Price object. The model_type field
1384
+ * determines the key for the configuration object that is present.
1385
+ *
1386
+ * For more on the types of prices, see
1387
+ * [the core concepts documentation](/core-concepts#plan-and-price)
1388
+ */
1389
+ price: PricesAPI.Price;
1390
+
1391
+ /**
1392
+ * The start date of the price interval. This is the date that Orb starts billing
1393
+ * for this price.
1394
+ */
1395
+ start_date: string;
1396
+
1397
+ /**
1398
+ * A list of customer IDs whose usage events will be aggregated and billed under
1399
+ * this price interval.
1400
+ */
1401
+ usage_customer_ids: Array<string> | null;
1402
+ }
1403
+
1404
+ export namespace PriceInterval {
1405
+ export interface FixedFeeQuantityTransition {
1406
+ effective_date: string;
1407
+
1408
+ price_id: string;
1409
+
1410
+ quantity: number;
1411
+ }
1412
+ }
1413
+
1414
+ export interface RedeemedCoupon {
1415
+ coupon_id: string;
1416
+
1417
+ end_date: string | null;
1418
+
1419
+ start_date: string;
1420
+ }
1421
+
1422
+ export interface TrialInfo {
1423
+ end_date: string | null;
1424
+ }
1425
+
1426
+ /**
1427
+ * The resources that were changed as part of this operation. Only present when
1428
+ * fetched through the subscription changes API or if the
1429
+ * `include_changed_resources` parameter was passed in the request.
1430
+ */
1431
+ export interface ChangedResources {
1432
+ /**
1433
+ * The credit notes that were created as part of this operation.
1434
+ */
1435
+ created_credit_notes: Array<CreditNotesAPI.CreditNote>;
1436
+
1437
+ /**
1438
+ * The invoices that were created as part of this operation.
1439
+ */
1440
+ created_invoices: Array<InvoicesAPI.Invoice>;
1441
+
1442
+ /**
1443
+ * The credit notes that were voided as part of this operation.
1444
+ */
1445
+ voided_credit_notes: Array<CreditNotesAPI.CreditNote>;
1446
+
1447
+ /**
1448
+ * The invoices that were voided as part of this operation.
1449
+ */
1450
+ voided_invoices: Array<InvoicesAPI.Invoice>;
1451
+ }
1452
+ }
1453
+ }
1454
+
1455
+ /**
1456
+ * A subscription change represents a desired new subscription / pending change to
1457
+ * an existing subscription. It is a way to first preview the effects on the
1458
+ * subscription as well as any changes/creation of invoices (see
1459
+ * `subscription.changed_resources`).
1460
+ */
1461
+ export interface SubscriptionChangeCancelResponse {
1462
+ id: string;
1463
+
1464
+ /**
1465
+ * Subscription change will be cancelled at this time and can no longer be applied.
1466
+ */
1467
+ expiration_time: string;
1468
+
1469
+ status: 'pending' | 'applied' | 'cancelled';
1470
+
1471
+ subscription: SubscriptionChangeCancelResponse.Subscription | null;
1472
+
1473
+ /**
1474
+ * When this change was applied.
1475
+ */
1476
+ applied_at?: string | null;
1477
+
1478
+ /**
1479
+ * When this change was cancelled.
1480
+ */
1481
+ cancelled_at?: string | null;
1482
+ }
1483
+
1484
+ export namespace SubscriptionChangeCancelResponse {
1485
+ export interface Subscription {
1486
+ id: string;
1487
+
1488
+ /**
1489
+ * The current plan phase that is active, only if the subscription's plan has
1490
+ * phases.
1491
+ */
1492
+ active_plan_phase_order: number | null;
1493
+
1494
+ /**
1495
+ * The adjustment intervals for this subscription sorted by the start_date of the
1496
+ * adjustment interval.
1497
+ */
1498
+ adjustment_intervals: Array<Subscription.AdjustmentInterval>;
1499
+
1500
+ /**
1501
+ * Determines whether issued invoices for this subscription will automatically be
1502
+ * charged with the saved payment method on the due date. This property defaults to
1503
+ * the plan's behavior. If null, defaults to the customer's setting.
1504
+ */
1505
+ auto_collection: boolean | null;
1506
+
1507
+ billing_cycle_anchor_configuration: Subscription.BillingCycleAnchorConfiguration;
1508
+
1509
+ /**
1510
+ * The day of the month on which the billing cycle is anchored. If the maximum
1511
+ * number of days in a month is greater than this value, the last day of the month
1512
+ * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing
1513
+ * period begins on the 30th.
1514
+ */
1515
+ billing_cycle_day: number;
1516
+
1517
+ created_at: string;
1518
+
1519
+ /**
1520
+ * The end of the current billing period. This is an exclusive timestamp, such that
1521
+ * the instant returned is not part of the billing period. Set to null for
1522
+ * subscriptions that are not currently active.
1523
+ */
1524
+ current_billing_period_end_date: string | null;
1525
+
1526
+ /**
1527
+ * The start date of the current billing period. This is an inclusive timestamp;
1528
+ * the instant returned is exactly the beginning of the billing period. Set to null
1529
+ * if the subscription is not currently active.
1530
+ */
1531
+ current_billing_period_start_date: string | null;
1532
+
1533
+ /**
1534
+ * A customer is a buyer of your products, and the other party to the billing
1535
+ * relationship.
1536
+ *
1537
+ * In Orb, customers are assigned system generated identifiers automatically, but
1538
+ * it's often desirable to have these match existing identifiers in your system. To
1539
+ * avoid having to denormalize Orb ID information, you can pass in an
1540
+ * `external_customer_id` with your own identifier. See
1541
+ * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further
1542
+ * information about how these aliases work in Orb.
1543
+ *
1544
+ * In addition to having an identifier in your system, a customer may exist in a
1545
+ * payment provider solution like Stripe. Use the `payment_provider_id` and the
1546
+ * `payment_provider` enum field to express this mapping.
1547
+ *
1548
+ * A customer also has a timezone (from the standard
1549
+ * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to
1550
+ * your account's timezone. See [Timezone localization](/essentials/timezones) for
1551
+ * information on what this timezone parameter influences within Orb.
1552
+ */
1553
+ customer: CustomersAPI.Customer;
1554
+
1555
+ /**
1556
+ * Determines the default memo on this subscriptions' invoices. Note that if this
1557
+ * is not provided, it is determined by the plan configuration.
1558
+ */
1559
+ default_invoice_memo: string | null;
1560
+
1561
+ /**
1562
+ * The discount intervals for this subscription sorted by the start_date.
1563
+ */
1564
+ discount_intervals: Array<
1565
+ | Subscription.AmountDiscountInterval
1566
+ | Subscription.PercentageDiscountInterval
1567
+ | Subscription.UsageDiscountInterval
1568
+ >;
1569
+
1570
+ /**
1571
+ * The date Orb stops billing for this subscription.
1572
+ */
1573
+ end_date: string | null;
1574
+
1575
+ fixed_fee_quantity_schedule: Array<Subscription.FixedFeeQuantitySchedule>;
1576
+
1577
+ invoicing_threshold: string | null;
1578
+
1579
+ /**
1580
+ * The maximum intervals for this subscription sorted by the start_date.
1581
+ */
1582
+ maximum_intervals: Array<Subscription.MaximumInterval>;
1583
+
1584
+ /**
1585
+ * User specified key-value pairs for the resource. If not present, this defaults
1586
+ * to an empty dictionary. Individual keys can be removed by setting the value to
1587
+ * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
1588
+ * `null`.
1589
+ */
1590
+ metadata: Record<string, string>;
1591
+
1592
+ /**
1593
+ * The minimum intervals for this subscription sorted by the start_date.
1594
+ */
1595
+ minimum_intervals: Array<Subscription.MinimumInterval>;
1596
+
1597
+ /**
1598
+ * Determines the difference between the invoice issue date for subscription
1599
+ * invoices as the date that they are due. A value of `0` here represents that the
1600
+ * invoice is due on issue, whereas a value of `30` represents that the customer
1601
+ * has a month to pay the invoice.
1602
+ */
1603
+ net_terms: number;
1604
+
1605
+ /**
1606
+ * A pending subscription change if one exists on this subscription.
1607
+ */
1608
+ pending_subscription_change: Subscription.PendingSubscriptionChange | null;
1609
+
1610
+ /**
1611
+ * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be
1612
+ * subscribed to by a customer. Plans define the billing behavior of the
1613
+ * subscription. You can see more about how to configure prices in the
1614
+ * [Price resource](/reference/price).
1615
+ */
1616
+ plan: PlansAPI.Plan;
1617
+
1618
+ /**
1619
+ * The price intervals for this subscription.
1620
+ */
1621
+ price_intervals: Array<Subscription.PriceInterval>;
1622
+
1623
+ redeemed_coupon: Subscription.RedeemedCoupon | null;
1624
+
1625
+ /**
1626
+ * The date Orb starts billing for this subscription.
1627
+ */
1628
+ start_date: string;
1629
+
1630
+ status: 'active' | 'ended' | 'upcoming';
1631
+
1632
+ trial_info: Subscription.TrialInfo;
1633
+
1634
+ /**
1635
+ * The resources that were changed as part of this operation. Only present when
1636
+ * fetched through the subscription changes API or if the
1637
+ * `include_changed_resources` parameter was passed in the request.
1638
+ */
1639
+ changed_resources?: Subscription.ChangedResources | null;
1640
+ }
1641
+
1642
+ export namespace Subscription {
1643
+ export interface AdjustmentInterval {
1644
+ id: string;
1645
+
1646
+ adjustment:
1647
+ | AdjustmentInterval.PlanPhaseUsageDiscountAdjustment
1648
+ | AdjustmentInterval.PlanPhaseAmountDiscountAdjustment
1649
+ | AdjustmentInterval.PlanPhasePercentageDiscountAdjustment
1650
+ | AdjustmentInterval.PlanPhaseMinimumAdjustment
1651
+ | AdjustmentInterval.PlanPhaseMaximumAdjustment;
1652
+
1653
+ /**
1654
+ * The price interval IDs that this adjustment applies to.
1655
+ */
1656
+ applies_to_price_interval_ids: Array<string>;
1657
+
1658
+ /**
1659
+ * The end date of the adjustment interval.
1660
+ */
1661
+ end_date: string | null;
1662
+
1663
+ /**
1664
+ * The start date of the adjustment interval.
1665
+ */
1666
+ start_date: string;
1667
+ }
1668
+
1669
+ export namespace AdjustmentInterval {
1670
+ export interface PlanPhaseUsageDiscountAdjustment {
1671
+ id: string;
1672
+
1673
+ adjustment_type: 'usage_discount';
1674
+
1675
+ /**
1676
+ * The price IDs that this adjustment applies to.
1677
+ */
1678
+ applies_to_price_ids: Array<string>;
1679
+
1680
+ /**
1681
+ * True for adjustments that apply to an entire invocice, false for adjustments
1682
+ * that apply to only one price.
1683
+ */
1684
+ is_invoice_level: boolean;
1685
+
1686
+ /**
1687
+ * The plan phase in which this adjustment is active.
1688
+ */
1689
+ plan_phase_order: number | null;
1690
+
1691
+ /**
1692
+ * The reason for the adjustment.
1693
+ */
1694
+ reason: string | null;
1695
+
1696
+ /**
1697
+ * The number of usage units by which to discount the price this adjustment applies
1698
+ * to in a given billing period.
1699
+ */
1700
+ usage_discount: number;
1701
+ }
1702
+
1703
+ export interface PlanPhaseAmountDiscountAdjustment {
1704
+ id: string;
1705
+
1706
+ adjustment_type: 'amount_discount';
1707
+
1708
+ /**
1709
+ * The amount by which to discount the prices this adjustment applies to in a given
1710
+ * billing period.
1711
+ */
1712
+ amount_discount: string;
1713
+
1714
+ /**
1715
+ * The price IDs that this adjustment applies to.
1716
+ */
1717
+ applies_to_price_ids: Array<string>;
1718
+
1719
+ /**
1720
+ * True for adjustments that apply to an entire invocice, false for adjustments
1721
+ * that apply to only one price.
1722
+ */
1723
+ is_invoice_level: boolean;
1724
+
1725
+ /**
1726
+ * The plan phase in which this adjustment is active.
1727
+ */
1728
+ plan_phase_order: number | null;
1729
+
1730
+ /**
1731
+ * The reason for the adjustment.
1732
+ */
1733
+ reason: string | null;
1734
+ }
1735
+
1736
+ export interface PlanPhasePercentageDiscountAdjustment {
1737
+ id: string;
1738
+
1739
+ adjustment_type: 'percentage_discount';
1740
+
1741
+ /**
1742
+ * The price IDs that this adjustment applies to.
1743
+ */
1744
+ applies_to_price_ids: Array<string>;
1745
+
1746
+ /**
1747
+ * True for adjustments that apply to an entire invocice, false for adjustments
1748
+ * that apply to only one price.
1749
+ */
1750
+ is_invoice_level: boolean;
1751
+
1752
+ /**
1753
+ * The percentage (as a value between 0 and 1) by which to discount the price
1754
+ * intervals this adjustment applies to in a given billing period.
1755
+ */
1756
+ percentage_discount: number;
1757
+
1758
+ /**
1759
+ * The plan phase in which this adjustment is active.
1760
+ */
1761
+ plan_phase_order: number | null;
1762
+
1763
+ /**
1764
+ * The reason for the adjustment.
1765
+ */
1766
+ reason: string | null;
1767
+ }
1768
+
1769
+ export interface PlanPhaseMinimumAdjustment {
1770
+ id: string;
1771
+
1772
+ adjustment_type: 'minimum';
1773
+
1774
+ /**
1775
+ * The price IDs that this adjustment applies to.
1776
+ */
1777
+ applies_to_price_ids: Array<string>;
1778
+
1779
+ /**
1780
+ * True for adjustments that apply to an entire invocice, false for adjustments
1781
+ * that apply to only one price.
1782
+ */
1783
+ is_invoice_level: boolean;
1784
+
1785
+ /**
1786
+ * The item ID that revenue from this minimum will be attributed to.
1787
+ */
1788
+ item_id: string;
1789
+
1790
+ /**
1791
+ * The minimum amount to charge in a given billing period for the prices this
1792
+ * adjustment applies to.
1793
+ */
1794
+ minimum_amount: string;
1795
+
1796
+ /**
1797
+ * The plan phase in which this adjustment is active.
1798
+ */
1799
+ plan_phase_order: number | null;
1800
+
1801
+ /**
1802
+ * The reason for the adjustment.
1803
+ */
1804
+ reason: string | null;
1805
+ }
1806
+
1807
+ export interface PlanPhaseMaximumAdjustment {
1808
+ id: string;
1809
+
1810
+ adjustment_type: 'maximum';
1811
+
1812
+ /**
1813
+ * The price IDs that this adjustment applies to.
1814
+ */
1815
+ applies_to_price_ids: Array<string>;
1816
+
1817
+ /**
1818
+ * True for adjustments that apply to an entire invocice, false for adjustments
1819
+ * that apply to only one price.
1820
+ */
1821
+ is_invoice_level: boolean;
1822
+
1823
+ /**
1824
+ * The maximum amount to charge in a given billing period for the prices this
1825
+ * adjustment applies to.
1826
+ */
1827
+ maximum_amount: string;
1828
+
1829
+ /**
1830
+ * The plan phase in which this adjustment is active.
1831
+ */
1832
+ plan_phase_order: number | null;
1833
+
1834
+ /**
1835
+ * The reason for the adjustment.
1836
+ */
1837
+ reason: string | null;
1838
+ }
1839
+ }
1840
+
1841
+ export interface BillingCycleAnchorConfiguration {
1842
+ /**
1843
+ * The day of the month on which the billing cycle is anchored. If the maximum
1844
+ * number of days in a month is greater than this value, the last day of the month
1845
+ * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing
1846
+ * period begins on the 30th.
1847
+ */
1848
+ day: number;
1849
+
1850
+ /**
1851
+ * The month on which the billing cycle is anchored (e.g. a quarterly price
1852
+ * anchored in February would have cycles starting February, May, August, and
1853
+ * November).
1854
+ */
1855
+ month?: number | null;
1856
+
1857
+ /**
1858
+ * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle
1859
+ * anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.).
1860
+ */
1861
+ year?: number | null;
1862
+ }
1863
+
1864
+ export interface AmountDiscountInterval {
1865
+ /**
1866
+ * Only available if discount_type is `amount`.
1867
+ */
1868
+ amount_discount: string;
1869
+
1870
+ /**
1871
+ * The price ids that this discount interval applies to.
1872
+ */
1873
+ applies_to_price_ids: Array<string>;
1874
+
1875
+ /**
1876
+ * The price interval ids that this discount interval applies to.
1877
+ */
1878
+ applies_to_price_interval_ids: Array<string>;
1879
+
1880
+ discount_type: 'amount';
1881
+
1882
+ /**
1883
+ * The end date of the discount interval.
1884
+ */
1885
+ end_date: string | null;
1886
+
1887
+ /**
1888
+ * The start date of the discount interval.
1889
+ */
1890
+ start_date: string;
1891
+ }
1892
+
1893
+ export interface PercentageDiscountInterval {
1894
+ /**
1895
+ * The price ids that this discount interval applies to.
1896
+ */
1897
+ applies_to_price_ids: Array<string>;
1898
+
1899
+ /**
1900
+ * The price interval ids that this discount interval applies to.
1901
+ */
1902
+ applies_to_price_interval_ids: Array<string>;
1903
+
1904
+ discount_type: 'percentage';
1905
+
1906
+ /**
1907
+ * The end date of the discount interval.
1908
+ */
1909
+ end_date: string | null;
1910
+
1911
+ /**
1912
+ * Only available if discount_type is `percentage`.This is a number between 0
1913
+ * and 1.
1914
+ */
1915
+ percentage_discount: number;
1916
+
1917
+ /**
1918
+ * The start date of the discount interval.
1919
+ */
1920
+ start_date: string;
1921
+ }
1922
+
1923
+ export interface UsageDiscountInterval {
1924
+ /**
1925
+ * The price ids that this discount interval applies to.
1926
+ */
1927
+ applies_to_price_ids: Array<string>;
1928
+
1929
+ /**
1930
+ * The price interval ids that this discount interval applies to.
1931
+ */
1932
+ applies_to_price_interval_ids: Array<string>;
1933
+
1934
+ discount_type: 'usage';
1935
+
1936
+ /**
1937
+ * The end date of the discount interval.
1938
+ */
1939
+ end_date: string | null;
1940
+
1941
+ /**
1942
+ * The start date of the discount interval.
1943
+ */
1944
+ start_date: string;
1945
+
1946
+ /**
1947
+ * Only available if discount_type is `usage`. Number of usage units that this
1948
+ * discount is for
1949
+ */
1950
+ usage_discount: number;
1951
+ }
1952
+
1953
+ export interface FixedFeeQuantitySchedule {
1954
+ end_date: string | null;
1955
+
1956
+ price_id: string;
1957
+
1958
+ quantity: number;
1959
+
1960
+ start_date: string;
1961
+ }
1962
+
1963
+ export interface MaximumInterval {
1964
+ /**
1965
+ * The price ids that this maximum interval applies to.
1966
+ */
1967
+ applies_to_price_ids: Array<string>;
1968
+
1969
+ /**
1970
+ * The price interval ids that this maximum interval applies to.
1971
+ */
1972
+ applies_to_price_interval_ids: Array<string>;
1973
+
1974
+ /**
1975
+ * The end date of the maximum interval.
1976
+ */
1977
+ end_date: string | null;
1978
+
1979
+ /**
1980
+ * The maximum amount to charge in a given billing period for the price intervals
1981
+ * this transform applies to.
1982
+ */
1983
+ maximum_amount: string;
1984
+
1985
+ /**
1986
+ * The start date of the maximum interval.
1987
+ */
1988
+ start_date: string;
1989
+ }
1990
+
1991
+ export interface MinimumInterval {
1992
+ /**
1993
+ * The price ids that this minimum interval applies to.
1994
+ */
1995
+ applies_to_price_ids: Array<string>;
1996
+
1997
+ /**
1998
+ * The price interval ids that this minimum interval applies to.
1999
+ */
2000
+ applies_to_price_interval_ids: Array<string>;
2001
+
2002
+ /**
2003
+ * The end date of the minimum interval.
2004
+ */
2005
+ end_date: string | null;
2006
+
2007
+ /**
2008
+ * The minimum amount to charge in a given billing period for the price intervals
2009
+ * this minimum applies to.
2010
+ */
2011
+ minimum_amount: string;
2012
+
2013
+ /**
2014
+ * The start date of the minimum interval.
2015
+ */
2016
+ start_date: string;
2017
+ }
2018
+
2019
+ /**
2020
+ * A pending subscription change if one exists on this subscription.
2021
+ */
2022
+ export interface PendingSubscriptionChange {
2023
+ id: string;
2024
+ }
2025
+
2026
+ /**
2027
+ * The Price Interval resource represents a period of time for which a price will
2028
+ * bill on a subscription. A subscription’s price intervals define its billing
2029
+ * behavior.
2030
+ */
2031
+ export interface PriceInterval {
2032
+ id: string;
2033
+
2034
+ /**
2035
+ * The day of the month that Orb bills for this price
2036
+ */
2037
+ billing_cycle_day: number;
2038
+
2039
+ /**
2040
+ * The end of the current billing period. This is an exclusive timestamp, such that
2041
+ * the instant returned is exactly the end of the billing period. Set to null if
2042
+ * this price interval is not currently active.
2043
+ */
2044
+ current_billing_period_end_date: string | null;
2045
+
2046
+ /**
2047
+ * The start date of the current billing period. This is an inclusive timestamp;
2048
+ * the instant returned is exactly the beginning of the billing period. Set to null
2049
+ * if this price interval is not currently active.
2050
+ */
2051
+ current_billing_period_start_date: string | null;
2052
+
2053
+ /**
2054
+ * The end date of the price interval. This is the date that Orb stops billing for
2055
+ * this price.
2056
+ */
2057
+ end_date: string | null;
2058
+
2059
+ /**
2060
+ * An additional filter to apply to usage queries.
2061
+ */
2062
+ filter: string | null;
2063
+
2064
+ /**
2065
+ * The fixed fee quantity transitions for this price interval. This is only
2066
+ * relevant for fixed fees.
2067
+ */
2068
+ fixed_fee_quantity_transitions: Array<PriceInterval.FixedFeeQuantityTransition> | null;
2069
+
2070
+ /**
2071
+ * The Price resource represents a price that can be billed on a subscription,
2072
+ * resulting in a charge on an invoice in the form of an invoice line item. Prices
2073
+ * take a quantity and determine an amount to bill.
2074
+ *
2075
+ * Orb supports a few different pricing models out of the box. Each of these models
2076
+ * is serialized differently in a given Price object. The model_type field
2077
+ * determines the key for the configuration object that is present.
2078
+ *
2079
+ * For more on the types of prices, see
2080
+ * [the core concepts documentation](/core-concepts#plan-and-price)
2081
+ */
2082
+ price: PricesAPI.Price;
2083
+
2084
+ /**
2085
+ * The start date of the price interval. This is the date that Orb starts billing
2086
+ * for this price.
2087
+ */
2088
+ start_date: string;
2089
+
2090
+ /**
2091
+ * A list of customer IDs whose usage events will be aggregated and billed under
2092
+ * this price interval.
2093
+ */
2094
+ usage_customer_ids: Array<string> | null;
2095
+ }
2096
+
2097
+ export namespace PriceInterval {
2098
+ export interface FixedFeeQuantityTransition {
2099
+ effective_date: string;
2100
+
2101
+ price_id: string;
2102
+
2103
+ quantity: number;
2104
+ }
2105
+ }
2106
+
2107
+ export interface RedeemedCoupon {
2108
+ coupon_id: string;
2109
+
2110
+ end_date: string | null;
2111
+
2112
+ start_date: string;
2113
+ }
2114
+
2115
+ export interface TrialInfo {
2116
+ end_date: string | null;
2117
+ }
2118
+
2119
+ /**
2120
+ * The resources that were changed as part of this operation. Only present when
2121
+ * fetched through the subscription changes API or if the
2122
+ * `include_changed_resources` parameter was passed in the request.
2123
+ */
2124
+ export interface ChangedResources {
2125
+ /**
2126
+ * The credit notes that were created as part of this operation.
2127
+ */
2128
+ created_credit_notes: Array<CreditNotesAPI.CreditNote>;
2129
+
2130
+ /**
2131
+ * The invoices that were created as part of this operation.
2132
+ */
2133
+ created_invoices: Array<InvoicesAPI.Invoice>;
2134
+
2135
+ /**
2136
+ * The credit notes that were voided as part of this operation.
2137
+ */
2138
+ voided_credit_notes: Array<CreditNotesAPI.CreditNote>;
2139
+
2140
+ /**
2141
+ * The invoices that were voided as part of this operation.
2142
+ */
2143
+ voided_invoices: Array<InvoicesAPI.Invoice>;
2144
+ }
2145
+ }
2146
+ }
2147
+
2148
+ export interface SubscriptionChangeApplyParams {
2149
+ /**
2150
+ * Description to apply to the balance transaction representing this credit.
2151
+ */
2152
+ description?: string | null;
2153
+
2154
+ /**
2155
+ * Amount already collected to apply to the customer's balance.
2156
+ */
2157
+ previously_collected_amount?: string | null;
2158
+ }
2159
+
2160
+ export declare namespace SubscriptionChanges {
2161
+ export {
2162
+ type SubscriptionChangeRetrieveResponse as SubscriptionChangeRetrieveResponse,
2163
+ type SubscriptionChangeApplyResponse as SubscriptionChangeApplyResponse,
2164
+ type SubscriptionChangeCancelResponse as SubscriptionChangeCancelResponse,
2165
+ type SubscriptionChangeApplyParams as SubscriptionChangeApplyParams,
2166
+ };
2167
+ }