orb-billing 5.48.0 → 5.75.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.
- package/CHANGELOG.md +241 -0
- package/core.js +2 -2
- package/core.js.map +1 -1
- package/core.mjs +2 -2
- package/core.mjs.map +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +11 -0
- package/index.js.map +1 -1
- package/index.mjs +11 -0
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/alerts.d.ts +140 -3
- package/resources/alerts.d.ts.map +1 -1
- package/resources/alerts.js.map +1 -1
- package/resources/alerts.mjs.map +1 -1
- package/resources/beta/beta.d.ts +738 -7570
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/external-plan-id.d.ts +664 -7572
- package/resources/beta/external-plan-id.d.ts.map +1 -1
- package/resources/coupons/coupons.d.ts +29 -0
- package/resources/coupons/coupons.d.ts.map +1 -1
- package/resources/coupons/coupons.js +21 -0
- package/resources/coupons/coupons.js.map +1 -1
- package/resources/coupons/coupons.mjs +21 -0
- package/resources/coupons/coupons.mjs.map +1 -1
- package/resources/coupons/subscriptions.d.ts +10 -0
- package/resources/coupons/subscriptions.d.ts.map +1 -1
- package/resources/coupons/subscriptions.js.map +1 -1
- package/resources/coupons/subscriptions.mjs.map +1 -1
- package/resources/credit-blocks.d.ts +98 -7
- package/resources/credit-blocks.d.ts.map +1 -1
- package/resources/credit-blocks.js +10 -7
- package/resources/credit-blocks.js.map +1 -1
- package/resources/credit-blocks.mjs +10 -7
- package/resources/credit-blocks.mjs.map +1 -1
- package/resources/credit-notes.d.ts +28 -0
- package/resources/credit-notes.d.ts.map +1 -1
- package/resources/credit-notes.js +20 -0
- package/resources/credit-notes.js.map +1 -1
- package/resources/credit-notes.mjs +20 -0
- package/resources/credit-notes.mjs.map +1 -1
- package/resources/customers/credits/credits.d.ts +89 -0
- package/resources/customers/credits/credits.d.ts.map +1 -1
- package/resources/customers/credits/credits.js.map +1 -1
- package/resources/customers/credits/credits.mjs.map +1 -1
- package/resources/customers/credits/ledger.d.ts +34 -20
- package/resources/customers/credits/ledger.d.ts.map +1 -1
- package/resources/customers/credits/ledger.js +28 -14
- package/resources/customers/credits/ledger.js.map +1 -1
- package/resources/customers/credits/ledger.mjs +28 -14
- package/resources/customers/credits/ledger.mjs.map +1 -1
- package/resources/customers/customers.d.ts +89 -6
- package/resources/customers/customers.d.ts.map +1 -1
- package/resources/customers/customers.js.map +1 -1
- package/resources/customers/customers.mjs.map +1 -1
- package/resources/dimensional-price-groups/dimensional-price-groups.d.ts +35 -1
- package/resources/dimensional-price-groups/dimensional-price-groups.d.ts.map +1 -1
- package/resources/dimensional-price-groups/dimensional-price-groups.js +26 -0
- package/resources/dimensional-price-groups/dimensional-price-groups.js.map +1 -1
- package/resources/dimensional-price-groups/dimensional-price-groups.mjs +26 -0
- package/resources/dimensional-price-groups/dimensional-price-groups.mjs.map +1 -1
- package/resources/dimensional-price-groups/external-dimensional-price-group-id.d.ts +16 -0
- package/resources/dimensional-price-groups/external-dimensional-price-group-id.d.ts.map +1 -1
- package/resources/dimensional-price-groups/external-dimensional-price-group-id.js +16 -0
- package/resources/dimensional-price-groups/external-dimensional-price-group-id.js.map +1 -1
- package/resources/dimensional-price-groups/external-dimensional-price-group-id.mjs +16 -0
- package/resources/dimensional-price-groups/external-dimensional-price-group-id.mjs.map +1 -1
- package/resources/events/backfills.d.ts +37 -0
- package/resources/events/backfills.d.ts.map +1 -1
- package/resources/events/backfills.js +29 -0
- package/resources/events/backfills.js.map +1 -1
- package/resources/events/backfills.mjs +29 -0
- package/resources/events/backfills.mjs.map +1 -1
- package/resources/events/events.d.ts +41 -33
- package/resources/events/events.d.ts.map +1 -1
- package/resources/events/events.js +39 -31
- package/resources/events/events.js.map +1 -1
- package/resources/events/events.mjs +39 -31
- package/resources/events/events.mjs.map +1 -1
- package/resources/events/volume.d.ts +7 -0
- package/resources/events/volume.d.ts.map +1 -1
- package/resources/events/volume.js +7 -0
- package/resources/events/volume.js.map +1 -1
- package/resources/events/volume.mjs +7 -0
- package/resources/events/volume.mjs.map +1 -1
- package/resources/invoice-line-items.d.ts +89 -1
- package/resources/invoice-line-items.d.ts.map +1 -1
- package/resources/invoice-line-items.js +12 -0
- package/resources/invoice-line-items.js.map +1 -1
- package/resources/invoice-line-items.mjs +12 -0
- package/resources/invoice-line-items.mjs.map +1 -1
- package/resources/invoices.d.ts +200 -12
- package/resources/invoices.d.ts.map +1 -1
- package/resources/invoices.js +64 -0
- package/resources/invoices.js.map +1 -1
- package/resources/invoices.mjs +64 -0
- package/resources/invoices.mjs.map +1 -1
- package/resources/items.d.ts +30 -0
- package/resources/items.d.ts.map +1 -1
- package/resources/items.js +22 -0
- package/resources/items.js.map +1 -1
- package/resources/items.mjs +22 -0
- package/resources/items.mjs.map +1 -1
- package/resources/licenses/external-licenses.d.ts +13 -1
- package/resources/licenses/external-licenses.d.ts.map +1 -1
- package/resources/licenses/external-licenses.js +12 -0
- package/resources/licenses/external-licenses.js.map +1 -1
- package/resources/licenses/external-licenses.mjs +12 -0
- package/resources/licenses/external-licenses.mjs.map +1 -1
- package/resources/licenses/licenses.d.ts +44 -0
- package/resources/licenses/licenses.d.ts.map +1 -1
- package/resources/licenses/licenses.js +44 -0
- package/resources/licenses/licenses.js.map +1 -1
- package/resources/licenses/licenses.mjs +44 -0
- package/resources/licenses/licenses.mjs.map +1 -1
- package/resources/licenses/usage.d.ts +17 -2
- package/resources/licenses/usage.d.ts.map +1 -1
- package/resources/licenses/usage.js +8 -0
- package/resources/licenses/usage.js.map +1 -1
- package/resources/licenses/usage.mjs +8 -0
- package/resources/licenses/usage.mjs.map +1 -1
- package/resources/metrics.d.ts +37 -5
- package/resources/metrics.d.ts.map +1 -1
- package/resources/metrics.js +27 -2
- package/resources/metrics.js.map +1 -1
- package/resources/metrics.mjs +27 -2
- package/resources/metrics.mjs.map +1 -1
- package/resources/plans/external-plan-id.d.ts +6 -2
- package/resources/plans/external-plan-id.d.ts.map +1 -1
- package/resources/plans/external-plan-id.js +2 -2
- package/resources/plans/external-plan-id.mjs +2 -2
- package/resources/plans/migrations.d.ts +42 -0
- package/resources/plans/migrations.d.ts.map +1 -1
- package/resources/plans/migrations.js.map +1 -1
- package/resources/plans/migrations.mjs.map +1 -1
- package/resources/plans/plans.d.ts +382 -3754
- package/resources/plans/plans.d.ts.map +1 -1
- package/resources/plans/plans.js +2 -2
- package/resources/plans/plans.js.map +1 -1
- package/resources/plans/plans.mjs +2 -2
- package/resources/plans/plans.mjs.map +1 -1
- package/resources/prices/external-price-id.d.ts +14 -0
- package/resources/prices/external-price-id.d.ts.map +1 -1
- package/resources/prices/external-price-id.js +14 -0
- package/resources/prices/external-price-id.js.map +1 -1
- package/resources/prices/external-price-id.mjs +14 -0
- package/resources/prices/external-price-id.mjs.map +1 -1
- package/resources/prices/prices.d.ts +1632 -393
- package/resources/prices/prices.d.ts.map +1 -1
- package/resources/prices/prices.js +46 -0
- package/resources/prices/prices.js.map +1 -1
- package/resources/prices/prices.mjs +46 -0
- package/resources/prices/prices.mjs.map +1 -1
- package/resources/shared.d.ts +922 -52
- package/resources/shared.d.ts.map +1 -1
- package/resources/shared.js.map +1 -1
- package/resources/shared.mjs.map +1 -1
- package/resources/subscription-changes.d.ts +72 -1
- package/resources/subscription-changes.d.ts.map +1 -1
- package/resources/subscription-changes.js.map +1 -1
- package/resources/subscription-changes.mjs.map +1 -1
- package/resources/subscriptions.d.ts +3075 -464
- package/resources/subscriptions.d.ts.map +1 -1
- package/resources/subscriptions.js +111 -0
- package/resources/subscriptions.js.map +1 -1
- package/resources/subscriptions.mjs +111 -0
- package/resources/subscriptions.mjs.map +1 -1
- package/src/core.ts +2 -2
- package/src/index.ts +12 -0
- package/src/resources/alerts.ts +161 -3
- package/src/resources/beta/beta.ts +828 -8988
- package/src/resources/beta/external-plan-id.ts +745 -8997
- package/src/resources/coupons/coupons.ts +29 -0
- package/src/resources/coupons/subscriptions.ts +10 -0
- package/src/resources/credit-blocks.ts +120 -7
- package/src/resources/credit-notes.ts +28 -0
- package/src/resources/customers/credits/credits.ts +111 -0
- package/src/resources/customers/credits/ledger.ts +34 -20
- package/src/resources/customers/customers.ts +99 -6
- package/src/resources/dimensional-price-groups/dimensional-price-groups.ts +35 -1
- package/src/resources/dimensional-price-groups/external-dimensional-price-group-id.ts +16 -0
- package/src/resources/events/backfills.ts +37 -0
- package/src/resources/events/events.ts +41 -33
- package/src/resources/events/volume.ts +7 -0
- package/src/resources/invoice-line-items.ts +104 -0
- package/src/resources/invoices.ts +215 -11
- package/src/resources/items.ts +30 -0
- package/src/resources/licenses/external-licenses.ts +13 -1
- package/src/resources/licenses/licenses.ts +44 -0
- package/src/resources/licenses/usage.ts +17 -2
- package/src/resources/metrics.ts +37 -5
- package/src/resources/plans/external-plan-id.ts +7 -2
- package/src/resources/plans/migrations.ts +42 -0
- package/src/resources/plans/plans.ts +456 -4482
- package/src/resources/prices/external-price-id.ts +14 -0
- package/src/resources/prices/prices.ts +1743 -264
- package/src/resources/shared.ts +1172 -50
- package/src/resources/subscription-changes.ts +88 -1
- package/src/resources/subscriptions.ts +4707 -1585
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -17,6 +17,17 @@ export class Coupons extends APIResource {
|
|
|
17
17
|
/**
|
|
18
18
|
* This endpoint allows the creation of coupons, which can then be redeemed at
|
|
19
19
|
* subscription creation or plan change.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const coupon = await client.coupons.create({
|
|
24
|
+
* discount: {
|
|
25
|
+
* discount_type: 'percentage',
|
|
26
|
+
* percentage_discount: 0,
|
|
27
|
+
* },
|
|
28
|
+
* redemption_code: 'HALFOFF',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
20
31
|
*/
|
|
21
32
|
create(body: CouponCreateParams, options?: Core.RequestOptions): Core.APIPromise<Coupon> {
|
|
22
33
|
return this._client.post('/coupons', { body, ...options });
|
|
@@ -28,6 +39,14 @@ export class Coupons extends APIResource {
|
|
|
28
39
|
* The list of coupons is ordered starting from the most recently created coupon.
|
|
29
40
|
* The response also includes `pagination_metadata`, which lets the caller retrieve
|
|
30
41
|
* the next page of results if they exist.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* // Automatically fetches more pages as needed.
|
|
46
|
+
* for await (const coupon of client.coupons.list()) {
|
|
47
|
+
* // ...
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
31
50
|
*/
|
|
32
51
|
list(query?: CouponListParams, options?: Core.RequestOptions): Core.PagePromise<CouponsPage, Coupon>;
|
|
33
52
|
list(options?: Core.RequestOptions): Core.PagePromise<CouponsPage, Coupon>;
|
|
@@ -45,6 +64,11 @@ export class Coupons extends APIResource {
|
|
|
45
64
|
* This endpoint allows a coupon to be archived. Archived coupons can no longer be
|
|
46
65
|
* redeemed, and will be hidden from lists of active coupons. Additionally, once a
|
|
47
66
|
* coupon is archived, its redemption code can be reused for a different coupon.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const coupon = await client.coupons.archive('coupon_id');
|
|
71
|
+
* ```
|
|
48
72
|
*/
|
|
49
73
|
archive(couponId: string, options?: Core.RequestOptions): Core.APIPromise<Coupon> {
|
|
50
74
|
return this._client.post(`/coupons/${couponId}/archive`, options);
|
|
@@ -54,6 +78,11 @@ export class Coupons extends APIResource {
|
|
|
54
78
|
* This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption
|
|
55
79
|
* code, use the [List coupons](list-coupons) endpoint with the redemption_code
|
|
56
80
|
* parameter.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const coupon = await client.coupons.fetch('coupon_id');
|
|
85
|
+
* ```
|
|
57
86
|
*/
|
|
58
87
|
fetch(couponId: string, options?: Core.RequestOptions): Core.APIPromise<Coupon> {
|
|
59
88
|
return this._client.get(`/coupons/${couponId}`, options);
|
|
@@ -16,6 +16,16 @@ export class Subscriptions extends APIResource {
|
|
|
16
16
|
* coupon as a [paginated](/api-reference/pagination) list, ordered starting from
|
|
17
17
|
* the most recently created subscription. For a full discussion of the
|
|
18
18
|
* subscription resource, see [Subscription](/core-concepts#subscription).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // Automatically fetches more pages as needed.
|
|
23
|
+
* for await (const subscription of client.coupons.subscriptions.list(
|
|
24
|
+
* 'coupon_id',
|
|
25
|
+
* )) {
|
|
26
|
+
* // ...
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
19
29
|
*/
|
|
20
30
|
list(
|
|
21
31
|
couponId: string,
|
|
@@ -42,14 +42,17 @@ export class CreditBlocks extends APIResource {
|
|
|
42
42
|
/**
|
|
43
43
|
* This endpoint returns the credit block and its associated purchasing invoices.
|
|
44
44
|
*
|
|
45
|
-
* If a credit block was purchased (as opposed to being manually added
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* multiple invoices will be returned.
|
|
45
|
+
* If a credit block was purchased (as opposed to being manually added), this
|
|
46
|
+
* endpoint returns the invoices that were created to charge the customer for the
|
|
47
|
+
* credit block. For credit blocks with payment schedules spanning multiple periods
|
|
48
|
+
* (e.g., monthly payments over 12 months), multiple invoices will be returned.
|
|
50
49
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* For credit blocks created by subscription allocation prices, this endpoint
|
|
51
|
+
* returns the subscription invoice containing the allocation line item that
|
|
52
|
+
* created the block.
|
|
53
|
+
*
|
|
54
|
+
* If the credit block was not purchased (e.g., manual increment), an empty
|
|
55
|
+
* invoices list is returned.
|
|
53
56
|
*
|
|
54
57
|
* **Note: This endpoint is currently experimental and its interface may change in
|
|
55
58
|
* future releases. Please contact support before building production integrations
|
|
@@ -71,6 +74,14 @@ export interface CreditBlockRetrieveResponse {
|
|
|
71
74
|
|
|
72
75
|
balance: number;
|
|
73
76
|
|
|
77
|
+
/**
|
|
78
|
+
* How this credit block was created: `allocation` (a subscription's recurring
|
|
79
|
+
* credit allocation), `top_up` (an automatic balance-threshold top-up), or
|
|
80
|
+
* `manual` (a manual credit ledger increment, including credits voided or expired
|
|
81
|
+
* off another block).
|
|
82
|
+
*/
|
|
83
|
+
credit_block_source: 'allocation' | 'top_up' | 'manual';
|
|
84
|
+
|
|
74
85
|
effective_date: string | null;
|
|
75
86
|
|
|
76
87
|
expiry_date: string | null;
|
|
@@ -90,6 +101,12 @@ export interface CreditBlockRetrieveResponse {
|
|
|
90
101
|
per_unit_cost_basis: string | null;
|
|
91
102
|
|
|
92
103
|
status: 'active' | 'pending_payment';
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
107
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
108
|
+
*/
|
|
109
|
+
credit_allocation?: CreditBlockRetrieveResponse.CreditAllocation | null;
|
|
93
110
|
}
|
|
94
111
|
|
|
95
112
|
export namespace CreditBlockRetrieveResponse {
|
|
@@ -109,6 +126,47 @@ export namespace CreditBlockRetrieveResponse {
|
|
|
109
126
|
*/
|
|
110
127
|
values: Array<string>;
|
|
111
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
132
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
133
|
+
*/
|
|
134
|
+
export interface CreditAllocation {
|
|
135
|
+
allows_rollover: boolean;
|
|
136
|
+
|
|
137
|
+
currency: string;
|
|
138
|
+
|
|
139
|
+
custom_expiration: Shared.CustomExpiration | null;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The ID of the catalog item this block was allocated from, derived from the
|
|
143
|
+
* allocation's price.
|
|
144
|
+
*/
|
|
145
|
+
item_id: string;
|
|
146
|
+
|
|
147
|
+
filters?: Array<CreditAllocation.Filter>;
|
|
148
|
+
|
|
149
|
+
license_type_id?: string | null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export namespace CreditAllocation {
|
|
153
|
+
export interface Filter {
|
|
154
|
+
/**
|
|
155
|
+
* The property of the price to filter on.
|
|
156
|
+
*/
|
|
157
|
+
field: 'price_id' | 'item_id' | 'price_type' | 'currency' | 'pricing_unit_id';
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Should prices that match the filter be included or excluded.
|
|
161
|
+
*/
|
|
162
|
+
operator: 'includes' | 'excludes';
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The IDs or values that match this filter.
|
|
166
|
+
*/
|
|
167
|
+
values: Array<string>;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
112
170
|
}
|
|
113
171
|
|
|
114
172
|
export interface CreditBlockListInvoicesResponse {
|
|
@@ -129,6 +187,14 @@ export namespace CreditBlockListInvoicesResponse {
|
|
|
129
187
|
|
|
130
188
|
balance: number;
|
|
131
189
|
|
|
190
|
+
/**
|
|
191
|
+
* How this credit block was created: `allocation` (a subscription's recurring
|
|
192
|
+
* credit allocation), `top_up` (an automatic balance-threshold top-up), or
|
|
193
|
+
* `manual` (a manual credit ledger increment, including credits voided or expired
|
|
194
|
+
* off another block).
|
|
195
|
+
*/
|
|
196
|
+
credit_block_source: 'allocation' | 'top_up' | 'manual';
|
|
197
|
+
|
|
132
198
|
effective_date: string | null;
|
|
133
199
|
|
|
134
200
|
expiry_date: string | null;
|
|
@@ -148,6 +214,12 @@ export namespace CreditBlockListInvoicesResponse {
|
|
|
148
214
|
per_unit_cost_basis: string | null;
|
|
149
215
|
|
|
150
216
|
status: 'active' | 'pending_payment';
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
220
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
221
|
+
*/
|
|
222
|
+
credit_allocation?: Block.CreditAllocation | null;
|
|
151
223
|
}
|
|
152
224
|
|
|
153
225
|
export namespace Block {
|
|
@@ -167,6 +239,47 @@ export namespace CreditBlockListInvoicesResponse {
|
|
|
167
239
|
*/
|
|
168
240
|
values: Array<string>;
|
|
169
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
245
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
246
|
+
*/
|
|
247
|
+
export interface CreditAllocation {
|
|
248
|
+
allows_rollover: boolean;
|
|
249
|
+
|
|
250
|
+
currency: string;
|
|
251
|
+
|
|
252
|
+
custom_expiration: Shared.CustomExpiration | null;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The ID of the catalog item this block was allocated from, derived from the
|
|
256
|
+
* allocation's price.
|
|
257
|
+
*/
|
|
258
|
+
item_id: string;
|
|
259
|
+
|
|
260
|
+
filters?: Array<CreditAllocation.Filter>;
|
|
261
|
+
|
|
262
|
+
license_type_id?: string | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export namespace CreditAllocation {
|
|
266
|
+
export interface Filter {
|
|
267
|
+
/**
|
|
268
|
+
* The property of the price to filter on.
|
|
269
|
+
*/
|
|
270
|
+
field: 'price_id' | 'item_id' | 'price_type' | 'currency' | 'pricing_unit_id';
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Should prices that match the filter be included or excluded.
|
|
274
|
+
*/
|
|
275
|
+
operator: 'includes' | 'excludes';
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The IDs or values that match this filter.
|
|
279
|
+
*/
|
|
280
|
+
values: Array<string>;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
170
283
|
}
|
|
171
284
|
|
|
172
285
|
export interface Invoice {
|
|
@@ -40,6 +40,19 @@ export class CreditNotes extends APIResource {
|
|
|
40
40
|
* Note: Both start_date and end_date are inclusive - the service period will cover
|
|
41
41
|
* both the start date and end date completely (from start of start_date to end of
|
|
42
42
|
* end_date).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const creditNote = await client.creditNotes.create({
|
|
47
|
+
* line_items: [
|
|
48
|
+
* {
|
|
49
|
+
* amount: 'amount',
|
|
50
|
+
* invoice_line_item_id: '4khy3nwzktxv7',
|
|
51
|
+
* },
|
|
52
|
+
* ],
|
|
53
|
+
* reason: 'duplicate',
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
43
56
|
*/
|
|
44
57
|
create(body: CreditNoteCreateParams, options?: Core.RequestOptions): Core.APIPromise<Shared.CreditNote> {
|
|
45
58
|
return this._client.post('/credit_notes', { body, ...options });
|
|
@@ -49,6 +62,14 @@ export class CreditNotes extends APIResource {
|
|
|
49
62
|
* Get a paginated list of CreditNotes. Users can also filter by customer_id,
|
|
50
63
|
* subscription_id, or external_customer_id. The credit notes will be returned in
|
|
51
64
|
* reverse chronological order by `creation_time`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // Automatically fetches more pages as needed.
|
|
69
|
+
* for await (const creditNote of client.creditNotes.list()) {
|
|
70
|
+
* // ...
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
52
73
|
*/
|
|
53
74
|
list(
|
|
54
75
|
query?: CreditNoteListParams,
|
|
@@ -68,6 +89,13 @@ export class CreditNotes extends APIResource {
|
|
|
68
89
|
/**
|
|
69
90
|
* This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes)
|
|
70
91
|
* given an identifier.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const creditNote = await client.creditNotes.fetch(
|
|
96
|
+
* 'credit_note_id',
|
|
97
|
+
* );
|
|
98
|
+
* ```
|
|
71
99
|
*/
|
|
72
100
|
fetch(creditNoteId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.CreditNote> {
|
|
73
101
|
return this._client.get(`/credit_notes/${creditNoteId}`, options);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { APIResource } from '../../../resource';
|
|
4
4
|
import { isRequestOptions } from '../../../core';
|
|
5
5
|
import * as Core from '../../../core';
|
|
6
|
+
import * as Shared from '../../shared';
|
|
6
7
|
import * as LedgerAPI from './ledger';
|
|
7
8
|
import {
|
|
8
9
|
AffectedBlock,
|
|
@@ -134,6 +135,14 @@ export interface CreditListResponse {
|
|
|
134
135
|
|
|
135
136
|
balance: number;
|
|
136
137
|
|
|
138
|
+
/**
|
|
139
|
+
* How this credit block was created: `allocation` (a subscription's recurring
|
|
140
|
+
* credit allocation), `top_up` (an automatic balance-threshold top-up), or
|
|
141
|
+
* `manual` (a manual credit ledger increment, including credits voided or expired
|
|
142
|
+
* off another block).
|
|
143
|
+
*/
|
|
144
|
+
credit_block_source: 'allocation' | 'top_up' | 'manual';
|
|
145
|
+
|
|
137
146
|
effective_date: string | null;
|
|
138
147
|
|
|
139
148
|
expiry_date: string | null;
|
|
@@ -153,6 +162,12 @@ export interface CreditListResponse {
|
|
|
153
162
|
per_unit_cost_basis: string | null;
|
|
154
163
|
|
|
155
164
|
status: 'active' | 'pending_payment';
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
168
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
169
|
+
*/
|
|
170
|
+
credit_allocation?: CreditListResponse.CreditAllocation | null;
|
|
156
171
|
}
|
|
157
172
|
|
|
158
173
|
export namespace CreditListResponse {
|
|
@@ -175,6 +190,47 @@ export namespace CreditListResponse {
|
|
|
175
190
|
*/
|
|
176
191
|
values: Array<string>;
|
|
177
192
|
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
196
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
197
|
+
*/
|
|
198
|
+
export interface CreditAllocation {
|
|
199
|
+
allows_rollover: boolean;
|
|
200
|
+
|
|
201
|
+
currency: string;
|
|
202
|
+
|
|
203
|
+
custom_expiration: Shared.CustomExpiration | null;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The ID of the catalog item this block was allocated from, derived from the
|
|
207
|
+
* allocation's price.
|
|
208
|
+
*/
|
|
209
|
+
item_id: string;
|
|
210
|
+
|
|
211
|
+
filters?: Array<CreditAllocation.Filter>;
|
|
212
|
+
|
|
213
|
+
license_type_id?: string | null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export namespace CreditAllocation {
|
|
217
|
+
export interface Filter {
|
|
218
|
+
/**
|
|
219
|
+
* The property of the price to filter on.
|
|
220
|
+
*/
|
|
221
|
+
field: 'price_id' | 'item_id' | 'price_type' | 'currency' | 'pricing_unit_id';
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Should prices that match the filter be included or excluded.
|
|
225
|
+
*/
|
|
226
|
+
operator: 'includes' | 'excludes';
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The IDs or values that match this filter.
|
|
230
|
+
*/
|
|
231
|
+
values: Array<string>;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
178
234
|
}
|
|
179
235
|
|
|
180
236
|
export interface CreditListByExternalIDResponse {
|
|
@@ -182,6 +238,14 @@ export interface CreditListByExternalIDResponse {
|
|
|
182
238
|
|
|
183
239
|
balance: number;
|
|
184
240
|
|
|
241
|
+
/**
|
|
242
|
+
* How this credit block was created: `allocation` (a subscription's recurring
|
|
243
|
+
* credit allocation), `top_up` (an automatic balance-threshold top-up), or
|
|
244
|
+
* `manual` (a manual credit ledger increment, including credits voided or expired
|
|
245
|
+
* off another block).
|
|
246
|
+
*/
|
|
247
|
+
credit_block_source: 'allocation' | 'top_up' | 'manual';
|
|
248
|
+
|
|
185
249
|
effective_date: string | null;
|
|
186
250
|
|
|
187
251
|
expiry_date: string | null;
|
|
@@ -201,6 +265,12 @@ export interface CreditListByExternalIDResponse {
|
|
|
201
265
|
per_unit_cost_basis: string | null;
|
|
202
266
|
|
|
203
267
|
status: 'active' | 'pending_payment';
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
271
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
272
|
+
*/
|
|
273
|
+
credit_allocation?: CreditListByExternalIDResponse.CreditAllocation | null;
|
|
204
274
|
}
|
|
205
275
|
|
|
206
276
|
export namespace CreditListByExternalIDResponse {
|
|
@@ -223,6 +293,47 @@ export namespace CreditListByExternalIDResponse {
|
|
|
223
293
|
*/
|
|
224
294
|
values: Array<string>;
|
|
225
295
|
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* The credit allocation that funded a block. Extends the allocation resource
|
|
299
|
+
* serialized on prices with the catalog-item attribution of the funding price.
|
|
300
|
+
*/
|
|
301
|
+
export interface CreditAllocation {
|
|
302
|
+
allows_rollover: boolean;
|
|
303
|
+
|
|
304
|
+
currency: string;
|
|
305
|
+
|
|
306
|
+
custom_expiration: Shared.CustomExpiration | null;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The ID of the catalog item this block was allocated from, derived from the
|
|
310
|
+
* allocation's price.
|
|
311
|
+
*/
|
|
312
|
+
item_id: string;
|
|
313
|
+
|
|
314
|
+
filters?: Array<CreditAllocation.Filter>;
|
|
315
|
+
|
|
316
|
+
license_type_id?: string | null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export namespace CreditAllocation {
|
|
320
|
+
export interface Filter {
|
|
321
|
+
/**
|
|
322
|
+
* The property of the price to filter on.
|
|
323
|
+
*/
|
|
324
|
+
field: 'price_id' | 'item_id' | 'price_type' | 'currency' | 'pricing_unit_id';
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Should prices that match the filter be included or excluded.
|
|
328
|
+
*/
|
|
329
|
+
operator: 'includes' | 'excludes';
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* The IDs or values that match this filter.
|
|
333
|
+
*/
|
|
334
|
+
values: Array<string>;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
226
337
|
}
|
|
227
338
|
|
|
228
339
|
export interface CreditListParams extends PageParams {
|
|
@@ -155,8 +155,9 @@ export class Ledger extends APIResource {
|
|
|
155
155
|
* }
|
|
156
156
|
* ```
|
|
157
157
|
*
|
|
158
|
-
* Note that
|
|
159
|
-
*
|
|
158
|
+
* Note that an `increment` entry always creates a new credit block (defined by the
|
|
159
|
+
* optional `effective_date` and `expiry_date`); it never modifies an existing
|
|
160
|
+
* block.
|
|
160
161
|
*
|
|
161
162
|
* ### Invoicing for credits
|
|
162
163
|
*
|
|
@@ -177,11 +178,17 @@ export class Ledger extends APIResource {
|
|
|
177
178
|
* ## Deducting Credits
|
|
178
179
|
*
|
|
179
180
|
* Orb allows you to deduct credits from a customer by creating an entry of type
|
|
180
|
-
* `decrement`.
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
181
|
+
* `decrement`. A `decrement` entry records credits as usage and immediately
|
|
182
|
+
* recognizes revenue at the block's `per_unit_cost_basis`.
|
|
183
|
+
*
|
|
184
|
+
* For most credit removals, use `void` (no revenue impact) or `expiration_change`
|
|
185
|
+
* (revenue recognized on expiration) instead. Only use `decrement` when credits
|
|
186
|
+
* were genuinely consumed outside of normal event ingestion.
|
|
187
|
+
*
|
|
188
|
+
* Orb matches the algorithm for automatic deductions for determining which credit
|
|
189
|
+
* blocks to decrement from. In the case that the deduction leads to multiple
|
|
190
|
+
* ledger entries, the response from this endpoint will be the final deduction. Orb
|
|
191
|
+
* also optionally allows specifying a description to assist with auditing.
|
|
185
192
|
*
|
|
186
193
|
* The following snippet illustrates a sample request body to decrement credits.
|
|
187
194
|
*
|
|
@@ -282,8 +289,9 @@ export class Ledger extends APIResource {
|
|
|
282
289
|
* }
|
|
283
290
|
* ```
|
|
284
291
|
*
|
|
285
|
-
* Note that
|
|
286
|
-
*
|
|
292
|
+
* Note that an `increment` entry always creates a new credit block (defined by the
|
|
293
|
+
* optional `effective_date` and `expiry_date`); it never modifies an existing
|
|
294
|
+
* block.
|
|
287
295
|
*
|
|
288
296
|
* ### Invoicing for credits
|
|
289
297
|
*
|
|
@@ -304,11 +312,17 @@ export class Ledger extends APIResource {
|
|
|
304
312
|
* ## Deducting Credits
|
|
305
313
|
*
|
|
306
314
|
* Orb allows you to deduct credits from a customer by creating an entry of type
|
|
307
|
-
* `decrement`.
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
315
|
+
* `decrement`. A `decrement` entry records credits as usage and immediately
|
|
316
|
+
* recognizes revenue at the block's `per_unit_cost_basis`.
|
|
317
|
+
*
|
|
318
|
+
* For most credit removals, use `void` (no revenue impact) or `expiration_change`
|
|
319
|
+
* (revenue recognized on expiration) instead. Only use `decrement` when credits
|
|
320
|
+
* were genuinely consumed outside of normal event ingestion.
|
|
321
|
+
*
|
|
322
|
+
* Orb matches the algorithm for automatic deductions for determining which credit
|
|
323
|
+
* blocks to decrement from. In the case that the deduction leads to multiple
|
|
324
|
+
* ledger entries, the response from this endpoint will be the final deduction. Orb
|
|
325
|
+
* also optionally allows specifying a description to assist with auditing.
|
|
312
326
|
*
|
|
313
327
|
* The following snippet illustrates a sample request body to decrement credits.
|
|
314
328
|
*
|
|
@@ -1040,9 +1054,9 @@ export declare namespace LedgerCreateEntryParams {
|
|
|
1040
1054
|
entry_type: 'expiration_change';
|
|
1041
1055
|
|
|
1042
1056
|
/**
|
|
1043
|
-
* A
|
|
1044
|
-
*
|
|
1045
|
-
*
|
|
1057
|
+
* A date (specified in YYYY-MM-DD format) used for expiration change, denoting
|
|
1058
|
+
* when credits transferred (as part of a partial block expiration) should expire.
|
|
1059
|
+
* This date must be on or after the effective date of the credit block.
|
|
1046
1060
|
*/
|
|
1047
1061
|
target_expiry_date: string;
|
|
1048
1062
|
|
|
@@ -1344,9 +1358,9 @@ export declare namespace LedgerCreateEntryByExternalIDParams {
|
|
|
1344
1358
|
entry_type: 'expiration_change';
|
|
1345
1359
|
|
|
1346
1360
|
/**
|
|
1347
|
-
* A
|
|
1348
|
-
*
|
|
1349
|
-
*
|
|
1361
|
+
* A date (specified in YYYY-MM-DD format) used for expiration change, denoting
|
|
1362
|
+
* when credits transferred (as part of a partial block expiration) should expire.
|
|
1363
|
+
* This date must be on or after the effective date of the credit block.
|
|
1350
1364
|
*/
|
|
1351
1365
|
target_expiry_date: string;
|
|
1352
1366
|
|