chargebee 3.16.0 → 3.17.0-beta.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 +6 -0
- package/README.md +168 -0
- package/cjs/chargebee.cjs.js +7 -0
- package/cjs/resources/webhook/auth.js +27 -0
- package/cjs/resources/webhook/content.js +3 -0
- package/cjs/resources/webhook/handler.js +37 -0
- package/esm/chargebee.esm.js +4 -0
- package/esm/resources/webhook/auth.js +23 -0
- package/esm/resources/webhook/content.js +2 -0
- package/esm/resources/webhook/handler.js +33 -0
- package/package.json +11 -6
- package/types/index.d.ts +65 -0
- package/types/resources/WebhookEvent.d.ts +225 -223
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -148,6 +148,174 @@ const chargebeeSiteEU = new Chargebee({
|
|
|
148
148
|
});
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
+
### Handle webhooks
|
|
152
|
+
|
|
153
|
+
Use the webhook handlers to parse and route webhook payloads from Chargebee with full TypeScript support.
|
|
154
|
+
|
|
155
|
+
#### Quick Start: Using the default `webhook` instance
|
|
156
|
+
|
|
157
|
+
The simplest way to handle webhooks is using the pre-configured `webhook` instance:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import express from 'express';
|
|
161
|
+
import { webhook, type WebhookEvent } from 'chargebee';
|
|
162
|
+
|
|
163
|
+
const app = express();
|
|
164
|
+
app.use(express.json());
|
|
165
|
+
|
|
166
|
+
webhook.on('subscription_created', async (event: WebhookEvent) => {
|
|
167
|
+
console.log(`Subscription created: ${event.id}`);
|
|
168
|
+
const subscription = event.content.subscription;
|
|
169
|
+
console.log(`Customer: ${subscription.customer_id}`);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
webhook.on('error', (err: Error) => {
|
|
173
|
+
console.error('Webhook error:', err.message);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
app.post('/chargebee/webhooks', (req, res) => {
|
|
177
|
+
webhook.handle(req.body, req.headers);
|
|
178
|
+
res.status(200).send('OK');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
app.listen(8080);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Auto-configured Basic Auth:** The default `webhook` instance automatically configures Basic Auth validation if the following environment variables are set:
|
|
185
|
+
|
|
186
|
+
- `CHARGEBEE_WEBHOOK_USERNAME` - The expected username
|
|
187
|
+
- `CHARGEBEE_WEBHOOK_PASSWORD` - The expected password
|
|
188
|
+
|
|
189
|
+
When both are present, incoming webhook requests will be validated against these credentials. If not set, no authentication is applied.
|
|
190
|
+
|
|
191
|
+
#### Creating custom `WebhookHandler` instances
|
|
192
|
+
|
|
193
|
+
For more control or multiple webhook endpoints, create your own instances:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import express from 'express';
|
|
197
|
+
import { WebhookHandler, basicAuthValidator } from 'chargebee';
|
|
198
|
+
|
|
199
|
+
const app = express();
|
|
200
|
+
app.use(express.json());
|
|
201
|
+
|
|
202
|
+
const handler = new WebhookHandler();
|
|
203
|
+
|
|
204
|
+
// Register event listeners using .on() - events are fully typed
|
|
205
|
+
handler.on('subscription_created', async (event) => {
|
|
206
|
+
console.log(`Subscription created: ${event.id}`);
|
|
207
|
+
const subscription = event.content.subscription;
|
|
208
|
+
console.log(`Customer: ${subscription.customer_id}`);
|
|
209
|
+
console.log(`Plan: ${subscription.plan_id}`);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
handler.on('payment_succeeded', async (event) => {
|
|
213
|
+
console.log(`Payment succeeded: ${event.id}`);
|
|
214
|
+
const transaction = event.content.transaction;
|
|
215
|
+
const customer = event.content.customer;
|
|
216
|
+
console.log(`Amount: ${transaction.amount}, Customer: ${customer.email}`);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Optional: Add request validator (e.g., Basic Auth)
|
|
220
|
+
handler.requestValidator = basicAuthValidator((username, password) => {
|
|
221
|
+
return username === 'admin' && password === 'secret';
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
app.post('/chargebee/webhooks', (req, res) => {
|
|
225
|
+
handler.handle(req.body, req.headers);
|
|
226
|
+
res.status(200).send('OK');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
app.listen(8080);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### Low-level: Parse and handle events manually
|
|
233
|
+
|
|
234
|
+
For more control, you can parse webhook events manually:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import express from 'express';
|
|
238
|
+
import Chargebee, { type WebhookEvent } from 'chargebee';
|
|
239
|
+
|
|
240
|
+
const app = express();
|
|
241
|
+
app.use(express.json());
|
|
242
|
+
|
|
243
|
+
app.post('/chargebee/webhooks', async (req, res) => {
|
|
244
|
+
try {
|
|
245
|
+
const event = req.body as WebhookEvent;
|
|
246
|
+
|
|
247
|
+
switch (event.event_type) {
|
|
248
|
+
case 'subscription_created':
|
|
249
|
+
// Access event content with proper typing
|
|
250
|
+
const subscription = event.content.subscription;
|
|
251
|
+
console.log('Subscription created:', subscription.id);
|
|
252
|
+
break;
|
|
253
|
+
|
|
254
|
+
case 'payment_succeeded':
|
|
255
|
+
const transaction = event.content.transaction;
|
|
256
|
+
console.log('Payment succeeded:', transaction.amount);
|
|
257
|
+
break;
|
|
258
|
+
|
|
259
|
+
default:
|
|
260
|
+
console.log('Unhandled event type:', event.event_type);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
res.status(200).send('OK');
|
|
264
|
+
} catch (err) {
|
|
265
|
+
console.error('Error processing webhook:', err);
|
|
266
|
+
res.status(500).send('Error processing webhook');
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
app.listen(8080);
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### Handling Unhandled Events
|
|
274
|
+
|
|
275
|
+
By default, if an incoming webhook event type is not recognized or you haven't registered a corresponding callback handler, the SDK provides flexible options to handle these scenarios:
|
|
276
|
+
|
|
277
|
+
**Using the `unhandled_event` listener:**
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
import { WebhookHandler } from 'chargebee';
|
|
281
|
+
|
|
282
|
+
const handler = new WebhookHandler();
|
|
283
|
+
|
|
284
|
+
handler.on('subscription_created', async (event) => {
|
|
285
|
+
// Handle subscription created
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Gracefully handle events without registered listeners
|
|
289
|
+
handler.on('unhandled_event', async (event) => {
|
|
290
|
+
console.log(`Received unhandled event: ${event.event_type}`);
|
|
291
|
+
// Log for monitoring or store for later processing
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Using the `error` listener for error handling:**
|
|
296
|
+
|
|
297
|
+
If an error occurs during webhook processing (e.g., invalid JSON, validator failure), the SDK will emit an `error` event:
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
const handler = new WebhookHandler();
|
|
301
|
+
|
|
302
|
+
handler.on('subscription_created', async (event) => {
|
|
303
|
+
// Handle subscription created
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Catch any errors during webhook processing
|
|
307
|
+
handler.on('error', (err) => {
|
|
308
|
+
console.error('Webhook processing error:', err);
|
|
309
|
+
// Log to monitoring service, alert team, etc.
|
|
310
|
+
});
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Best Practices:**
|
|
314
|
+
|
|
315
|
+
- Use `unhandled_event` listener to acknowledge unknown events (return 200 OK) and log them
|
|
316
|
+
- Use `error` listener to catch and handle exceptions thrown during event processing
|
|
317
|
+
- Both listeners help ensure your webhook endpoint remains stable even when new event types are introduced by Chargebee
|
|
318
|
+
|
|
151
319
|
### Processing Webhooks - API Version Check
|
|
152
320
|
|
|
153
321
|
An attribute `api_version` 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.
|
package/cjs/chargebee.cjs.js
CHANGED
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const createChargebee_js_1 = require("./createChargebee.js");
|
|
4
4
|
const FetchClient_js_1 = require("./net/FetchClient.js");
|
|
5
|
+
const handler_js_1 = require("./resources/webhook/handler.js");
|
|
6
|
+
const handler_js_2 = require("./resources/webhook/handler.js");
|
|
7
|
+
const auth_js_1 = require("./resources/webhook/auth.js");
|
|
5
8
|
const httpClient = new FetchClient_js_1.FetchHttpClient();
|
|
6
9
|
const Chargebee = (0, createChargebee_js_1.CreateChargebee)(httpClient);
|
|
7
10
|
module.exports = Chargebee;
|
|
8
11
|
module.exports.Chargebee = Chargebee;
|
|
9
12
|
module.exports.default = Chargebee;
|
|
13
|
+
// Export webhook modules
|
|
14
|
+
module.exports.WebhookHandler = handler_js_1.WebhookHandler;
|
|
15
|
+
module.exports.webhook = handler_js_2.default;
|
|
16
|
+
module.exports.basicAuthValidator = auth_js_1.basicAuthValidator;
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
package/esm/chargebee.esm.js
CHANGED
|
@@ -3,3 +3,7 @@ import { FetchHttpClient } from './net/FetchClient.js';
|
|
|
3
3
|
const httpClient = new FetchHttpClient();
|
|
4
4
|
const Chargebee = CreateChargebee(httpClient);
|
|
5
5
|
export default Chargebee;
|
|
6
|
+
// Export webhook modules
|
|
7
|
+
export { WebhookHandler } from './resources/webhook/handler.js';
|
|
8
|
+
export { default as webhook } from './resources/webhook/handler.js';
|
|
9
|
+
export { basicAuthValidator } from './resources/webhook/auth.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chargebee",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0-beta.1",
|
|
4
4
|
"description": "A library for integrating with Chargebee.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepack": "npm install && npm run build",
|
|
7
|
+
"test": "mocha -r ts-node/register 'test/**/*.test.ts'",
|
|
7
8
|
"build": "npm run build-esm && npm run build-cjs",
|
|
8
9
|
"build-esm": "rm -rf esm && mkdir -p esm && tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > esm/package.json",
|
|
9
10
|
"build-cjs": "rm -rf cjs && mkdir -p cjs && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > cjs/package.json",
|
|
@@ -32,8 +33,6 @@
|
|
|
32
33
|
"url": "http://github.com/chargebee/chargebee-node/blob/master/LICENSE"
|
|
33
34
|
}
|
|
34
35
|
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
},
|
|
37
36
|
"exports": {
|
|
38
37
|
"types": "./types/index.d.ts",
|
|
39
38
|
"browser": {
|
|
@@ -62,13 +61,19 @@
|
|
|
62
61
|
}
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@types/
|
|
64
|
+
"@types/chai": "^4.3.5",
|
|
65
|
+
"@types/mocha": "^10.0.10",
|
|
66
|
+
"@types/node": "20.12.0",
|
|
67
|
+
"chai": "^4.3.7",
|
|
68
|
+
"mocha": "^10.2.0",
|
|
66
69
|
"prettier": "^3.3.3",
|
|
67
|
-
"
|
|
70
|
+
"ts-node": "^10.9.1",
|
|
71
|
+
"typescript": "^5.5.4",
|
|
72
|
+
"undici-types": "^7.16.0"
|
|
68
73
|
},
|
|
69
74
|
"prettier": {
|
|
70
75
|
"semi": true,
|
|
71
76
|
"singleQuote": true,
|
|
72
77
|
"parser": "typescript"
|
|
73
78
|
}
|
|
74
|
-
}
|
|
79
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -250,4 +250,69 @@ declare module 'chargebee' {
|
|
|
250
250
|
virtualBankAccount: VirtualBankAccount.VirtualBankAccountResource;
|
|
251
251
|
webhookEndpoint: WebhookEndpoint.WebhookEndpointResource;
|
|
252
252
|
}
|
|
253
|
+
|
|
254
|
+
// Webhook Handler
|
|
255
|
+
export type WebhookEventName = EventTypeEnum | 'unhandled_event';
|
|
256
|
+
export type WebhookEventTypeValue = `${WebhookEventType}`;
|
|
257
|
+
/** @deprecated Use WebhookEventTypeValue instead */
|
|
258
|
+
export type WebhookContentTypeValue = WebhookEventTypeValue;
|
|
259
|
+
|
|
260
|
+
export type WebhookEventListener<
|
|
261
|
+
T extends WebhookEventType = WebhookEventType,
|
|
262
|
+
> = (event: WebhookEvent<T>) => Promise<void> | void;
|
|
263
|
+
export type WebhookErrorListener = (error: Error) => Promise<void> | void;
|
|
264
|
+
|
|
265
|
+
// Helper type to map string literal to enum member
|
|
266
|
+
type StringToWebhookEventType<S extends WebhookEventTypeValue> = {
|
|
267
|
+
[K in WebhookEventType]: `${K}` extends S ? K : never;
|
|
268
|
+
}[WebhookEventType];
|
|
269
|
+
|
|
270
|
+
export class WebhookHandler {
|
|
271
|
+
on<T extends WebhookEventType>(
|
|
272
|
+
eventName: T,
|
|
273
|
+
listener: WebhookEventListener<T>,
|
|
274
|
+
): this;
|
|
275
|
+
on<S extends WebhookEventTypeValue>(
|
|
276
|
+
eventName: S,
|
|
277
|
+
listener: WebhookEventListener<StringToWebhookEventType<S>>,
|
|
278
|
+
): this;
|
|
279
|
+
on(eventName: 'unhandled_event', listener: WebhookEventListener): this;
|
|
280
|
+
on(eventName: 'error', listener: WebhookErrorListener): this;
|
|
281
|
+
once<T extends WebhookEventType>(
|
|
282
|
+
eventName: T,
|
|
283
|
+
listener: WebhookEventListener<T>,
|
|
284
|
+
): this;
|
|
285
|
+
once<S extends WebhookEventTypeValue>(
|
|
286
|
+
eventName: S,
|
|
287
|
+
listener: WebhookEventListener<StringToWebhookEventType<S>>,
|
|
288
|
+
): this;
|
|
289
|
+
once(eventName: 'unhandled_event', listener: WebhookEventListener): this;
|
|
290
|
+
once(eventName: 'error', listener: WebhookErrorListener): this;
|
|
291
|
+
off<T extends WebhookEventType>(
|
|
292
|
+
eventName: T,
|
|
293
|
+
listener: WebhookEventListener<T>,
|
|
294
|
+
): this;
|
|
295
|
+
off<S extends WebhookEventTypeValue>(
|
|
296
|
+
eventName: S,
|
|
297
|
+
listener: WebhookEventListener<StringToWebhookEventType<S>>,
|
|
298
|
+
): this;
|
|
299
|
+
off(eventName: 'unhandled_event', listener: WebhookEventListener): this;
|
|
300
|
+
off(eventName: 'error', listener: WebhookErrorListener): this;
|
|
301
|
+
handle(
|
|
302
|
+
body: string | object,
|
|
303
|
+
headers?: Record<string, string | string[] | undefined>,
|
|
304
|
+
): void;
|
|
305
|
+
onError?: (error: any) => void;
|
|
306
|
+
requestValidator?: (
|
|
307
|
+
headers: Record<string, string | string[] | undefined>,
|
|
308
|
+
) => void;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Webhook Auth
|
|
312
|
+
export function basicAuthValidator(
|
|
313
|
+
validateCredentials: (username: string, password: string) => boolean,
|
|
314
|
+
): (headers: Record<string, string | string[] | undefined>) => void;
|
|
315
|
+
|
|
316
|
+
// Default webhook handler instance
|
|
317
|
+
export const webhook: WebhookHandler;
|
|
253
318
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
///<reference path='./filter.d.ts'/>
|
|
4
4
|
|
|
5
5
|
declare module 'chargebee' {
|
|
6
|
-
export enum
|
|
6
|
+
export enum WebhookEventType {
|
|
7
7
|
SubscriptionPauseScheduled = 'subscription_pause_scheduled',
|
|
8
8
|
CustomerBusinessEntityChanged = 'customer_business_entity_changed',
|
|
9
9
|
SubscriptionAdvanceInvoiceScheduleAdded = 'subscription_advance_invoice_schedule_added',
|
|
@@ -220,230 +220,232 @@ declare module 'chargebee' {
|
|
|
220
220
|
PlanCreated = 'plan_created',
|
|
221
221
|
PlanUpdated = 'plan_updated',
|
|
222
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* @deprecated Use WebhookEventType instead.
|
|
225
|
+
*/
|
|
226
|
+
export import WebhookContentType = WebhookEventType;
|
|
223
227
|
|
|
224
228
|
export type WebhookContentMap = {
|
|
225
|
-
[
|
|
226
|
-
[
|
|
227
|
-
[
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
[
|
|
231
|
-
[
|
|
232
|
-
[
|
|
233
|
-
[
|
|
234
|
-
[
|
|
235
|
-
[
|
|
236
|
-
[
|
|
237
|
-
[
|
|
238
|
-
[
|
|
239
|
-
[
|
|
240
|
-
[
|
|
241
|
-
[
|
|
242
|
-
[
|
|
243
|
-
[
|
|
244
|
-
[
|
|
245
|
-
[
|
|
246
|
-
[
|
|
247
|
-
[
|
|
248
|
-
[
|
|
249
|
-
[
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
[
|
|
253
|
-
[
|
|
254
|
-
[
|
|
255
|
-
[
|
|
256
|
-
[
|
|
257
|
-
[
|
|
258
|
-
[
|
|
259
|
-
[
|
|
260
|
-
[
|
|
261
|
-
[
|
|
262
|
-
[
|
|
263
|
-
[
|
|
264
|
-
[
|
|
265
|
-
[
|
|
266
|
-
[
|
|
267
|
-
[
|
|
268
|
-
[
|
|
269
|
-
[
|
|
270
|
-
[
|
|
271
|
-
[
|
|
272
|
-
[
|
|
273
|
-
[
|
|
274
|
-
[
|
|
275
|
-
[
|
|
276
|
-
[
|
|
277
|
-
[
|
|
278
|
-
[
|
|
279
|
-
[
|
|
280
|
-
[
|
|
281
|
-
[
|
|
282
|
-
[
|
|
283
|
-
[
|
|
284
|
-
[
|
|
285
|
-
[
|
|
286
|
-
[
|
|
287
|
-
[
|
|
288
|
-
[
|
|
289
|
-
[
|
|
290
|
-
[
|
|
291
|
-
[
|
|
292
|
-
[
|
|
293
|
-
[
|
|
294
|
-
[
|
|
295
|
-
[
|
|
296
|
-
[
|
|
297
|
-
[
|
|
298
|
-
[
|
|
299
|
-
[
|
|
300
|
-
[
|
|
301
|
-
[
|
|
302
|
-
[
|
|
303
|
-
[
|
|
304
|
-
[
|
|
305
|
-
[
|
|
306
|
-
[
|
|
307
|
-
[
|
|
308
|
-
[
|
|
309
|
-
[
|
|
310
|
-
[
|
|
311
|
-
[
|
|
312
|
-
[
|
|
313
|
-
[
|
|
314
|
-
[
|
|
315
|
-
[
|
|
316
|
-
[
|
|
317
|
-
[
|
|
318
|
-
[
|
|
319
|
-
[
|
|
320
|
-
[
|
|
321
|
-
[
|
|
322
|
-
[
|
|
323
|
-
[
|
|
324
|
-
[
|
|
325
|
-
[
|
|
326
|
-
[
|
|
327
|
-
[
|
|
328
|
-
[
|
|
329
|
-
[
|
|
330
|
-
[
|
|
331
|
-
[
|
|
332
|
-
[
|
|
333
|
-
[
|
|
334
|
-
[
|
|
335
|
-
[
|
|
336
|
-
[
|
|
337
|
-
[
|
|
338
|
-
[
|
|
339
|
-
[
|
|
340
|
-
[
|
|
341
|
-
[
|
|
342
|
-
[
|
|
343
|
-
[
|
|
344
|
-
[
|
|
345
|
-
[
|
|
346
|
-
[
|
|
347
|
-
[
|
|
348
|
-
[
|
|
349
|
-
[
|
|
350
|
-
[
|
|
351
|
-
[
|
|
352
|
-
[
|
|
353
|
-
[
|
|
354
|
-
[
|
|
355
|
-
[
|
|
356
|
-
[
|
|
357
|
-
[
|
|
358
|
-
[
|
|
359
|
-
[
|
|
360
|
-
[
|
|
361
|
-
[
|
|
362
|
-
[
|
|
363
|
-
[
|
|
364
|
-
[
|
|
365
|
-
[
|
|
366
|
-
[
|
|
367
|
-
[
|
|
368
|
-
[
|
|
369
|
-
[
|
|
370
|
-
[
|
|
371
|
-
[
|
|
372
|
-
[
|
|
373
|
-
[
|
|
374
|
-
[
|
|
375
|
-
[
|
|
376
|
-
[
|
|
377
|
-
[
|
|
378
|
-
[
|
|
379
|
-
[
|
|
380
|
-
[
|
|
381
|
-
[
|
|
382
|
-
[
|
|
383
|
-
[
|
|
384
|
-
[
|
|
385
|
-
[
|
|
386
|
-
[
|
|
387
|
-
[
|
|
388
|
-
[
|
|
389
|
-
[
|
|
390
|
-
[
|
|
391
|
-
[
|
|
392
|
-
[
|
|
393
|
-
[
|
|
394
|
-
[
|
|
395
|
-
[
|
|
396
|
-
[
|
|
397
|
-
[
|
|
398
|
-
[
|
|
399
|
-
[
|
|
400
|
-
[
|
|
401
|
-
[
|
|
402
|
-
[
|
|
403
|
-
[
|
|
404
|
-
[
|
|
405
|
-
[
|
|
406
|
-
[
|
|
407
|
-
[
|
|
408
|
-
[
|
|
409
|
-
[
|
|
410
|
-
[
|
|
411
|
-
[
|
|
412
|
-
[
|
|
413
|
-
[
|
|
414
|
-
[
|
|
415
|
-
[
|
|
416
|
-
[
|
|
417
|
-
[
|
|
418
|
-
[
|
|
419
|
-
[
|
|
420
|
-
[
|
|
421
|
-
[
|
|
422
|
-
[
|
|
423
|
-
[
|
|
424
|
-
[
|
|
425
|
-
[
|
|
426
|
-
[
|
|
427
|
-
[
|
|
428
|
-
[
|
|
429
|
-
[
|
|
430
|
-
[
|
|
431
|
-
[
|
|
432
|
-
[
|
|
433
|
-
[
|
|
434
|
-
[
|
|
435
|
-
[
|
|
436
|
-
[
|
|
437
|
-
[
|
|
438
|
-
[
|
|
439
|
-
[
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
export type ContentFor<T extends
|
|
443
|
-
|
|
444
|
-
export interface WebhookEvent<
|
|
445
|
-
T extends WebhookContentType = WebhookContentType,
|
|
446
|
-
> {
|
|
229
|
+
[WebhookEventType.SubscriptionPauseScheduled]: SubscriptionPauseScheduledContent;
|
|
230
|
+
[WebhookEventType.CustomerBusinessEntityChanged]: CustomerBusinessEntityChangedContent;
|
|
231
|
+
[WebhookEventType.SubscriptionAdvanceInvoiceScheduleAdded]: SubscriptionAdvanceInvoiceScheduleAddedContent;
|
|
232
|
+
[WebhookEventType.GiftExpired]: GiftExpiredContent;
|
|
233
|
+
[WebhookEventType.TaxWithheldDeleted]: TaxWithheldDeletedContent;
|
|
234
|
+
[WebhookEventType.UnbilledChargesDeleted]: UnbilledChargesDeletedContent;
|
|
235
|
+
[WebhookEventType.CouponUpdated]: CouponUpdatedContent;
|
|
236
|
+
[WebhookEventType.OmnichannelSubscriptionItemReactivated]: OmnichannelSubscriptionItemReactivatedContent;
|
|
237
|
+
[WebhookEventType.OmnichannelSubscriptionItemRenewed]: OmnichannelSubscriptionItemRenewedContent;
|
|
238
|
+
[WebhookEventType.UnbilledChargesCreated]: UnbilledChargesCreatedContent;
|
|
239
|
+
[WebhookEventType.SubscriptionResumed]: SubscriptionResumedContent;
|
|
240
|
+
[WebhookEventType.OmnichannelOneTimeOrderItemCancelled]: OmnichannelOneTimeOrderItemCancelledContent;
|
|
241
|
+
[WebhookEventType.SubscriptionCancelled]: SubscriptionCancelledContent;
|
|
242
|
+
[WebhookEventType.ItemEntitlementsRemoved]: ItemEntitlementsRemovedContent;
|
|
243
|
+
[WebhookEventType.BusinessEntityCreated]: BusinessEntityCreatedContent;
|
|
244
|
+
[WebhookEventType.CouponSetUpdated]: CouponSetUpdatedContent;
|
|
245
|
+
[WebhookEventType.DifferentialPriceUpdated]: DifferentialPriceUpdatedContent;
|
|
246
|
+
[WebhookEventType.OmnichannelSubscriptionItemPaused]: OmnichannelSubscriptionItemPausedContent;
|
|
247
|
+
[WebhookEventType.EntitlementOverridesRemoved]: EntitlementOverridesRemovedContent;
|
|
248
|
+
[WebhookEventType.SubscriptionActivatedWithBackdating]: SubscriptionActivatedWithBackdatingContent;
|
|
249
|
+
[WebhookEventType.SubscriptionTrialEndReminder]: SubscriptionTrialEndReminderContent;
|
|
250
|
+
[WebhookEventType.SubscriptionShippingAddressUpdated]: SubscriptionShippingAddressUpdatedContent;
|
|
251
|
+
[WebhookEventType.VoucherCreateFailed]: VoucherCreateFailedContent;
|
|
252
|
+
[WebhookEventType.GiftClaimed]: GiftClaimedContent;
|
|
253
|
+
[WebhookEventType.CustomerDeleted]: CustomerDeletedContent;
|
|
254
|
+
[WebhookEventType.RefundInitiated]: RefundInitiatedContent;
|
|
255
|
+
[WebhookEventType.InvoiceGeneratedWithBackdating]: InvoiceGeneratedWithBackdatingContent;
|
|
256
|
+
[WebhookEventType.OmnichannelTransactionCreated]: OmnichannelTransactionCreatedContent;
|
|
257
|
+
[WebhookEventType.AddUsagesReminder]: AddUsagesReminderContent;
|
|
258
|
+
[WebhookEventType.VoucherCreated]: VoucherCreatedContent;
|
|
259
|
+
[WebhookEventType.RuleUpdated]: RuleUpdatedContent;
|
|
260
|
+
[WebhookEventType.PaymentSchedulesCreated]: PaymentSchedulesCreatedContent;
|
|
261
|
+
[WebhookEventType.FeatureActivated]: FeatureActivatedContent;
|
|
262
|
+
[WebhookEventType.PaymentSourceLocallyDeleted]: PaymentSourceLocallyDeletedContent;
|
|
263
|
+
[WebhookEventType.InvoiceGenerated]: InvoiceGeneratedContent;
|
|
264
|
+
[WebhookEventType.VoucherExpired]: VoucherExpiredContent;
|
|
265
|
+
[WebhookEventType.AuthorizationSucceeded]: AuthorizationSucceededContent;
|
|
266
|
+
[WebhookEventType.GiftScheduled]: GiftScheduledContent;
|
|
267
|
+
[WebhookEventType.SubscriptionChangesScheduled]: SubscriptionChangesScheduledContent;
|
|
268
|
+
[WebhookEventType.SubscriptionChangedWithBackdating]: SubscriptionChangedWithBackdatingContent;
|
|
269
|
+
[WebhookEventType.OmnichannelSubscriptionItemChanged]: OmnichannelSubscriptionItemChangedContent;
|
|
270
|
+
[WebhookEventType.GiftUnclaimed]: GiftUnclaimedContent;
|
|
271
|
+
[WebhookEventType.VirtualBankAccountAdded]: VirtualBankAccountAddedContent;
|
|
272
|
+
[WebhookEventType.PaymentIntentCreated]: PaymentIntentCreatedContent;
|
|
273
|
+
[WebhookEventType.CreditNoteCreatedWithBackdating]: CreditNoteCreatedWithBackdatingContent;
|
|
274
|
+
[WebhookEventType.ContractTermTerminated]: ContractTermTerminatedContent;
|
|
275
|
+
[WebhookEventType.ItemFamilyUpdated]: ItemFamilyUpdatedContent;
|
|
276
|
+
[WebhookEventType.OrderCreated]: OrderCreatedContent;
|
|
277
|
+
[WebhookEventType.PriceVariantDeleted]: PriceVariantDeletedContent;
|
|
278
|
+
[WebhookEventType.SubscriptionMovementFailed]: SubscriptionMovementFailedContent;
|
|
279
|
+
[WebhookEventType.CustomerMovedIn]: CustomerMovedInContent;
|
|
280
|
+
[WebhookEventType.SubscriptionAdvanceInvoiceScheduleUpdated]: SubscriptionAdvanceInvoiceScheduleUpdatedContent;
|
|
281
|
+
[WebhookEventType.ItemDeleted]: ItemDeletedContent;
|
|
282
|
+
[WebhookEventType.SubscriptionRampDrafted]: SubscriptionRampDraftedContent;
|
|
283
|
+
[WebhookEventType.DunningUpdated]: DunningUpdatedContent;
|
|
284
|
+
[WebhookEventType.ItemEntitlementsUpdated]: ItemEntitlementsUpdatedContent;
|
|
285
|
+
[WebhookEventType.TokenConsumed]: TokenConsumedContent;
|
|
286
|
+
[WebhookEventType.HierarchyDeleted]: HierarchyDeletedContent;
|
|
287
|
+
[WebhookEventType.SubscriptionCancellationScheduled]: SubscriptionCancellationScheduledContent;
|
|
288
|
+
[WebhookEventType.SubscriptionRenewed]: SubscriptionRenewedContent;
|
|
289
|
+
[WebhookEventType.FeatureUpdated]: FeatureUpdatedContent;
|
|
290
|
+
[WebhookEventType.FeatureDeleted]: FeatureDeletedContent;
|
|
291
|
+
[WebhookEventType.ItemFamilyCreated]: ItemFamilyCreatedContent;
|
|
292
|
+
[WebhookEventType.OmnichannelSubscriptionItemScheduledChangeRemoved]: OmnichannelSubscriptionItemScheduledChangeRemovedContent;
|
|
293
|
+
[WebhookEventType.OmnichannelSubscriptionItemResumed]: OmnichannelSubscriptionItemResumedContent;
|
|
294
|
+
[WebhookEventType.PurchaseCreated]: PurchaseCreatedContent;
|
|
295
|
+
[WebhookEventType.EntitlementOverridesUpdated]: EntitlementOverridesUpdatedContent;
|
|
296
|
+
[WebhookEventType.ItemFamilyDeleted]: ItemFamilyDeletedContent;
|
|
297
|
+
[WebhookEventType.SubscriptionResumptionScheduled]: SubscriptionResumptionScheduledContent;
|
|
298
|
+
[WebhookEventType.FeatureReactivated]: FeatureReactivatedContent;
|
|
299
|
+
[WebhookEventType.CouponCodesDeleted]: CouponCodesDeletedContent;
|
|
300
|
+
[WebhookEventType.CardExpired]: CardExpiredContent;
|
|
301
|
+
[WebhookEventType.CreditNoteUpdated]: CreditNoteUpdatedContent;
|
|
302
|
+
[WebhookEventType.OmnichannelSubscriptionItemDowngraded]: OmnichannelSubscriptionItemDowngradedContent;
|
|
303
|
+
[WebhookEventType.PriceVariantUpdated]: PriceVariantUpdatedContent;
|
|
304
|
+
[WebhookEventType.PromotionalCreditsDeducted]: PromotionalCreditsDeductedContent;
|
|
305
|
+
[WebhookEventType.SubscriptionRampApplied]: SubscriptionRampAppliedContent;
|
|
306
|
+
[WebhookEventType.SubscriptionPaused]: SubscriptionPausedContent;
|
|
307
|
+
[WebhookEventType.OrderReadyToProcess]: OrderReadyToProcessContent;
|
|
308
|
+
[WebhookEventType.FeatureCreated]: FeatureCreatedContent;
|
|
309
|
+
[WebhookEventType.TransactionDeleted]: TransactionDeletedContent;
|
|
310
|
+
[WebhookEventType.CreditNoteCreated]: CreditNoteCreatedContent;
|
|
311
|
+
[WebhookEventType.OmnichannelSubscriptionItemResubscribed]: OmnichannelSubscriptionItemResubscribedContent;
|
|
312
|
+
[WebhookEventType.RecordPurchaseFailed]: RecordPurchaseFailedContent;
|
|
313
|
+
[WebhookEventType.ItemCreated]: ItemCreatedContent;
|
|
314
|
+
[WebhookEventType.TransactionUpdated]: TransactionUpdatedContent;
|
|
315
|
+
[WebhookEventType.MrrUpdated]: MrrUpdatedContent;
|
|
316
|
+
[WebhookEventType.UnbilledChargesInvoiced]: UnbilledChargesInvoicedContent;
|
|
317
|
+
[WebhookEventType.ItemPriceUpdated]: ItemPriceUpdatedContent;
|
|
318
|
+
[WebhookEventType.CouponCodesUpdated]: CouponCodesUpdatedContent;
|
|
319
|
+
[WebhookEventType.VirtualBankAccountUpdated]: VirtualBankAccountUpdatedContent;
|
|
320
|
+
[WebhookEventType.ContractTermCreated]: ContractTermCreatedContent;
|
|
321
|
+
[WebhookEventType.SubscriptionChanged]: SubscriptionChangedContent;
|
|
322
|
+
[WebhookEventType.PaymentFailed]: PaymentFailedContent;
|
|
323
|
+
[WebhookEventType.CreditNoteDeleted]: CreditNoteDeletedContent;
|
|
324
|
+
[WebhookEventType.TaxWithheldRefunded]: TaxWithheldRefundedContent;
|
|
325
|
+
[WebhookEventType.ContractTermCompleted]: ContractTermCompletedContent;
|
|
326
|
+
[WebhookEventType.PaymentSchedulesUpdated]: PaymentSchedulesUpdatedContent;
|
|
327
|
+
[WebhookEventType.OmnichannelSubscriptionItemExpired]: OmnichannelSubscriptionItemExpiredContent;
|
|
328
|
+
[WebhookEventType.CardUpdated]: CardUpdatedContent;
|
|
329
|
+
[WebhookEventType.CustomerCreated]: CustomerCreatedContent;
|
|
330
|
+
[WebhookEventType.SubscriptionRenewalReminder]: SubscriptionRenewalReminderContent;
|
|
331
|
+
[WebhookEventType.OrderDelivered]: OrderDeliveredContent;
|
|
332
|
+
[WebhookEventType.OmnichannelSubscriptionItemCancellationScheduled]: OmnichannelSubscriptionItemCancellationScheduledContent;
|
|
333
|
+
[WebhookEventType.OmnichannelSubscriptionItemGracePeriodExpired]: OmnichannelSubscriptionItemGracePeriodExpiredContent;
|
|
334
|
+
[WebhookEventType.CouponCodesAdded]: CouponCodesAddedContent;
|
|
335
|
+
[WebhookEventType.GiftCancelled]: GiftCancelledContent;
|
|
336
|
+
[WebhookEventType.OrderCancelled]: OrderCancelledContent;
|
|
337
|
+
[WebhookEventType.CouponDeleted]: CouponDeletedContent;
|
|
338
|
+
[WebhookEventType.SubscriptionScheduledChangesRemoved]: SubscriptionScheduledChangesRemovedContent;
|
|
339
|
+
[WebhookEventType.PendingInvoiceCreated]: PendingInvoiceCreatedContent;
|
|
340
|
+
[WebhookEventType.EntitlementOverridesAutoRemoved]: EntitlementOverridesAutoRemovedContent;
|
|
341
|
+
[WebhookEventType.OmnichannelSubscriptionItemUpgraded]: OmnichannelSubscriptionItemUpgradedContent;
|
|
342
|
+
[WebhookEventType.SubscriptionBusinessEntityChanged]: SubscriptionBusinessEntityChangedContent;
|
|
343
|
+
[WebhookEventType.OmnichannelOneTimeOrderCreated]: OmnichannelOneTimeOrderCreatedContent;
|
|
344
|
+
[WebhookEventType.PaymentSourceDeleted]: PaymentSourceDeletedContent;
|
|
345
|
+
[WebhookEventType.OmnichannelSubscriptionItemCancelled]: OmnichannelSubscriptionItemCancelledContent;
|
|
346
|
+
[WebhookEventType.QuoteDeleted]: QuoteDeletedContent;
|
|
347
|
+
[WebhookEventType.InvoiceUpdated]: InvoiceUpdatedContent;
|
|
348
|
+
[WebhookEventType.SubscriptionAdvanceInvoiceScheduleRemoved]: SubscriptionAdvanceInvoiceScheduleRemovedContent;
|
|
349
|
+
[WebhookEventType.CardDeleted]: CardDeletedContent;
|
|
350
|
+
[WebhookEventType.OrderReadyToShip]: OrderReadyToShipContent;
|
|
351
|
+
[WebhookEventType.SubscriptionMovedOut]: SubscriptionMovedOutContent;
|
|
352
|
+
[WebhookEventType.PaymentScheduleSchemeCreated]: PaymentScheduleSchemeCreatedContent;
|
|
353
|
+
[WebhookEventType.BusinessEntityUpdated]: BusinessEntityUpdatedContent;
|
|
354
|
+
[WebhookEventType.SubscriptionScheduledResumptionRemoved]: SubscriptionScheduledResumptionRemovedContent;
|
|
355
|
+
[WebhookEventType.PaymentInitiated]: PaymentInitiatedContent;
|
|
356
|
+
[WebhookEventType.FeatureArchived]: FeatureArchivedContent;
|
|
357
|
+
[WebhookEventType.SubscriptionReactivatedWithBackdating]: SubscriptionReactivatedWithBackdatingContent;
|
|
358
|
+
[WebhookEventType.OmnichannelSubscriptionImported]: OmnichannelSubscriptionImportedContent;
|
|
359
|
+
[WebhookEventType.TokenExpired]: TokenExpiredContent;
|
|
360
|
+
[WebhookEventType.CardAdded]: CardAddedContent;
|
|
361
|
+
[WebhookEventType.CouponCreated]: CouponCreatedContent;
|
|
362
|
+
[WebhookEventType.RuleDeleted]: RuleDeletedContent;
|
|
363
|
+
[WebhookEventType.ItemPriceEntitlementsUpdated]: ItemPriceEntitlementsUpdatedContent;
|
|
364
|
+
[WebhookEventType.ItemPriceDeleted]: ItemPriceDeletedContent;
|
|
365
|
+
[WebhookEventType.VirtualBankAccountDeleted]: VirtualBankAccountDeletedContent;
|
|
366
|
+
[WebhookEventType.PaymentScheduleSchemeDeleted]: PaymentScheduleSchemeDeletedContent;
|
|
367
|
+
[WebhookEventType.SubscriptionCreated]: SubscriptionCreatedContent;
|
|
368
|
+
[WebhookEventType.SubscriptionEntitlementsCreated]: SubscriptionEntitlementsCreatedContent;
|
|
369
|
+
[WebhookEventType.OrderReturned]: OrderReturnedContent;
|
|
370
|
+
[WebhookEventType.SubscriptionDeleted]: SubscriptionDeletedContent;
|
|
371
|
+
[WebhookEventType.PaymentSourceAdded]: PaymentSourceAddedContent;
|
|
372
|
+
[WebhookEventType.SubscriptionMovedIn]: SubscriptionMovedInContent;
|
|
373
|
+
[WebhookEventType.ItemPriceCreated]: ItemPriceCreatedContent;
|
|
374
|
+
[WebhookEventType.SubscriptionScheduledCancellationRemoved]: SubscriptionScheduledCancellationRemovedContent;
|
|
375
|
+
[WebhookEventType.PaymentRefunded]: PaymentRefundedContent;
|
|
376
|
+
[WebhookEventType.UsageFileIngested]: UsageFileIngestedContent;
|
|
377
|
+
[WebhookEventType.OmnichannelSubscriptionMovedIn]: OmnichannelSubscriptionMovedInContent;
|
|
378
|
+
[WebhookEventType.DifferentialPriceCreated]: DifferentialPriceCreatedContent;
|
|
379
|
+
[WebhookEventType.TransactionCreated]: TransactionCreatedContent;
|
|
380
|
+
[WebhookEventType.PaymentSucceeded]: PaymentSucceededContent;
|
|
381
|
+
[WebhookEventType.SubscriptionCanceledWithBackdating]: SubscriptionCanceledWithBackdatingContent;
|
|
382
|
+
[WebhookEventType.UnbilledChargesVoided]: UnbilledChargesVoidedContent;
|
|
383
|
+
[WebhookEventType.QuoteCreated]: QuoteCreatedContent;
|
|
384
|
+
[WebhookEventType.CouponSetDeleted]: CouponSetDeletedContent;
|
|
385
|
+
[WebhookEventType.AttachedItemCreated]: AttachedItemCreatedContent;
|
|
386
|
+
[WebhookEventType.SalesOrderCreated]: SalesOrderCreatedContent;
|
|
387
|
+
[WebhookEventType.CustomerChanged]: CustomerChangedContent;
|
|
388
|
+
[WebhookEventType.SubscriptionStarted]: SubscriptionStartedContent;
|
|
389
|
+
[WebhookEventType.SubscriptionActivated]: SubscriptionActivatedContent;
|
|
390
|
+
[WebhookEventType.PaymentSourceExpiring]: PaymentSourceExpiringContent;
|
|
391
|
+
[WebhookEventType.SubscriptionReactivated]: SubscriptionReactivatedContent;
|
|
392
|
+
[WebhookEventType.OrderUpdated]: OrderUpdatedContent;
|
|
393
|
+
[WebhookEventType.SubscriptionScheduledPauseRemoved]: SubscriptionScheduledPauseRemovedContent;
|
|
394
|
+
[WebhookEventType.SubscriptionCancellationReminder]: SubscriptionCancellationReminderContent;
|
|
395
|
+
[WebhookEventType.SubscriptionCreatedWithBackdating]: SubscriptionCreatedWithBackdatingContent;
|
|
396
|
+
[WebhookEventType.SubscriptionRampCreated]: SubscriptionRampCreatedContent;
|
|
397
|
+
[WebhookEventType.OrderDeleted]: OrderDeletedContent;
|
|
398
|
+
[WebhookEventType.OmnichannelSubscriptionItemPauseScheduled]: OmnichannelSubscriptionItemPauseScheduledContent;
|
|
399
|
+
[WebhookEventType.GiftUpdated]: GiftUpdatedContent;
|
|
400
|
+
[WebhookEventType.SubscriptionTrialExtended]: SubscriptionTrialExtendedContent;
|
|
401
|
+
[WebhookEventType.OmnichannelSubscriptionItemGracePeriodStarted]: OmnichannelSubscriptionItemGracePeriodStartedContent;
|
|
402
|
+
[WebhookEventType.CardExpiryReminder]: CardExpiryReminderContent;
|
|
403
|
+
[WebhookEventType.TokenCreated]: TokenCreatedContent;
|
|
404
|
+
[WebhookEventType.PromotionalCreditsAdded]: PromotionalCreditsAddedContent;
|
|
405
|
+
[WebhookEventType.SubscriptionRampUpdated]: SubscriptionRampUpdatedContent;
|
|
406
|
+
[WebhookEventType.CustomerEntitlementsUpdated]: CustomerEntitlementsUpdatedContent;
|
|
407
|
+
[WebhookEventType.PaymentSourceExpired]: PaymentSourceExpiredContent;
|
|
408
|
+
[WebhookEventType.CustomerMovedOut]: CustomerMovedOutContent;
|
|
409
|
+
[WebhookEventType.SubscriptionEntitlementsUpdated]: SubscriptionEntitlementsUpdatedContent;
|
|
410
|
+
[WebhookEventType.OmnichannelSubscriptionItemDunningExpired]: OmnichannelSubscriptionItemDunningExpiredContent;
|
|
411
|
+
[WebhookEventType.HierarchyCreated]: HierarchyCreatedContent;
|
|
412
|
+
[WebhookEventType.AttachedItemDeleted]: AttachedItemDeletedContent;
|
|
413
|
+
[WebhookEventType.OmnichannelSubscriptionItemScheduledCancellationRemoved]: OmnichannelSubscriptionItemScheduledCancellationRemovedContent;
|
|
414
|
+
[WebhookEventType.ItemUpdated]: ItemUpdatedContent;
|
|
415
|
+
[WebhookEventType.CouponSetCreated]: CouponSetCreatedContent;
|
|
416
|
+
[WebhookEventType.PaymentIntentUpdated]: PaymentIntentUpdatedContent;
|
|
417
|
+
[WebhookEventType.OrderResent]: OrderResentContent;
|
|
418
|
+
[WebhookEventType.OmnichannelSubscriptionCreated]: OmnichannelSubscriptionCreatedContent;
|
|
419
|
+
[WebhookEventType.TaxWithheldRecorded]: TaxWithheldRecordedContent;
|
|
420
|
+
[WebhookEventType.PriceVariantCreated]: PriceVariantCreatedContent;
|
|
421
|
+
[WebhookEventType.DifferentialPriceDeleted]: DifferentialPriceDeletedContent;
|
|
422
|
+
[WebhookEventType.SubscriptionItemsRenewed]: SubscriptionItemsRenewedContent;
|
|
423
|
+
[WebhookEventType.RuleCreated]: RuleCreatedContent;
|
|
424
|
+
[WebhookEventType.ContractTermCancelled]: ContractTermCancelledContent;
|
|
425
|
+
[WebhookEventType.ContractTermRenewed]: ContractTermRenewedContent;
|
|
426
|
+
[WebhookEventType.InvoiceDeleted]: InvoiceDeletedContent;
|
|
427
|
+
[WebhookEventType.ItemPriceEntitlementsRemoved]: ItemPriceEntitlementsRemovedContent;
|
|
428
|
+
[WebhookEventType.SalesOrderUpdated]: SalesOrderUpdatedContent;
|
|
429
|
+
[WebhookEventType.OmnichannelSubscriptionItemDunningStarted]: OmnichannelSubscriptionItemDunningStartedContent;
|
|
430
|
+
[WebhookEventType.OmnichannelSubscriptionItemChangeScheduled]: OmnichannelSubscriptionItemChangeScheduledContent;
|
|
431
|
+
[WebhookEventType.PendingInvoiceUpdated]: PendingInvoiceUpdatedContent;
|
|
432
|
+
[WebhookEventType.QuoteUpdated]: QuoteUpdatedContent;
|
|
433
|
+
[WebhookEventType.AttachedItemUpdated]: AttachedItemUpdatedContent;
|
|
434
|
+
[WebhookEventType.PaymentSourceUpdated]: PaymentSourceUpdatedContent;
|
|
435
|
+
[WebhookEventType.BusinessEntityDeleted]: BusinessEntityDeletedContent;
|
|
436
|
+
[WebhookEventType.AuthorizationVoided]: AuthorizationVoidedContent;
|
|
437
|
+
[WebhookEventType.SubscriptionRampDeleted]: SubscriptionRampDeletedContent;
|
|
438
|
+
[WebhookEventType.PlanDeleted]: PlanDeletedContent;
|
|
439
|
+
[WebhookEventType.AddonDeleted]: AddonDeletedContent;
|
|
440
|
+
[WebhookEventType.AddonUpdated]: AddonUpdatedContent;
|
|
441
|
+
[WebhookEventType.AddonCreated]: AddonCreatedContent;
|
|
442
|
+
[WebhookEventType.PlanCreated]: PlanCreatedContent;
|
|
443
|
+
[WebhookEventType.PlanUpdated]: PlanUpdatedContent;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
export type ContentFor<T extends WebhookEventType> = WebhookContentMap[T];
|
|
447
|
+
|
|
448
|
+
export interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
447
449
|
content: ContentFor<T>;
|
|
448
450
|
id: string;
|
|
449
451
|
occurred_at: number;
|