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 +31 -0
- package/README.md +55 -49
- package/lib/chargebee.js +1 -1
- package/package.json +1 -1
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
|
|
1
|
+
# Chargebee Node.js Client Library
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/chargebee)
|
|
4
4
|
[](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
|
-
>
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
109
|
+
You can import the types as shown below.
|
|
106
110
|
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
.list({
|
|
110
|
-
/* params */
|
|
111
|
-
})
|
|
112
|
-
.request();
|
|
111
|
+
```ts
|
|
112
|
+
import chargebee, { Customer } from 'chargebee';
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
chargebee.configure({
|
|
115
|
+
site: '<YOUR_SITE_NAME>',
|
|
116
|
+
api_key: '<YOUR_API_KEY>',
|
|
117
|
+
});
|
|
117
118
|
|
|
118
|
-
|
|
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
|
-
|
|
126
|
+
const { customer } = await chargebee.customer.create(inputParams).request();
|
|
127
|
+
console.log(customer);
|
|
128
|
+
};
|
|
121
129
|
|
|
122
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
223
|
+
### Processing Webhooks - API Version Check
|
|
218
224
|
|
|
219
|
-
[https://apidocs.chargebee.com/docs/api
|
|
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