chargebee 2.45.0 → 2.47.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 +82 -0
- package/lib/chargebee.js +48 -25
- package/lib/resources/api_endpoints.js +2154 -406
- package/package.json +1 -1
- package/types/core.d.ts +3 -2
- package/types/index.d.ts +6 -0
- package/types/resources/AttachedItem.d.ts +20 -205
- package/types/resources/Configuration.d.ts +22 -0
- package/types/resources/Coupon.d.ts +2 -0
- package/types/resources/CreditNote.d.ts +119 -1216
- package/types/resources/CreditNoteEstimate.d.ts +20 -15
- package/types/resources/DifferentialPrice.d.ts +20 -200
- package/types/resources/Event.d.ts +2 -2
- package/types/resources/GatewayErrorDetail.d.ts +2 -0
- package/types/resources/Invoice.d.ts +344 -2219
- package/types/resources/InvoiceEstimate.d.ts +36 -26
- package/types/resources/Item.d.ts +2 -0
- package/types/resources/ItemFamily.d.ts +2 -0
- package/types/resources/ItemPrice.d.ts +2 -0
- package/types/resources/OmnichannelSubscription.d.ts +23 -1
- package/types/resources/OmnichannelSubscriptionItem.d.ts +3 -1
- package/types/resources/Order.d.ts +184 -1073
- package/types/resources/PriceVariant.d.ts +24 -163
- package/types/resources/Quote.d.ts +4 -0
- package/types/resources/QuotedSubscription.d.ts +6 -0
- package/types/resources/Rule.d.ts +38 -0
- package/types/resources/Subscription.d.ts +19 -0
- package/types/resources/Transaction.d.ts +1 -0
- package/types/resources/UsageEvent.d.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
+
### v2.47.0 (2025-02-10)
|
|
2
|
+
* * *
|
|
3
|
+
|
|
4
|
+
#### New Resources:
|
|
5
|
+
* Rule has been added.
|
|
6
|
+
* UsageEvent has been added.
|
|
7
|
+
|
|
8
|
+
#### New Attribute:
|
|
9
|
+
* deleted has been added to AttachedItem.
|
|
10
|
+
* deleted has been added to Coupon.
|
|
11
|
+
* deleted has been added to DifferentialPrice.
|
|
12
|
+
* deleted has been added to ItemFamily.
|
|
13
|
+
* deleted has been added to ItemPrice.
|
|
14
|
+
* deleted has been added to Item.
|
|
15
|
+
* deleted has been added to PriceVariant.
|
|
16
|
+
* tax_application has abeend added to CreditNote#Allocation.
|
|
17
|
+
* tax_application has been added to Invoice#AppliedCredit.
|
|
18
|
+
* line_item_credit has been added to Invoice.
|
|
19
|
+
|
|
20
|
+
#### New Input Params:
|
|
21
|
+
* exhausted_coupon_ids has been added to Subscription#ImportForItems.
|
|
22
|
+
|
|
23
|
+
#### New Enums
|
|
24
|
+
* STORE has been added in CreditNote#TypeEnum.
|
|
25
|
+
* STORE has been added in CreditNoteEstimate#TypeEnum.
|
|
26
|
+
* STORE has been added in Order#TypeEnum.
|
|
27
|
+
* TaxApplicationEnum has been added in CreditNote#Application.
|
|
28
|
+
* TaxApplicationEnum has been added in Invoice#AppliedCredit.
|
|
29
|
+
* RECORDED_PURCHASE has been added in EntityTypeEnum.
|
|
30
|
+
* RECORD_PURCHASE_FAILED, has been added in EventTypeEnum.
|
|
31
|
+
|
|
32
|
+
#### Deleted Input Params
|
|
33
|
+
* tax_providers_fields has been removed from Customer#MoveParams.
|
|
34
|
+
* tax_providers_fields has been removed from Customer#MergeParams
|
|
35
|
+
|
|
36
|
+
#### Deprecated input params.
|
|
37
|
+
* deprecated label in discount_quantity has been removed from Coupon#CreateParams.
|
|
38
|
+
* deprecated label in discount_quantity has been removed from Coupon#UpdateParams.
|
|
39
|
+
* deprecated label in discount_quantity has been removed from Coupon#CreateForItemsParams.
|
|
40
|
+
* deprecated label in discount_quantity has been removed from Coupon#UpdateForItemsParams.
|
|
41
|
+
|
|
42
|
+
### v2.46.0 (2024-12-19)
|
|
43
|
+
* * *
|
|
44
|
+
|
|
45
|
+
#### New Resource:
|
|
46
|
+
* Configuration has been added.
|
|
47
|
+
|
|
48
|
+
#### New Attribute:
|
|
49
|
+
* discount_type has been added to CreditNote#Discount.
|
|
50
|
+
* discount_type has been added to CreditNoteEstimate#Discount.
|
|
51
|
+
* discount_type has been added to Invoice#Discount.
|
|
52
|
+
* discount_type has been added to InvoiceEstimate#Discount.
|
|
53
|
+
* discount_type has been added to QuoteLineGroup#Discount.
|
|
54
|
+
* initial_purchase_transaction has been added to OmnichannelSubscription.
|
|
55
|
+
* error_cause_id has been added to GatewayErrorDetail.
|
|
56
|
+
* error_cause_id has been added to Transaction#GatewayErrorDetail.
|
|
57
|
+
* error_cause_id has been added to APIError.
|
|
58
|
+
* deleted has been added to Quote.
|
|
59
|
+
* current_term_start has been added to QuotedSubscripiton#SubscriptionItem.
|
|
60
|
+
* current_term_end has been added to QuotedSubscripiton#SubscriptionItem.
|
|
61
|
+
* next_billing_at has been added to QuotedSubscripiton#SubscriptionItem.
|
|
62
|
+
* current_term_start has been added to Subscription#SubscriptionItem.
|
|
63
|
+
* current_term_end has been added to Subscription#SubscriptionItem.
|
|
64
|
+
* next_billing_at has been added to Subscription#SubscriptionItem.
|
|
65
|
+
* billing_override has been added to Subscription.
|
|
66
|
+
* grace_period_expires_at has been added to OmnichannelSubscriptionItem.
|
|
67
|
+
|
|
68
|
+
#### New Input Params:
|
|
69
|
+
* billing_override has been added to Subscription#CreateWithItemsInputParam.
|
|
70
|
+
* billing_override has been added to Subscription#UpdateForItemsInputParam.
|
|
71
|
+
|
|
72
|
+
#### New Enum Values:
|
|
73
|
+
* OMNICHANNEL_SUBSCRIPTION_IMPORTED has been added to EventTypeEnum.
|
|
74
|
+
* DISABLED has been added to Event#WebhookStatus.
|
|
75
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_STARTED has been added to EventTypeEnum.
|
|
76
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_EXPIRED has been added to EventTypeEnum.
|
|
77
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_STARTED has been added to EventTypeEnum.
|
|
78
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_EXPIRED has been added to EventTypeEnum.
|
|
79
|
+
* IGNORED has been added to RecordedPurchase#StatusEnum.
|
|
80
|
+
* IN_DUNNING & IN_GRACE_PERIOD have been added to OmnichannelSubscriptionItem#StatusEnum.
|
|
81
|
+
|
|
82
|
+
|
|
1
83
|
### v2.45.0 (2024-11-27)
|
|
2
84
|
* * *
|
|
3
85
|
|
package/lib/chargebee.js
CHANGED
|
@@ -11,7 +11,7 @@ ChargeBee._env = {
|
|
|
11
11
|
hostSuffix: '.chargebee.com',
|
|
12
12
|
apiPath: '/api/v2',
|
|
13
13
|
timeout: 80000,
|
|
14
|
-
clientVersion: 'v2.
|
|
14
|
+
clientVersion: 'v2.47.0',
|
|
15
15
|
port: 443,
|
|
16
16
|
timemachineWaitInMillis: 3000,
|
|
17
17
|
exportWaitInMillis: 3000
|
|
@@ -164,7 +164,7 @@ RequestWrapper.prototype.request = function(callBack, envOptions) {
|
|
|
164
164
|
deferred.resolve(response);
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
|
-
ChargeBee._core.makeApiRequest(env, callBackWrapper, this.apiCall.httpMethod, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam, params, this.httpHeaders, this.apiCall.isListReq);
|
|
167
|
+
ChargeBee._core.makeApiRequest(env, callBackWrapper, this.apiCall.httpMethod, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam, params, this.httpHeaders, this.apiCall.isListReq, this.apiCall.subDomain, this.apiCall.isJsonRequest, this.apiCall.jsonKeys);
|
|
168
168
|
return deferred.promise;
|
|
169
169
|
};
|
|
170
170
|
|
|
@@ -241,7 +241,7 @@ ChargeBee._core = (function() {
|
|
|
241
241
|
response.isIdempotencyReplayed = res.headers[IDEMPOTENCY_REPLAYED_HEADER];
|
|
242
242
|
}
|
|
243
243
|
response.headers = res.headers;
|
|
244
|
-
|
|
244
|
+
response.http_status_code = res.statusCode;
|
|
245
245
|
callBack(null, response);
|
|
246
246
|
}
|
|
247
247
|
});
|
|
@@ -256,7 +256,7 @@ ChargeBee._core = (function() {
|
|
|
256
256
|
};
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
coreRef.makeApiRequest = function(env, callBack, httpMethod, urlPrefix, urlSuffix, urlIdParam, params, headers, isListReq) {
|
|
259
|
+
coreRef.makeApiRequest = function(env, callBack, httpMethod, urlPrefix, urlSuffix, urlIdParam, params, headers, isListReq, subDomain, isJsonRequest, jsonKeys) {
|
|
260
260
|
var path = getApiURL(env, urlPrefix, urlSuffix, urlIdParam);
|
|
261
261
|
if (typeof params === 'undefined' || params === null) {
|
|
262
262
|
params = {};
|
|
@@ -266,13 +266,14 @@ ChargeBee._core = (function() {
|
|
|
266
266
|
path += "?" + queryParam;
|
|
267
267
|
params = {};
|
|
268
268
|
}
|
|
269
|
-
var data = encodeParams(params);
|
|
269
|
+
var data = isJsonRequest ? JSON.stringify(params) : encodeParams(params, null, null, null, jsonKeys);
|
|
270
|
+
var contentTypeHeader = !isJsonRequest ? 'application/x-www-form-urlencoded; charset=utf-8' : 'application/json;charset=UTF-8';
|
|
270
271
|
var protocol = (env.protocol === 'http' ? http : https);
|
|
271
272
|
|
|
272
273
|
ChargeBee._util.extend(true, headers, {
|
|
273
274
|
'Authorization': 'Basic ' + Buffer.from(env.api_key+':').toString('base64'),
|
|
274
275
|
'Accept': 'application/json',
|
|
275
|
-
'Content-Type':
|
|
276
|
+
'Content-Type': contentTypeHeader,
|
|
276
277
|
"Content-Length": data.length,
|
|
277
278
|
'User-Agent': "Chargebee-NodeJs-Client " + env.clientVersion,
|
|
278
279
|
'Lang-Version': process.version,
|
|
@@ -280,7 +281,7 @@ ChargeBee._core = (function() {
|
|
|
280
281
|
});
|
|
281
282
|
|
|
282
283
|
var req = protocol.request({
|
|
283
|
-
"hostname": getHost(env),
|
|
284
|
+
"hostname": getHost(env, subDomain),
|
|
284
285
|
"path": path,
|
|
285
286
|
"method": httpMethod,
|
|
286
287
|
"port": env.port,
|
|
@@ -303,7 +304,10 @@ ChargeBee._core = (function() {
|
|
|
303
304
|
'/' + encodeURIComponent(urlIdParam).replace(/%2F/g,'/') : '') + (urlSuffix !== null ? urlSuffix : '');
|
|
304
305
|
}
|
|
305
306
|
|
|
306
|
-
function getHost(env) {
|
|
307
|
+
function getHost(env, subDomain) {
|
|
308
|
+
if(subDomain != null ) {
|
|
309
|
+
return env.site + '.' + subDomain + env.hostSuffix;
|
|
310
|
+
}
|
|
307
311
|
return env.site + env.hostSuffix;
|
|
308
312
|
}
|
|
309
313
|
|
|
@@ -320,45 +324,59 @@ ChargeBee._core = (function() {
|
|
|
320
324
|
return encodeParams(paramObj);
|
|
321
325
|
}
|
|
322
326
|
|
|
323
|
-
var encodeParams = function(paramObj, serialized, scope, index) {
|
|
324
|
-
|
|
327
|
+
var encodeParams = function (paramObj, serialized, scope, index, jsonKeys, level = 0) {
|
|
328
|
+
let key, value;
|
|
325
329
|
if (typeof serialized === 'undefined' || serialized === null) {
|
|
326
330
|
serialized = [];
|
|
327
331
|
}
|
|
328
332
|
for (key in paramObj) {
|
|
329
|
-
value = paramObj[key]
|
|
333
|
+
value = paramObj[key]
|
|
334
|
+
const originalKey = key;
|
|
330
335
|
if (scope) {
|
|
331
336
|
key = "" + scope + "[" + key + "]";
|
|
332
337
|
}
|
|
333
338
|
if (typeof index !== 'undefined' && index !== null) {
|
|
334
339
|
key = key + "[" + index + "]";
|
|
335
340
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
341
|
+
if (jsonKeys && jsonKeys[originalKey] === level) {
|
|
342
|
+
let attrVal = '';
|
|
343
|
+
if (value !== null) {
|
|
344
|
+
attrVal = encodeURIComponent(
|
|
345
|
+
Object.prototype.toString.call(value) === '[object String]'
|
|
346
|
+
? ChargeBee._util.trim(value)
|
|
347
|
+
: JSON.stringify(value),
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
serialized.push(encodeURIComponent(key) + '=' + attrVal);
|
|
351
|
+
} else if (ChargeBee._util.isArray(value) && !(jsonKeys && jsonKeys[originalKey] === level)) {
|
|
352
|
+
for (let arrIdx = 0; arrIdx < value.length; arrIdx++) {
|
|
339
353
|
if (typeof value[arrIdx] === 'object' || ChargeBee._util.isArray(value[arrIdx])) {
|
|
340
|
-
encodeParams(
|
|
354
|
+
encodeParams(
|
|
355
|
+
value[arrIdx],
|
|
356
|
+
serialized,
|
|
357
|
+
key,
|
|
358
|
+
arrIdx,
|
|
359
|
+
jsonKeys,
|
|
360
|
+
level + 1,
|
|
361
|
+
);
|
|
341
362
|
} else {
|
|
342
363
|
if (typeof value[arrIdx] !== 'undefined') {
|
|
343
364
|
serialized.push(encodeURIComponent(key + "[" + arrIdx + "]") + "=" + encodeURIComponent(ChargeBee._util.trim(value[arrIdx]) !== '' ? value[arrIdx] : ''));
|
|
344
365
|
}
|
|
345
366
|
}
|
|
346
367
|
}
|
|
347
|
-
} else if(["meta_data", "metadata"].indexOf(key) !== -1) {
|
|
348
|
-
var attrVal="";
|
|
349
|
-
if(value !== null) {
|
|
350
|
-
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === "[object String]" ? ChargeBee._util.trim(value) : JSON.stringify(value));
|
|
351
|
-
}
|
|
352
|
-
serialized.push(encodeURIComponent(key) + "=" + attrVal);
|
|
353
368
|
} else if (typeof value === 'object' && !ChargeBee._util.isArray(value)) {
|
|
354
|
-
encodeParams(value, serialized, key);
|
|
369
|
+
encodeParams(value, serialized, key, undefined, jsonKeys, level + 1);
|
|
355
370
|
} else {
|
|
356
371
|
if (typeof value !== 'undefined') {
|
|
357
|
-
serialized.push(
|
|
372
|
+
serialized.push(
|
|
373
|
+
encodeURIComponent(key) +
|
|
374
|
+
'=' +
|
|
375
|
+
encodeURIComponent(ChargeBee._util.trim(value) !== '' ? value : ''),
|
|
376
|
+
);
|
|
358
377
|
}
|
|
359
378
|
}
|
|
360
379
|
}
|
|
361
|
-
|
|
362
380
|
return serialized.join('&').replace(/%20/g, '+');
|
|
363
381
|
};
|
|
364
382
|
var throwError = function(callBack,type,httpStatusCode, errorCode, message, detail) {
|
|
@@ -502,7 +520,12 @@ ChargeBee._util = (function() {
|
|
|
502
520
|
"urlPrefix": metaArr[2],
|
|
503
521
|
"urlSuffix": metaArr[3],
|
|
504
522
|
"hasIdInUrl": metaArr[4],
|
|
505
|
-
"isListReq": metaArr[0]==="list"
|
|
523
|
+
"isListReq": metaArr[0]==="list",
|
|
524
|
+
"subDomain": metaArr[5],
|
|
525
|
+
"isJsonRequest": metaArr[6],
|
|
526
|
+
"jsonKeys": metaArr[7],
|
|
527
|
+
|
|
528
|
+
};
|
|
506
529
|
module.exports[res][apiCall.methodName] = createApiFunc(apiCall);
|
|
507
530
|
}
|
|
508
531
|
}
|