chargebee 2.25.3 → 2.26.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 CHANGED
@@ -1,3 +1,34 @@
1
+ ### v2.26.0 (2023-07-31)
2
+ * * *
3
+
4
+ #### New Attributes:
5
+ * tax_category has been added to the CreditNote, Quote and Invoice resource.
6
+ * proration_type has been added in Addon resource.
7
+
8
+ #### New Enum values:
9
+ * tax has been added to EntityType enum in Invoice resource.
10
+ * payment_source_locally_deleted has been added to EventType.
11
+
12
+ #### New Input parameters:
13
+
14
+ * CouponId and CouponApplyTill has been added to Subscritpion#CreateRequest in Subscritpion resource.
15
+ * CouponId and CouponApplyTill has been added to Subscritpion#CreateForCustomerRequest in Subscritpion resource.
16
+ * CouponId and CouponApplyTill has been added to Subscritpion#CreateWithItemsRequest in Subscritpion resource.
17
+ * CouponId and CouponApplyTill has been added to Subscritpion#UpdateRequest in Subscritpion resource.
18
+ * CouponId and CouponApplyTill has been added to Subscritpion#UpdateForItemsRequest in Subscritpion resource.
19
+ * CouponId and CouponApplyTill has been added to Subscritpion#ImportSubscriptionRequest in Subscritpion resource.
20
+ * CouponId and CouponApplyTill has been added to Subscritpion#ImportForCustomerRequest in Subscritpion resource.
21
+ * CouponId and CouponApplyTill has been added to Subscritpion#ImportForItemsRequest in Subscritpion resource.
22
+ * cancel_reason_code has been added to Subscritpion#ImportForItemsRequest in Subscritpion resource.
23
+ * proration_type has been added in addon#createRequest and addon#UpdateRequest in Addon resource.
24
+ * addons[proration_type] has been added in Estimate#UpdateSubscriptionRequest in Estimate resource.
25
+ * addons[proration_type] has been added in Subscription#UpdateRequest in Subscritpion resource.
26
+
27
+ #### New Enum Class:
28
+ * ProrationType enum has been added to addon resource.
29
+ * ProrationType enum has been added.
30
+
31
+
1
32
  ### v2.25.3 (2023-07-24)
2
33
  * * *
3
34
  * Add Request Config Type
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Chargebee Node Client Library - API V2
1
+ # Chargebee Node.js Client Library
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/chargebee.svg?maxAge=3)](https://www.npmjs.com/package/chargebee)
4
4
  [![npm](https://img.shields.io/npm/dt/chargebee.svg?maxAge=3)](https://www.npmjs.com/package/chargebee)
@@ -6,7 +6,7 @@
6
6
  This is the [node.js](http://nodejs.org/) library for integrating with Chargebee. Sign up for a Chargebee account [here](https://www.chargebee.com).
7
7
 
8
8
  > **Note**
9
- > Chargebee now supports two API versions - [V1](https://apidocs.chargebee.com/docs/api/v1) and [V2](https://apidocs.chargebee.com/docs/api), of which V2 is the latest release and all future developments will happen in V2. This library is for <b>API version V2</b>. If you’re looking for V1, head to [chargebee-v1 branch](https://github.com/chargebee/chargebee-node/tree/chargebee-v1).
9
+ > If you’re using [API V1](https://apidocs.chargebee.com/docs/api/v1), head to [chargebee-v1 branch](https://github.com/chargebee/chargebee-node/tree/chargebee-v1).
10
10
 
11
11
  ## Requirements
12
12
 
@@ -26,15 +26,30 @@ pnpm install chargebee
26
26
 
27
27
  ## Usage
28
28
 
29
- The package needs to be configured with your site's API key, which is available under Configure Chargebee Section. Refer [here](https://www.chargebee.com/docs/2.0/api_keys.html) for more details.
29
+ The package needs to be configured with your site's API key, which is available under Configure Chargebee Section. Refer [here](https://www.chargebee.com/docs/2.0/api_keys.html) for more details.
30
+
31
+ The full documentation can be found on the Chargebee API Docs: [https://apidocs.chargebee.com/docs/api?lang=node](https://apidocs.chargebee.com/docs/api?lang=node)
32
+
33
+
34
+ ```js
35
+ const chargebee = require('chargebee');
36
+
37
+ chargebee.configure({
38
+ site: '<YOUR_SITE_NAME>',
39
+ api_key: '<YOUR_API_KEY>',
40
+ });
41
+ ```
42
+
43
+ Or using ES modules,
30
44
 
31
45
  ```js
32
- var chargebee = require('chargebee');
46
+ import chargebee from 'chargebee';
33
47
 
34
48
  chargebee.configure({
35
- site: 'YOUR_SITE_NAME',
36
- api_key: 'YOUR_API_KEY',
49
+ site: '<YOUR_SITE_NAME>',
50
+ api_key: '<YOUR_API_KEY>',
37
51
  });
52
+
38
53
  ```
39
54
 
40
55
  ### Using Async / Await
@@ -89,49 +104,33 @@ chargebee.customer
89
104
  });
90
105
  ```
91
106
 
92
- ### Accessing the response object
93
-
94
- The response object returned by the `request()` method is generic response wrapper. You need to access the resource from it. For example,
95
-
96
- - To access customer object.
97
-
98
- ```js
99
- const result = await chargebee.customer.create({ email: 'john@test.com' }).request();
100
- console.log(result.customer);
101
- ```
102
-
103
- Other resources can be accessed by the same approach. For subscription, it will be `result.subscription`
107
+ ### Usage with TypeScript
104
108
 
105
- - To access list response.
109
+ You can import the types as shown below.
106
110
 
107
- ```js
108
- const result = await chargebee.subscription
109
- .list({
110
- /* params */
111
- })
112
- .request();
111
+ ```ts
112
+ import chargebee, { Customer } from 'chargebee';
113
113
 
114
- // A list of Subscription objects
115
- console.log(result.list.map((obj) => obj.subscription));
116
- ```
114
+ chargebee.configure({
115
+ site: '<YOUR_SITE_NAME>',
116
+ api_key: '<YOUR_API_KEY>',
117
+ });
117
118
 
118
- **Note**
119
+ const createCustomer = async () => {
120
+ const inputParams: Customer.CreateInputParam = {
121
+ email: 'john@test.com',
122
+ first_name: 'John',
123
+ last_name: 'Doe',
124
+ };
119
125
 
120
- If you have a `result` (or children further down the line) and are unsure what properties are available, you can use `Object.keys` to get a list of available accessor properties. Using `Object.keys` in the previous example would yield
126
+ const { customer } = await chargebee.customer.create(inputParams).request();
127
+ console.log(customer);
128
+ };
121
129
 
122
- ```js
123
- // ['list', 'next_offset']
124
- console.log(Object.keys(result));
125
- // ['1', '2', '3'], e.g. `result.list` is an array with 3 entries
126
- console.log(Object.keys(result.list));
127
- // ['activated_at', 'base_currency_code', ...]
128
- // ['activated_at', 'base_currency_code', ...]
129
- // ['activated_at', 'base_currency_code', ...]
130
- // Which means we've reached the bottom and should have all the information available from this request
131
- console.log(result.list.map((obj) => obj.subscription));
130
+ createCustomer();
132
131
  ```
133
132
 
134
- #### Using filters in the List API
133
+ ### Using filters in the List API
135
134
 
136
135
  For pagination: `offset` is the parameter that is being used. The value used for this parameter must be the value returned for `next_offset` parameter in the previous API call.
137
136
 
@@ -162,7 +161,7 @@ const fetchCustomers = async (offset) => {
162
161
  });
163
162
  ```
164
163
 
165
- #### Using custom headers and custom fields:
164
+ ### Using custom headers and custom fields:
166
165
 
167
166
  ```js
168
167
  const result = await chargebee.customer
@@ -178,7 +177,7 @@ const customer = result.customer;
178
177
  console.log(customer.cf_host_url);
179
178
  ```
180
179
 
181
- ### Create an idempotent request
180
+ ### Creating an idempotent request
182
181
 
183
182
  [Idempotency keys](https://apidocs.chargebee.com/docs/api/idempotency?prod_cat_ver=2) are passed along with request headers to allow a safe retry of POST requests.
184
183
 
@@ -208,15 +207,22 @@ chargebee.customer.create({ email: 'john@test.com', cf_host_url: 'http://xyz.com
208
207
  });
209
208
  ```
210
209
 
211
- ### Processing Webhooks - API Version Check
212
-
213
- An attribute, <b>api_version</b>, is added to the [Event](https://apidocs.chargebee.com/docs/api/events) resource, which indicates the API version based on which the event content is structured. In your webhook servers, ensure this \_api_version* is the same as the [API version](https://apidocs.chargebee.com/docs/api#versions) used by your webhook server's client library.
210
+ ### Passing API Keys at request level
214
211
 
215
- ## Documentation
212
+ ```js
213
+ const newCust = await chargebee.customer.create({
214
+ email: 'john@test.com',
215
+ first_name: 'John',
216
+ last_name: 'Doe'
217
+ }).request({
218
+ site: '<YOUR_SITE_NAME>',
219
+ api_key: '<YOUR_API_KEY>',
220
+ });
221
+ ```
216
222
 
217
- The full documentation can be found on the Chargebee API Docs:
223
+ ### Processing Webhooks - API Version Check
218
224
 
219
- [https://apidocs.chargebee.com/docs/api?lang=node](https://apidocs.chargebee.com/docs/api?lang=node)
225
+ An attribute, <b>api_version</b>, is added to the [Event](https://apidocs.chargebee.com/docs/api/events) resource, which indicates the API version based on which the event content is structured. In your webhook servers, ensure this \_api_version* is the same as the [API version](https://apidocs.chargebee.com/docs/api#versions) used by your webhook server's client library.
220
226
 
221
227
  ## License
222
228
 
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.25.3',
14
+ clientVersion: 'v2.26.0',
15
15
  port: 443,
16
16
  timemachineWaitInMillis: 3000,
17
17
  exportWaitInMillis: 3000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name":"chargebee",
3
- "version":"2.25.3",
3
+ "version":"2.26.0",
4
4
  "description":"A library for integrating with ChargeBee.",
5
5
  "keywords":[
6
6
  "payments",