chargebee 3.8.0-beta.1 → 3.9.0
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 +74 -0
- package/cjs/RequestWrapper.js +19 -18
- package/cjs/asyncApiSupport.js +7 -7
- package/cjs/coreCommon.js +4 -4
- package/cjs/createChargebee.js +15 -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 +42 -0
- package/esm/RequestWrapper.js +4 -3
- package/esm/asyncApiSupport.js +1 -1
- package/esm/coreCommon.js +2 -2
- package/esm/createChargebee.js +5 -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 +42 -0
- package/package.json +1 -1
- package/types/core.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/resources/Configuration.d.ts +1 -0
- package/types/resources/CreditNote.d.ts +10 -1
- package/types/resources/CreditNoteEstimate.d.ts +1 -1
- package/types/resources/Estimate.d.ts +10 -0
- package/types/resources/Invoice.d.ts +40 -4
- package/types/resources/InvoiceEstimate.d.ts +1 -1
- package/types/resources/Item.d.ts +2 -1
- package/types/resources/OmnichannelSubscriptionItem.d.ts +6 -0
- package/types/resources/Quote.d.ts +139 -4
- package/types/resources/QuoteLineGroup.d.ts +1 -1
- package/types/resources/QuotedRamp.d.ts +93 -0
- package/types/resources/Subscription.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
+
### v3.9.0 (2025-06-23)
|
|
2
|
+
* * *
|
|
3
|
+
|
|
4
|
+
### New Features
|
|
5
|
+
* Added built-in retry support for handling transient errors and rate-limiting.
|
|
6
|
+
* Retries are now supported for HTTP status codes 500, 502, 503, 504, and 429.
|
|
7
|
+
* Includes exponential backoff for server errors and Retry-After respect for rate limits (429).
|
|
8
|
+
* Configurable via retryConfig during SDK initialization.
|
|
9
|
+
|
|
10
|
+
### v3.8.0 (2025-06-19)
|
|
11
|
+
* * *
|
|
12
|
+
|
|
13
|
+
### New Resources
|
|
14
|
+
* QuotedRamp has been added.
|
|
15
|
+
|
|
16
|
+
### New Attributes
|
|
17
|
+
* chargebee_response_schema_type has been added to Configuration.
|
|
18
|
+
* linked_item has been added to OmnichannelSubscriptionItem.
|
|
19
|
+
* resumes_at has been added to OmnichannelSubscriptionItem.
|
|
20
|
+
|
|
21
|
+
### Changed Attributes
|
|
22
|
+
* percentage changed to is_percentage_pricing in CreditNote.
|
|
23
|
+
* percentage changed to is_percentage_pricing in QuoteLineGroup.
|
|
24
|
+
* percentage changed to is_percentage_pricing in CreditNoteEstimate.
|
|
25
|
+
* percentage changed to is_percentage_pricing in Invoice.
|
|
26
|
+
* percentage changed to is_percentage_pricing in InvoiceEstimate.
|
|
27
|
+
* percentage changed to is_percentage_pricing in Quote.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### New Input Parameters
|
|
31
|
+
* is_percentage_pricing has been added to Item#UpdateRequest.
|
|
32
|
+
* line_item[subscription_id] has been added to CreditNote#RetrieveRequest.
|
|
33
|
+
* line_item[customer_id] has been added to CreditNote#RetrieveRequest.
|
|
34
|
+
* line_item[subscription_id] has been added to Invoice#RetrieveRequest.
|
|
35
|
+
* line_item[customer_id] has been added to Invoice#RetrieveRequest.
|
|
36
|
+
* billing_override[max_excess_payment_usage] has been added to Estimate#CreateSubItemForCustomerEstimateRequest.
|
|
37
|
+
* billing_override[max_refundable_credits_usage] has been added to Estimate#CreateSubItemForCustomerEstimateRequest.
|
|
38
|
+
* billing_override[max_excess_payment_usage] has been added to Estimate#UpdateSubscriptionForItemsRequest.
|
|
39
|
+
* billing_override[max_refundable_credits_usage] has been added to Estimate#UpdateSubscriptionForItemsRequest.
|
|
40
|
+
* billing_start_option has been added to Quote#CreateSubItemsForCustomerQuoteRequest.
|
|
41
|
+
* net_term_days has been added to Quote#CreateSubItemsForCustomerQuoteRequest.
|
|
42
|
+
* billing_address has been added to Quote#CreateSubItemsForCustomerQuoteRequest.
|
|
43
|
+
* subscription_items has been added to Quote#CreateSubItemsForCustomerQuoteRequest.
|
|
44
|
+
* discounts has been added to Quote#CreateSubItemsForCustomerQuoteRequest.
|
|
45
|
+
* billing_start_option has been added to Quote#EditCreateSubCustomerQuoteForItemsRequest.
|
|
46
|
+
* net_term_days has been added to Quote#EditCreateSubCustomerQuoteForItemsRequest.
|
|
47
|
+
* billing_address has been added to Quote#EditCreateSubCustomerQuoteForItemsRequest.
|
|
48
|
+
* subscription_items has been added to Quote#EditCreateSubCustomerQuoteForItemsRequest.
|
|
49
|
+
* discounts has been added to Quote#EditCreateSubCustomerQuoteForItemsRequest.
|
|
50
|
+
* net_term_days has been added to Quote#UpdateSubscriptionQuoteForItemsRequest.
|
|
51
|
+
* subscription_items has been added to Quote#UpdateSubscriptionQuoteForItemsRequest.
|
|
52
|
+
* discount has been added to Quote#UpdateSubscriptionQuoteForItemsRequest.
|
|
53
|
+
* coupons has been added to Quote#UpdateSubscriptionQuoteForItemsRequest.
|
|
54
|
+
* net_term_days has been added to Quote#EditUpdateSubscriptionQuoteForItemsRequest.
|
|
55
|
+
* subscription_items has been added to Quote#EditUpdateSubscriptionQuoteForItemsRequest.
|
|
56
|
+
* discounts has been added to Quote#EditUpdateSubscriptionQuoteForItemsRequest.
|
|
57
|
+
* coupons has been added to Quote#EditUpdateSubscriptionQuoteForItemsRequest.
|
|
58
|
+
* billing_address has been added to Quote#CreateForChargeItemsAndChargesRequest.
|
|
59
|
+
* billing_address has been added to Quote#EditForChargeItemsAndChargesRequest.
|
|
60
|
+
* sort_by[order] has been added to Subscription#SubscriptionContractTermsForSubscriptionRequest.
|
|
61
|
+
* item_tiers has been added to Quote#UpdateSubscriptionQuoteForItemsRequest.
|
|
62
|
+
* item_tiers has been added to Quote#EditUpdateSubscriptionQuoteForItemsRequest.
|
|
63
|
+
* item_tiers has been added to Quote#CreateSubItemsForCustomerQuoteRequest.
|
|
64
|
+
* item_tiers has been added to Quote#EditCreateSubCustomerQuoteForItemsRequest.
|
|
65
|
+
|
|
66
|
+
### New Endpoints:
|
|
67
|
+
* PauseDunningRequest has been added to Invoice.
|
|
68
|
+
* ResumeDunningRequest has been added to Invoice.
|
|
69
|
+
|
|
70
|
+
### Enum Attributes:
|
|
71
|
+
* BillingPeriodUnitEnum has been added.
|
|
72
|
+
* BillingStartOptionEnum has been added.
|
|
73
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_RESUMED has been added to EventTypeEnum.
|
|
74
|
+
|
|
1
75
|
### v3.7.0 (2025-05-15)
|
|
2
76
|
* * *
|
|
3
77
|
|
package/cjs/RequestWrapper.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RequestWrapper = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const util_js_1 = require("./util.js");
|
|
5
|
+
const coreCommon_js_1 = require("./coreCommon.js");
|
|
6
6
|
const node_buffer_1 = require("node:buffer");
|
|
7
7
|
class RequestWrapper {
|
|
8
8
|
constructor(args, apiCall, envArg) {
|
|
@@ -34,7 +34,7 @@ class RequestWrapper {
|
|
|
34
34
|
}
|
|
35
35
|
async request() {
|
|
36
36
|
let env = {};
|
|
37
|
-
(0,
|
|
37
|
+
(0, util_js_1.extend)(true, env, this.envArg);
|
|
38
38
|
const retryConfig = Object.assign({ enabled: false, maxRetries: 3, delayMs: 200, retryOn: [500, 502, 503, 504] }, env.retryConfig);
|
|
39
39
|
const urlIdParam = this.apiCall.hasIdInUrl ? this.args[0] : null;
|
|
40
40
|
let params = this.apiCall.hasIdInUrl
|
|
@@ -45,35 +45,36 @@ class RequestWrapper {
|
|
|
45
45
|
if (this.apiCall.httpMethod === 'POST' &&
|
|
46
46
|
!this.httpHeaders['chargebee-idempotency-key'] &&
|
|
47
47
|
this.apiCall.options &&
|
|
48
|
-
this.apiCall.options.isIdempotent
|
|
49
|
-
|
|
48
|
+
this.apiCall.options.isIdempotent &&
|
|
49
|
+
retryConfig.enabled) {
|
|
50
|
+
this.httpHeaders['chargebee-idempotency-key'] = (0, util_js_1.generateUUIDv4)();
|
|
50
51
|
}
|
|
51
52
|
const makeRequest = async (attempt = 0) => {
|
|
52
|
-
let path = (0,
|
|
53
|
+
let path = (0, util_js_1.getApiURL)(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
|
|
53
54
|
if (typeof params === 'undefined' || params === null) {
|
|
54
55
|
params = {};
|
|
55
56
|
}
|
|
56
57
|
if (this.apiCall.httpMethod === 'GET') {
|
|
57
58
|
const queryParam = this.apiCall.isListReq
|
|
58
|
-
? (0,
|
|
59
|
-
: (0,
|
|
59
|
+
? (0, util_js_1.encodeListParams)((0, util_js_1.serialize)(params))
|
|
60
|
+
: (0, util_js_1.encodeParams)((0, util_js_1.serialize)(params));
|
|
60
61
|
path += '?' + queryParam;
|
|
61
62
|
params = {};
|
|
62
63
|
}
|
|
63
64
|
const jsonKeys = this.apiCall.jsonKeys;
|
|
64
65
|
const data = this.apiCall.isJsonRequest
|
|
65
66
|
? JSON.stringify(params)
|
|
66
|
-
: (0,
|
|
67
|
+
: (0, util_js_1.encodeParams)(params, undefined, undefined, undefined, jsonKeys);
|
|
67
68
|
const requestHeaders = Object.assign({}, this.httpHeaders);
|
|
68
69
|
if (data.length) {
|
|
69
|
-
(0,
|
|
70
|
+
(0, util_js_1.extend)(true, requestHeaders, {
|
|
70
71
|
'Content-Length': data.length,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
const contentType = this.apiCall.isJsonRequest
|
|
74
75
|
? 'application/json;charset=UTF-8'
|
|
75
76
|
: 'application/x-www-form-urlencoded; charset=utf-8';
|
|
76
|
-
(0,
|
|
77
|
+
(0, util_js_1.extend)(true, requestHeaders, {
|
|
77
78
|
Authorization: 'Basic ' + node_buffer_1.Buffer.from(env.apiKey + ':').toString('base64'),
|
|
78
79
|
Accept: 'application/json',
|
|
79
80
|
'Content-Type': contentType,
|
|
@@ -84,7 +85,7 @@ class RequestWrapper {
|
|
|
84
85
|
requestHeaders['X-CB-Retry-Attempt'] = attempt.toString();
|
|
85
86
|
}
|
|
86
87
|
const resp = await this.envArg.httpClient.makeApiRequest({
|
|
87
|
-
host: (0,
|
|
88
|
+
host: (0, util_js_1.getHost)(env, this.apiCall.subDomain),
|
|
88
89
|
port: env.port,
|
|
89
90
|
path,
|
|
90
91
|
method: this.apiCall.httpMethod,
|
|
@@ -94,7 +95,7 @@ class RequestWrapper {
|
|
|
94
95
|
timeout: env.timeout,
|
|
95
96
|
});
|
|
96
97
|
return new Promise((resolve, reject) => {
|
|
97
|
-
(0,
|
|
98
|
+
(0, coreCommon_js_1.handleResponse)((err, response) => {
|
|
98
99
|
if (err)
|
|
99
100
|
return reject(err);
|
|
100
101
|
return resolve(response);
|
|
@@ -115,13 +116,13 @@ class RequestWrapper {
|
|
|
115
116
|
const retryAfterHeader = (_f = headers['retry-after']) === null || _f === void 0 ? void 0 : _f.toLowerCase();
|
|
116
117
|
const parsedDelay = RequestWrapper.parseRetryAfter(retryAfterHeader);
|
|
117
118
|
if (!parsedDelay) {
|
|
118
|
-
(0,
|
|
119
|
+
(0, util_js_1.log)(env, {
|
|
119
120
|
level: 'ERROR',
|
|
120
121
|
message: `Rate limit error occurred, but no retry-after header found. Retrying in ${retryConfig.delayMs}ms.`,
|
|
121
122
|
});
|
|
122
123
|
throw err;
|
|
123
124
|
}
|
|
124
|
-
(0,
|
|
125
|
+
(0, util_js_1.log)(env, {
|
|
125
126
|
level: 'INFO',
|
|
126
127
|
message: `Rate limit error occurred. Retrying in ${parsedDelay}ms.`,
|
|
127
128
|
});
|
|
@@ -132,7 +133,7 @@ class RequestWrapper {
|
|
|
132
133
|
retryConfig.retryOn.includes(statusCode) &&
|
|
133
134
|
retryCount < retryConfig.maxRetries;
|
|
134
135
|
if (!canRetry) {
|
|
135
|
-
(0,
|
|
136
|
+
(0, util_js_1.log)(env, {
|
|
136
137
|
level: 'ERROR',
|
|
137
138
|
message: `Request failed after ${retryCount} retries: ${err.message}`,
|
|
138
139
|
});
|
|
@@ -140,7 +141,7 @@ class RequestWrapper {
|
|
|
140
141
|
}
|
|
141
142
|
let retryDelayMs = retryConfig.delayMs * Math.pow(2, retryCount) +
|
|
142
143
|
Math.random() * 100;
|
|
143
|
-
(0,
|
|
144
|
+
(0, util_js_1.log)(env, {
|
|
144
145
|
level: 'INFO',
|
|
145
146
|
message: `Retrying request [${retryCount + 1}/${retryConfig.maxRetries}] in ${retryDelayMs}ms due to status code ${statusCode}.`,
|
|
146
147
|
});
|
|
@@ -150,7 +151,7 @@ class RequestWrapper {
|
|
|
150
151
|
}
|
|
151
152
|
};
|
|
152
153
|
const promise = withRetry(0, Date.now());
|
|
153
|
-
return (0,
|
|
154
|
+
return (0, util_js_1.callbackifyPromise)(promise);
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
exports.RequestWrapper = RequestWrapper;
|
package/cjs/asyncApiSupport.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitForProcessToComplete = void 0;
|
|
4
|
-
const
|
|
4
|
+
const util_js_1 = require("./util.js");
|
|
5
5
|
const waitForProcessToComplete = (retrieveHandling, env) => {
|
|
6
|
-
if (typeof retrieveHandling == 'undefined' || !(0,
|
|
6
|
+
if (typeof retrieveHandling == 'undefined' || !(0, util_js_1.isFunction)(retrieveHandling)) {
|
|
7
7
|
throw new Error('The handling parameter should be a method.');
|
|
8
8
|
}
|
|
9
9
|
const DummyRequestWrapper = function () {
|
|
@@ -12,15 +12,15 @@ const waitForProcessToComplete = (retrieveHandling, env) => {
|
|
|
12
12
|
const _request = function (callBack, envOptions) {
|
|
13
13
|
const jsonConstructor = {}.constructor;
|
|
14
14
|
if (typeof envOptions !== 'undefined') {
|
|
15
|
-
(0,
|
|
15
|
+
(0, util_js_1.extend)(true, env, envOptions);
|
|
16
16
|
}
|
|
17
17
|
else if (typeof callBack !== 'undefined' &&
|
|
18
18
|
callBack.constructor === jsonConstructor &&
|
|
19
|
-
!(0,
|
|
20
|
-
(0,
|
|
19
|
+
!(0, util_js_1.isFunction)(callBack)) {
|
|
20
|
+
(0, util_js_1.extend)(true, env, callBack);
|
|
21
21
|
callBack = undefined;
|
|
22
22
|
}
|
|
23
|
-
if (typeof callBack !== 'undefined' && !(0,
|
|
23
|
+
if (typeof callBack !== 'undefined' && !(0, util_js_1.isFunction)(callBack)) {
|
|
24
24
|
throw new Error('The callback parameter passed is incorrect.');
|
|
25
25
|
}
|
|
26
26
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -32,7 +32,7 @@ const waitForProcessToComplete = (retrieveHandling, env) => {
|
|
|
32
32
|
reject(err);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, util_js_1.callbackifyPromise)(promise, callBack);
|
|
36
36
|
};
|
|
37
37
|
return new DummyRequestWrapper();
|
|
38
38
|
};
|
package/cjs/coreCommon.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleResponse = void 0;
|
|
4
4
|
exports.throwError = throwError;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const chargebeeError_js_1 = require("./chargebeeError.js");
|
|
6
|
+
const util_js_1 = require("./util.js");
|
|
7
7
|
const IDEMPOTENCY_REPLAYED_HEADER = 'chargebee-idempotency-replayed';
|
|
8
8
|
function throwError(callBack, rawError, headers) {
|
|
9
|
-
const error = new
|
|
9
|
+
const error = new chargebeeError_js_1.ChargebeeError({
|
|
10
10
|
message: rawError.message,
|
|
11
11
|
type: rawError.type,
|
|
12
12
|
api_error_code: rawError.errorCode,
|
|
@@ -31,7 +31,7 @@ const handleResponse = async (callback, response) => {
|
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
res.isIdempotencyReplayed = false;
|
|
34
|
-
if ((0,
|
|
34
|
+
if ((0, util_js_1.isNotUndefinedNEmpty)(headers[IDEMPOTENCY_REPLAYED_HEADER])) {
|
|
35
35
|
res.isIdempotencyReplayed = headers[IDEMPOTENCY_REPLAYED_HEADER];
|
|
36
36
|
}
|
|
37
37
|
res.headers = headers;
|
package/cjs/createChargebee.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CreateChargebee = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const RequestWrapper_js_1 = require("./RequestWrapper.js");
|
|
5
|
+
const environment_js_1 = require("./environment.js");
|
|
6
|
+
const api_endpoints_js_1 = require("./resources/api_endpoints.js");
|
|
7
|
+
const util_js_1 = require("./util.js");
|
|
8
|
+
const asyncApiSupport_js_1 = require("./asyncApiSupport.js");
|
|
9
9
|
const CreateChargebee = (httpClient) => {
|
|
10
10
|
const Chargebee = function (conf) {
|
|
11
|
-
this._env = Object.assign({},
|
|
12
|
-
(0,
|
|
11
|
+
this._env = Object.assign({}, environment_js_1.Environment);
|
|
12
|
+
(0, util_js_1.extend)(true, this._env, conf);
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
this._env.httpClient = httpClient;
|
|
15
15
|
this._buildResources();
|
|
16
|
-
this._endpoints =
|
|
16
|
+
this._endpoints = api_endpoints_js_1.Endpoints;
|
|
17
17
|
};
|
|
18
18
|
Chargebee.prototype = {
|
|
19
19
|
_createApiFunc(apiCall, env) {
|
|
20
20
|
return async function () {
|
|
21
|
-
const rw = new
|
|
21
|
+
const rw = new RequestWrapper_js_1.RequestWrapper(arguments, apiCall, env);
|
|
22
22
|
return rw.getRequest();
|
|
23
23
|
};
|
|
24
24
|
},
|
|
@@ -32,7 +32,7 @@ const CreateChargebee = (httpClient) => {
|
|
|
32
32
|
return result;
|
|
33
33
|
}
|
|
34
34
|
else if (exportObj.status === 'in_process') {
|
|
35
|
-
await (0,
|
|
35
|
+
await (0, util_js_1.sleep)(this._env.exportWaitInMillis);
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
@@ -41,7 +41,7 @@ const CreateChargebee = (httpClient) => {
|
|
|
41
41
|
}
|
|
42
42
|
throw new Error('Export is taking too long');
|
|
43
43
|
};
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, asyncApiSupport_js_1.waitForProcessToComplete)(retrieve);
|
|
45
45
|
},
|
|
46
46
|
_timeMachineWait() {
|
|
47
47
|
let count = 0;
|
|
@@ -53,7 +53,7 @@ const CreateChargebee = (httpClient) => {
|
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
55
55
|
else if (time_machine.time_travel_status === 'in_progress') {
|
|
56
|
-
await (0,
|
|
56
|
+
await (0, util_js_1.sleep)(this._env.timemachineWaitInMillis);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
@@ -62,13 +62,13 @@ const CreateChargebee = (httpClient) => {
|
|
|
62
62
|
}
|
|
63
63
|
throw new Error('The time travel is taking too much time');
|
|
64
64
|
};
|
|
65
|
-
return (0,
|
|
65
|
+
return (0, asyncApiSupport_js_1.waitForProcessToComplete)(retrieve);
|
|
66
66
|
},
|
|
67
67
|
_buildResources() {
|
|
68
|
-
for (const res in
|
|
68
|
+
for (const res in api_endpoints_js_1.Endpoints) {
|
|
69
69
|
this[res] = {};
|
|
70
70
|
// @ts-ignore
|
|
71
|
-
const apiCalls =
|
|
71
|
+
const apiCalls = api_endpoints_js_1.Endpoints[res];
|
|
72
72
|
for (let apiIdx = 0; apiIdx < apiCalls.length; apiIdx++) {
|
|
73
73
|
const metaArr = apiCalls[apiIdx];
|
|
74
74
|
const apiCall = {
|
package/cjs/environment.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.Environment = {
|
|
|
11
11
|
hostSuffix: '.chargebee.com',
|
|
12
12
|
apiPath: '/api/v2',
|
|
13
13
|
timeout: DEFAULT_TIME_OUT,
|
|
14
|
-
clientVersion: 'v3.
|
|
14
|
+
clientVersion: 'v3.9.0',
|
|
15
15
|
port: DEFAULT_PORT,
|
|
16
16
|
timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
|
|
17
17
|
exportWaitInMillis: DEFAULT_EXPORT_WAIT,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpClientResponse = exports.HttpClient = void 0;
|
|
4
|
-
const
|
|
4
|
+
const chargebeeError_js_1 = require("../chargebeeError.js");
|
|
5
5
|
class HttpClient {
|
|
6
6
|
async makeApiRequest(props) {
|
|
7
7
|
throw new Error('makeApiRequest is not implemented');
|
|
8
8
|
}
|
|
9
9
|
static timeOutError() {
|
|
10
|
-
const error = new
|
|
10
|
+
const error = new chargebeeError_js_1.ChargebeeError({
|
|
11
11
|
message: 'io_error',
|
|
12
12
|
type: 'timeout',
|
|
13
13
|
api_error_code: 'request aborted due to timeout.',
|
package/cjs/net/FetchClient.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FetchHttpClientResponse = exports.FetchHttpClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
class FetchHttpClient extends
|
|
4
|
+
const ClientInterface_js_1 = require("./ClientInterface.js");
|
|
5
|
+
class FetchHttpClient extends ClientInterface_js_1.HttpClient {
|
|
6
6
|
async makeApiRequest(props) {
|
|
7
7
|
const headers = this._createHeaders(props.headers);
|
|
8
8
|
let url = `${props.protocol}://${props.host}:${props.port}${props.path}`;
|
|
@@ -33,7 +33,7 @@ class FetchHttpClient extends ClientInterface_1.HttpClient {
|
|
|
33
33
|
const timeoutPromise = new Promise((_, reject) => {
|
|
34
34
|
pendingTimeoutId = setTimeout(() => {
|
|
35
35
|
pendingTimeoutId = null;
|
|
36
|
-
reject(
|
|
36
|
+
reject(ClientInterface_js_1.HttpClient.timeOutError());
|
|
37
37
|
}, timeout);
|
|
38
38
|
});
|
|
39
39
|
const fetchPromise = fetch(url, fetchOptions);
|
|
@@ -47,14 +47,14 @@ class FetchHttpClient extends ClientInterface_1.HttpClient {
|
|
|
47
47
|
const abort = new AbortController();
|
|
48
48
|
let timeoutId = setTimeout(() => {
|
|
49
49
|
timeoutId = null;
|
|
50
|
-
abort.abort(
|
|
50
|
+
abort.abort(ClientInterface_js_1.HttpClient.timeOutError());
|
|
51
51
|
}, timeout);
|
|
52
52
|
try {
|
|
53
53
|
return await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
|
|
54
54
|
}
|
|
55
55
|
catch (err) {
|
|
56
56
|
if (err.name === 'AbortError') {
|
|
57
|
-
return Promise.reject(
|
|
57
|
+
return Promise.reject(ClientInterface_js_1.HttpClient.timeOutError());
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
return Promise.reject(err);
|
|
@@ -68,7 +68,7 @@ class FetchHttpClient extends ClientInterface_1.HttpClient {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
exports.FetchHttpClient = FetchHttpClient;
|
|
71
|
-
class FetchHttpClientResponse extends
|
|
71
|
+
class FetchHttpClientResponse extends ClientInterface_js_1.HttpClientResponse {
|
|
72
72
|
constructor(response) {
|
|
73
73
|
super(response.status, FetchHttpClientResponse._transformHeadersToObject(response.headers));
|
|
74
74
|
this._res = response;
|
package/cjs/net/NodeClient.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeHttpClientResponse = exports.NodeHttpClient = void 0;
|
|
4
|
-
const
|
|
4
|
+
const ClientInterface_js_1 = require("./ClientInterface.js");
|
|
5
5
|
const http = require("http");
|
|
6
6
|
const https = require("https");
|
|
7
|
-
class NodeHttpClient extends
|
|
7
|
+
class NodeHttpClient extends ClientInterface_js_1.HttpClient {
|
|
8
8
|
async makeApiRequest(props) {
|
|
9
9
|
const protocol = props.protocol === 'http' ? http : https;
|
|
10
10
|
const requestPromise = new Promise((resolve, reject) => {
|
|
@@ -16,7 +16,7 @@ class NodeHttpClient extends ClientInterface_1.HttpClient {
|
|
|
16
16
|
headers: props.headers,
|
|
17
17
|
});
|
|
18
18
|
req.setTimeout(props.timeout, () => {
|
|
19
|
-
throw
|
|
19
|
+
throw ClientInterface_js_1.HttpClient.timeOutError();
|
|
20
20
|
});
|
|
21
21
|
req.on('response', (res) => {
|
|
22
22
|
resolve(new NodeHttpClientResponse(res));
|
|
@@ -31,7 +31,7 @@ class NodeHttpClient extends ClientInterface_1.HttpClient {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.NodeHttpClient = NodeHttpClient;
|
|
34
|
-
class NodeHttpClientResponse extends
|
|
34
|
+
class NodeHttpClientResponse extends ClientInterface_js_1.HttpClientResponse {
|
|
35
35
|
constructor(res) {
|
|
36
36
|
//@ts-ignore
|
|
37
37
|
super(res.statusCode, res.headers);
|
|
@@ -1249,6 +1249,32 @@ exports.Endpoints = {
|
|
|
1249
1249
|
isIdempotent: true,
|
|
1250
1250
|
},
|
|
1251
1251
|
],
|
|
1252
|
+
[
|
|
1253
|
+
'pauseDunning',
|
|
1254
|
+
'POST',
|
|
1255
|
+
'/invoices',
|
|
1256
|
+
'/pause_dunning',
|
|
1257
|
+
true,
|
|
1258
|
+
null,
|
|
1259
|
+
false,
|
|
1260
|
+
{},
|
|
1261
|
+
{
|
|
1262
|
+
isIdempotent: true,
|
|
1263
|
+
},
|
|
1264
|
+
],
|
|
1265
|
+
[
|
|
1266
|
+
'resumeDunning',
|
|
1267
|
+
'POST',
|
|
1268
|
+
'/invoices',
|
|
1269
|
+
'/resume_dunning',
|
|
1270
|
+
true,
|
|
1271
|
+
null,
|
|
1272
|
+
false,
|
|
1273
|
+
{},
|
|
1274
|
+
{
|
|
1275
|
+
isIdempotent: true,
|
|
1276
|
+
},
|
|
1277
|
+
],
|
|
1252
1278
|
[
|
|
1253
1279
|
'importInvoice',
|
|
1254
1280
|
'POST',
|
|
@@ -2913,6 +2939,7 @@ exports.Endpoints = {
|
|
|
2913
2939
|
],
|
|
2914
2940
|
quotedSubscription: [],
|
|
2915
2941
|
quotedCharge: [],
|
|
2942
|
+
quotedRamp: [],
|
|
2916
2943
|
quoteLineGroup: [],
|
|
2917
2944
|
plan: [
|
|
2918
2945
|
[
|
|
@@ -4270,6 +4297,21 @@ exports.Endpoints = {
|
|
|
4270
4297
|
},
|
|
4271
4298
|
],
|
|
4272
4299
|
],
|
|
4300
|
+
nonSubscription: [
|
|
4301
|
+
[
|
|
4302
|
+
'processReceipt',
|
|
4303
|
+
'POST',
|
|
4304
|
+
'/non_subscriptions',
|
|
4305
|
+
'/one_time_purchase',
|
|
4306
|
+
true,
|
|
4307
|
+
null,
|
|
4308
|
+
false,
|
|
4309
|
+
{},
|
|
4310
|
+
{
|
|
4311
|
+
isIdempotent: true,
|
|
4312
|
+
},
|
|
4313
|
+
],
|
|
4314
|
+
],
|
|
4273
4315
|
entitlementOverride: [
|
|
4274
4316
|
[
|
|
4275
4317
|
'addEntitlementOverrideForSubscription',
|
package/esm/RequestWrapper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { extend, callbackifyPromise, getApiURL, encodeListParams, encodeParams, serialize, getHost, log, generateUUIDv4 as uuidv4, } from './util';
|
|
2
|
-
import { handleResponse } from './coreCommon';
|
|
1
|
+
import { extend, callbackifyPromise, getApiURL, encodeListParams, encodeParams, serialize, getHost, log, generateUUIDv4 as uuidv4, } from './util.js';
|
|
2
|
+
import { handleResponse } from './coreCommon.js';
|
|
3
3
|
import { Buffer } from 'node:buffer';
|
|
4
4
|
export class RequestWrapper {
|
|
5
5
|
constructor(args, apiCall, envArg) {
|
|
@@ -42,7 +42,8 @@ export class RequestWrapper {
|
|
|
42
42
|
if (this.apiCall.httpMethod === 'POST' &&
|
|
43
43
|
!this.httpHeaders['chargebee-idempotency-key'] &&
|
|
44
44
|
this.apiCall.options &&
|
|
45
|
-
this.apiCall.options.isIdempotent
|
|
45
|
+
this.apiCall.options.isIdempotent &&
|
|
46
|
+
retryConfig.enabled) {
|
|
46
47
|
this.httpHeaders['chargebee-idempotency-key'] = uuidv4();
|
|
47
48
|
}
|
|
48
49
|
const makeRequest = async (attempt = 0) => {
|
package/esm/asyncApiSupport.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, extend, callbackifyPromise } from './util';
|
|
1
|
+
import { isFunction, extend, callbackifyPromise } from './util.js';
|
|
2
2
|
export const waitForProcessToComplete = (retrieveHandling, env) => {
|
|
3
3
|
if (typeof retrieveHandling == 'undefined' || !isFunction(retrieveHandling)) {
|
|
4
4
|
throw new Error('The handling parameter should be a method.');
|
package/esm/coreCommon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChargebeeError } from './chargebeeError';
|
|
2
|
-
import { isNotUndefinedNEmpty } from './util';
|
|
1
|
+
import { ChargebeeError } from './chargebeeError.js';
|
|
2
|
+
import { isNotUndefinedNEmpty } from './util.js';
|
|
3
3
|
const IDEMPOTENCY_REPLAYED_HEADER = 'chargebee-idempotency-replayed';
|
|
4
4
|
export function throwError(callBack, rawError, headers) {
|
|
5
5
|
const error = new ChargebeeError({
|
package/esm/createChargebee.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RequestWrapper } from './RequestWrapper';
|
|
2
|
-
import { Environment } from './environment';
|
|
3
|
-
import { Endpoints } from './resources/api_endpoints';
|
|
4
|
-
import { extend, sleep } from './util';
|
|
5
|
-
import { waitForProcessToComplete } from './asyncApiSupport';
|
|
1
|
+
import { RequestWrapper } from './RequestWrapper.js';
|
|
2
|
+
import { Environment } from './environment.js';
|
|
3
|
+
import { Endpoints } from './resources/api_endpoints.js';
|
|
4
|
+
import { extend, sleep } from './util.js';
|
|
5
|
+
import { waitForProcessToComplete } from './asyncApiSupport.js';
|
|
6
6
|
export const CreateChargebee = (httpClient) => {
|
|
7
7
|
const Chargebee = function (conf) {
|
|
8
8
|
this._env = Object.assign({}, Environment);
|
package/esm/environment.js
CHANGED
|
@@ -8,7 +8,7 @@ export const Environment = {
|
|
|
8
8
|
hostSuffix: '.chargebee.com',
|
|
9
9
|
apiPath: '/api/v2',
|
|
10
10
|
timeout: DEFAULT_TIME_OUT,
|
|
11
|
-
clientVersion: 'v3.
|
|
11
|
+
clientVersion: 'v3.9.0',
|
|
12
12
|
port: DEFAULT_PORT,
|
|
13
13
|
timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
|
|
14
14
|
exportWaitInMillis: DEFAULT_EXPORT_WAIT,
|
package/esm/net/FetchClient.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpClient, HttpClientResponse, } from './ClientInterface';
|
|
1
|
+
import { HttpClient, HttpClientResponse, } from './ClientInterface.js';
|
|
2
2
|
export class FetchHttpClient extends HttpClient {
|
|
3
3
|
async makeApiRequest(props) {
|
|
4
4
|
const headers = this._createHeaders(props.headers);
|
package/esm/net/NodeClient.js
CHANGED
|
@@ -1246,6 +1246,32 @@ export const Endpoints = {
|
|
|
1246
1246
|
isIdempotent: true,
|
|
1247
1247
|
},
|
|
1248
1248
|
],
|
|
1249
|
+
[
|
|
1250
|
+
'pauseDunning',
|
|
1251
|
+
'POST',
|
|
1252
|
+
'/invoices',
|
|
1253
|
+
'/pause_dunning',
|
|
1254
|
+
true,
|
|
1255
|
+
null,
|
|
1256
|
+
false,
|
|
1257
|
+
{},
|
|
1258
|
+
{
|
|
1259
|
+
isIdempotent: true,
|
|
1260
|
+
},
|
|
1261
|
+
],
|
|
1262
|
+
[
|
|
1263
|
+
'resumeDunning',
|
|
1264
|
+
'POST',
|
|
1265
|
+
'/invoices',
|
|
1266
|
+
'/resume_dunning',
|
|
1267
|
+
true,
|
|
1268
|
+
null,
|
|
1269
|
+
false,
|
|
1270
|
+
{},
|
|
1271
|
+
{
|
|
1272
|
+
isIdempotent: true,
|
|
1273
|
+
},
|
|
1274
|
+
],
|
|
1249
1275
|
[
|
|
1250
1276
|
'importInvoice',
|
|
1251
1277
|
'POST',
|
|
@@ -2910,6 +2936,7 @@ export const Endpoints = {
|
|
|
2910
2936
|
],
|
|
2911
2937
|
quotedSubscription: [],
|
|
2912
2938
|
quotedCharge: [],
|
|
2939
|
+
quotedRamp: [],
|
|
2913
2940
|
quoteLineGroup: [],
|
|
2914
2941
|
plan: [
|
|
2915
2942
|
[
|
|
@@ -4267,6 +4294,21 @@ export const Endpoints = {
|
|
|
4267
4294
|
},
|
|
4268
4295
|
],
|
|
4269
4296
|
],
|
|
4297
|
+
nonSubscription: [
|
|
4298
|
+
[
|
|
4299
|
+
'processReceipt',
|
|
4300
|
+
'POST',
|
|
4301
|
+
'/non_subscriptions',
|
|
4302
|
+
'/one_time_purchase',
|
|
4303
|
+
true,
|
|
4304
|
+
null,
|
|
4305
|
+
false,
|
|
4306
|
+
{},
|
|
4307
|
+
{
|
|
4308
|
+
isIdempotent: true,
|
|
4309
|
+
},
|
|
4310
|
+
],
|
|
4311
|
+
],
|
|
4270
4312
|
entitlementOverride: [
|
|
4271
4313
|
[
|
|
4272
4314
|
'addEntitlementOverrideForSubscription',
|