chargebee 3.6.1 → 3.8.0-beta.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 +34 -0
- package/README.md +66 -0
- package/cjs/RequestWrapper.js +117 -56
- package/cjs/asyncApiSupport.js +7 -7
- package/cjs/coreCommon.js +4 -4
- package/cjs/createChargebee.js +16 -15
- package/cjs/environment.js +1 -1
- package/cjs/net/ClientInterface.js +2 -2
- package/cjs/net/FetchClient.js +6 -6
- package/cjs/net/NodeClient.js +4 -4
- package/cjs/resources/api_endpoints.js +2085 -269
- package/cjs/util.js +61 -36
- package/esm/RequestWrapper.js +115 -54
- package/esm/asyncApiSupport.js +1 -1
- package/esm/coreCommon.js +2 -2
- package/esm/createChargebee.js +6 -5
- package/esm/environment.js +1 -1
- package/esm/net/ClientInterface.js +1 -1
- package/esm/net/FetchClient.js +1 -1
- package/esm/net/NodeClient.js +1 -1
- package/esm/resources/api_endpoints.js +2085 -269
- package/esm/util.js +59 -36
- package/package.json +1 -1
- package/types/core.d.ts +1 -0
- package/types/index.d.ts +25 -0
- package/types/resources/Estimate.d.ts +3 -3
- package/types/resources/HostedPage.d.ts +2 -2
- package/types/resources/Invoice.d.ts +18 -0
- package/types/resources/OmnichannelSubscription.d.ts +1 -0
- package/types/resources/OmnichannelSubscriptionItem.d.ts +4 -2
- package/types/resources/PricingPageSession.d.ts +2 -2
- package/types/resources/Quote.d.ts +4 -4
- package/types/resources/Subscription.d.ts +3 -3
- package/types/resources/UsageFile.d.ts +56 -0
- package/types/resources/VirtualBankAccount.d.ts +1 -1
package/esm/util.js
CHANGED
|
@@ -2,48 +2,43 @@ export const extend = (deep, target, copy) => {
|
|
|
2
2
|
_extendsFn(deep, target, copy);
|
|
3
3
|
};
|
|
4
4
|
const _extendsFn = (...args) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
(typeof copy === 'object' || (copyIsArray = isArray(copy)))) {
|
|
30
|
-
if (copyIsArray) {
|
|
31
|
-
copyIsArray = false;
|
|
32
|
-
clone = src && isArray(src) ? src : [];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
clone = src && typeof src === 'object' ? src : {};
|
|
36
|
-
}
|
|
37
|
-
target[name] = extend(deep, clone, copy);
|
|
5
|
+
let options, name, src, copy, copyIsArray, clone;
|
|
6
|
+
let target = args[0] || {};
|
|
7
|
+
let i = 1;
|
|
8
|
+
const length = args.length;
|
|
9
|
+
let deep = false;
|
|
10
|
+
if (typeof target === 'boolean') {
|
|
11
|
+
deep = target;
|
|
12
|
+
target = args[1] || {};
|
|
13
|
+
i = 2;
|
|
14
|
+
}
|
|
15
|
+
if (typeof target !== 'object' && typeof target !== 'function') {
|
|
16
|
+
target = {};
|
|
17
|
+
}
|
|
18
|
+
for (; i < length; i++) {
|
|
19
|
+
if ((options = args[i]) !== null && options !== undefined) {
|
|
20
|
+
for (name in options) {
|
|
21
|
+
src = target[name];
|
|
22
|
+
copy = options[name];
|
|
23
|
+
if (target === copy) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (deep && copy && (typeof copy === 'object' || isArray(copy))) {
|
|
27
|
+
if (isArray(copy)) {
|
|
28
|
+
clone = isArray(src) ? src : [];
|
|
38
29
|
}
|
|
39
|
-
else
|
|
40
|
-
|
|
30
|
+
else {
|
|
31
|
+
clone = isObject(src) ? src : {};
|
|
41
32
|
}
|
|
33
|
+
target[name] = _extendsFn(deep, clone, copy);
|
|
34
|
+
}
|
|
35
|
+
else if (copy !== undefined) {
|
|
36
|
+
target[name] = copy;
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
return target;
|
|
46
40
|
}
|
|
41
|
+
return target;
|
|
47
42
|
};
|
|
48
43
|
export const isArray = (obj) => {
|
|
49
44
|
return (Array.isArray(obj) ||
|
|
@@ -205,3 +200,31 @@ export function encodeParams(paramObj, serialized, scope, index, jsonKeys, level
|
|
|
205
200
|
}
|
|
206
201
|
return serialized.join('&').replace(/%20/g, '+');
|
|
207
202
|
}
|
|
203
|
+
export function log(env, { level = 'INFO', message = '', context = {}, functionName = '' }) {
|
|
204
|
+
if (!env.enableDebugLogs) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const timestamp = new Date().toISOString();
|
|
208
|
+
const service = 'chargebee-node';
|
|
209
|
+
const metaString = Object.entries(context)
|
|
210
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
211
|
+
.join(', ');
|
|
212
|
+
const logLine = `[${timestamp}] [${level.toUpperCase()}] [${service}] ${functionName} - ${message}${metaString ? ` (${metaString})` : ''}`;
|
|
213
|
+
console.debug(logLine);
|
|
214
|
+
}
|
|
215
|
+
import { randomBytes } from 'crypto';
|
|
216
|
+
export function generateUUIDv4() {
|
|
217
|
+
const bytes = randomBytes(16);
|
|
218
|
+
// Set version to 4 (UUIDv4)
|
|
219
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
220
|
+
// Set variant to 10xxxxxx
|
|
221
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
222
|
+
const hex = bytes.toString('hex');
|
|
223
|
+
return [
|
|
224
|
+
hex.slice(0, 8),
|
|
225
|
+
hex.slice(8, 12),
|
|
226
|
+
hex.slice(12, 16),
|
|
227
|
+
hex.slice(16, 20),
|
|
228
|
+
hex.slice(20),
|
|
229
|
+
].join('-');
|
|
230
|
+
}
|
package/package.json
CHANGED
package/types/core.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
///<reference path='./resources/UnbilledCharge.d.ts' />
|
|
82
82
|
///<reference path='./resources/Usage.d.ts' />
|
|
83
83
|
///<reference path='./resources/UsageEvent.d.ts' />
|
|
84
|
+
///<reference path='./resources/UsageFile.d.ts' />
|
|
84
85
|
///<reference path='./resources/VirtualBankAccount.d.ts' />
|
|
85
86
|
|
|
86
87
|
export type Config = {
|
|
@@ -120,6 +121,29 @@ export type Config = {
|
|
|
120
121
|
* @hostSuffix url host suffix, default value is .chargebee.com
|
|
121
122
|
*/
|
|
122
123
|
hostSuffix?: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @retryConfig retry configuration for the client, default value is { enabled: false, maxRetries: 3, delayMs: 1000, retryOn: [500, 502, 503, 504]}
|
|
127
|
+
*/
|
|
128
|
+
retryConfig?: RetryConfig;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @enableDebugLogs whether to enable debug logs, default value is false
|
|
132
|
+
*/
|
|
133
|
+
enableDebugLogs?: boolean;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type RetryConfig = {
|
|
137
|
+
/**
|
|
138
|
+
* @enabled whether to enable retry logic, default value is false
|
|
139
|
+
* @maxRetries maximum number of retries, default value is 3
|
|
140
|
+
* @delayMs delay in milliseconds between retries, default value is 1000ms
|
|
141
|
+
* @retryOn array of HTTP status codes to retry on, default value is [500, 502, 503, 504]
|
|
142
|
+
*/
|
|
143
|
+
enabled?: boolean;
|
|
144
|
+
maxRetries?: number;
|
|
145
|
+
delayMs?: number;
|
|
146
|
+
retryOn?: Array<number>;
|
|
123
147
|
};
|
|
124
148
|
declare module 'chargebee' {
|
|
125
149
|
export default class Chargebee {
|
|
@@ -180,6 +204,7 @@ declare module 'chargebee' {
|
|
|
180
204
|
unbilledCharge: UnbilledCharge.UnbilledChargeResource;
|
|
181
205
|
usage: Usage.UsageResource;
|
|
182
206
|
usageEvent: UsageEvent.UsageEventResource;
|
|
207
|
+
usageFile: UsageFile.UsageFileResource;
|
|
183
208
|
virtualBankAccount: VirtualBankAccount.VirtualBankAccountResource;
|
|
184
209
|
}
|
|
185
210
|
}
|
|
@@ -615,7 +615,7 @@ declare module 'chargebee' {
|
|
|
615
615
|
charge_on_option?: ChargeOnOptionEnum;
|
|
616
616
|
}
|
|
617
617
|
export interface DiscountsCreateSubItemEstimateInputParam {
|
|
618
|
-
apply_on
|
|
618
|
+
apply_on?: ApplyOnEnum;
|
|
619
619
|
duration_type: DurationTypeEnum;
|
|
620
620
|
percentage?: number;
|
|
621
621
|
amount?: number;
|
|
@@ -751,7 +751,7 @@ declare module 'chargebee' {
|
|
|
751
751
|
charge_on_option?: ChargeOnOptionEnum;
|
|
752
752
|
}
|
|
753
753
|
export interface DiscountsCreateSubItemForCustomerEstimateInputParam {
|
|
754
|
-
apply_on
|
|
754
|
+
apply_on?: ApplyOnEnum;
|
|
755
755
|
duration_type: DurationTypeEnum;
|
|
756
756
|
percentage?: number;
|
|
757
757
|
amount?: number;
|
|
@@ -909,7 +909,7 @@ declare module 'chargebee' {
|
|
|
909
909
|
proration_type?: ProrationTypeEnum;
|
|
910
910
|
}
|
|
911
911
|
export interface DiscountsUpdateSubscriptionForItemsInputParam {
|
|
912
|
-
apply_on
|
|
912
|
+
apply_on?: ApplyOnEnum;
|
|
913
913
|
duration_type: DurationTypeEnum;
|
|
914
914
|
percentage?: number;
|
|
915
915
|
amount?: number;
|
|
@@ -842,7 +842,7 @@ declare module 'chargebee' {
|
|
|
842
842
|
charge_on_option?: ChargeOnOptionEnum;
|
|
843
843
|
}
|
|
844
844
|
export interface DiscountsCheckoutNewForItemsInputParam {
|
|
845
|
-
apply_on
|
|
845
|
+
apply_on?: ApplyOnEnum;
|
|
846
846
|
duration_type: DurationTypeEnum;
|
|
847
847
|
percentage?: number;
|
|
848
848
|
amount?: number;
|
|
@@ -977,7 +977,7 @@ declare module 'chargebee' {
|
|
|
977
977
|
item_type?: ItemTypeEnum;
|
|
978
978
|
}
|
|
979
979
|
export interface DiscountsCheckoutExistingForItemsInputParam {
|
|
980
|
-
apply_on
|
|
980
|
+
apply_on?: ApplyOnEnum;
|
|
981
981
|
duration_type: DurationTypeEnum;
|
|
982
982
|
percentage?: number;
|
|
983
983
|
amount?: number;
|
|
@@ -956,6 +956,7 @@ declare module 'chargebee' {
|
|
|
956
956
|
taxes?: TaxesImportInvoiceInputParam[];
|
|
957
957
|
payments?: PaymentsImportInvoiceInputParam[];
|
|
958
958
|
notes?: NotesImportInvoiceInputParam[];
|
|
959
|
+
line_item_addresses?: LineItemAddressesImportInvoiceInputParam[];
|
|
959
960
|
}
|
|
960
961
|
export interface ApplyPaymentsInputParam {
|
|
961
962
|
comment?: string;
|
|
@@ -1539,6 +1540,23 @@ declare module 'chargebee' {
|
|
|
1539
1540
|
quantity_used_in_decimal?: string;
|
|
1540
1541
|
unit_amount_in_decimal?: string;
|
|
1541
1542
|
}
|
|
1543
|
+
export interface LineItemAddressesImportInvoiceInputParam {
|
|
1544
|
+
line_item_id?: string;
|
|
1545
|
+
first_name?: string;
|
|
1546
|
+
last_name?: string;
|
|
1547
|
+
email?: string;
|
|
1548
|
+
company?: string;
|
|
1549
|
+
phone?: string;
|
|
1550
|
+
line1?: string;
|
|
1551
|
+
line2?: string;
|
|
1552
|
+
line3?: string;
|
|
1553
|
+
city?: string;
|
|
1554
|
+
state_code?: string;
|
|
1555
|
+
state?: string;
|
|
1556
|
+
zip?: string;
|
|
1557
|
+
country?: string;
|
|
1558
|
+
validation_status?: ValidationStatusEnum;
|
|
1559
|
+
}
|
|
1542
1560
|
export interface LineItemsImportInvoiceInputParam {
|
|
1543
1561
|
id?: string;
|
|
1544
1562
|
date_from?: number;
|
|
@@ -11,7 +11,8 @@ declare module 'chargebee' {
|
|
|
11
11
|
| 'expired'
|
|
12
12
|
| 'cancelled'
|
|
13
13
|
| 'in_dunning'
|
|
14
|
-
| 'in_grace_period'
|
|
14
|
+
| 'in_grace_period'
|
|
15
|
+
| 'paused';
|
|
15
16
|
auto_renew_status?: 'off' | 'on';
|
|
16
17
|
current_term_start?: number;
|
|
17
18
|
current_term_end?: number;
|
|
@@ -22,7 +23,8 @@ declare module 'chargebee' {
|
|
|
22
23
|
| 'customer_cancelled'
|
|
23
24
|
| 'customer_did_not_consent_to_price_increase'
|
|
24
25
|
| 'refunded_due_to_app_issue'
|
|
25
|
-
| 'refunded_for_other_reason'
|
|
26
|
+
| 'refunded_for_other_reason'
|
|
27
|
+
| 'merchant_revoked';
|
|
26
28
|
grace_period_expires_at?: number;
|
|
27
29
|
has_scheduled_changes: boolean;
|
|
28
30
|
resource_version?: number;
|
|
@@ -98,7 +98,7 @@ declare module 'chargebee' {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export interface DiscountsCreateForNewSubscriptionInputParam {
|
|
101
|
-
apply_on
|
|
101
|
+
apply_on?: ApplyOnEnum;
|
|
102
102
|
duration_type: DurationTypeEnum;
|
|
103
103
|
percentage?: number;
|
|
104
104
|
amount?: number;
|
|
@@ -116,7 +116,7 @@ declare module 'chargebee' {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export interface DiscountsCreateForExistingSubscriptionInputParam {
|
|
119
|
-
apply_on
|
|
119
|
+
apply_on?: ApplyOnEnum;
|
|
120
120
|
duration_type: DurationTypeEnum;
|
|
121
121
|
percentage?: number;
|
|
122
122
|
amount?: number;
|
|
@@ -1083,7 +1083,7 @@ declare module 'chargebee' {
|
|
|
1083
1083
|
charge_on_option?: ChargeOnOptionEnum;
|
|
1084
1084
|
}
|
|
1085
1085
|
export interface DiscountsCreateSubItemsForCustomerQuoteInputParam {
|
|
1086
|
-
apply_on
|
|
1086
|
+
apply_on?: ApplyOnEnum;
|
|
1087
1087
|
duration_type: DurationTypeEnum;
|
|
1088
1088
|
percentage?: number;
|
|
1089
1089
|
amount?: number;
|
|
@@ -1153,7 +1153,7 @@ declare module 'chargebee' {
|
|
|
1153
1153
|
charge_on_option?: ChargeOnOptionEnum;
|
|
1154
1154
|
}
|
|
1155
1155
|
export interface DiscountsEditCreateSubCustomerQuoteForItemsInputParam {
|
|
1156
|
-
apply_on
|
|
1156
|
+
apply_on?: ApplyOnEnum;
|
|
1157
1157
|
duration_type: DurationTypeEnum;
|
|
1158
1158
|
percentage?: number;
|
|
1159
1159
|
amount?: number;
|
|
@@ -1249,7 +1249,7 @@ declare module 'chargebee' {
|
|
|
1249
1249
|
item_type?: ItemTypeEnum;
|
|
1250
1250
|
}
|
|
1251
1251
|
export interface DiscountsUpdateSubscriptionQuoteForItemsInputParam {
|
|
1252
|
-
apply_on
|
|
1252
|
+
apply_on?: ApplyOnEnum;
|
|
1253
1253
|
duration_type: DurationTypeEnum;
|
|
1254
1254
|
percentage?: number;
|
|
1255
1255
|
amount?: number;
|
|
@@ -1346,7 +1346,7 @@ declare module 'chargebee' {
|
|
|
1346
1346
|
item_type?: ItemTypeEnum;
|
|
1347
1347
|
}
|
|
1348
1348
|
export interface DiscountsEditUpdateSubscriptionQuoteForItemsInputParam {
|
|
1349
|
-
apply_on
|
|
1349
|
+
apply_on?: ApplyOnEnum;
|
|
1350
1350
|
duration_type: DurationTypeEnum;
|
|
1351
1351
|
percentage?: number;
|
|
1352
1352
|
amount?: number;
|
|
@@ -1644,7 +1644,7 @@ declare module 'chargebee' {
|
|
|
1644
1644
|
usage_accumulation_reset_frequency?: UsageAccumulationResetFrequencyEnum;
|
|
1645
1645
|
}
|
|
1646
1646
|
export interface DiscountsCreateWithItemsInputParam {
|
|
1647
|
-
apply_on
|
|
1647
|
+
apply_on?: ApplyOnEnum;
|
|
1648
1648
|
duration_type: DurationTypeEnum;
|
|
1649
1649
|
percentage?: number;
|
|
1650
1650
|
amount?: number;
|
|
@@ -1981,7 +1981,7 @@ declare module 'chargebee' {
|
|
|
1981
1981
|
usage_accumulation_reset_frequency?: UsageAccumulationResetFrequencyEnum;
|
|
1982
1982
|
}
|
|
1983
1983
|
export interface DiscountsUpdateForItemsInputParam {
|
|
1984
|
-
apply_on
|
|
1984
|
+
apply_on?: ApplyOnEnum;
|
|
1985
1985
|
duration_type: DurationTypeEnum;
|
|
1986
1986
|
percentage?: number;
|
|
1987
1987
|
amount?: number;
|
|
@@ -2389,7 +2389,7 @@ declare module 'chargebee' {
|
|
|
2389
2389
|
item_type?: ItemTypeEnum;
|
|
2390
2390
|
}
|
|
2391
2391
|
export interface DiscountsImportForItemsInputParam {
|
|
2392
|
-
apply_on
|
|
2392
|
+
apply_on?: ApplyOnEnum;
|
|
2393
2393
|
duration_type: DurationTypeEnum;
|
|
2394
2394
|
percentage?: number;
|
|
2395
2395
|
amount?: number;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///<reference path='./../core.d.ts'/>
|
|
2
|
+
///<reference path='./../index.d.ts'/>
|
|
3
|
+
|
|
4
|
+
declare module 'chargebee' {
|
|
5
|
+
export interface UsageFile {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
mime_type: string;
|
|
9
|
+
error_code?: string;
|
|
10
|
+
error_reason?: string;
|
|
11
|
+
status?: 'queued' | 'imported' | 'processing' | 'processed' | 'failed';
|
|
12
|
+
total_records_count?: number;
|
|
13
|
+
processed_records_count?: number;
|
|
14
|
+
failed_records_count?: number;
|
|
15
|
+
file_size_in_bytes?: number;
|
|
16
|
+
processing_started_at?: number;
|
|
17
|
+
processing_completed_at?: number;
|
|
18
|
+
uploaded_by?: string;
|
|
19
|
+
uploaded_at?: number;
|
|
20
|
+
upload_details?: UsageFile.UploadDetail;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export namespace UsageFile {
|
|
24
|
+
export class UsageFileResource {
|
|
25
|
+
upload(
|
|
26
|
+
input: UploadInputParam,
|
|
27
|
+
headers?: ChargebeeRequestHeader,
|
|
28
|
+
): Promise<ChargebeeResponse<UploadResponse>>;
|
|
29
|
+
|
|
30
|
+
status(
|
|
31
|
+
usage_file_id: string,
|
|
32
|
+
headers?: ChargebeeRequestHeader,
|
|
33
|
+
): Promise<ChargebeeResponse<StatusResponse>>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface UploadResponse {
|
|
37
|
+
usage_file: UsageFile;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface StatusResponse {
|
|
41
|
+
usage_file: UsageFile;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface UploadDetail {
|
|
45
|
+
url: string;
|
|
46
|
+
expires_at: number;
|
|
47
|
+
}
|
|
48
|
+
// REQUEST PARAMS
|
|
49
|
+
//---------------
|
|
50
|
+
|
|
51
|
+
export interface UploadInputParam {
|
|
52
|
+
file_name: string;
|
|
53
|
+
mime_type: string;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|