chargebee 3.1.0 → 3.2.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 CHANGED
@@ -1,3 +1,34 @@
1
+ ### v3.2.1 (2024-12-04)
2
+ * * *
3
+
4
+ #### Bug Fixes
5
+ * unable to access content of HostedPage & Event (#57).
6
+ * uncaught promise in case of fetch failure (#58).
7
+
8
+ ### v3.2.0 (2024-11-27)
9
+ * * *
10
+ #### New Resource:
11
+ * OmnichannelSubscriptionItem has been added.
12
+
13
+ #### New Attribute:
14
+ * resource_version has been added to OmnichannelSubscription.
15
+ * resource_version has been added to OmnichannelTransaction.
16
+ * resource_version has been added to RecordedPurchase.
17
+
18
+ #### New Input Parameters:
19
+ * limit has been added to OmnichannelSubscription#ListRequest.
20
+ * offset has been added to OmnichannelSubscription#ListRequest.
21
+ * customer_id has been added to OmnichannelSubscription#ListRequest.
22
+ * replace_coupon_list has been added to HostedPage#CheckoutExistingRequest.
23
+ * replace_coupon_list has been added to HostedPage#CheckoutExistingForItemsRequest.
24
+ * subscription[po_number] has been added to HostedPage#CheckoutNewForItemsRequest.
25
+
26
+ #### Removed Subresource:
27
+ * OmnichannelSubscriptionItem subresource has been removed from OmnichannelSubscription and is now a standalone resource.
28
+
29
+ #### Removed Attribute:
30
+ * metadata has been removed from subscription.
31
+
1
32
  ### v3.1.0 (2024-11-14)
2
33
  * * *
3
34
 
@@ -41,42 +41,47 @@ class RequestWrapper {
41
41
  resolve(response);
42
42
  }
43
43
  }
44
- let path = (0, util_js_1.getApiURL)(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
45
- if (typeof params === 'undefined' || params === null) {
46
- params = {};
47
- }
48
- if (this.apiCall.httpMethod === 'GET') {
49
- params = (0, util_js_1.serialize)(params);
50
- let queryParam = this.apiCall.isListReq
51
- ? (0, util_js_1.encodeListParams)(params)
52
- : (0, util_js_1.encodeParams)(params);
53
- path += '?' + queryParam;
54
- params = {};
55
- }
56
- let data = (0, util_js_1.encodeParams)(params);
57
- if (data.length) {
44
+ try {
45
+ let path = (0, util_js_1.getApiURL)(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
46
+ if (typeof params === 'undefined' || params === null) {
47
+ params = {};
48
+ }
49
+ if (this.apiCall.httpMethod === 'GET') {
50
+ params = (0, util_js_1.serialize)(params);
51
+ let queryParam = this.apiCall.isListReq
52
+ ? (0, util_js_1.encodeListParams)(params)
53
+ : (0, util_js_1.encodeParams)(params);
54
+ path += '?' + queryParam;
55
+ params = {};
56
+ }
57
+ let data = (0, util_js_1.encodeParams)(params);
58
+ if (data.length) {
59
+ (0, util_js_1.extend)(true, this.httpHeaders, {
60
+ 'Content-Length': data.length,
61
+ });
62
+ }
58
63
  (0, util_js_1.extend)(true, this.httpHeaders, {
59
- 'Content-Length': data.length,
64
+ Authorization: 'Basic ' + node_buffer_1.Buffer.from(env.apiKey + ':').toString('base64'),
65
+ Accept: 'application/json',
66
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
67
+ 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
68
+ 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
69
+ });
70
+ const resp = await this.envArg.httpClient.makeApiRequest({
71
+ host: (0, util_js_1.getHost)(env),
72
+ port: env.port,
73
+ path,
74
+ method: this.apiCall.httpMethod,
75
+ protocol: env.protocol,
76
+ headers: this.httpHeaders,
77
+ data: data,
78
+ timeout: env.timeout,
60
79
  });
80
+ (0, coreCommon_js_1.handleResponse)(callBackWrapper, resp);
81
+ }
82
+ catch (err) {
83
+ callBackWrapper(err, null);
61
84
  }
62
- (0, util_js_1.extend)(true, this.httpHeaders, {
63
- Authorization: 'Basic ' + node_buffer_1.Buffer.from(env.apiKey + ':').toString('base64'),
64
- Accept: 'application/json',
65
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
66
- 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
67
- 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
68
- });
69
- const resp = await this.envArg.httpClient.makeApiRequest({
70
- host: (0, util_js_1.getHost)(env),
71
- port: env.port,
72
- path,
73
- method: this.apiCall.httpMethod,
74
- protocol: env.protocol,
75
- headers: this.httpHeaders,
76
- data: data,
77
- timeout: env.timeout,
78
- });
79
- (0, coreCommon_js_1.handleResponse)(callBackWrapper, resp);
80
85
  });
81
86
  return (0, util_js_1.callbackifyPromise)(promise);
82
87
  }
@@ -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.1.0',
14
+ clientVersion: 'v3.2.1',
15
15
  port: DEFAULT_PORT,
16
16
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
17
17
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -11,10 +11,15 @@ class FetchHttpClient extends ClientInterface_js_1.HttpClient {
11
11
  headers: headers,
12
12
  body: props.data ? props.data : undefined,
13
13
  };
14
- const response = globalThis.AbortController
15
- ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
16
- : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
17
- return new FetchHttpClientResponse(response);
14
+ try {
15
+ const response = globalThis.AbortController
16
+ ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
17
+ : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
18
+ return new FetchHttpClientResponse(response);
19
+ }
20
+ catch (err) {
21
+ return Promise.reject(err);
22
+ }
18
23
  }
19
24
  _createHeaders(httpHeaders) {
20
25
  const headers = new Headers();
@@ -44,20 +49,22 @@ class FetchHttpClient extends ClientInterface_js_1.HttpClient {
44
49
  timeoutId = null;
45
50
  abort.abort(ClientInterface_js_1.HttpClient.timeOutError());
46
51
  }, timeout);
47
- const fetchPromise = fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
48
- fetchPromise.finally(() => {
49
- if (timeoutId) {
50
- clearTimeout(timeoutId);
51
- }
52
- });
53
- return fetchPromise.catch((err) => {
52
+ try {
53
+ return await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
54
+ }
55
+ catch (err) {
54
56
  if (err.name === 'AbortError') {
55
- throw ClientInterface_js_1.HttpClient.timeOutError();
57
+ return Promise.reject(ClientInterface_js_1.HttpClient.timeOutError());
56
58
  }
57
59
  else {
58
- throw err;
60
+ return Promise.reject(err);
59
61
  }
60
- });
62
+ }
63
+ finally {
64
+ if (timeoutId) {
65
+ clearTimeout(timeoutId);
66
+ }
67
+ }
61
68
  }
62
69
  }
63
70
  exports.FetchHttpClient = FetchHttpClient;
@@ -1108,6 +1108,7 @@ exports.Endpoints = {
1108
1108
  ],
1109
1109
  ],
1110
1110
  omnichannelTransaction: [],
1111
+ omnichannelSubscriptionItem: [],
1111
1112
  recordedPurchase: [
1112
1113
  ['create', 'POST', '/recorded_purchases', null, false],
1113
1114
  ['retrieve', 'GET', '/recorded_purchases', null, true],
@@ -38,42 +38,47 @@ export class RequestWrapper {
38
38
  resolve(response);
39
39
  }
40
40
  }
41
- let path = getApiURL(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
42
- if (typeof params === 'undefined' || params === null) {
43
- params = {};
44
- }
45
- if (this.apiCall.httpMethod === 'GET') {
46
- params = serialize(params);
47
- let queryParam = this.apiCall.isListReq
48
- ? encodeListParams(params)
49
- : encodeParams(params);
50
- path += '?' + queryParam;
51
- params = {};
52
- }
53
- let data = encodeParams(params);
54
- if (data.length) {
41
+ try {
42
+ let path = getApiURL(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
43
+ if (typeof params === 'undefined' || params === null) {
44
+ params = {};
45
+ }
46
+ if (this.apiCall.httpMethod === 'GET') {
47
+ params = serialize(params);
48
+ let queryParam = this.apiCall.isListReq
49
+ ? encodeListParams(params)
50
+ : encodeParams(params);
51
+ path += '?' + queryParam;
52
+ params = {};
53
+ }
54
+ let data = encodeParams(params);
55
+ if (data.length) {
56
+ extend(true, this.httpHeaders, {
57
+ 'Content-Length': data.length,
58
+ });
59
+ }
55
60
  extend(true, this.httpHeaders, {
56
- 'Content-Length': data.length,
61
+ Authorization: 'Basic ' + Buffer.from(env.apiKey + ':').toString('base64'),
62
+ Accept: 'application/json',
63
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
64
+ 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
65
+ 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
66
+ });
67
+ const resp = await this.envArg.httpClient.makeApiRequest({
68
+ host: getHost(env),
69
+ port: env.port,
70
+ path,
71
+ method: this.apiCall.httpMethod,
72
+ protocol: env.protocol,
73
+ headers: this.httpHeaders,
74
+ data: data,
75
+ timeout: env.timeout,
57
76
  });
77
+ handleResponse(callBackWrapper, resp);
78
+ }
79
+ catch (err) {
80
+ callBackWrapper(err, null);
58
81
  }
59
- extend(true, this.httpHeaders, {
60
- Authorization: 'Basic ' + Buffer.from(env.apiKey + ':').toString('base64'),
61
- Accept: 'application/json',
62
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
63
- 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
64
- 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
65
- });
66
- const resp = await this.envArg.httpClient.makeApiRequest({
67
- host: getHost(env),
68
- port: env.port,
69
- path,
70
- method: this.apiCall.httpMethod,
71
- protocol: env.protocol,
72
- headers: this.httpHeaders,
73
- data: data,
74
- timeout: env.timeout,
75
- });
76
- handleResponse(callBackWrapper, resp);
77
82
  });
78
83
  return callbackifyPromise(promise);
79
84
  }
@@ -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.1.0',
11
+ clientVersion: 'v3.2.1',
12
12
  port: DEFAULT_PORT,
13
13
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
14
14
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -8,10 +8,15 @@ export class FetchHttpClient extends HttpClient {
8
8
  headers: headers,
9
9
  body: props.data ? props.data : undefined,
10
10
  };
11
- const response = globalThis.AbortController
12
- ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
13
- : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
14
- return new FetchHttpClientResponse(response);
11
+ try {
12
+ const response = globalThis.AbortController
13
+ ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
14
+ : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
15
+ return new FetchHttpClientResponse(response);
16
+ }
17
+ catch (err) {
18
+ return Promise.reject(err);
19
+ }
15
20
  }
16
21
  _createHeaders(httpHeaders) {
17
22
  const headers = new Headers();
@@ -41,20 +46,22 @@ export class FetchHttpClient extends HttpClient {
41
46
  timeoutId = null;
42
47
  abort.abort(HttpClient.timeOutError());
43
48
  }, timeout);
44
- const fetchPromise = fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
45
- fetchPromise.finally(() => {
46
- if (timeoutId) {
47
- clearTimeout(timeoutId);
48
- }
49
- });
50
- return fetchPromise.catch((err) => {
49
+ try {
50
+ return await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
51
+ }
52
+ catch (err) {
51
53
  if (err.name === 'AbortError') {
52
- throw HttpClient.timeOutError();
54
+ return Promise.reject(HttpClient.timeOutError());
53
55
  }
54
56
  else {
55
- throw err;
57
+ return Promise.reject(err);
56
58
  }
57
- });
59
+ }
60
+ finally {
61
+ if (timeoutId) {
62
+ clearTimeout(timeoutId);
63
+ }
64
+ }
58
65
  }
59
66
  }
60
67
  export class FetchHttpClientResponse extends HttpClientResponse {
@@ -1105,6 +1105,7 @@ export const Endpoints = {
1105
1105
  ],
1106
1106
  ],
1107
1107
  omnichannelTransaction: [],
1108
+ omnichannelSubscriptionItem: [],
1108
1109
  recordedPurchase: [
1109
1110
  ['create', 'POST', '/recorded_purchases', null, false],
1110
1111
  ['retrieve', 'GET', '/recorded_purchases', null, true],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chargebee",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "A library for integrating with Chargebee.",
5
5
  "scripts": {
6
6
  "prepack": "npm install && npm run build",
package/types/index.d.ts CHANGED
@@ -42,6 +42,7 @@
42
42
  ///<reference path='./resources/Metadata.d.ts' />
43
43
  ///<reference path='./resources/NonSubscription.d.ts' />
44
44
  ///<reference path='./resources/OmnichannelSubscription.d.ts' />
45
+ ///<reference path='./resources/OmnichannelSubscriptionItem.d.ts' />
45
46
  ///<reference path='./resources/OmnichannelTransaction.d.ts' />
46
47
  ///<reference path='./resources/Order.d.ts' />
47
48
  ///<reference path='./resources/PaymentIntent.d.ts' />
@@ -19,6 +19,7 @@ declare module 'chargebee' {
19
19
  webhooks?: Event.Webhook[];
20
20
  event_type?: EventTypeEnum;
21
21
  api_version?: ApiVersionEnum;
22
+ content: any;
22
23
  origin_user?: string;
23
24
  }
24
25
 
@@ -28,6 +28,7 @@ declare module 'chargebee' {
28
28
  embed: boolean;
29
29
  created_at?: number;
30
30
  expires_at?: number;
31
+ content: any;
31
32
  updated_at?: number;
32
33
  resource_version?: number;
33
34
  checkout_info?: any;
@@ -337,6 +338,7 @@ declare module 'chargebee' {
337
338
  reactivate_from?: number;
338
339
  billing_alignment_mode?: BillingAlignmentModeEnum;
339
340
  coupon_ids?: string[];
341
+ replace_coupon_list?: boolean;
340
342
  reactivate?: boolean;
341
343
  force_term_reset?: boolean;
342
344
  redirect_url?: string;
@@ -362,6 +364,7 @@ declare module 'chargebee' {
362
364
  reactivate_from?: number;
363
365
  billing_alignment_mode?: BillingAlignmentModeEnum;
364
366
  coupon_ids?: string[];
367
+ replace_coupon_list?: boolean;
365
368
  reactivate?: boolean;
366
369
  force_term_reset?: boolean;
367
370
  change_option?: ChangeOptionEnum;
@@ -808,6 +811,7 @@ declare module 'chargebee' {
808
811
  coupon?: string;
809
812
  auto_collection?: AutoCollectionEnum;
810
813
  invoice_notes?: string;
814
+ po_number?: string;
811
815
  contract_term_billing_cycle_on_renewal?: number;
812
816
  }
813
817
  export interface CardCheckoutNewForItemsInputParam {
@@ -9,7 +9,8 @@ declare module 'chargebee' {
9
9
  source: 'apple_app_store';
10
10
  customer_id?: string;
11
11
  created_at: number;
12
- omnichannel_subscription_items: OmnichannelSubscription.OmnichannelSubscriptionItem[];
12
+ resource_version?: number;
13
+ omnichannel_subscription_items: OmnichannelSubscriptionItem[];
13
14
  }
14
15
 
15
16
  export namespace OmnichannelSubscription {
@@ -47,25 +48,13 @@ declare module 'chargebee' {
47
48
  next_offset?: string;
48
49
  }
49
50
 
50
- export interface OmnichannelSubscriptionItem {
51
- id: string;
52
- id_at_source: string;
53
- status: 'active' | 'expired' | 'cancelled';
54
- current_term_start?: number;
55
- current_term_end?: number;
56
- expired_at?: number;
57
- expiration_reason?: 'billing_error' | 'product_not_available' | 'other';
58
- cancelled_at?: number;
59
- cancellation_reason?:
60
- | 'customer_cancelled'
61
- | 'customer_did_not_consent_to_price_increase';
62
- }
63
51
  // REQUEST PARAMS
64
52
  //---------------
65
53
 
66
54
  export interface ListInputParam {
67
55
  limit?: number;
68
56
  offset?: string;
57
+ customer_id?: filter.String;
69
58
  }
70
59
  export interface OmnichannelTransactionsForOmnichannelSubscriptionInputParam {
71
60
  limit?: number;
@@ -0,0 +1,19 @@
1
+ ///<reference path='./../core.d.ts'/>
2
+ ///<reference path='./../index.d.ts'/>
3
+
4
+ declare module 'chargebee' {
5
+ export interface OmnichannelSubscriptionItem {
6
+ id: string;
7
+ item_id_at_source: string;
8
+ status: 'active' | 'expired' | 'cancelled';
9
+ current_term_start?: number;
10
+ current_term_end?: number;
11
+ expired_at?: number;
12
+ expiration_reason?: 'billing_error' | 'product_not_available' | 'other';
13
+ cancelled_at?: number;
14
+ cancellation_reason?:
15
+ | 'customer_cancelled'
16
+ | 'customer_did_not_consent_to_price_increase';
17
+ resource_version?: number;
18
+ }
19
+ }
@@ -12,5 +12,6 @@ declare module 'chargebee' {
12
12
  type: 'purchase' | 'renewal';
13
13
  transacted_at: number;
14
14
  created_at: number;
15
+ resource_version?: number;
15
16
  }
16
17
  }
@@ -10,6 +10,7 @@ declare module 'chargebee' {
10
10
  status: 'in_process' | 'completed' | 'failed';
11
11
  omnichannel_transaction_id?: string;
12
12
  created_at: number;
13
+ resource_version?: number;
13
14
  linked_omnichannel_subscriptions?: RecordedPurchase.LinkedOmnichannelSubscription[];
14
15
  error_detail?: RecordedPurchase.ErrorDetail;
15
16
  }
@@ -85,7 +85,6 @@ declare module 'chargebee' {
85
85
  referral_info?: Subscription.ReferralInfo;
86
86
  invoice_notes?: string;
87
87
  meta_data?: any;
88
- metadata?: any;
89
88
  deleted: boolean;
90
89
  changes_scheduled_at?: number;
91
90
  contract_term?: Subscription.ContractTerm;