chargebee 3.17.0-beta.1 → 3.17.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 +33 -4
- package/README.md +25 -173
- package/cjs/chargebee.cjs.js +4 -7
- package/cjs/environment.js +1 -1
- package/cjs/resources/api_endpoints.js +6 -2
- package/cjs/resources/webhook/eventType.js +238 -0
- package/esm/chargebee.esm.js +2 -4
- package/esm/environment.js +1 -1
- package/esm/resources/api_endpoints.js +6 -2
- package/esm/resources/webhook/eventType.js +235 -0
- package/package.json +6 -11
- package/types/core.d.ts +19 -2
- package/types/index.d.ts +0 -65
- package/types/resources/CouponCode.d.ts +4 -0
- package/types/resources/CreditNote.d.ts +4 -0
- package/types/resources/Customer.d.ts +24 -2
- package/types/resources/Estimate.d.ts +13 -2
- package/types/resources/Gift.d.ts +12 -2
- package/types/resources/HostedPage.d.ts +4 -0
- package/types/resources/Invoice.d.ts +25 -2
- package/types/resources/ItemPrice.d.ts +5 -0
- package/types/resources/Order.d.ts +4 -0
- package/types/resources/PaymentIntent.d.ts +30 -5
- package/types/resources/PaymentSource.d.ts +6 -1
- package/types/resources/PricingPageSession.d.ts +2 -0
- package/types/resources/Purchase.d.ts +6 -1
- package/types/resources/Subscription.d.ts +46 -7
- package/types/resources/Transaction.d.ts +8 -0
- package/types/resources/WebhookEvent.d.ts +1 -0
- package/cjs/resources/webhook/auth.js +0 -27
- package/cjs/resources/webhook/content.js +0 -3
- package/cjs/resources/webhook/handler.js +0 -37
- package/esm/resources/webhook/auth.js +0 -23
- package/esm/resources/webhook/content.js +0 -2
- package/esm/resources/webhook/handler.js +0 -33
|
@@ -143,6 +143,10 @@ declare module 'chargebee' {
|
|
|
143
143
|
headers?: ChargebeeRequestHeader,
|
|
144
144
|
): Promise<ChargebeeResponse<ListResponse>>;
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
148
|
+
*/
|
|
149
|
+
|
|
146
150
|
ordersForInvoice(
|
|
147
151
|
invoice_id: string,
|
|
148
152
|
input?: OrdersForInvoiceInputParam,
|
|
@@ -31,7 +31,12 @@ declare module 'chargebee' {
|
|
|
31
31
|
| 'sepa_instant_transfer'
|
|
32
32
|
| 'klarna_pay_now'
|
|
33
33
|
| 'online_banking_poland'
|
|
34
|
-
| 'payconiq_by_bancontact'
|
|
34
|
+
| 'payconiq_by_bancontact'
|
|
35
|
+
| 'electronic_payment_standard'
|
|
36
|
+
| 'kbc_payment_button'
|
|
37
|
+
| 'pay_by_bank'
|
|
38
|
+
| 'trustly'
|
|
39
|
+
| 'stablecoin';
|
|
35
40
|
success_url?: string;
|
|
36
41
|
failure_url?: string;
|
|
37
42
|
created_at: number;
|
|
@@ -107,7 +112,12 @@ declare module 'chargebee' {
|
|
|
107
112
|
| 'sepa_instant_transfer'
|
|
108
113
|
| 'klarna_pay_now'
|
|
109
114
|
| 'online_banking_poland'
|
|
110
|
-
| 'payconiq_by_bancontact'
|
|
115
|
+
| 'payconiq_by_bancontact'
|
|
116
|
+
| 'electronic_payment_standard'
|
|
117
|
+
| 'kbc_payment_button'
|
|
118
|
+
| 'pay_by_bank'
|
|
119
|
+
| 'trustly'
|
|
120
|
+
| 'stablecoin';
|
|
111
121
|
id_at_gateway?: string;
|
|
112
122
|
error_code?: string;
|
|
113
123
|
error_text?: string;
|
|
@@ -147,7 +157,12 @@ declare module 'chargebee' {
|
|
|
147
157
|
| 'sepa_instant_transfer'
|
|
148
158
|
| 'klarna_pay_now'
|
|
149
159
|
| 'online_banking_poland'
|
|
150
|
-
| 'payconiq_by_bancontact'
|
|
160
|
+
| 'payconiq_by_bancontact'
|
|
161
|
+
| 'electronic_payment_standard'
|
|
162
|
+
| 'kbc_payment_button'
|
|
163
|
+
| 'pay_by_bank'
|
|
164
|
+
| 'trustly'
|
|
165
|
+
| 'stablecoin';
|
|
151
166
|
id_at_gateway?: string;
|
|
152
167
|
error_code?: string;
|
|
153
168
|
error_text?: string;
|
|
@@ -187,7 +202,12 @@ declare module 'chargebee' {
|
|
|
187
202
|
| 'sepa_instant_transfer'
|
|
188
203
|
| 'klarna_pay_now'
|
|
189
204
|
| 'online_banking_poland'
|
|
190
|
-
| 'payconiq_by_bancontact'
|
|
205
|
+
| 'payconiq_by_bancontact'
|
|
206
|
+
| 'electronic_payment_standard'
|
|
207
|
+
| 'kbc_payment_button'
|
|
208
|
+
| 'pay_by_bank'
|
|
209
|
+
| 'trustly'
|
|
210
|
+
| 'stablecoin';
|
|
191
211
|
success_url?: string;
|
|
192
212
|
failure_url?: string;
|
|
193
213
|
}
|
|
@@ -216,7 +236,12 @@ declare module 'chargebee' {
|
|
|
216
236
|
| 'sepa_instant_transfer'
|
|
217
237
|
| 'klarna_pay_now'
|
|
218
238
|
| 'online_banking_poland'
|
|
219
|
-
| 'payconiq_by_bancontact'
|
|
239
|
+
| 'payconiq_by_bancontact'
|
|
240
|
+
| 'electronic_payment_standard'
|
|
241
|
+
| 'kbc_payment_button'
|
|
242
|
+
| 'pay_by_bank'
|
|
243
|
+
| 'trustly'
|
|
244
|
+
| 'stablecoin';
|
|
220
245
|
success_url?: string;
|
|
221
246
|
failure_url?: string;
|
|
222
247
|
}
|
|
@@ -453,7 +453,12 @@ declare module 'chargebee' {
|
|
|
453
453
|
| 'sepa_instant_transfer'
|
|
454
454
|
| 'klarna_pay_now'
|
|
455
455
|
| 'online_banking_poland'
|
|
456
|
-
| 'payconiq_by_bancontact'
|
|
456
|
+
| 'payconiq_by_bancontact'
|
|
457
|
+
| 'electronic_payment_standard'
|
|
458
|
+
| 'kbc_payment_button'
|
|
459
|
+
| 'pay_by_bank'
|
|
460
|
+
| 'trustly'
|
|
461
|
+
| 'stablecoin';
|
|
457
462
|
reference_id?: string;
|
|
458
463
|
/**
|
|
459
464
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -37,6 +37,7 @@ declare module 'chargebee' {
|
|
|
37
37
|
redirect_url?: string;
|
|
38
38
|
business_entity_id?: string;
|
|
39
39
|
auto_select_local_currency?: boolean;
|
|
40
|
+
custom?: any;
|
|
40
41
|
pricing_page?: PricingPageCreateForNewSubscriptionInputParam;
|
|
41
42
|
subscription?: SubscriptionCreateForNewSubscriptionInputParam;
|
|
42
43
|
customer?: CustomerCreateForNewSubscriptionInputParam;
|
|
@@ -46,6 +47,7 @@ declare module 'chargebee' {
|
|
|
46
47
|
}
|
|
47
48
|
export interface CreateForExistingSubscriptionInputParam {
|
|
48
49
|
redirect_url?: string;
|
|
50
|
+
custom?: any;
|
|
49
51
|
pricing_page?: PricingPageCreateForExistingSubscriptionInputParam;
|
|
50
52
|
subscription?: SubscriptionCreateForExistingSubscriptionInputParam;
|
|
51
53
|
discounts?: DiscountsCreateForExistingSubscriptionInputParam[];
|
|
@@ -98,7 +98,12 @@ declare module 'chargebee' {
|
|
|
98
98
|
| 'sepa_instant_transfer'
|
|
99
99
|
| 'klarna_pay_now'
|
|
100
100
|
| 'online_banking_poland'
|
|
101
|
-
| 'payconiq_by_bancontact'
|
|
101
|
+
| 'payconiq_by_bancontact'
|
|
102
|
+
| 'electronic_payment_standard'
|
|
103
|
+
| 'kbc_payment_button'
|
|
104
|
+
| 'pay_by_bank'
|
|
105
|
+
| 'trustly'
|
|
106
|
+
| 'stablecoin';
|
|
102
107
|
reference_id?: string;
|
|
103
108
|
/**
|
|
104
109
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -122,6 +122,10 @@ declare module 'chargebee' {
|
|
|
122
122
|
headers?: ChargebeeRequestHeader,
|
|
123
123
|
): Promise<ChargebeeResponse<ListResponse>>;
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
127
|
+
*/
|
|
128
|
+
|
|
125
129
|
subscriptionsForCustomer(
|
|
126
130
|
customer_id: string,
|
|
127
131
|
input?: SubscriptionsForCustomerInputParam,
|
|
@@ -1401,7 +1405,12 @@ declare module 'chargebee' {
|
|
|
1401
1405
|
| 'sepa_instant_transfer'
|
|
1402
1406
|
| 'klarna_pay_now'
|
|
1403
1407
|
| 'online_banking_poland'
|
|
1404
|
-
| 'payconiq_by_bancontact'
|
|
1408
|
+
| 'payconiq_by_bancontact'
|
|
1409
|
+
| 'electronic_payment_standard'
|
|
1410
|
+
| 'kbc_payment_button'
|
|
1411
|
+
| 'pay_by_bank'
|
|
1412
|
+
| 'trustly'
|
|
1413
|
+
| 'stablecoin';
|
|
1405
1414
|
reference_id?: string;
|
|
1406
1415
|
/**
|
|
1407
1416
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -1529,7 +1538,12 @@ declare module 'chargebee' {
|
|
|
1529
1538
|
| 'sepa_instant_transfer'
|
|
1530
1539
|
| 'klarna_pay_now'
|
|
1531
1540
|
| 'online_banking_poland'
|
|
1532
|
-
| 'payconiq_by_bancontact'
|
|
1541
|
+
| 'payconiq_by_bancontact'
|
|
1542
|
+
| 'electronic_payment_standard'
|
|
1543
|
+
| 'kbc_payment_button'
|
|
1544
|
+
| 'pay_by_bank'
|
|
1545
|
+
| 'trustly'
|
|
1546
|
+
| 'stablecoin';
|
|
1533
1547
|
reference_id?: string;
|
|
1534
1548
|
/**
|
|
1535
1549
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -1624,7 +1638,12 @@ declare module 'chargebee' {
|
|
|
1624
1638
|
| 'sepa_instant_transfer'
|
|
1625
1639
|
| 'klarna_pay_now'
|
|
1626
1640
|
| 'online_banking_poland'
|
|
1627
|
-
| 'payconiq_by_bancontact'
|
|
1641
|
+
| 'payconiq_by_bancontact'
|
|
1642
|
+
| 'electronic_payment_standard'
|
|
1643
|
+
| 'kbc_payment_button'
|
|
1644
|
+
| 'pay_by_bank'
|
|
1645
|
+
| 'trustly'
|
|
1646
|
+
| 'stablecoin';
|
|
1628
1647
|
reference_id?: string;
|
|
1629
1648
|
/**
|
|
1630
1649
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -1774,7 +1793,12 @@ declare module 'chargebee' {
|
|
|
1774
1793
|
| 'sepa_instant_transfer'
|
|
1775
1794
|
| 'klarna_pay_now'
|
|
1776
1795
|
| 'online_banking_poland'
|
|
1777
|
-
| 'payconiq_by_bancontact'
|
|
1796
|
+
| 'payconiq_by_bancontact'
|
|
1797
|
+
| 'electronic_payment_standard'
|
|
1798
|
+
| 'kbc_payment_button'
|
|
1799
|
+
| 'pay_by_bank'
|
|
1800
|
+
| 'trustly'
|
|
1801
|
+
| 'stablecoin';
|
|
1778
1802
|
reference_id?: string;
|
|
1779
1803
|
/**
|
|
1780
1804
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -1938,7 +1962,12 @@ declare module 'chargebee' {
|
|
|
1938
1962
|
| 'sepa_instant_transfer'
|
|
1939
1963
|
| 'klarna_pay_now'
|
|
1940
1964
|
| 'online_banking_poland'
|
|
1941
|
-
| 'payconiq_by_bancontact'
|
|
1965
|
+
| 'payconiq_by_bancontact'
|
|
1966
|
+
| 'electronic_payment_standard'
|
|
1967
|
+
| 'kbc_payment_button'
|
|
1968
|
+
| 'pay_by_bank'
|
|
1969
|
+
| 'trustly'
|
|
1970
|
+
| 'stablecoin';
|
|
1942
1971
|
reference_id?: string;
|
|
1943
1972
|
/**
|
|
1944
1973
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -2058,7 +2087,12 @@ declare module 'chargebee' {
|
|
|
2058
2087
|
| 'sepa_instant_transfer'
|
|
2059
2088
|
| 'klarna_pay_now'
|
|
2060
2089
|
| 'online_banking_poland'
|
|
2061
|
-
| 'payconiq_by_bancontact'
|
|
2090
|
+
| 'payconiq_by_bancontact'
|
|
2091
|
+
| 'electronic_payment_standard'
|
|
2092
|
+
| 'kbc_payment_button'
|
|
2093
|
+
| 'pay_by_bank'
|
|
2094
|
+
| 'trustly'
|
|
2095
|
+
| 'stablecoin';
|
|
2062
2096
|
reference_id?: string;
|
|
2063
2097
|
/**
|
|
2064
2098
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -2484,7 +2518,12 @@ declare module 'chargebee' {
|
|
|
2484
2518
|
| 'sepa_instant_transfer'
|
|
2485
2519
|
| 'klarna_pay_now'
|
|
2486
2520
|
| 'online_banking_poland'
|
|
2487
|
-
| 'payconiq_by_bancontact'
|
|
2521
|
+
| 'payconiq_by_bancontact'
|
|
2522
|
+
| 'electronic_payment_standard'
|
|
2523
|
+
| 'kbc_payment_button'
|
|
2524
|
+
| 'pay_by_bank'
|
|
2525
|
+
| 'trustly'
|
|
2526
|
+
| 'stablecoin';
|
|
2488
2527
|
reference_id?: string;
|
|
2489
2528
|
/**
|
|
2490
2529
|
* @deprecated Please refer API docs to use other attributes
|
|
@@ -96,12 +96,20 @@ declare module 'chargebee' {
|
|
|
96
96
|
headers?: ChargebeeRequestHeader,
|
|
97
97
|
): Promise<ChargebeeResponse<ListResponse>>;
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
101
|
+
*/
|
|
102
|
+
|
|
99
103
|
transactionsForCustomer(
|
|
100
104
|
customer_id: string,
|
|
101
105
|
input?: TransactionsForCustomerInputParam,
|
|
102
106
|
headers?: ChargebeeRequestHeader,
|
|
103
107
|
): Promise<ChargebeeResponse<TransactionsForCustomerResponse>>;
|
|
104
108
|
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
111
|
+
*/
|
|
112
|
+
|
|
105
113
|
transactionsForSubscription(
|
|
106
114
|
subscription_id: string,
|
|
107
115
|
input?: TransactionsForSubscriptionInputParam,
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.basicAuthValidator = void 0;
|
|
4
|
-
const basicAuthValidator = (validateCredentials) => {
|
|
5
|
-
return (headers) => {
|
|
6
|
-
const authHeader = headers['authorization'] || headers['Authorization'];
|
|
7
|
-
if (!authHeader) {
|
|
8
|
-
throw new Error('Invalid authorization header');
|
|
9
|
-
}
|
|
10
|
-
const authStr = Array.isArray(authHeader) ? authHeader[0] : authHeader;
|
|
11
|
-
if (!authStr) {
|
|
12
|
-
throw new Error('Invalid authorization header');
|
|
13
|
-
}
|
|
14
|
-
const parts = authStr.split(' ');
|
|
15
|
-
if (parts.length !== 2 || parts[0] !== 'Basic') {
|
|
16
|
-
throw new Error('Invalid authorization header');
|
|
17
|
-
}
|
|
18
|
-
const credentials = Buffer.from(parts[1], 'base64').toString().split(':');
|
|
19
|
-
if (credentials.length !== 2) {
|
|
20
|
-
throw new Error('Invalid credentials');
|
|
21
|
-
}
|
|
22
|
-
if (!validateCredentials(credentials[0], credentials[1])) {
|
|
23
|
-
throw new Error('Invalid credentials');
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
exports.basicAuthValidator = basicAuthValidator;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookHandler = void 0;
|
|
4
|
-
const node_events_1 = require("node:events");
|
|
5
|
-
const auth_js_1 = require("./auth.js");
|
|
6
|
-
class WebhookHandler extends node_events_1.EventEmitter {
|
|
7
|
-
constructor() {
|
|
8
|
-
super({ captureRejections: true });
|
|
9
|
-
}
|
|
10
|
-
handle(body, headers) {
|
|
11
|
-
try {
|
|
12
|
-
if (this.requestValidator && headers) {
|
|
13
|
-
this.requestValidator(headers);
|
|
14
|
-
}
|
|
15
|
-
const event = typeof body === 'string' ? JSON.parse(body) : body;
|
|
16
|
-
const eventType = event.event_type;
|
|
17
|
-
if (this.listenerCount(eventType) > 0) {
|
|
18
|
-
this.emit(eventType, event);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
this.emit('unhandled_event', event);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
this.emit('error', err instanceof Error ? err : new Error(String(err)));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.WebhookHandler = WebhookHandler;
|
|
30
|
-
const webhook = new WebhookHandler();
|
|
31
|
-
// Auto-configure basic auth if env vars are present
|
|
32
|
-
const username = process.env.CHARGEBEE_WEBHOOK_USERNAME;
|
|
33
|
-
const password = process.env.CHARGEBEE_WEBHOOK_PASSWORD;
|
|
34
|
-
if (username && password) {
|
|
35
|
-
webhook.requestValidator = (0, auth_js_1.basicAuthValidator)((u, p) => u === username && p === password);
|
|
36
|
-
}
|
|
37
|
-
exports.default = webhook;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const basicAuthValidator = (validateCredentials) => {
|
|
2
|
-
return (headers) => {
|
|
3
|
-
const authHeader = headers['authorization'] || headers['Authorization'];
|
|
4
|
-
if (!authHeader) {
|
|
5
|
-
throw new Error('Invalid authorization header');
|
|
6
|
-
}
|
|
7
|
-
const authStr = Array.isArray(authHeader) ? authHeader[0] : authHeader;
|
|
8
|
-
if (!authStr) {
|
|
9
|
-
throw new Error('Invalid authorization header');
|
|
10
|
-
}
|
|
11
|
-
const parts = authStr.split(' ');
|
|
12
|
-
if (parts.length !== 2 || parts[0] !== 'Basic') {
|
|
13
|
-
throw new Error('Invalid authorization header');
|
|
14
|
-
}
|
|
15
|
-
const credentials = Buffer.from(parts[1], 'base64').toString().split(':');
|
|
16
|
-
if (credentials.length !== 2) {
|
|
17
|
-
throw new Error('Invalid credentials');
|
|
18
|
-
}
|
|
19
|
-
if (!validateCredentials(credentials[0], credentials[1])) {
|
|
20
|
-
throw new Error('Invalid credentials');
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { basicAuthValidator } from './auth.js';
|
|
3
|
-
export class WebhookHandler extends EventEmitter {
|
|
4
|
-
constructor() {
|
|
5
|
-
super({ captureRejections: true });
|
|
6
|
-
}
|
|
7
|
-
handle(body, headers) {
|
|
8
|
-
try {
|
|
9
|
-
if (this.requestValidator && headers) {
|
|
10
|
-
this.requestValidator(headers);
|
|
11
|
-
}
|
|
12
|
-
const event = typeof body === 'string' ? JSON.parse(body) : body;
|
|
13
|
-
const eventType = event.event_type;
|
|
14
|
-
if (this.listenerCount(eventType) > 0) {
|
|
15
|
-
this.emit(eventType, event);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
this.emit('unhandled_event', event);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
this.emit('error', err instanceof Error ? err : new Error(String(err)));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const webhook = new WebhookHandler();
|
|
27
|
-
// Auto-configure basic auth if env vars are present
|
|
28
|
-
const username = process.env.CHARGEBEE_WEBHOOK_USERNAME;
|
|
29
|
-
const password = process.env.CHARGEBEE_WEBHOOK_PASSWORD;
|
|
30
|
-
if (username && password) {
|
|
31
|
-
webhook.requestValidator = basicAuthValidator((u, p) => u === username && p === password);
|
|
32
|
-
}
|
|
33
|
-
export default webhook;
|