From 30d36c01e6357e960124f70c5dda4f5f53b61e52 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Mon, 24 Nov 2025 14:26:16 +0530 Subject: [PATCH 01/11] Webhook event handlers --- .github/workflows/ci.yml | 31 + .gitignore | 1 - README.md | 143 + package-lock.json | 1214 +++++ package.json | 10 +- src/chargebee.cjs.ts | 10 + src/chargebee.esm.ts | 8 + src/resources/webhook/auth.ts | 30 + src/resources/webhook/content.ts | 1460 ++++++ src/resources/webhook/event_types.ts | 449 ++ src/resources/webhook/handler.ts | 6700 ++++++++++++++++++++++++++ test/webhook.test.ts | 189 + tsconfig.json | 4 +- types/index.d.ts | 31 + 14 files changed, 10275 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 src/resources/webhook/auth.ts create mode 100644 src/resources/webhook/content.ts create mode 100644 src/resources/webhook/event_types.ts create mode 100644 src/resources/webhook/handler.ts create mode 100644 test/webhook.test.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bb9e27f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + diff --git a/.gitignore b/.gitignore index 7386b6e..76588e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ node_modules -test* *js cjs esm diff --git a/README.md b/README.md index ef95a86..2f5d566 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,149 @@ const chargebeeSiteEU = new Chargebee({ }); ``` +### Handle webhooks + +Use the webhook handlers to parse and route webhook payloads from Chargebee with full TypeScript support. + +#### High-level: Route events with callbacks using `WebhookHandler` + +```typescript +import express from 'express'; +import { WebhookHandler, basicAuthValidator } from 'chargebee'; +import type { + SubscriptionCreatedContent, + PaymentSucceededContent, + WebhookEvent +} from 'chargebee'; + +const app = express(); +app.use(express.json()); + +const handler = new WebhookHandler({ + // Register only the events you care about + // Event callbacks are fully typed with proper content types + onSubscriptionCreated: async (event: WebhookEvent & { content: SubscriptionCreatedContent }) => { + console.log(`Subscription created: ${event.id}`); + // Full IntelliSense for subscription properties + const subscription = event.content.subscription; + console.log(`Customer: ${subscription.customer_id}`); + console.log(`Plan: ${subscription.plan_id}`); + }, + + onPaymentSucceeded: async (event: WebhookEvent & { content: PaymentSucceededContent }) => { + console.log(`Payment succeeded: ${event.id}`); + // Full IntelliSense for transaction and customer + const transaction = event.content.transaction; + const customer = event.content.customer; + console.log(`Amount: ${transaction.amount}, Customer: ${customer.email}`); + }, +}); + +// Optional: Add request validator (e.g., Basic Auth) +handler.requestValidator = basicAuthValidator((username, password) => { + return username === 'admin' && password === 'secret'; +}); + +app.post('/chargebee/webhooks', async (req, res) => { + try { + await handler.handle(req.body, req.headers); + res.status(200).send('OK'); + } catch (err) { + console.error('Webhook error:', err); + res.status(500).send('Error processing webhook'); + } +}); + +app.listen(8080); +``` + +#### Low-level: Parse and handle events manually + +For more control, you can parse webhook events manually: + +```typescript +import express from 'express'; +import Chargebee, { type WebhookEvent } from 'chargebee'; + +const app = express(); +app.use(express.json()); + +app.post('/chargebee/webhooks', async (req, res) => { + try { + const event = req.body as WebhookEvent; + + switch (event.event_type) { + case 'subscription_created': + // Access event content with proper typing + const subscription = event.content.subscription; + console.log('Subscription created:', subscription.id); + break; + + case 'payment_succeeded': + const transaction = event.content.transaction; + console.log('Payment succeeded:', transaction.amount); + break; + + default: + console.log('Unhandled event type:', event.event_type); + } + + res.status(200).send('OK'); + } catch (err) { + console.error('Error processing webhook:', err); + res.status(500).send('Error processing webhook'); + } +}); + +app.listen(8080); +``` + +#### Handling Unhandled Events + +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: + +**Using `onUnhandledEvent` callback:** + +```typescript +import { WebhookHandler } from 'chargebee'; + +const handler = new WebhookHandler({ + onSubscriptionCreated: async (event) => { + // Handle subscription created + }, + + // Gracefully handle events without registered callbacks + onUnhandledEvent: async (event) => { + console.log(`Received unhandled event: ${event.event_type}`); + // Log for monitoring or store for later processing + }, +}); +``` + +**Using `onError` for error handling:** + +If no `onUnhandledEvent` callback is provided and an unhandled event is received, the SDK will invoke the `onError` callback (if configured): + +```typescript +const handler = new WebhookHandler({ + onSubscriptionCreated: async (event) => { + // Handle subscription created + }, + + // Catch any errors during webhook processing + onError: (err) => { + console.error('Webhook processing error:', err); + // Log to monitoring service, alert team, etc. + }, +}); +``` + +**Best Practices:** + +- Set `onUnhandledEvent` if you want to acknowledge unknown events (return 200 OK) and log them +- Use `onError` to catch and handle exceptions thrown during event processing +- Both callbacks help ensure your webhook endpoint remains stable even when new event types are introduced by Chargebee + ### Processing Webhooks - API Version Check 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. diff --git a/package-lock.json b/package-lock.json index 228717c..16aeb08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,20 +8,919 @@ "name": "chargebee", "version": "3.15.1", "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.10", "@types/node": "20.0.0", + "chai": "^4.3.7", + "mocha": "^10.2.0", "prettier": "^3.3.3", + "ts-node": "^10.9.1", "typescript": "^5.5.4" }, "engines": { "node": ">=18.*" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz", + "integrity": "sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "4.3.20", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.20.tgz", + "integrity": "sha512-/pC9HAB5I/xMlc5FP77qjCnI16ChlJfW0tGa0IUcFn38VJrTV6DeZ60NU5KZBtaOZqjdpwTWohz5HU1RrhiYxQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mocha": { + "version": "10.0.10", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.10.tgz", + "integrity": "sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "20.0.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.0.0.tgz", "integrity": "sha512-cD2uPTDnQQCVpmRefonO98/PPijuOnnEy5oytWJFPY1N9aJCz2wJ5kSGWO+zJoed2cY2JxQh6yBuUq4vIn61hw==", "dev": true }, + "node_modules/acorn": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true, + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true, + "license": "ISC" + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", + "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "license": "BSD-3-Clause", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true, + "license": "ISC" + }, + "node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", + "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/prettier": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", @@ -37,6 +936,204 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/type-detect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", + "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/typescript": { "version": "5.5.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", @@ -49,6 +1146,123 @@ "engines": { "node": ">=14.17" } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true, + "license": "MIT" + }, + "node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index 6bfe5b0..25c45ba 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A library for integrating with Chargebee.", "scripts": { "prepack": "npm install && npm run build", + "test": "mocha -r ts-node/register 'test/**/*.test.ts'", "build": "npm run build-esm && npm run build-cjs", "build-esm": "rm -rf esm && mkdir -p esm && tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > esm/package.json", "build-cjs": "rm -rf cjs && mkdir -p cjs && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > cjs/package.json", @@ -32,8 +33,6 @@ "url": "http://github.com/chargebee/chargebee-node/blob/master/LICENSE" } ], - "dependencies": { - }, "exports": { "types": "./types/index.d.ts", "browser": { @@ -62,8 +61,13 @@ } }, "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.10", "@types/node": "20.0.0", + "chai": "^4.3.7", + "mocha": "^10.2.0", "prettier": "^3.3.3", + "ts-node": "^10.9.1", "typescript": "^5.5.4" }, "prettier": { @@ -71,4 +75,4 @@ "singleQuote": true, "parser": "typescript" } -} \ No newline at end of file +} diff --git a/src/chargebee.cjs.ts b/src/chargebee.cjs.ts index af8fe09..51996f5 100644 --- a/src/chargebee.cjs.ts +++ b/src/chargebee.cjs.ts @@ -1,8 +1,18 @@ import { CreateChargebee } from './createChargebee.js'; import { FetchHttpClient } from './net/FetchClient.js'; +import { WebhookHandler } from './resources/webhook/handler.js'; +import { basicAuthValidator } from './resources/webhook/auth.js'; const httpClient = new FetchHttpClient(); const Chargebee = CreateChargebee(httpClient); module.exports = Chargebee; module.exports.Chargebee = Chargebee; module.exports.default = Chargebee; + +// Export webhook modules +module.exports.WebhookHandler = WebhookHandler; +module.exports.basicAuthValidator = basicAuthValidator; + +// Export webhook types (for TypeScript users) +export type * from './resources/webhook/content.js'; +export type * from './resources/webhook/event_types.js'; diff --git a/src/chargebee.esm.ts b/src/chargebee.esm.ts index 0263bce..9053f33 100644 --- a/src/chargebee.esm.ts +++ b/src/chargebee.esm.ts @@ -5,3 +5,11 @@ const httpClient = new FetchHttpClient(); const Chargebee = CreateChargebee(httpClient); export default Chargebee; + +// Export webhook modules - runtime exports +export { WebhookHandler } from './resources/webhook/handler.js'; +export { basicAuthValidator } from './resources/webhook/auth.js'; + +// Export webhook types only (no runtime impact) +export type * from './resources/webhook/content.js'; +export type * from './resources/webhook/event_types.js'; diff --git a/src/resources/webhook/auth.ts b/src/resources/webhook/auth.ts new file mode 100644 index 0000000..23a207a --- /dev/null +++ b/src/resources/webhook/auth.ts @@ -0,0 +1,30 @@ +export const basicAuthValidator = ( + validateCredentials: (username: string, password: string) => boolean, +) => { + return (headers: Record) => { + const authHeader = headers['authorization'] || headers['Authorization']; + + if (!authHeader) { + throw new Error('Invalid authorization header'); + } + + const authStr = Array.isArray(authHeader) ? authHeader[0] : authHeader; + if (!authStr) { + throw new Error('Invalid authorization header'); + } + + const parts = authStr.split(' '); + if (parts.length !== 2 || parts[0] !== 'Basic') { + throw new Error('Invalid authorization header'); + } + + const credentials = Buffer.from(parts[1], 'base64').toString().split(':'); + if (credentials.length !== 2) { + throw new Error('Invalid credentials'); + } + + if (!validateCredentials(credentials[0], credentials[1])) { + throw new Error('Invalid credentials'); + } + }; +}; diff --git a/src/resources/webhook/content.ts b/src/resources/webhook/content.ts new file mode 100644 index 0000000..138fcf5 --- /dev/null +++ b/src/resources/webhook/content.ts @@ -0,0 +1,1460 @@ +/// + +export interface AddUsagesReminderContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + UsageReminderInfo: import('chargebee').UsageReminderInfo; +} + +export interface AddonCreatedContent { + Addon: import('chargebee').Addon; +} + +export interface AddonDeletedContent { + Addon: import('chargebee').Addon; +} + +export interface AddonUpdatedContent { + Addon: import('chargebee').Addon; +} + +export interface AttachedItemCreatedContent { + AttachedItem: import('chargebee').AttachedItem; +} + +export interface AttachedItemDeletedContent { + AttachedItem: import('chargebee').AttachedItem; +} + +export interface AttachedItemUpdatedContent { + AttachedItem: import('chargebee').AttachedItem; +} + +export interface AuthorizationSucceededContent { + Transaction: import('chargebee').Transaction; +} + +export interface AuthorizationVoidedContent { + Transaction: import('chargebee').Transaction; +} + +export interface BusinessEntityCreatedContent { + BusinessEntity: import('chargebee').BusinessEntity; +} + +export interface BusinessEntityDeletedContent { + BusinessEntity: import('chargebee').BusinessEntity; +} + +export interface BusinessEntityUpdatedContent { + BusinessEntity: import('chargebee').BusinessEntity; +} + +export interface CardAddedContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CardDeletedContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CardExpiredContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CardExpiryReminderContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CardUpdatedContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface ContractTermCancelledContent { + ContractTerm: import('chargebee').ContractTerm; +} + +export interface ContractTermCompletedContent { + ContractTerm: import('chargebee').ContractTerm; +} + +export interface ContractTermCreatedContent { + ContractTerm: import('chargebee').ContractTerm; +} + +export interface ContractTermRenewedContent { + ContractTerm: import('chargebee').ContractTerm; +} + +export interface ContractTermTerminatedContent { + ContractTerm: import('chargebee').ContractTerm; +} + +export interface CouponCodesAddedContent { + Coupon: import('chargebee').Coupon; + + CouponSet: import('chargebee').CouponSet; +} + +export interface CouponCodesDeletedContent { + Coupon: import('chargebee').Coupon; + + CouponSet: import('chargebee').CouponSet; + + CouponCode: import('chargebee').CouponCode; +} + +export interface CouponCodesUpdatedContent { + Coupon: import('chargebee').Coupon; + + CouponSet: import('chargebee').CouponSet; +} + +export interface CouponCreatedContent { + Coupon: import('chargebee').Coupon; +} + +export interface CouponDeletedContent { + Coupon: import('chargebee').Coupon; +} + +export interface CouponSetCreatedContent { + Coupon: import('chargebee').Coupon; + + CouponSet: import('chargebee').CouponSet; +} + +export interface CouponSetDeletedContent { + Coupon: import('chargebee').Coupon; + + CouponSet: import('chargebee').CouponSet; +} + +export interface CouponSetUpdatedContent { + Coupon: import('chargebee').Coupon; + + CouponSet: import('chargebee').CouponSet; +} + +export interface CouponUpdatedContent { + Coupon: import('chargebee').Coupon; +} + +export interface CreditNoteCreatedContent { + CreditNote: import('chargebee').CreditNote; +} + +export interface CreditNoteCreatedWithBackdatingContent { + CreditNote: import('chargebee').CreditNote; +} + +export interface CreditNoteDeletedContent { + CreditNote: import('chargebee').CreditNote; +} + +export interface CreditNoteUpdatedContent { + CreditNote: import('chargebee').CreditNote; +} + +export interface CustomerBusinessEntityChangedContent { + BusinessEntityChange: import('chargebee').BusinessEntityChange; + + BusinessEntityTransfer: import('chargebee').BusinessEntityTransfer; + + Customer: import('chargebee').Customer; +} + +export interface CustomerChangedContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CustomerCreatedContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CustomerDeletedContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Subscription: import('chargebee').Subscription; +} + +export interface CustomerEntitlementsUpdatedContent { + ImpactedCustomer: import('chargebee').ImpactedCustomer; +} + +export interface CustomerMovedInContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface CustomerMovedOutContent { + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; +} + +export interface DifferentialPriceCreatedContent { + DifferentialPrice: import('chargebee').DifferentialPrice; +} + +export interface DifferentialPriceDeletedContent { + DifferentialPrice: import('chargebee').DifferentialPrice; +} + +export interface DifferentialPriceUpdatedContent { + DifferentialPrice: import('chargebee').DifferentialPrice; +} + +export interface DunningUpdatedContent { + Invoice: import('chargebee').Invoice; +} + +export interface EntitlementOverridesAutoRemovedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItem: import('chargebee').ImpactedItem; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface EntitlementOverridesRemovedContent { + ImpactedSubscription: import('chargebee').ImpactedSubscription; + + Metadata: import('chargebee').Metadata; +} + +export interface EntitlementOverridesUpdatedContent { + ImpactedSubscription: import('chargebee').ImpactedSubscription; + + Metadata: import('chargebee').Metadata; +} + +export interface FeatureActivatedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItem: import('chargebee').ImpactedItem; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface FeatureArchivedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; +} + +export interface FeatureCreatedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItem: import('chargebee').ImpactedItem; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface FeatureDeletedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItem: import('chargebee').ImpactedItem; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface FeatureReactivatedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; +} + +export interface FeatureUpdatedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; +} + +export interface GiftCancelledContent { + Gift: import('chargebee').Gift; +} + +export interface GiftClaimedContent { + Gift: import('chargebee').Gift; +} + +export interface GiftExpiredContent { + Gift: import('chargebee').Gift; +} + +export interface GiftScheduledContent { + Gift: import('chargebee').Gift; +} + +export interface GiftUnclaimedContent { + Gift: import('chargebee').Gift; +} + +export interface GiftUpdatedContent { + Gift: import('chargebee').Gift; +} + +export interface HierarchyCreatedContent { + Customer: import('chargebee').Customer; +} + +export interface HierarchyDeletedContent { + Customer: import('chargebee').Customer; +} + +export interface InvoiceDeletedContent { + Invoice: import('chargebee').Invoice; +} + +export interface InvoiceGeneratedContent { + Invoice: import('chargebee').Invoice; +} + +export interface InvoiceGeneratedWithBackdatingContent { + Invoice: import('chargebee').Invoice; +} + +export interface InvoiceUpdatedContent { + Invoice: import('chargebee').Invoice; +} + +export interface ItemCreatedContent { + Item: import('chargebee').Item; +} + +export interface ItemDeletedContent { + Item: import('chargebee').Item; +} + +export interface ItemEntitlementsRemovedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItem: import('chargebee').ImpactedItem; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface ItemEntitlementsUpdatedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItem: import('chargebee').ImpactedItem; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface ItemFamilyCreatedContent { + ItemFamily: import('chargebee').ItemFamily; +} + +export interface ItemFamilyDeletedContent { + ItemFamily: import('chargebee').ItemFamily; +} + +export interface ItemFamilyUpdatedContent { + ItemFamily: import('chargebee').ItemFamily; +} + +export interface ItemPriceCreatedContent { + ItemPrice: import('chargebee').ItemPrice; +} + +export interface ItemPriceDeletedContent { + ItemPrice: import('chargebee').ItemPrice; +} + +export interface ItemPriceEntitlementsRemovedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItemPrice: import('chargebee').ImpactedItemPrice; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface ItemPriceEntitlementsUpdatedContent { + Feature: import('chargebee').Feature; + + Metadata: import('chargebee').Metadata; + + ImpactedItemPrice: import('chargebee').ImpactedItemPrice; + + ImpactedSubscription: import('chargebee').ImpactedSubscription; +} + +export interface ItemPriceUpdatedContent { + ItemPrice: import('chargebee').ItemPrice; +} + +export interface ItemUpdatedContent { + Item: import('chargebee').Item; +} + +export interface MrrUpdatedContent { + Subscription: import('chargebee').Subscription; +} + +export interface NetdPaymentDueReminderContent { + Invoice: import('chargebee').Invoice; +} + +export interface OmnichannelOneTimeOrderCreatedContent { + OmnichannelOneTimeOrder: import('chargebee').OmnichannelOneTimeOrder; + + OmnichannelOneTimeOrderItem: import('chargebee').OmnichannelOneTimeOrderItem; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelOneTimeOrderItemCancelledContent { + OmnichannelOneTimeOrder: import('chargebee').OmnichannelOneTimeOrder; + + OmnichannelOneTimeOrderItem: import('chargebee').OmnichannelOneTimeOrderItem; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionCreatedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionImportedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemCancellationScheduledContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemCancelledContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemChangeScheduledContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemChangedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemDowngradeScheduledContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemDowngradedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemDunningExpiredContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemDunningStartedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemExpiredContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemGracePeriodExpiredContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemGracePeriodStartedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemPauseScheduledContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemPausedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemReactivatedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemRenewedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemResubscribedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemResumedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemScheduledCancellationRemovedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemScheduledChangeRemovedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemScheduledDowngradeRemovedContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionItemUpgradedContent { + OmnichannelSubscriptionItem: import('chargebee').OmnichannelSubscriptionItem; + + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; + + OmnichannelSubscriptionItemScheduledChange: import('chargebee').OmnichannelSubscriptionItemScheduledChange; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelSubscriptionMovedInContent { + OmnichannelSubscription: import('chargebee').OmnichannelSubscription; + + Customer: import('chargebee').Customer; +} + +export interface OmnichannelTransactionCreatedContent { + OmnichannelTransaction: import('chargebee').OmnichannelTransaction; +} + +export interface OrderCancelledContent { + Order: import('chargebee').Order; +} + +export interface OrderCreatedContent { + Order: import('chargebee').Order; +} + +export interface OrderDeletedContent { + Order: import('chargebee').Order; +} + +export interface OrderDeliveredContent { + Order: import('chargebee').Order; +} + +export interface OrderReadyToProcessContent { + Order: import('chargebee').Order; +} + +export interface OrderReadyToShipContent { + Order: import('chargebee').Order; +} + +export interface OrderResentContent { + Order: import('chargebee').Order; +} + +export interface OrderReturnedContent { + Order: import('chargebee').Order; +} + +export interface OrderUpdatedContent { + Order: import('chargebee').Order; +} + +export interface PaymentFailedContent { + Transaction: import('chargebee').Transaction; + + Invoice: import('chargebee').Invoice; + + Customer: import('chargebee').Customer; + + Subscription: import('chargebee').Subscription; + + Card: import('chargebee').Card; +} + +export interface PaymentInitiatedContent { + Transaction: import('chargebee').Transaction; + + Invoice: import('chargebee').Invoice; + + Customer: import('chargebee').Customer; + + Subscription: import('chargebee').Subscription; + + Card: import('chargebee').Card; +} + +export interface PaymentIntentCreatedContent { + PaymentIntent: import('chargebee').PaymentIntent; +} + +export interface PaymentIntentUpdatedContent { + PaymentIntent: import('chargebee').PaymentIntent; +} + +export interface PaymentRefundedContent { + Transaction: import('chargebee').Transaction; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + Customer: import('chargebee').Customer; + + Subscription: import('chargebee').Subscription; + + Card: import('chargebee').Card; +} + +export interface PaymentScheduleSchemeCreatedContent { + PaymentScheduleScheme: import('chargebee').PaymentScheduleScheme; +} + +export interface PaymentScheduleSchemeDeletedContent { + PaymentScheduleScheme: import('chargebee').PaymentScheduleScheme; +} + +export interface PaymentSchedulesCreatedContent { + PaymentSchedule: import('chargebee').PaymentSchedule; +} + +export interface PaymentSchedulesUpdatedContent { + PaymentSchedule: import('chargebee').PaymentSchedule; +} + +export interface PaymentSourceAddedContent { + Customer: import('chargebee').Customer; + + PaymentSource: import('chargebee').PaymentSource; +} + +export interface PaymentSourceDeletedContent { + Customer: import('chargebee').Customer; + + PaymentSource: import('chargebee').PaymentSource; +} + +export interface PaymentSourceExpiredContent { + Customer: import('chargebee').Customer; + + PaymentSource: import('chargebee').PaymentSource; +} + +export interface PaymentSourceExpiringContent { + Customer: import('chargebee').Customer; + + PaymentSource: import('chargebee').PaymentSource; +} + +export interface PaymentSourceLocallyDeletedContent { + Customer: import('chargebee').Customer; + + PaymentSource: import('chargebee').PaymentSource; +} + +export interface PaymentSourceUpdatedContent { + Customer: import('chargebee').Customer; + + PaymentSource: import('chargebee').PaymentSource; +} + +export interface PaymentSucceededContent { + Transaction: import('chargebee').Transaction; + + Invoice: import('chargebee').Invoice; + + Customer: import('chargebee').Customer; + + Subscription: import('chargebee').Subscription; + + Card: import('chargebee').Card; +} + +export interface PendingInvoiceCreatedContent { + Invoice: import('chargebee').Invoice; +} + +export interface PendingInvoiceUpdatedContent { + Invoice: import('chargebee').Invoice; +} + +export interface PlanCreatedContent { + Plan: import('chargebee').Plan; +} + +export interface PlanDeletedContent { + Plan: import('chargebee').Plan; +} + +export interface PlanUpdatedContent { + Plan: import('chargebee').Plan; +} + +export interface PriceVariantCreatedContent { + PriceVariant: import('chargebee').PriceVariant; + + Attribute: import('chargebee').Attribute; +} + +export interface PriceVariantDeletedContent { + PriceVariant: import('chargebee').PriceVariant; + + Attribute: import('chargebee').Attribute; +} + +export interface PriceVariantUpdatedContent { + PriceVariant: import('chargebee').PriceVariant; + + Attribute: import('chargebee').Attribute; +} + +export interface ProductCreatedContent { + Product: import('chargebee').Product; +} + +export interface ProductDeletedContent { + Product: import('chargebee').Product; +} + +export interface ProductUpdatedContent { + Product: import('chargebee').Product; +} + +export interface PromotionalCreditsAddedContent { + Customer: import('chargebee').Customer; + + PromotionalCredit: import('chargebee').PromotionalCredit; +} + +export interface PromotionalCreditsDeductedContent { + Customer: import('chargebee').Customer; + + PromotionalCredit: import('chargebee').PromotionalCredit; +} + +export interface PurchaseCreatedContent { + Purchase: import('chargebee').Purchase; +} + +export interface QuoteCreatedContent { + Quote: import('chargebee').Quote; +} + +export interface QuoteDeletedContent { + Quote: import('chargebee').Quote; +} + +export interface QuoteUpdatedContent { + Quote: import('chargebee').Quote; +} + +export interface RecordPurchaseFailedContent { + RecordedPurchase: import('chargebee').RecordedPurchase; + + Customer: import('chargebee').Customer; +} + +export interface RefundInitiatedContent { + Transaction: import('chargebee').Transaction; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + Customer: import('chargebee').Customer; + + Subscription: import('chargebee').Subscription; + + Card: import('chargebee').Card; +} + +export interface RuleCreatedContent { + Rule: import('chargebee').Rule; +} + +export interface RuleDeletedContent { + Rule: import('chargebee').Rule; +} + +export interface RuleUpdatedContent { + Rule: import('chargebee').Rule; +} + +export interface SalesOrderCreatedContent { + SalesOrder: import('chargebee').SalesOrder; +} + +export interface SalesOrderUpdatedContent { + SalesOrder: import('chargebee').SalesOrder; +} + +export interface SubscriptionActivatedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; +} + +export interface SubscriptionActivatedWithBackdatingContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionAdvanceInvoiceScheduleAddedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionAdvanceInvoiceScheduleRemovedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionAdvanceInvoiceScheduleUpdatedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionBusinessEntityChangedContent { + BusinessEntityChange: import('chargebee').BusinessEntityChange; + + BusinessEntityTransfer: import('chargebee').BusinessEntityTransfer; + + Subscription: import('chargebee').Subscription; +} + +export interface SubscriptionCanceledWithBackdatingContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionCancellationReminderContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionCancellationScheduledContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionCancelledContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionChangedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionChangedWithBackdatingContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionChangesScheduledContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionCreatedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionCreatedWithBackdatingContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionDeletedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionEntitlementsCreatedContent { + SubscriptionEntitlementsCreatedDetail: import('chargebee').SubscriptionEntitlementsCreatedDetail; +} + +export interface SubscriptionEntitlementsUpdatedContent { + SubscriptionEntitlementsUpdatedDetail: import('chargebee').SubscriptionEntitlementsUpdatedDetail; +} + +export interface SubscriptionItemsRenewedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionMovedInContent { + Subscription: import('chargebee').Subscription; +} + +export interface SubscriptionMovedOutContent { + Subscription: import('chargebee').Subscription; +} + +export interface SubscriptionMovementFailedContent { + Subscription: import('chargebee').Subscription; +} + +export interface SubscriptionPauseScheduledContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionPausedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionRampAppliedContent { + Ramp: import('chargebee').Ramp; +} + +export interface SubscriptionRampCreatedContent { + Ramp: import('chargebee').Ramp; +} + +export interface SubscriptionRampDeletedContent { + Ramp: import('chargebee').Ramp; +} + +export interface SubscriptionRampDraftedContent { + Ramp: import('chargebee').Ramp; +} + +export interface SubscriptionRampUpdatedContent { + Ramp: import('chargebee').Ramp; +} + +export interface SubscriptionReactivatedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionReactivatedWithBackdatingContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionRenewalReminderContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionRenewedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionResumedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; + + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface SubscriptionResumptionScheduledContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionScheduledCancellationRemovedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionScheduledChangesRemovedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionScheduledPauseRemovedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionScheduledResumptionRemovedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionShippingAddressUpdatedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionStartedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + Invoice: import('chargebee').Invoice; +} + +export interface SubscriptionTrialEndReminderContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface SubscriptionTrialExtendedContent { + Subscription: import('chargebee').Subscription; + + Customer: import('chargebee').Customer; + + Card: import('chargebee').Card; + + AdvanceInvoiceSchedule: import('chargebee').AdvanceInvoiceSchedule; +} + +export interface TaxWithheldDeletedContent { + TaxWithheld: import('chargebee').TaxWithheld; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; +} + +export interface TaxWithheldRecordedContent { + TaxWithheld: import('chargebee').TaxWithheld; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; +} + +export interface TaxWithheldRefundedContent { + TaxWithheld: import('chargebee').TaxWithheld; + + Invoice: import('chargebee').Invoice; + + CreditNote: import('chargebee').CreditNote; +} + +export interface TokenConsumedContent { + Token: import('chargebee').Token; +} + +export interface TokenCreatedContent { + Token: import('chargebee').Token; +} + +export interface TokenExpiredContent { + Token: import('chargebee').Token; +} + +export interface TransactionCreatedContent { + Transaction: import('chargebee').Transaction; +} + +export interface TransactionDeletedContent { + Transaction: import('chargebee').Transaction; +} + +export interface TransactionUpdatedContent { + Transaction: import('chargebee').Transaction; +} + +export interface UnbilledChargesCreatedContent { + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface UnbilledChargesDeletedContent { + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface UnbilledChargesInvoicedContent { + UnbilledCharge: import('chargebee').UnbilledCharge; + + Invoice: import('chargebee').Invoice; +} + +export interface UnbilledChargesVoidedContent { + UnbilledCharge: import('chargebee').UnbilledCharge; +} + +export interface UsageFileIngestedContent { + UsageFile: import('chargebee').UsageFile; +} + +export interface VariantCreatedContent { + Variant: import('chargebee').Variant; +} + +export interface VariantDeletedContent { + Variant: import('chargebee').Variant; +} + +export interface VariantUpdatedContent { + Variant: import('chargebee').Variant; +} + +export interface VirtualBankAccountAddedContent { + Customer: import('chargebee').Customer; + + VirtualBankAccount: import('chargebee').VirtualBankAccount; +} + +export interface VirtualBankAccountDeletedContent { + Customer: import('chargebee').Customer; + + VirtualBankAccount: import('chargebee').VirtualBankAccount; +} + +export interface VirtualBankAccountUpdatedContent { + Customer: import('chargebee').Customer; + + VirtualBankAccount: import('chargebee').VirtualBankAccount; +} + +export interface VoucherCreateFailedContent { + PaymentVoucher: import('chargebee').PaymentVoucher; +} + +export interface VoucherCreatedContent { + PaymentVoucher: import('chargebee').PaymentVoucher; +} + +export interface VoucherExpiredContent { + PaymentVoucher: import('chargebee').PaymentVoucher; +} + +export interface WebhookEvent { + id: string; + occurred_at: number; + source: string; + user?: string; + webhook_status: string; + webhook_failure_reason?: string; + webhooks?: any[]; + event_type: string; + api_version: string; + content: any; +} diff --git a/src/resources/webhook/event_types.ts b/src/resources/webhook/event_types.ts new file mode 100644 index 0000000..f574712 --- /dev/null +++ b/src/resources/webhook/event_types.ts @@ -0,0 +1,449 @@ +export enum EventType { + ADD_USAGES_REMINDER = 'add_usages_reminder', + + ADDON_CREATED = 'addon_created', + + ADDON_DELETED = 'addon_deleted', + + ADDON_UPDATED = 'addon_updated', + + ATTACHED_ITEM_CREATED = 'attached_item_created', + + ATTACHED_ITEM_DELETED = 'attached_item_deleted', + + ATTACHED_ITEM_UPDATED = 'attached_item_updated', + + AUTHORIZATION_SUCCEEDED = 'authorization_succeeded', + + AUTHORIZATION_VOIDED = 'authorization_voided', + + BUSINESS_ENTITY_CREATED = 'business_entity_created', + + BUSINESS_ENTITY_DELETED = 'business_entity_deleted', + + BUSINESS_ENTITY_UPDATED = 'business_entity_updated', + + CARD_ADDED = 'card_added', + + CARD_DELETED = 'card_deleted', + + CARD_EXPIRED = 'card_expired', + + CARD_EXPIRY_REMINDER = 'card_expiry_reminder', + + CARD_UPDATED = 'card_updated', + + CONTRACT_TERM_CANCELLED = 'contract_term_cancelled', + + CONTRACT_TERM_COMPLETED = 'contract_term_completed', + + CONTRACT_TERM_CREATED = 'contract_term_created', + + CONTRACT_TERM_RENEWED = 'contract_term_renewed', + + CONTRACT_TERM_TERMINATED = 'contract_term_terminated', + + COUPON_CODES_ADDED = 'coupon_codes_added', + + COUPON_CODES_DELETED = 'coupon_codes_deleted', + + COUPON_CODES_UPDATED = 'coupon_codes_updated', + + COUPON_CREATED = 'coupon_created', + + COUPON_DELETED = 'coupon_deleted', + + COUPON_SET_CREATED = 'coupon_set_created', + + COUPON_SET_DELETED = 'coupon_set_deleted', + + COUPON_SET_UPDATED = 'coupon_set_updated', + + COUPON_UPDATED = 'coupon_updated', + + CREDIT_NOTE_CREATED = 'credit_note_created', + + CREDIT_NOTE_CREATED_WITH_BACKDATING = 'credit_note_created_with_backdating', + + CREDIT_NOTE_DELETED = 'credit_note_deleted', + + CREDIT_NOTE_UPDATED = 'credit_note_updated', + + CUSTOMER_BUSINESS_ENTITY_CHANGED = 'customer_business_entity_changed', + + CUSTOMER_CHANGED = 'customer_changed', + + CUSTOMER_CREATED = 'customer_created', + + CUSTOMER_DELETED = 'customer_deleted', + + CUSTOMER_ENTITLEMENTS_UPDATED = 'customer_entitlements_updated', + + CUSTOMER_MOVED_IN = 'customer_moved_in', + + CUSTOMER_MOVED_OUT = 'customer_moved_out', + + DIFFERENTIAL_PRICE_CREATED = 'differential_price_created', + + DIFFERENTIAL_PRICE_DELETED = 'differential_price_deleted', + + DIFFERENTIAL_PRICE_UPDATED = 'differential_price_updated', + + DUNNING_UPDATED = 'dunning_updated', + + ENTITLEMENT_OVERRIDES_AUTO_REMOVED = 'entitlement_overrides_auto_removed', + + ENTITLEMENT_OVERRIDES_REMOVED = 'entitlement_overrides_removed', + + ENTITLEMENT_OVERRIDES_UPDATED = 'entitlement_overrides_updated', + + FEATURE_ACTIVATED = 'feature_activated', + + FEATURE_ARCHIVED = 'feature_archived', + + FEATURE_CREATED = 'feature_created', + + FEATURE_DELETED = 'feature_deleted', + + FEATURE_REACTIVATED = 'feature_reactivated', + + FEATURE_UPDATED = 'feature_updated', + + GIFT_CANCELLED = 'gift_cancelled', + + GIFT_CLAIMED = 'gift_claimed', + + GIFT_EXPIRED = 'gift_expired', + + GIFT_SCHEDULED = 'gift_scheduled', + + GIFT_UNCLAIMED = 'gift_unclaimed', + + GIFT_UPDATED = 'gift_updated', + + HIERARCHY_CREATED = 'hierarchy_created', + + HIERARCHY_DELETED = 'hierarchy_deleted', + + INVOICE_DELETED = 'invoice_deleted', + + INVOICE_GENERATED = 'invoice_generated', + + INVOICE_GENERATED_WITH_BACKDATING = 'invoice_generated_with_backdating', + + INVOICE_UPDATED = 'invoice_updated', + + ITEM_CREATED = 'item_created', + + ITEM_DELETED = 'item_deleted', + + ITEM_ENTITLEMENTS_REMOVED = 'item_entitlements_removed', + + ITEM_ENTITLEMENTS_UPDATED = 'item_entitlements_updated', + + ITEM_FAMILY_CREATED = 'item_family_created', + + ITEM_FAMILY_DELETED = 'item_family_deleted', + + ITEM_FAMILY_UPDATED = 'item_family_updated', + + ITEM_PRICE_CREATED = 'item_price_created', + + ITEM_PRICE_DELETED = 'item_price_deleted', + + ITEM_PRICE_ENTITLEMENTS_REMOVED = 'item_price_entitlements_removed', + + ITEM_PRICE_ENTITLEMENTS_UPDATED = 'item_price_entitlements_updated', + + ITEM_PRICE_UPDATED = 'item_price_updated', + + ITEM_UPDATED = 'item_updated', + + MRR_UPDATED = 'mrr_updated', + + NETD_PAYMENT_DUE_REMINDER = 'netd_payment_due_reminder', + + OMNICHANNEL_ONE_TIME_ORDER_CREATED = 'omnichannel_one_time_order_created', + + OMNICHANNEL_ONE_TIME_ORDER_ITEM_CANCELLED = 'omnichannel_one_time_order_item_cancelled', + + OMNICHANNEL_SUBSCRIPTION_CREATED = 'omnichannel_subscription_created', + + OMNICHANNEL_SUBSCRIPTION_IMPORTED = 'omnichannel_subscription_imported', + + OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLATION_SCHEDULED = 'omnichannel_subscription_item_cancellation_scheduled', + + OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLED = 'omnichannel_subscription_item_cancelled', + + OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGE_SCHEDULED = 'omnichannel_subscription_item_change_scheduled', + + OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGED = 'omnichannel_subscription_item_changed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADE_SCHEDULED = 'omnichannel_subscription_item_downgrade_scheduled', + + OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADED = 'omnichannel_subscription_item_downgraded', + + OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_EXPIRED = 'omnichannel_subscription_item_dunning_expired', + + OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_STARTED = 'omnichannel_subscription_item_dunning_started', + + OMNICHANNEL_SUBSCRIPTION_ITEM_EXPIRED = 'omnichannel_subscription_item_expired', + + OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_EXPIRED = 'omnichannel_subscription_item_grace_period_expired', + + OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_STARTED = 'omnichannel_subscription_item_grace_period_started', + + OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSE_SCHEDULED = 'omnichannel_subscription_item_pause_scheduled', + + OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSED = 'omnichannel_subscription_item_paused', + + OMNICHANNEL_SUBSCRIPTION_ITEM_REACTIVATED = 'omnichannel_subscription_item_reactivated', + + OMNICHANNEL_SUBSCRIPTION_ITEM_RENEWED = 'omnichannel_subscription_item_renewed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_RESUBSCRIBED = 'omnichannel_subscription_item_resubscribed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_RESUMED = 'omnichannel_subscription_item_resumed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CANCELLATION_REMOVED = 'omnichannel_subscription_item_scheduled_cancellation_removed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CHANGE_REMOVED = 'omnichannel_subscription_item_scheduled_change_removed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_DOWNGRADE_REMOVED = 'omnichannel_subscription_item_scheduled_downgrade_removed', + + OMNICHANNEL_SUBSCRIPTION_ITEM_UPGRADED = 'omnichannel_subscription_item_upgraded', + + OMNICHANNEL_SUBSCRIPTION_MOVED_IN = 'omnichannel_subscription_moved_in', + + OMNICHANNEL_TRANSACTION_CREATED = 'omnichannel_transaction_created', + + ORDER_CANCELLED = 'order_cancelled', + + ORDER_CREATED = 'order_created', + + ORDER_DELETED = 'order_deleted', + + ORDER_DELIVERED = 'order_delivered', + + ORDER_READY_TO_PROCESS = 'order_ready_to_process', + + ORDER_READY_TO_SHIP = 'order_ready_to_ship', + + ORDER_RESENT = 'order_resent', + + ORDER_RETURNED = 'order_returned', + + ORDER_UPDATED = 'order_updated', + + PAYMENT_FAILED = 'payment_failed', + + PAYMENT_INITIATED = 'payment_initiated', + + PAYMENT_INTENT_CREATED = 'payment_intent_created', + + PAYMENT_INTENT_UPDATED = 'payment_intent_updated', + + PAYMENT_REFUNDED = 'payment_refunded', + + PAYMENT_SCHEDULE_SCHEME_CREATED = 'payment_schedule_scheme_created', + + PAYMENT_SCHEDULE_SCHEME_DELETED = 'payment_schedule_scheme_deleted', + + PAYMENT_SCHEDULES_CREATED = 'payment_schedules_created', + + PAYMENT_SCHEDULES_UPDATED = 'payment_schedules_updated', + + PAYMENT_SOURCE_ADDED = 'payment_source_added', + + PAYMENT_SOURCE_DELETED = 'payment_source_deleted', + + PAYMENT_SOURCE_EXPIRED = 'payment_source_expired', + + PAYMENT_SOURCE_EXPIRING = 'payment_source_expiring', + + PAYMENT_SOURCE_LOCALLY_DELETED = 'payment_source_locally_deleted', + + PAYMENT_SOURCE_UPDATED = 'payment_source_updated', + + PAYMENT_SUCCEEDED = 'payment_succeeded', + + PENDING_INVOICE_CREATED = 'pending_invoice_created', + + PENDING_INVOICE_UPDATED = 'pending_invoice_updated', + + PLAN_CREATED = 'plan_created', + + PLAN_DELETED = 'plan_deleted', + + PLAN_UPDATED = 'plan_updated', + + PRICE_VARIANT_CREATED = 'price_variant_created', + + PRICE_VARIANT_DELETED = 'price_variant_deleted', + + PRICE_VARIANT_UPDATED = 'price_variant_updated', + + PRODUCT_CREATED = 'product_created', + + PRODUCT_DELETED = 'product_deleted', + + PRODUCT_UPDATED = 'product_updated', + + PROMOTIONAL_CREDITS_ADDED = 'promotional_credits_added', + + PROMOTIONAL_CREDITS_DEDUCTED = 'promotional_credits_deducted', + + PURCHASE_CREATED = 'purchase_created', + + QUOTE_CREATED = 'quote_created', + + QUOTE_DELETED = 'quote_deleted', + + QUOTE_UPDATED = 'quote_updated', + + RECORD_PURCHASE_FAILED = 'record_purchase_failed', + + REFUND_INITIATED = 'refund_initiated', + + RULE_CREATED = 'rule_created', + + RULE_DELETED = 'rule_deleted', + + RULE_UPDATED = 'rule_updated', + + SALES_ORDER_CREATED = 'sales_order_created', + + SALES_ORDER_UPDATED = 'sales_order_updated', + + SUBSCRIPTION_ACTIVATED = 'subscription_activated', + + SUBSCRIPTION_ACTIVATED_WITH_BACKDATING = 'subscription_activated_with_backdating', + + SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_ADDED = 'subscription_advance_invoice_schedule_added', + + SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_REMOVED = 'subscription_advance_invoice_schedule_removed', + + SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_UPDATED = 'subscription_advance_invoice_schedule_updated', + + SUBSCRIPTION_BUSINESS_ENTITY_CHANGED = 'subscription_business_entity_changed', + + SUBSCRIPTION_CANCELED_WITH_BACKDATING = 'subscription_canceled_with_backdating', + + SUBSCRIPTION_CANCELLATION_REMINDER = 'subscription_cancellation_reminder', + + SUBSCRIPTION_CANCELLATION_SCHEDULED = 'subscription_cancellation_scheduled', + + SUBSCRIPTION_CANCELLED = 'subscription_cancelled', + + SUBSCRIPTION_CHANGED = 'subscription_changed', + + SUBSCRIPTION_CHANGED_WITH_BACKDATING = 'subscription_changed_with_backdating', + + SUBSCRIPTION_CHANGES_SCHEDULED = 'subscription_changes_scheduled', + + SUBSCRIPTION_CREATED = 'subscription_created', + + SUBSCRIPTION_CREATED_WITH_BACKDATING = 'subscription_created_with_backdating', + + SUBSCRIPTION_DELETED = 'subscription_deleted', + + SUBSCRIPTION_ENTITLEMENTS_CREATED = 'subscription_entitlements_created', + + SUBSCRIPTION_ENTITLEMENTS_UPDATED = 'subscription_entitlements_updated', + + SUBSCRIPTION_ITEMS_RENEWED = 'subscription_items_renewed', + + SUBSCRIPTION_MOVED_IN = 'subscription_moved_in', + + SUBSCRIPTION_MOVED_OUT = 'subscription_moved_out', + + SUBSCRIPTION_MOVEMENT_FAILED = 'subscription_movement_failed', + + SUBSCRIPTION_PAUSE_SCHEDULED = 'subscription_pause_scheduled', + + SUBSCRIPTION_PAUSED = 'subscription_paused', + + SUBSCRIPTION_RAMP_APPLIED = 'subscription_ramp_applied', + + SUBSCRIPTION_RAMP_CREATED = 'subscription_ramp_created', + + SUBSCRIPTION_RAMP_DELETED = 'subscription_ramp_deleted', + + SUBSCRIPTION_RAMP_DRAFTED = 'subscription_ramp_drafted', + + SUBSCRIPTION_RAMP_UPDATED = 'subscription_ramp_updated', + + SUBSCRIPTION_REACTIVATED = 'subscription_reactivated', + + SUBSCRIPTION_REACTIVATED_WITH_BACKDATING = 'subscription_reactivated_with_backdating', + + SUBSCRIPTION_RENEWAL_REMINDER = 'subscription_renewal_reminder', + + SUBSCRIPTION_RENEWED = 'subscription_renewed', + + SUBSCRIPTION_RESUMED = 'subscription_resumed', + + SUBSCRIPTION_RESUMPTION_SCHEDULED = 'subscription_resumption_scheduled', + + SUBSCRIPTION_SCHEDULED_CANCELLATION_REMOVED = 'subscription_scheduled_cancellation_removed', + + SUBSCRIPTION_SCHEDULED_CHANGES_REMOVED = 'subscription_scheduled_changes_removed', + + SUBSCRIPTION_SCHEDULED_PAUSE_REMOVED = 'subscription_scheduled_pause_removed', + + SUBSCRIPTION_SCHEDULED_RESUMPTION_REMOVED = 'subscription_scheduled_resumption_removed', + + SUBSCRIPTION_SHIPPING_ADDRESS_UPDATED = 'subscription_shipping_address_updated', + + SUBSCRIPTION_STARTED = 'subscription_started', + + SUBSCRIPTION_TRIAL_END_REMINDER = 'subscription_trial_end_reminder', + + SUBSCRIPTION_TRIAL_EXTENDED = 'subscription_trial_extended', + + TAX_WITHHELD_DELETED = 'tax_withheld_deleted', + + TAX_WITHHELD_RECORDED = 'tax_withheld_recorded', + + TAX_WITHHELD_REFUNDED = 'tax_withheld_refunded', + + TOKEN_CONSUMED = 'token_consumed', + + TOKEN_CREATED = 'token_created', + + TOKEN_EXPIRED = 'token_expired', + + TRANSACTION_CREATED = 'transaction_created', + + TRANSACTION_DELETED = 'transaction_deleted', + + TRANSACTION_UPDATED = 'transaction_updated', + + UNBILLED_CHARGES_CREATED = 'unbilled_charges_created', + + UNBILLED_CHARGES_DELETED = 'unbilled_charges_deleted', + + UNBILLED_CHARGES_INVOICED = 'unbilled_charges_invoiced', + + UNBILLED_CHARGES_VOIDED = 'unbilled_charges_voided', + + USAGE_FILE_INGESTED = 'usage_file_ingested', + + VARIANT_CREATED = 'variant_created', + + VARIANT_DELETED = 'variant_deleted', + + VARIANT_UPDATED = 'variant_updated', + + VIRTUAL_BANK_ACCOUNT_ADDED = 'virtual_bank_account_added', + + VIRTUAL_BANK_ACCOUNT_DELETED = 'virtual_bank_account_deleted', + + VIRTUAL_BANK_ACCOUNT_UPDATED = 'virtual_bank_account_updated', + + VOUCHER_CREATE_FAILED = 'voucher_create_failed', + + VOUCHER_CREATED = 'voucher_created', + + VOUCHER_EXPIRED = 'voucher_expired', +} diff --git a/src/resources/webhook/handler.ts b/src/resources/webhook/handler.ts new file mode 100644 index 0000000..33f618a --- /dev/null +++ b/src/resources/webhook/handler.ts @@ -0,0 +1,6700 @@ +import { EventType } from './event_types.js'; +import { + AddUsagesReminderContent, + AddonCreatedContent, + AddonDeletedContent, + AddonUpdatedContent, + AttachedItemCreatedContent, + AttachedItemDeletedContent, + AttachedItemUpdatedContent, + AuthorizationSucceededContent, + AuthorizationVoidedContent, + BusinessEntityCreatedContent, + BusinessEntityDeletedContent, + BusinessEntityUpdatedContent, + CardAddedContent, + CardDeletedContent, + CardExpiredContent, + CardExpiryReminderContent, + CardUpdatedContent, + ContractTermCancelledContent, + ContractTermCompletedContent, + ContractTermCreatedContent, + ContractTermRenewedContent, + ContractTermTerminatedContent, + CouponCodesAddedContent, + CouponCodesDeletedContent, + CouponCodesUpdatedContent, + CouponCreatedContent, + CouponDeletedContent, + CouponSetCreatedContent, + CouponSetDeletedContent, + CouponSetUpdatedContent, + CouponUpdatedContent, + CreditNoteCreatedContent, + CreditNoteCreatedWithBackdatingContent, + CreditNoteDeletedContent, + CreditNoteUpdatedContent, + CustomerBusinessEntityChangedContent, + CustomerChangedContent, + CustomerCreatedContent, + CustomerDeletedContent, + CustomerEntitlementsUpdatedContent, + CustomerMovedInContent, + CustomerMovedOutContent, + DifferentialPriceCreatedContent, + DifferentialPriceDeletedContent, + DifferentialPriceUpdatedContent, + DunningUpdatedContent, + EntitlementOverridesAutoRemovedContent, + EntitlementOverridesRemovedContent, + EntitlementOverridesUpdatedContent, + FeatureActivatedContent, + FeatureArchivedContent, + FeatureCreatedContent, + FeatureDeletedContent, + FeatureReactivatedContent, + FeatureUpdatedContent, + GiftCancelledContent, + GiftClaimedContent, + GiftExpiredContent, + GiftScheduledContent, + GiftUnclaimedContent, + GiftUpdatedContent, + HierarchyCreatedContent, + HierarchyDeletedContent, + InvoiceDeletedContent, + InvoiceGeneratedContent, + InvoiceGeneratedWithBackdatingContent, + InvoiceUpdatedContent, + ItemCreatedContent, + ItemDeletedContent, + ItemEntitlementsRemovedContent, + ItemEntitlementsUpdatedContent, + ItemFamilyCreatedContent, + ItemFamilyDeletedContent, + ItemFamilyUpdatedContent, + ItemPriceCreatedContent, + ItemPriceDeletedContent, + ItemPriceEntitlementsRemovedContent, + ItemPriceEntitlementsUpdatedContent, + ItemPriceUpdatedContent, + ItemUpdatedContent, + MrrUpdatedContent, + NetdPaymentDueReminderContent, + OmnichannelOneTimeOrderCreatedContent, + OmnichannelOneTimeOrderItemCancelledContent, + OmnichannelSubscriptionCreatedContent, + OmnichannelSubscriptionImportedContent, + OmnichannelSubscriptionItemCancellationScheduledContent, + OmnichannelSubscriptionItemCancelledContent, + OmnichannelSubscriptionItemChangeScheduledContent, + OmnichannelSubscriptionItemChangedContent, + OmnichannelSubscriptionItemDowngradeScheduledContent, + OmnichannelSubscriptionItemDowngradedContent, + OmnichannelSubscriptionItemDunningExpiredContent, + OmnichannelSubscriptionItemDunningStartedContent, + OmnichannelSubscriptionItemExpiredContent, + OmnichannelSubscriptionItemGracePeriodExpiredContent, + OmnichannelSubscriptionItemGracePeriodStartedContent, + OmnichannelSubscriptionItemPauseScheduledContent, + OmnichannelSubscriptionItemPausedContent, + OmnichannelSubscriptionItemReactivatedContent, + OmnichannelSubscriptionItemRenewedContent, + OmnichannelSubscriptionItemResubscribedContent, + OmnichannelSubscriptionItemResumedContent, + OmnichannelSubscriptionItemScheduledCancellationRemovedContent, + OmnichannelSubscriptionItemScheduledChangeRemovedContent, + OmnichannelSubscriptionItemScheduledDowngradeRemovedContent, + OmnichannelSubscriptionItemUpgradedContent, + OmnichannelSubscriptionMovedInContent, + OmnichannelTransactionCreatedContent, + OrderCancelledContent, + OrderCreatedContent, + OrderDeletedContent, + OrderDeliveredContent, + OrderReadyToProcessContent, + OrderReadyToShipContent, + OrderResentContent, + OrderReturnedContent, + OrderUpdatedContent, + PaymentFailedContent, + PaymentInitiatedContent, + PaymentIntentCreatedContent, + PaymentIntentUpdatedContent, + PaymentRefundedContent, + PaymentScheduleSchemeCreatedContent, + PaymentScheduleSchemeDeletedContent, + PaymentSchedulesCreatedContent, + PaymentSchedulesUpdatedContent, + PaymentSourceAddedContent, + PaymentSourceDeletedContent, + PaymentSourceExpiredContent, + PaymentSourceExpiringContent, + PaymentSourceLocallyDeletedContent, + PaymentSourceUpdatedContent, + PaymentSucceededContent, + PendingInvoiceCreatedContent, + PendingInvoiceUpdatedContent, + PlanCreatedContent, + PlanDeletedContent, + PlanUpdatedContent, + PriceVariantCreatedContent, + PriceVariantDeletedContent, + PriceVariantUpdatedContent, + ProductCreatedContent, + ProductDeletedContent, + ProductUpdatedContent, + PromotionalCreditsAddedContent, + PromotionalCreditsDeductedContent, + PurchaseCreatedContent, + QuoteCreatedContent, + QuoteDeletedContent, + QuoteUpdatedContent, + RecordPurchaseFailedContent, + RefundInitiatedContent, + RuleCreatedContent, + RuleDeletedContent, + RuleUpdatedContent, + SalesOrderCreatedContent, + SalesOrderUpdatedContent, + SubscriptionActivatedContent, + SubscriptionActivatedWithBackdatingContent, + SubscriptionAdvanceInvoiceScheduleAddedContent, + SubscriptionAdvanceInvoiceScheduleRemovedContent, + SubscriptionAdvanceInvoiceScheduleUpdatedContent, + SubscriptionBusinessEntityChangedContent, + SubscriptionCanceledWithBackdatingContent, + SubscriptionCancellationReminderContent, + SubscriptionCancellationScheduledContent, + SubscriptionCancelledContent, + SubscriptionChangedContent, + SubscriptionChangedWithBackdatingContent, + SubscriptionChangesScheduledContent, + SubscriptionCreatedContent, + SubscriptionCreatedWithBackdatingContent, + SubscriptionDeletedContent, + SubscriptionEntitlementsCreatedContent, + SubscriptionEntitlementsUpdatedContent, + SubscriptionItemsRenewedContent, + SubscriptionMovedInContent, + SubscriptionMovedOutContent, + SubscriptionMovementFailedContent, + SubscriptionPauseScheduledContent, + SubscriptionPausedContent, + SubscriptionRampAppliedContent, + SubscriptionRampCreatedContent, + SubscriptionRampDeletedContent, + SubscriptionRampDraftedContent, + SubscriptionRampUpdatedContent, + SubscriptionReactivatedContent, + SubscriptionReactivatedWithBackdatingContent, + SubscriptionRenewalReminderContent, + SubscriptionRenewedContent, + SubscriptionResumedContent, + SubscriptionResumptionScheduledContent, + SubscriptionScheduledCancellationRemovedContent, + SubscriptionScheduledChangesRemovedContent, + SubscriptionScheduledPauseRemovedContent, + SubscriptionScheduledResumptionRemovedContent, + SubscriptionShippingAddressUpdatedContent, + SubscriptionStartedContent, + SubscriptionTrialEndReminderContent, + SubscriptionTrialExtendedContent, + TaxWithheldDeletedContent, + TaxWithheldRecordedContent, + TaxWithheldRefundedContent, + TokenConsumedContent, + TokenCreatedContent, + TokenExpiredContent, + TransactionCreatedContent, + TransactionDeletedContent, + TransactionUpdatedContent, + UnbilledChargesCreatedContent, + UnbilledChargesDeletedContent, + UnbilledChargesInvoicedContent, + UnbilledChargesVoidedContent, + UsageFileIngestedContent, + VariantCreatedContent, + VariantDeletedContent, + VariantUpdatedContent, + VirtualBankAccountAddedContent, + VirtualBankAccountDeletedContent, + VirtualBankAccountUpdatedContent, + VoucherCreateFailedContent, + VoucherCreatedContent, + VoucherExpiredContent, + WebhookEvent, +} from './content.js'; + +export interface WebhookHandlers { + onAddUsagesReminder?: ( + event: WebhookEvent & { content: AddUsagesReminderContent }, + ) => Promise; + + onAddonCreated?: ( + event: WebhookEvent & { content: AddonCreatedContent }, + ) => Promise; + + onAddonDeleted?: ( + event: WebhookEvent & { content: AddonDeletedContent }, + ) => Promise; + + onAddonUpdated?: ( + event: WebhookEvent & { content: AddonUpdatedContent }, + ) => Promise; + + onAttachedItemCreated?: ( + event: WebhookEvent & { content: AttachedItemCreatedContent }, + ) => Promise; + + onAttachedItemDeleted?: ( + event: WebhookEvent & { content: AttachedItemDeletedContent }, + ) => Promise; + + onAttachedItemUpdated?: ( + event: WebhookEvent & { content: AttachedItemUpdatedContent }, + ) => Promise; + + onAuthorizationSucceeded?: ( + event: WebhookEvent & { content: AuthorizationSucceededContent }, + ) => Promise; + + onAuthorizationVoided?: ( + event: WebhookEvent & { content: AuthorizationVoidedContent }, + ) => Promise; + + onBusinessEntityCreated?: ( + event: WebhookEvent & { content: BusinessEntityCreatedContent }, + ) => Promise; + + onBusinessEntityDeleted?: ( + event: WebhookEvent & { content: BusinessEntityDeletedContent }, + ) => Promise; + + onBusinessEntityUpdated?: ( + event: WebhookEvent & { content: BusinessEntityUpdatedContent }, + ) => Promise; + + onCardAdded?: ( + event: WebhookEvent & { content: CardAddedContent }, + ) => Promise; + + onCardDeleted?: ( + event: WebhookEvent & { content: CardDeletedContent }, + ) => Promise; + + onCardExpired?: ( + event: WebhookEvent & { content: CardExpiredContent }, + ) => Promise; + + onCardExpiryReminder?: ( + event: WebhookEvent & { content: CardExpiryReminderContent }, + ) => Promise; + + onCardUpdated?: ( + event: WebhookEvent & { content: CardUpdatedContent }, + ) => Promise; + + onContractTermCancelled?: ( + event: WebhookEvent & { content: ContractTermCancelledContent }, + ) => Promise; + + onContractTermCompleted?: ( + event: WebhookEvent & { content: ContractTermCompletedContent }, + ) => Promise; + + onContractTermCreated?: ( + event: WebhookEvent & { content: ContractTermCreatedContent }, + ) => Promise; + + onContractTermRenewed?: ( + event: WebhookEvent & { content: ContractTermRenewedContent }, + ) => Promise; + + onContractTermTerminated?: ( + event: WebhookEvent & { content: ContractTermTerminatedContent }, + ) => Promise; + + onCouponCodesAdded?: ( + event: WebhookEvent & { content: CouponCodesAddedContent }, + ) => Promise; + + onCouponCodesDeleted?: ( + event: WebhookEvent & { content: CouponCodesDeletedContent }, + ) => Promise; + + onCouponCodesUpdated?: ( + event: WebhookEvent & { content: CouponCodesUpdatedContent }, + ) => Promise; + + onCouponCreated?: ( + event: WebhookEvent & { content: CouponCreatedContent }, + ) => Promise; + + onCouponDeleted?: ( + event: WebhookEvent & { content: CouponDeletedContent }, + ) => Promise; + + onCouponSetCreated?: ( + event: WebhookEvent & { content: CouponSetCreatedContent }, + ) => Promise; + + onCouponSetDeleted?: ( + event: WebhookEvent & { content: CouponSetDeletedContent }, + ) => Promise; + + onCouponSetUpdated?: ( + event: WebhookEvent & { content: CouponSetUpdatedContent }, + ) => Promise; + + onCouponUpdated?: ( + event: WebhookEvent & { content: CouponUpdatedContent }, + ) => Promise; + + onCreditNoteCreated?: ( + event: WebhookEvent & { content: CreditNoteCreatedContent }, + ) => Promise; + + onCreditNoteCreatedWithBackdating?: ( + event: WebhookEvent & { content: CreditNoteCreatedWithBackdatingContent }, + ) => Promise; + + onCreditNoteDeleted?: ( + event: WebhookEvent & { content: CreditNoteDeletedContent }, + ) => Promise; + + onCreditNoteUpdated?: ( + event: WebhookEvent & { content: CreditNoteUpdatedContent }, + ) => Promise; + + onCustomerBusinessEntityChanged?: ( + event: WebhookEvent & { content: CustomerBusinessEntityChangedContent }, + ) => Promise; + + onCustomerChanged?: ( + event: WebhookEvent & { content: CustomerChangedContent }, + ) => Promise; + + onCustomerCreated?: ( + event: WebhookEvent & { content: CustomerCreatedContent }, + ) => Promise; + + onCustomerDeleted?: ( + event: WebhookEvent & { content: CustomerDeletedContent }, + ) => Promise; + + onCustomerEntitlementsUpdated?: ( + event: WebhookEvent & { content: CustomerEntitlementsUpdatedContent }, + ) => Promise; + + onCustomerMovedIn?: ( + event: WebhookEvent & { content: CustomerMovedInContent }, + ) => Promise; + + onCustomerMovedOut?: ( + event: WebhookEvent & { content: CustomerMovedOutContent }, + ) => Promise; + + onDifferentialPriceCreated?: ( + event: WebhookEvent & { content: DifferentialPriceCreatedContent }, + ) => Promise; + + onDifferentialPriceDeleted?: ( + event: WebhookEvent & { content: DifferentialPriceDeletedContent }, + ) => Promise; + + onDifferentialPriceUpdated?: ( + event: WebhookEvent & { content: DifferentialPriceUpdatedContent }, + ) => Promise; + + onDunningUpdated?: ( + event: WebhookEvent & { content: DunningUpdatedContent }, + ) => Promise; + + onEntitlementOverridesAutoRemoved?: ( + event: WebhookEvent & { content: EntitlementOverridesAutoRemovedContent }, + ) => Promise; + + onEntitlementOverridesRemoved?: ( + event: WebhookEvent & { content: EntitlementOverridesRemovedContent }, + ) => Promise; + + onEntitlementOverridesUpdated?: ( + event: WebhookEvent & { content: EntitlementOverridesUpdatedContent }, + ) => Promise; + + onFeatureActivated?: ( + event: WebhookEvent & { content: FeatureActivatedContent }, + ) => Promise; + + onFeatureArchived?: ( + event: WebhookEvent & { content: FeatureArchivedContent }, + ) => Promise; + + onFeatureCreated?: ( + event: WebhookEvent & { content: FeatureCreatedContent }, + ) => Promise; + + onFeatureDeleted?: ( + event: WebhookEvent & { content: FeatureDeletedContent }, + ) => Promise; + + onFeatureReactivated?: ( + event: WebhookEvent & { content: FeatureReactivatedContent }, + ) => Promise; + + onFeatureUpdated?: ( + event: WebhookEvent & { content: FeatureUpdatedContent }, + ) => Promise; + + onGiftCancelled?: ( + event: WebhookEvent & { content: GiftCancelledContent }, + ) => Promise; + + onGiftClaimed?: ( + event: WebhookEvent & { content: GiftClaimedContent }, + ) => Promise; + + onGiftExpired?: ( + event: WebhookEvent & { content: GiftExpiredContent }, + ) => Promise; + + onGiftScheduled?: ( + event: WebhookEvent & { content: GiftScheduledContent }, + ) => Promise; + + onGiftUnclaimed?: ( + event: WebhookEvent & { content: GiftUnclaimedContent }, + ) => Promise; + + onGiftUpdated?: ( + event: WebhookEvent & { content: GiftUpdatedContent }, + ) => Promise; + + onHierarchyCreated?: ( + event: WebhookEvent & { content: HierarchyCreatedContent }, + ) => Promise; + + onHierarchyDeleted?: ( + event: WebhookEvent & { content: HierarchyDeletedContent }, + ) => Promise; + + onInvoiceDeleted?: ( + event: WebhookEvent & { content: InvoiceDeletedContent }, + ) => Promise; + + onInvoiceGenerated?: ( + event: WebhookEvent & { content: InvoiceGeneratedContent }, + ) => Promise; + + onInvoiceGeneratedWithBackdating?: ( + event: WebhookEvent & { content: InvoiceGeneratedWithBackdatingContent }, + ) => Promise; + + onInvoiceUpdated?: ( + event: WebhookEvent & { content: InvoiceUpdatedContent }, + ) => Promise; + + onItemCreated?: ( + event: WebhookEvent & { content: ItemCreatedContent }, + ) => Promise; + + onItemDeleted?: ( + event: WebhookEvent & { content: ItemDeletedContent }, + ) => Promise; + + onItemEntitlementsRemoved?: ( + event: WebhookEvent & { content: ItemEntitlementsRemovedContent }, + ) => Promise; + + onItemEntitlementsUpdated?: ( + event: WebhookEvent & { content: ItemEntitlementsUpdatedContent }, + ) => Promise; + + onItemFamilyCreated?: ( + event: WebhookEvent & { content: ItemFamilyCreatedContent }, + ) => Promise; + + onItemFamilyDeleted?: ( + event: WebhookEvent & { content: ItemFamilyDeletedContent }, + ) => Promise; + + onItemFamilyUpdated?: ( + event: WebhookEvent & { content: ItemFamilyUpdatedContent }, + ) => Promise; + + onItemPriceCreated?: ( + event: WebhookEvent & { content: ItemPriceCreatedContent }, + ) => Promise; + + onItemPriceDeleted?: ( + event: WebhookEvent & { content: ItemPriceDeletedContent }, + ) => Promise; + + onItemPriceEntitlementsRemoved?: ( + event: WebhookEvent & { content: ItemPriceEntitlementsRemovedContent }, + ) => Promise; + + onItemPriceEntitlementsUpdated?: ( + event: WebhookEvent & { content: ItemPriceEntitlementsUpdatedContent }, + ) => Promise; + + onItemPriceUpdated?: ( + event: WebhookEvent & { content: ItemPriceUpdatedContent }, + ) => Promise; + + onItemUpdated?: ( + event: WebhookEvent & { content: ItemUpdatedContent }, + ) => Promise; + + onMrrUpdated?: ( + event: WebhookEvent & { content: MrrUpdatedContent }, + ) => Promise; + + onNetdPaymentDueReminder?: ( + event: WebhookEvent & { content: NetdPaymentDueReminderContent }, + ) => Promise; + + onOmnichannelOneTimeOrderCreated?: ( + event: WebhookEvent & { content: OmnichannelOneTimeOrderCreatedContent }, + ) => Promise; + + onOmnichannelOneTimeOrderItemCancelled?: ( + event: WebhookEvent & { + content: OmnichannelOneTimeOrderItemCancelledContent; + }, + ) => Promise; + + onOmnichannelSubscriptionCreated?: ( + event: WebhookEvent & { content: OmnichannelSubscriptionCreatedContent }, + ) => Promise; + + onOmnichannelSubscriptionImported?: ( + event: WebhookEvent & { content: OmnichannelSubscriptionImportedContent }, + ) => Promise; + + onOmnichannelSubscriptionItemCancellationScheduled?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemCancellationScheduledContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemCancelled?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemCancelledContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemChangeScheduled?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemChangeScheduledContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemChanged?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemChangedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemDowngradeScheduled?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDowngradeScheduledContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemDowngraded?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDowngradedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemDunningExpired?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDunningExpiredContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemDunningStarted?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDunningStartedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemExpired?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemExpiredContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemGracePeriodExpired?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemGracePeriodExpiredContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemGracePeriodStarted?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemGracePeriodStartedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemPauseScheduled?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemPauseScheduledContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemPaused?: ( + event: WebhookEvent & { content: OmnichannelSubscriptionItemPausedContent }, + ) => Promise; + + onOmnichannelSubscriptionItemReactivated?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemReactivatedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemRenewed?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemRenewedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemResubscribed?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemResubscribedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemResumed?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemResumedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemScheduledCancellationRemoved?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemScheduledChangeRemoved?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledChangeRemovedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemScheduledDowngradeRemoved?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledDowngradeRemovedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionItemUpgraded?: ( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemUpgradedContent; + }, + ) => Promise; + + onOmnichannelSubscriptionMovedIn?: ( + event: WebhookEvent & { content: OmnichannelSubscriptionMovedInContent }, + ) => Promise; + + onOmnichannelTransactionCreated?: ( + event: WebhookEvent & { content: OmnichannelTransactionCreatedContent }, + ) => Promise; + + onOrderCancelled?: ( + event: WebhookEvent & { content: OrderCancelledContent }, + ) => Promise; + + onOrderCreated?: ( + event: WebhookEvent & { content: OrderCreatedContent }, + ) => Promise; + + onOrderDeleted?: ( + event: WebhookEvent & { content: OrderDeletedContent }, + ) => Promise; + + onOrderDelivered?: ( + event: WebhookEvent & { content: OrderDeliveredContent }, + ) => Promise; + + onOrderReadyToProcess?: ( + event: WebhookEvent & { content: OrderReadyToProcessContent }, + ) => Promise; + + onOrderReadyToShip?: ( + event: WebhookEvent & { content: OrderReadyToShipContent }, + ) => Promise; + + onOrderResent?: ( + event: WebhookEvent & { content: OrderResentContent }, + ) => Promise; + + onOrderReturned?: ( + event: WebhookEvent & { content: OrderReturnedContent }, + ) => Promise; + + onOrderUpdated?: ( + event: WebhookEvent & { content: OrderUpdatedContent }, + ) => Promise; + + onPaymentFailed?: ( + event: WebhookEvent & { content: PaymentFailedContent }, + ) => Promise; + + onPaymentInitiated?: ( + event: WebhookEvent & { content: PaymentInitiatedContent }, + ) => Promise; + + onPaymentIntentCreated?: ( + event: WebhookEvent & { content: PaymentIntentCreatedContent }, + ) => Promise; + + onPaymentIntentUpdated?: ( + event: WebhookEvent & { content: PaymentIntentUpdatedContent }, + ) => Promise; + + onPaymentRefunded?: ( + event: WebhookEvent & { content: PaymentRefundedContent }, + ) => Promise; + + onPaymentScheduleSchemeCreated?: ( + event: WebhookEvent & { content: PaymentScheduleSchemeCreatedContent }, + ) => Promise; + + onPaymentScheduleSchemeDeleted?: ( + event: WebhookEvent & { content: PaymentScheduleSchemeDeletedContent }, + ) => Promise; + + onPaymentSchedulesCreated?: ( + event: WebhookEvent & { content: PaymentSchedulesCreatedContent }, + ) => Promise; + + onPaymentSchedulesUpdated?: ( + event: WebhookEvent & { content: PaymentSchedulesUpdatedContent }, + ) => Promise; + + onPaymentSourceAdded?: ( + event: WebhookEvent & { content: PaymentSourceAddedContent }, + ) => Promise; + + onPaymentSourceDeleted?: ( + event: WebhookEvent & { content: PaymentSourceDeletedContent }, + ) => Promise; + + onPaymentSourceExpired?: ( + event: WebhookEvent & { content: PaymentSourceExpiredContent }, + ) => Promise; + + onPaymentSourceExpiring?: ( + event: WebhookEvent & { content: PaymentSourceExpiringContent }, + ) => Promise; + + onPaymentSourceLocallyDeleted?: ( + event: WebhookEvent & { content: PaymentSourceLocallyDeletedContent }, + ) => Promise; + + onPaymentSourceUpdated?: ( + event: WebhookEvent & { content: PaymentSourceUpdatedContent }, + ) => Promise; + + onPaymentSucceeded?: ( + event: WebhookEvent & { content: PaymentSucceededContent }, + ) => Promise; + + onPendingInvoiceCreated?: ( + event: WebhookEvent & { content: PendingInvoiceCreatedContent }, + ) => Promise; + + onPendingInvoiceUpdated?: ( + event: WebhookEvent & { content: PendingInvoiceUpdatedContent }, + ) => Promise; + + onPlanCreated?: ( + event: WebhookEvent & { content: PlanCreatedContent }, + ) => Promise; + + onPlanDeleted?: ( + event: WebhookEvent & { content: PlanDeletedContent }, + ) => Promise; + + onPlanUpdated?: ( + event: WebhookEvent & { content: PlanUpdatedContent }, + ) => Promise; + + onPriceVariantCreated?: ( + event: WebhookEvent & { content: PriceVariantCreatedContent }, + ) => Promise; + + onPriceVariantDeleted?: ( + event: WebhookEvent & { content: PriceVariantDeletedContent }, + ) => Promise; + + onPriceVariantUpdated?: ( + event: WebhookEvent & { content: PriceVariantUpdatedContent }, + ) => Promise; + + onProductCreated?: ( + event: WebhookEvent & { content: ProductCreatedContent }, + ) => Promise; + + onProductDeleted?: ( + event: WebhookEvent & { content: ProductDeletedContent }, + ) => Promise; + + onProductUpdated?: ( + event: WebhookEvent & { content: ProductUpdatedContent }, + ) => Promise; + + onPromotionalCreditsAdded?: ( + event: WebhookEvent & { content: PromotionalCreditsAddedContent }, + ) => Promise; + + onPromotionalCreditsDeducted?: ( + event: WebhookEvent & { content: PromotionalCreditsDeductedContent }, + ) => Promise; + + onPurchaseCreated?: ( + event: WebhookEvent & { content: PurchaseCreatedContent }, + ) => Promise; + + onQuoteCreated?: ( + event: WebhookEvent & { content: QuoteCreatedContent }, + ) => Promise; + + onQuoteDeleted?: ( + event: WebhookEvent & { content: QuoteDeletedContent }, + ) => Promise; + + onQuoteUpdated?: ( + event: WebhookEvent & { content: QuoteUpdatedContent }, + ) => Promise; + + onRecordPurchaseFailed?: ( + event: WebhookEvent & { content: RecordPurchaseFailedContent }, + ) => Promise; + + onRefundInitiated?: ( + event: WebhookEvent & { content: RefundInitiatedContent }, + ) => Promise; + + onRuleCreated?: ( + event: WebhookEvent & { content: RuleCreatedContent }, + ) => Promise; + + onRuleDeleted?: ( + event: WebhookEvent & { content: RuleDeletedContent }, + ) => Promise; + + onRuleUpdated?: ( + event: WebhookEvent & { content: RuleUpdatedContent }, + ) => Promise; + + onSalesOrderCreated?: ( + event: WebhookEvent & { content: SalesOrderCreatedContent }, + ) => Promise; + + onSalesOrderUpdated?: ( + event: WebhookEvent & { content: SalesOrderUpdatedContent }, + ) => Promise; + + onSubscriptionActivated?: ( + event: WebhookEvent & { content: SubscriptionActivatedContent }, + ) => Promise; + + onSubscriptionActivatedWithBackdating?: ( + event: WebhookEvent & { + content: SubscriptionActivatedWithBackdatingContent; + }, + ) => Promise; + + onSubscriptionAdvanceInvoiceScheduleAdded?: ( + event: WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleAddedContent; + }, + ) => Promise; + + onSubscriptionAdvanceInvoiceScheduleRemoved?: ( + event: WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleRemovedContent; + }, + ) => Promise; + + onSubscriptionAdvanceInvoiceScheduleUpdated?: ( + event: WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleUpdatedContent; + }, + ) => Promise; + + onSubscriptionBusinessEntityChanged?: ( + event: WebhookEvent & { content: SubscriptionBusinessEntityChangedContent }, + ) => Promise; + + onSubscriptionCanceledWithBackdating?: ( + event: WebhookEvent & { + content: SubscriptionCanceledWithBackdatingContent; + }, + ) => Promise; + + onSubscriptionCancellationReminder?: ( + event: WebhookEvent & { content: SubscriptionCancellationReminderContent }, + ) => Promise; + + onSubscriptionCancellationScheduled?: ( + event: WebhookEvent & { content: SubscriptionCancellationScheduledContent }, + ) => Promise; + + onSubscriptionCancelled?: ( + event: WebhookEvent & { content: SubscriptionCancelledContent }, + ) => Promise; + + onSubscriptionChanged?: ( + event: WebhookEvent & { content: SubscriptionChangedContent }, + ) => Promise; + + onSubscriptionChangedWithBackdating?: ( + event: WebhookEvent & { content: SubscriptionChangedWithBackdatingContent }, + ) => Promise; + + onSubscriptionChangesScheduled?: ( + event: WebhookEvent & { content: SubscriptionChangesScheduledContent }, + ) => Promise; + + onSubscriptionCreated?: ( + event: WebhookEvent & { content: SubscriptionCreatedContent }, + ) => Promise; + + onSubscriptionCreatedWithBackdating?: ( + event: WebhookEvent & { content: SubscriptionCreatedWithBackdatingContent }, + ) => Promise; + + onSubscriptionDeleted?: ( + event: WebhookEvent & { content: SubscriptionDeletedContent }, + ) => Promise; + + onSubscriptionEntitlementsCreated?: ( + event: WebhookEvent & { content: SubscriptionEntitlementsCreatedContent }, + ) => Promise; + + onSubscriptionEntitlementsUpdated?: ( + event: WebhookEvent & { content: SubscriptionEntitlementsUpdatedContent }, + ) => Promise; + + onSubscriptionItemsRenewed?: ( + event: WebhookEvent & { content: SubscriptionItemsRenewedContent }, + ) => Promise; + + onSubscriptionMovedIn?: ( + event: WebhookEvent & { content: SubscriptionMovedInContent }, + ) => Promise; + + onSubscriptionMovedOut?: ( + event: WebhookEvent & { content: SubscriptionMovedOutContent }, + ) => Promise; + + onSubscriptionMovementFailed?: ( + event: WebhookEvent & { content: SubscriptionMovementFailedContent }, + ) => Promise; + + onSubscriptionPauseScheduled?: ( + event: WebhookEvent & { content: SubscriptionPauseScheduledContent }, + ) => Promise; + + onSubscriptionPaused?: ( + event: WebhookEvent & { content: SubscriptionPausedContent }, + ) => Promise; + + onSubscriptionRampApplied?: ( + event: WebhookEvent & { content: SubscriptionRampAppliedContent }, + ) => Promise; + + onSubscriptionRampCreated?: ( + event: WebhookEvent & { content: SubscriptionRampCreatedContent }, + ) => Promise; + + onSubscriptionRampDeleted?: ( + event: WebhookEvent & { content: SubscriptionRampDeletedContent }, + ) => Promise; + + onSubscriptionRampDrafted?: ( + event: WebhookEvent & { content: SubscriptionRampDraftedContent }, + ) => Promise; + + onSubscriptionRampUpdated?: ( + event: WebhookEvent & { content: SubscriptionRampUpdatedContent }, + ) => Promise; + + onSubscriptionReactivated?: ( + event: WebhookEvent & { content: SubscriptionReactivatedContent }, + ) => Promise; + + onSubscriptionReactivatedWithBackdating?: ( + event: WebhookEvent & { + content: SubscriptionReactivatedWithBackdatingContent; + }, + ) => Promise; + + onSubscriptionRenewalReminder?: ( + event: WebhookEvent & { content: SubscriptionRenewalReminderContent }, + ) => Promise; + + onSubscriptionRenewed?: ( + event: WebhookEvent & { content: SubscriptionRenewedContent }, + ) => Promise; + + onSubscriptionResumed?: ( + event: WebhookEvent & { content: SubscriptionResumedContent }, + ) => Promise; + + onSubscriptionResumptionScheduled?: ( + event: WebhookEvent & { content: SubscriptionResumptionScheduledContent }, + ) => Promise; + + onSubscriptionScheduledCancellationRemoved?: ( + event: WebhookEvent & { + content: SubscriptionScheduledCancellationRemovedContent; + }, + ) => Promise; + + onSubscriptionScheduledChangesRemoved?: ( + event: WebhookEvent & { + content: SubscriptionScheduledChangesRemovedContent; + }, + ) => Promise; + + onSubscriptionScheduledPauseRemoved?: ( + event: WebhookEvent & { content: SubscriptionScheduledPauseRemovedContent }, + ) => Promise; + + onSubscriptionScheduledResumptionRemoved?: ( + event: WebhookEvent & { + content: SubscriptionScheduledResumptionRemovedContent; + }, + ) => Promise; + + onSubscriptionShippingAddressUpdated?: ( + event: WebhookEvent & { + content: SubscriptionShippingAddressUpdatedContent; + }, + ) => Promise; + + onSubscriptionStarted?: ( + event: WebhookEvent & { content: SubscriptionStartedContent }, + ) => Promise; + + onSubscriptionTrialEndReminder?: ( + event: WebhookEvent & { content: SubscriptionTrialEndReminderContent }, + ) => Promise; + + onSubscriptionTrialExtended?: ( + event: WebhookEvent & { content: SubscriptionTrialExtendedContent }, + ) => Promise; + + onTaxWithheldDeleted?: ( + event: WebhookEvent & { content: TaxWithheldDeletedContent }, + ) => Promise; + + onTaxWithheldRecorded?: ( + event: WebhookEvent & { content: TaxWithheldRecordedContent }, + ) => Promise; + + onTaxWithheldRefunded?: ( + event: WebhookEvent & { content: TaxWithheldRefundedContent }, + ) => Promise; + + onTokenConsumed?: ( + event: WebhookEvent & { content: TokenConsumedContent }, + ) => Promise; + + onTokenCreated?: ( + event: WebhookEvent & { content: TokenCreatedContent }, + ) => Promise; + + onTokenExpired?: ( + event: WebhookEvent & { content: TokenExpiredContent }, + ) => Promise; + + onTransactionCreated?: ( + event: WebhookEvent & { content: TransactionCreatedContent }, + ) => Promise; + + onTransactionDeleted?: ( + event: WebhookEvent & { content: TransactionDeletedContent }, + ) => Promise; + + onTransactionUpdated?: ( + event: WebhookEvent & { content: TransactionUpdatedContent }, + ) => Promise; + + onUnbilledChargesCreated?: ( + event: WebhookEvent & { content: UnbilledChargesCreatedContent }, + ) => Promise; + + onUnbilledChargesDeleted?: ( + event: WebhookEvent & { content: UnbilledChargesDeletedContent }, + ) => Promise; + + onUnbilledChargesInvoiced?: ( + event: WebhookEvent & { content: UnbilledChargesInvoicedContent }, + ) => Promise; + + onUnbilledChargesVoided?: ( + event: WebhookEvent & { content: UnbilledChargesVoidedContent }, + ) => Promise; + + onUsageFileIngested?: ( + event: WebhookEvent & { content: UsageFileIngestedContent }, + ) => Promise; + + onVariantCreated?: ( + event: WebhookEvent & { content: VariantCreatedContent }, + ) => Promise; + + onVariantDeleted?: ( + event: WebhookEvent & { content: VariantDeletedContent }, + ) => Promise; + + onVariantUpdated?: ( + event: WebhookEvent & { content: VariantUpdatedContent }, + ) => Promise; + + onVirtualBankAccountAdded?: ( + event: WebhookEvent & { content: VirtualBankAccountAddedContent }, + ) => Promise; + + onVirtualBankAccountDeleted?: ( + event: WebhookEvent & { content: VirtualBankAccountDeletedContent }, + ) => Promise; + + onVirtualBankAccountUpdated?: ( + event: WebhookEvent & { content: VirtualBankAccountUpdatedContent }, + ) => Promise; + + onVoucherCreateFailed?: ( + event: WebhookEvent & { content: VoucherCreateFailedContent }, + ) => Promise; + + onVoucherCreated?: ( + event: WebhookEvent & { content: VoucherCreatedContent }, + ) => Promise; + + onVoucherExpired?: ( + event: WebhookEvent & { content: VoucherExpiredContent }, + ) => Promise; +} + +export class WebhookHandler { + private _handlers: WebhookHandlers = {}; + + /** + * Optional callback for unhandled events. + */ + onUnhandledEvent?: (event: WebhookEvent) => Promise; + + /** + * Optional callback for errors during processing. + */ + onError?: (error: any) => void; + + /** + * Optional validator for request headers. + */ + requestValidator?: ( + headers: Record, + ) => void; + + constructor(handlers: WebhookHandlers = {}) { + this._handlers = handlers; + } + + set onAddUsagesReminder( + handler: + | (( + event: WebhookEvent & { content: AddUsagesReminderContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAddUsagesReminder = handler; + } + + get onAddUsagesReminder() { + return this._handlers.onAddUsagesReminder; + } + + set onAddonCreated( + handler: + | (( + event: WebhookEvent & { content: AddonCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAddonCreated = handler; + } + + get onAddonCreated() { + return this._handlers.onAddonCreated; + } + + set onAddonDeleted( + handler: + | (( + event: WebhookEvent & { content: AddonDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAddonDeleted = handler; + } + + get onAddonDeleted() { + return this._handlers.onAddonDeleted; + } + + set onAddonUpdated( + handler: + | (( + event: WebhookEvent & { content: AddonUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAddonUpdated = handler; + } + + get onAddonUpdated() { + return this._handlers.onAddonUpdated; + } + + set onAttachedItemCreated( + handler: + | (( + event: WebhookEvent & { content: AttachedItemCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAttachedItemCreated = handler; + } + + get onAttachedItemCreated() { + return this._handlers.onAttachedItemCreated; + } + + set onAttachedItemDeleted( + handler: + | (( + event: WebhookEvent & { content: AttachedItemDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAttachedItemDeleted = handler; + } + + get onAttachedItemDeleted() { + return this._handlers.onAttachedItemDeleted; + } + + set onAttachedItemUpdated( + handler: + | (( + event: WebhookEvent & { content: AttachedItemUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAttachedItemUpdated = handler; + } + + get onAttachedItemUpdated() { + return this._handlers.onAttachedItemUpdated; + } + + set onAuthorizationSucceeded( + handler: + | (( + event: WebhookEvent & { content: AuthorizationSucceededContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAuthorizationSucceeded = handler; + } + + get onAuthorizationSucceeded() { + return this._handlers.onAuthorizationSucceeded; + } + + set onAuthorizationVoided( + handler: + | (( + event: WebhookEvent & { content: AuthorizationVoidedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onAuthorizationVoided = handler; + } + + get onAuthorizationVoided() { + return this._handlers.onAuthorizationVoided; + } + + set onBusinessEntityCreated( + handler: + | (( + event: WebhookEvent & { content: BusinessEntityCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onBusinessEntityCreated = handler; + } + + get onBusinessEntityCreated() { + return this._handlers.onBusinessEntityCreated; + } + + set onBusinessEntityDeleted( + handler: + | (( + event: WebhookEvent & { content: BusinessEntityDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onBusinessEntityDeleted = handler; + } + + get onBusinessEntityDeleted() { + return this._handlers.onBusinessEntityDeleted; + } + + set onBusinessEntityUpdated( + handler: + | (( + event: WebhookEvent & { content: BusinessEntityUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onBusinessEntityUpdated = handler; + } + + get onBusinessEntityUpdated() { + return this._handlers.onBusinessEntityUpdated; + } + + set onCardAdded( + handler: + | ((event: WebhookEvent & { content: CardAddedContent }) => Promise) + | undefined, + ) { + this._handlers.onCardAdded = handler; + } + + get onCardAdded() { + return this._handlers.onCardAdded; + } + + set onCardDeleted( + handler: + | (( + event: WebhookEvent & { content: CardDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCardDeleted = handler; + } + + get onCardDeleted() { + return this._handlers.onCardDeleted; + } + + set onCardExpired( + handler: + | (( + event: WebhookEvent & { content: CardExpiredContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCardExpired = handler; + } + + get onCardExpired() { + return this._handlers.onCardExpired; + } + + set onCardExpiryReminder( + handler: + | (( + event: WebhookEvent & { content: CardExpiryReminderContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCardExpiryReminder = handler; + } + + get onCardExpiryReminder() { + return this._handlers.onCardExpiryReminder; + } + + set onCardUpdated( + handler: + | (( + event: WebhookEvent & { content: CardUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCardUpdated = handler; + } + + get onCardUpdated() { + return this._handlers.onCardUpdated; + } + + set onContractTermCancelled( + handler: + | (( + event: WebhookEvent & { content: ContractTermCancelledContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onContractTermCancelled = handler; + } + + get onContractTermCancelled() { + return this._handlers.onContractTermCancelled; + } + + set onContractTermCompleted( + handler: + | (( + event: WebhookEvent & { content: ContractTermCompletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onContractTermCompleted = handler; + } + + get onContractTermCompleted() { + return this._handlers.onContractTermCompleted; + } + + set onContractTermCreated( + handler: + | (( + event: WebhookEvent & { content: ContractTermCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onContractTermCreated = handler; + } + + get onContractTermCreated() { + return this._handlers.onContractTermCreated; + } + + set onContractTermRenewed( + handler: + | (( + event: WebhookEvent & { content: ContractTermRenewedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onContractTermRenewed = handler; + } + + get onContractTermRenewed() { + return this._handlers.onContractTermRenewed; + } + + set onContractTermTerminated( + handler: + | (( + event: WebhookEvent & { content: ContractTermTerminatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onContractTermTerminated = handler; + } + + get onContractTermTerminated() { + return this._handlers.onContractTermTerminated; + } + + set onCouponCodesAdded( + handler: + | (( + event: WebhookEvent & { content: CouponCodesAddedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponCodesAdded = handler; + } + + get onCouponCodesAdded() { + return this._handlers.onCouponCodesAdded; + } + + set onCouponCodesDeleted( + handler: + | (( + event: WebhookEvent & { content: CouponCodesDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponCodesDeleted = handler; + } + + get onCouponCodesDeleted() { + return this._handlers.onCouponCodesDeleted; + } + + set onCouponCodesUpdated( + handler: + | (( + event: WebhookEvent & { content: CouponCodesUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponCodesUpdated = handler; + } + + get onCouponCodesUpdated() { + return this._handlers.onCouponCodesUpdated; + } + + set onCouponCreated( + handler: + | (( + event: WebhookEvent & { content: CouponCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponCreated = handler; + } + + get onCouponCreated() { + return this._handlers.onCouponCreated; + } + + set onCouponDeleted( + handler: + | (( + event: WebhookEvent & { content: CouponDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponDeleted = handler; + } + + get onCouponDeleted() { + return this._handlers.onCouponDeleted; + } + + set onCouponSetCreated( + handler: + | (( + event: WebhookEvent & { content: CouponSetCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponSetCreated = handler; + } + + get onCouponSetCreated() { + return this._handlers.onCouponSetCreated; + } + + set onCouponSetDeleted( + handler: + | (( + event: WebhookEvent & { content: CouponSetDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponSetDeleted = handler; + } + + get onCouponSetDeleted() { + return this._handlers.onCouponSetDeleted; + } + + set onCouponSetUpdated( + handler: + | (( + event: WebhookEvent & { content: CouponSetUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponSetUpdated = handler; + } + + get onCouponSetUpdated() { + return this._handlers.onCouponSetUpdated; + } + + set onCouponUpdated( + handler: + | (( + event: WebhookEvent & { content: CouponUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCouponUpdated = handler; + } + + get onCouponUpdated() { + return this._handlers.onCouponUpdated; + } + + set onCreditNoteCreated( + handler: + | (( + event: WebhookEvent & { content: CreditNoteCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCreditNoteCreated = handler; + } + + get onCreditNoteCreated() { + return this._handlers.onCreditNoteCreated; + } + + set onCreditNoteCreatedWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: CreditNoteCreatedWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onCreditNoteCreatedWithBackdating = handler; + } + + get onCreditNoteCreatedWithBackdating() { + return this._handlers.onCreditNoteCreatedWithBackdating; + } + + set onCreditNoteDeleted( + handler: + | (( + event: WebhookEvent & { content: CreditNoteDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCreditNoteDeleted = handler; + } + + get onCreditNoteDeleted() { + return this._handlers.onCreditNoteDeleted; + } + + set onCreditNoteUpdated( + handler: + | (( + event: WebhookEvent & { content: CreditNoteUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCreditNoteUpdated = handler; + } + + get onCreditNoteUpdated() { + return this._handlers.onCreditNoteUpdated; + } + + set onCustomerBusinessEntityChanged( + handler: + | (( + event: WebhookEvent & { + content: CustomerBusinessEntityChangedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerBusinessEntityChanged = handler; + } + + get onCustomerBusinessEntityChanged() { + return this._handlers.onCustomerBusinessEntityChanged; + } + + set onCustomerChanged( + handler: + | (( + event: WebhookEvent & { content: CustomerChangedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerChanged = handler; + } + + get onCustomerChanged() { + return this._handlers.onCustomerChanged; + } + + set onCustomerCreated( + handler: + | (( + event: WebhookEvent & { content: CustomerCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerCreated = handler; + } + + get onCustomerCreated() { + return this._handlers.onCustomerCreated; + } + + set onCustomerDeleted( + handler: + | (( + event: WebhookEvent & { content: CustomerDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerDeleted = handler; + } + + get onCustomerDeleted() { + return this._handlers.onCustomerDeleted; + } + + set onCustomerEntitlementsUpdated( + handler: + | (( + event: WebhookEvent & { content: CustomerEntitlementsUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerEntitlementsUpdated = handler; + } + + get onCustomerEntitlementsUpdated() { + return this._handlers.onCustomerEntitlementsUpdated; + } + + set onCustomerMovedIn( + handler: + | (( + event: WebhookEvent & { content: CustomerMovedInContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerMovedIn = handler; + } + + get onCustomerMovedIn() { + return this._handlers.onCustomerMovedIn; + } + + set onCustomerMovedOut( + handler: + | (( + event: WebhookEvent & { content: CustomerMovedOutContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onCustomerMovedOut = handler; + } + + get onCustomerMovedOut() { + return this._handlers.onCustomerMovedOut; + } + + set onDifferentialPriceCreated( + handler: + | (( + event: WebhookEvent & { content: DifferentialPriceCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onDifferentialPriceCreated = handler; + } + + get onDifferentialPriceCreated() { + return this._handlers.onDifferentialPriceCreated; + } + + set onDifferentialPriceDeleted( + handler: + | (( + event: WebhookEvent & { content: DifferentialPriceDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onDifferentialPriceDeleted = handler; + } + + get onDifferentialPriceDeleted() { + return this._handlers.onDifferentialPriceDeleted; + } + + set onDifferentialPriceUpdated( + handler: + | (( + event: WebhookEvent & { content: DifferentialPriceUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onDifferentialPriceUpdated = handler; + } + + get onDifferentialPriceUpdated() { + return this._handlers.onDifferentialPriceUpdated; + } + + set onDunningUpdated( + handler: + | (( + event: WebhookEvent & { content: DunningUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onDunningUpdated = handler; + } + + get onDunningUpdated() { + return this._handlers.onDunningUpdated; + } + + set onEntitlementOverridesAutoRemoved( + handler: + | (( + event: WebhookEvent & { + content: EntitlementOverridesAutoRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onEntitlementOverridesAutoRemoved = handler; + } + + get onEntitlementOverridesAutoRemoved() { + return this._handlers.onEntitlementOverridesAutoRemoved; + } + + set onEntitlementOverridesRemoved( + handler: + | (( + event: WebhookEvent & { content: EntitlementOverridesRemovedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onEntitlementOverridesRemoved = handler; + } + + get onEntitlementOverridesRemoved() { + return this._handlers.onEntitlementOverridesRemoved; + } + + set onEntitlementOverridesUpdated( + handler: + | (( + event: WebhookEvent & { content: EntitlementOverridesUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onEntitlementOverridesUpdated = handler; + } + + get onEntitlementOverridesUpdated() { + return this._handlers.onEntitlementOverridesUpdated; + } + + set onFeatureActivated( + handler: + | (( + event: WebhookEvent & { content: FeatureActivatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onFeatureActivated = handler; + } + + get onFeatureActivated() { + return this._handlers.onFeatureActivated; + } + + set onFeatureArchived( + handler: + | (( + event: WebhookEvent & { content: FeatureArchivedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onFeatureArchived = handler; + } + + get onFeatureArchived() { + return this._handlers.onFeatureArchived; + } + + set onFeatureCreated( + handler: + | (( + event: WebhookEvent & { content: FeatureCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onFeatureCreated = handler; + } + + get onFeatureCreated() { + return this._handlers.onFeatureCreated; + } + + set onFeatureDeleted( + handler: + | (( + event: WebhookEvent & { content: FeatureDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onFeatureDeleted = handler; + } + + get onFeatureDeleted() { + return this._handlers.onFeatureDeleted; + } + + set onFeatureReactivated( + handler: + | (( + event: WebhookEvent & { content: FeatureReactivatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onFeatureReactivated = handler; + } + + get onFeatureReactivated() { + return this._handlers.onFeatureReactivated; + } + + set onFeatureUpdated( + handler: + | (( + event: WebhookEvent & { content: FeatureUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onFeatureUpdated = handler; + } + + get onFeatureUpdated() { + return this._handlers.onFeatureUpdated; + } + + set onGiftCancelled( + handler: + | (( + event: WebhookEvent & { content: GiftCancelledContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onGiftCancelled = handler; + } + + get onGiftCancelled() { + return this._handlers.onGiftCancelled; + } + + set onGiftClaimed( + handler: + | (( + event: WebhookEvent & { content: GiftClaimedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onGiftClaimed = handler; + } + + get onGiftClaimed() { + return this._handlers.onGiftClaimed; + } + + set onGiftExpired( + handler: + | (( + event: WebhookEvent & { content: GiftExpiredContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onGiftExpired = handler; + } + + get onGiftExpired() { + return this._handlers.onGiftExpired; + } + + set onGiftScheduled( + handler: + | (( + event: WebhookEvent & { content: GiftScheduledContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onGiftScheduled = handler; + } + + get onGiftScheduled() { + return this._handlers.onGiftScheduled; + } + + set onGiftUnclaimed( + handler: + | (( + event: WebhookEvent & { content: GiftUnclaimedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onGiftUnclaimed = handler; + } + + get onGiftUnclaimed() { + return this._handlers.onGiftUnclaimed; + } + + set onGiftUpdated( + handler: + | (( + event: WebhookEvent & { content: GiftUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onGiftUpdated = handler; + } + + get onGiftUpdated() { + return this._handlers.onGiftUpdated; + } + + set onHierarchyCreated( + handler: + | (( + event: WebhookEvent & { content: HierarchyCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onHierarchyCreated = handler; + } + + get onHierarchyCreated() { + return this._handlers.onHierarchyCreated; + } + + set onHierarchyDeleted( + handler: + | (( + event: WebhookEvent & { content: HierarchyDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onHierarchyDeleted = handler; + } + + get onHierarchyDeleted() { + return this._handlers.onHierarchyDeleted; + } + + set onInvoiceDeleted( + handler: + | (( + event: WebhookEvent & { content: InvoiceDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onInvoiceDeleted = handler; + } + + get onInvoiceDeleted() { + return this._handlers.onInvoiceDeleted; + } + + set onInvoiceGenerated( + handler: + | (( + event: WebhookEvent & { content: InvoiceGeneratedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onInvoiceGenerated = handler; + } + + get onInvoiceGenerated() { + return this._handlers.onInvoiceGenerated; + } + + set onInvoiceGeneratedWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: InvoiceGeneratedWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onInvoiceGeneratedWithBackdating = handler; + } + + get onInvoiceGeneratedWithBackdating() { + return this._handlers.onInvoiceGeneratedWithBackdating; + } + + set onInvoiceUpdated( + handler: + | (( + event: WebhookEvent & { content: InvoiceUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onInvoiceUpdated = handler; + } + + get onInvoiceUpdated() { + return this._handlers.onInvoiceUpdated; + } + + set onItemCreated( + handler: + | (( + event: WebhookEvent & { content: ItemCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemCreated = handler; + } + + get onItemCreated() { + return this._handlers.onItemCreated; + } + + set onItemDeleted( + handler: + | (( + event: WebhookEvent & { content: ItemDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemDeleted = handler; + } + + get onItemDeleted() { + return this._handlers.onItemDeleted; + } + + set onItemEntitlementsRemoved( + handler: + | (( + event: WebhookEvent & { content: ItemEntitlementsRemovedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemEntitlementsRemoved = handler; + } + + get onItemEntitlementsRemoved() { + return this._handlers.onItemEntitlementsRemoved; + } + + set onItemEntitlementsUpdated( + handler: + | (( + event: WebhookEvent & { content: ItemEntitlementsUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemEntitlementsUpdated = handler; + } + + get onItemEntitlementsUpdated() { + return this._handlers.onItemEntitlementsUpdated; + } + + set onItemFamilyCreated( + handler: + | (( + event: WebhookEvent & { content: ItemFamilyCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemFamilyCreated = handler; + } + + get onItemFamilyCreated() { + return this._handlers.onItemFamilyCreated; + } + + set onItemFamilyDeleted( + handler: + | (( + event: WebhookEvent & { content: ItemFamilyDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemFamilyDeleted = handler; + } + + get onItemFamilyDeleted() { + return this._handlers.onItemFamilyDeleted; + } + + set onItemFamilyUpdated( + handler: + | (( + event: WebhookEvent & { content: ItemFamilyUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemFamilyUpdated = handler; + } + + get onItemFamilyUpdated() { + return this._handlers.onItemFamilyUpdated; + } + + set onItemPriceCreated( + handler: + | (( + event: WebhookEvent & { content: ItemPriceCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemPriceCreated = handler; + } + + get onItemPriceCreated() { + return this._handlers.onItemPriceCreated; + } + + set onItemPriceDeleted( + handler: + | (( + event: WebhookEvent & { content: ItemPriceDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemPriceDeleted = handler; + } + + get onItemPriceDeleted() { + return this._handlers.onItemPriceDeleted; + } + + set onItemPriceEntitlementsRemoved( + handler: + | (( + event: WebhookEvent & { + content: ItemPriceEntitlementsRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemPriceEntitlementsRemoved = handler; + } + + get onItemPriceEntitlementsRemoved() { + return this._handlers.onItemPriceEntitlementsRemoved; + } + + set onItemPriceEntitlementsUpdated( + handler: + | (( + event: WebhookEvent & { + content: ItemPriceEntitlementsUpdatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemPriceEntitlementsUpdated = handler; + } + + get onItemPriceEntitlementsUpdated() { + return this._handlers.onItemPriceEntitlementsUpdated; + } + + set onItemPriceUpdated( + handler: + | (( + event: WebhookEvent & { content: ItemPriceUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemPriceUpdated = handler; + } + + get onItemPriceUpdated() { + return this._handlers.onItemPriceUpdated; + } + + set onItemUpdated( + handler: + | (( + event: WebhookEvent & { content: ItemUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onItemUpdated = handler; + } + + get onItemUpdated() { + return this._handlers.onItemUpdated; + } + + set onMrrUpdated( + handler: + | (( + event: WebhookEvent & { content: MrrUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onMrrUpdated = handler; + } + + get onMrrUpdated() { + return this._handlers.onMrrUpdated; + } + + set onNetdPaymentDueReminder( + handler: + | (( + event: WebhookEvent & { content: NetdPaymentDueReminderContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onNetdPaymentDueReminder = handler; + } + + get onNetdPaymentDueReminder() { + return this._handlers.onNetdPaymentDueReminder; + } + + set onOmnichannelOneTimeOrderCreated( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelOneTimeOrderCreatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelOneTimeOrderCreated = handler; + } + + get onOmnichannelOneTimeOrderCreated() { + return this._handlers.onOmnichannelOneTimeOrderCreated; + } + + set onOmnichannelOneTimeOrderItemCancelled( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelOneTimeOrderItemCancelledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelOneTimeOrderItemCancelled = handler; + } + + get onOmnichannelOneTimeOrderItemCancelled() { + return this._handlers.onOmnichannelOneTimeOrderItemCancelled; + } + + set onOmnichannelSubscriptionCreated( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionCreatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionCreated = handler; + } + + get onOmnichannelSubscriptionCreated() { + return this._handlers.onOmnichannelSubscriptionCreated; + } + + set onOmnichannelSubscriptionImported( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionImportedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionImported = handler; + } + + get onOmnichannelSubscriptionImported() { + return this._handlers.onOmnichannelSubscriptionImported; + } + + set onOmnichannelSubscriptionItemCancellationScheduled( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemCancellationScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemCancellationScheduled = handler; + } + + get onOmnichannelSubscriptionItemCancellationScheduled() { + return this._handlers.onOmnichannelSubscriptionItemCancellationScheduled; + } + + set onOmnichannelSubscriptionItemCancelled( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemCancelledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemCancelled = handler; + } + + get onOmnichannelSubscriptionItemCancelled() { + return this._handlers.onOmnichannelSubscriptionItemCancelled; + } + + set onOmnichannelSubscriptionItemChangeScheduled( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemChangeScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemChangeScheduled = handler; + } + + get onOmnichannelSubscriptionItemChangeScheduled() { + return this._handlers.onOmnichannelSubscriptionItemChangeScheduled; + } + + set onOmnichannelSubscriptionItemChanged( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemChangedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemChanged = handler; + } + + get onOmnichannelSubscriptionItemChanged() { + return this._handlers.onOmnichannelSubscriptionItemChanged; + } + + set onOmnichannelSubscriptionItemDowngradeScheduled( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDowngradeScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled = handler; + } + + get onOmnichannelSubscriptionItemDowngradeScheduled() { + return this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled; + } + + set onOmnichannelSubscriptionItemDowngraded( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDowngradedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemDowngraded = handler; + } + + get onOmnichannelSubscriptionItemDowngraded() { + return this._handlers.onOmnichannelSubscriptionItemDowngraded; + } + + set onOmnichannelSubscriptionItemDunningExpired( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDunningExpiredContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemDunningExpired = handler; + } + + get onOmnichannelSubscriptionItemDunningExpired() { + return this._handlers.onOmnichannelSubscriptionItemDunningExpired; + } + + set onOmnichannelSubscriptionItemDunningStarted( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemDunningStartedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemDunningStarted = handler; + } + + get onOmnichannelSubscriptionItemDunningStarted() { + return this._handlers.onOmnichannelSubscriptionItemDunningStarted; + } + + set onOmnichannelSubscriptionItemExpired( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemExpiredContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemExpired = handler; + } + + get onOmnichannelSubscriptionItemExpired() { + return this._handlers.onOmnichannelSubscriptionItemExpired; + } + + set onOmnichannelSubscriptionItemGracePeriodExpired( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemGracePeriodExpiredContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired = handler; + } + + get onOmnichannelSubscriptionItemGracePeriodExpired() { + return this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired; + } + + set onOmnichannelSubscriptionItemGracePeriodStarted( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemGracePeriodStartedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted = handler; + } + + get onOmnichannelSubscriptionItemGracePeriodStarted() { + return this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted; + } + + set onOmnichannelSubscriptionItemPauseScheduled( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemPauseScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemPauseScheduled = handler; + } + + get onOmnichannelSubscriptionItemPauseScheduled() { + return this._handlers.onOmnichannelSubscriptionItemPauseScheduled; + } + + set onOmnichannelSubscriptionItemPaused( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemPausedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemPaused = handler; + } + + get onOmnichannelSubscriptionItemPaused() { + return this._handlers.onOmnichannelSubscriptionItemPaused; + } + + set onOmnichannelSubscriptionItemReactivated( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemReactivatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemReactivated = handler; + } + + get onOmnichannelSubscriptionItemReactivated() { + return this._handlers.onOmnichannelSubscriptionItemReactivated; + } + + set onOmnichannelSubscriptionItemRenewed( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemRenewedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemRenewed = handler; + } + + get onOmnichannelSubscriptionItemRenewed() { + return this._handlers.onOmnichannelSubscriptionItemRenewed; + } + + set onOmnichannelSubscriptionItemResubscribed( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemResubscribedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemResubscribed = handler; + } + + get onOmnichannelSubscriptionItemResubscribed() { + return this._handlers.onOmnichannelSubscriptionItemResubscribed; + } + + set onOmnichannelSubscriptionItemResumed( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemResumedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemResumed = handler; + } + + get onOmnichannelSubscriptionItemResumed() { + return this._handlers.onOmnichannelSubscriptionItemResumed; + } + + set onOmnichannelSubscriptionItemScheduledCancellationRemoved( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemScheduledCancellationRemoved = + handler; + } + + get onOmnichannelSubscriptionItemScheduledCancellationRemoved() { + return this._handlers + .onOmnichannelSubscriptionItemScheduledCancellationRemoved; + } + + set onOmnichannelSubscriptionItemScheduledChangeRemoved( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledChangeRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved = + handler; + } + + get onOmnichannelSubscriptionItemScheduledChangeRemoved() { + return this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved; + } + + set onOmnichannelSubscriptionItemScheduledDowngradeRemoved( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledDowngradeRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemScheduledDowngradeRemoved = + handler; + } + + get onOmnichannelSubscriptionItemScheduledDowngradeRemoved() { + return this._handlers + .onOmnichannelSubscriptionItemScheduledDowngradeRemoved; + } + + set onOmnichannelSubscriptionItemUpgraded( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionItemUpgradedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionItemUpgraded = handler; + } + + get onOmnichannelSubscriptionItemUpgraded() { + return this._handlers.onOmnichannelSubscriptionItemUpgraded; + } + + set onOmnichannelSubscriptionMovedIn( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelSubscriptionMovedInContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelSubscriptionMovedIn = handler; + } + + get onOmnichannelSubscriptionMovedIn() { + return this._handlers.onOmnichannelSubscriptionMovedIn; + } + + set onOmnichannelTransactionCreated( + handler: + | (( + event: WebhookEvent & { + content: OmnichannelTransactionCreatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onOmnichannelTransactionCreated = handler; + } + + get onOmnichannelTransactionCreated() { + return this._handlers.onOmnichannelTransactionCreated; + } + + set onOrderCancelled( + handler: + | (( + event: WebhookEvent & { content: OrderCancelledContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderCancelled = handler; + } + + get onOrderCancelled() { + return this._handlers.onOrderCancelled; + } + + set onOrderCreated( + handler: + | (( + event: WebhookEvent & { content: OrderCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderCreated = handler; + } + + get onOrderCreated() { + return this._handlers.onOrderCreated; + } + + set onOrderDeleted( + handler: + | (( + event: WebhookEvent & { content: OrderDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderDeleted = handler; + } + + get onOrderDeleted() { + return this._handlers.onOrderDeleted; + } + + set onOrderDelivered( + handler: + | (( + event: WebhookEvent & { content: OrderDeliveredContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderDelivered = handler; + } + + get onOrderDelivered() { + return this._handlers.onOrderDelivered; + } + + set onOrderReadyToProcess( + handler: + | (( + event: WebhookEvent & { content: OrderReadyToProcessContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderReadyToProcess = handler; + } + + get onOrderReadyToProcess() { + return this._handlers.onOrderReadyToProcess; + } + + set onOrderReadyToShip( + handler: + | (( + event: WebhookEvent & { content: OrderReadyToShipContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderReadyToShip = handler; + } + + get onOrderReadyToShip() { + return this._handlers.onOrderReadyToShip; + } + + set onOrderResent( + handler: + | (( + event: WebhookEvent & { content: OrderResentContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderResent = handler; + } + + get onOrderResent() { + return this._handlers.onOrderResent; + } + + set onOrderReturned( + handler: + | (( + event: WebhookEvent & { content: OrderReturnedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderReturned = handler; + } + + get onOrderReturned() { + return this._handlers.onOrderReturned; + } + + set onOrderUpdated( + handler: + | (( + event: WebhookEvent & { content: OrderUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onOrderUpdated = handler; + } + + get onOrderUpdated() { + return this._handlers.onOrderUpdated; + } + + set onPaymentFailed( + handler: + | (( + event: WebhookEvent & { content: PaymentFailedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentFailed = handler; + } + + get onPaymentFailed() { + return this._handlers.onPaymentFailed; + } + + set onPaymentInitiated( + handler: + | (( + event: WebhookEvent & { content: PaymentInitiatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentInitiated = handler; + } + + get onPaymentInitiated() { + return this._handlers.onPaymentInitiated; + } + + set onPaymentIntentCreated( + handler: + | (( + event: WebhookEvent & { content: PaymentIntentCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentIntentCreated = handler; + } + + get onPaymentIntentCreated() { + return this._handlers.onPaymentIntentCreated; + } + + set onPaymentIntentUpdated( + handler: + | (( + event: WebhookEvent & { content: PaymentIntentUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentIntentUpdated = handler; + } + + get onPaymentIntentUpdated() { + return this._handlers.onPaymentIntentUpdated; + } + + set onPaymentRefunded( + handler: + | (( + event: WebhookEvent & { content: PaymentRefundedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentRefunded = handler; + } + + get onPaymentRefunded() { + return this._handlers.onPaymentRefunded; + } + + set onPaymentScheduleSchemeCreated( + handler: + | (( + event: WebhookEvent & { + content: PaymentScheduleSchemeCreatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentScheduleSchemeCreated = handler; + } + + get onPaymentScheduleSchemeCreated() { + return this._handlers.onPaymentScheduleSchemeCreated; + } + + set onPaymentScheduleSchemeDeleted( + handler: + | (( + event: WebhookEvent & { + content: PaymentScheduleSchemeDeletedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentScheduleSchemeDeleted = handler; + } + + get onPaymentScheduleSchemeDeleted() { + return this._handlers.onPaymentScheduleSchemeDeleted; + } + + set onPaymentSchedulesCreated( + handler: + | (( + event: WebhookEvent & { content: PaymentSchedulesCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSchedulesCreated = handler; + } + + get onPaymentSchedulesCreated() { + return this._handlers.onPaymentSchedulesCreated; + } + + set onPaymentSchedulesUpdated( + handler: + | (( + event: WebhookEvent & { content: PaymentSchedulesUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSchedulesUpdated = handler; + } + + get onPaymentSchedulesUpdated() { + return this._handlers.onPaymentSchedulesUpdated; + } + + set onPaymentSourceAdded( + handler: + | (( + event: WebhookEvent & { content: PaymentSourceAddedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSourceAdded = handler; + } + + get onPaymentSourceAdded() { + return this._handlers.onPaymentSourceAdded; + } + + set onPaymentSourceDeleted( + handler: + | (( + event: WebhookEvent & { content: PaymentSourceDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSourceDeleted = handler; + } + + get onPaymentSourceDeleted() { + return this._handlers.onPaymentSourceDeleted; + } + + set onPaymentSourceExpired( + handler: + | (( + event: WebhookEvent & { content: PaymentSourceExpiredContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSourceExpired = handler; + } + + get onPaymentSourceExpired() { + return this._handlers.onPaymentSourceExpired; + } + + set onPaymentSourceExpiring( + handler: + | (( + event: WebhookEvent & { content: PaymentSourceExpiringContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSourceExpiring = handler; + } + + get onPaymentSourceExpiring() { + return this._handlers.onPaymentSourceExpiring; + } + + set onPaymentSourceLocallyDeleted( + handler: + | (( + event: WebhookEvent & { content: PaymentSourceLocallyDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSourceLocallyDeleted = handler; + } + + get onPaymentSourceLocallyDeleted() { + return this._handlers.onPaymentSourceLocallyDeleted; + } + + set onPaymentSourceUpdated( + handler: + | (( + event: WebhookEvent & { content: PaymentSourceUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSourceUpdated = handler; + } + + get onPaymentSourceUpdated() { + return this._handlers.onPaymentSourceUpdated; + } + + set onPaymentSucceeded( + handler: + | (( + event: WebhookEvent & { content: PaymentSucceededContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPaymentSucceeded = handler; + } + + get onPaymentSucceeded() { + return this._handlers.onPaymentSucceeded; + } + + set onPendingInvoiceCreated( + handler: + | (( + event: WebhookEvent & { content: PendingInvoiceCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPendingInvoiceCreated = handler; + } + + get onPendingInvoiceCreated() { + return this._handlers.onPendingInvoiceCreated; + } + + set onPendingInvoiceUpdated( + handler: + | (( + event: WebhookEvent & { content: PendingInvoiceUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPendingInvoiceUpdated = handler; + } + + get onPendingInvoiceUpdated() { + return this._handlers.onPendingInvoiceUpdated; + } + + set onPlanCreated( + handler: + | (( + event: WebhookEvent & { content: PlanCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPlanCreated = handler; + } + + get onPlanCreated() { + return this._handlers.onPlanCreated; + } + + set onPlanDeleted( + handler: + | (( + event: WebhookEvent & { content: PlanDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPlanDeleted = handler; + } + + get onPlanDeleted() { + return this._handlers.onPlanDeleted; + } + + set onPlanUpdated( + handler: + | (( + event: WebhookEvent & { content: PlanUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPlanUpdated = handler; + } + + get onPlanUpdated() { + return this._handlers.onPlanUpdated; + } + + set onPriceVariantCreated( + handler: + | (( + event: WebhookEvent & { content: PriceVariantCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPriceVariantCreated = handler; + } + + get onPriceVariantCreated() { + return this._handlers.onPriceVariantCreated; + } + + set onPriceVariantDeleted( + handler: + | (( + event: WebhookEvent & { content: PriceVariantDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPriceVariantDeleted = handler; + } + + get onPriceVariantDeleted() { + return this._handlers.onPriceVariantDeleted; + } + + set onPriceVariantUpdated( + handler: + | (( + event: WebhookEvent & { content: PriceVariantUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPriceVariantUpdated = handler; + } + + get onPriceVariantUpdated() { + return this._handlers.onPriceVariantUpdated; + } + + set onProductCreated( + handler: + | (( + event: WebhookEvent & { content: ProductCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onProductCreated = handler; + } + + get onProductCreated() { + return this._handlers.onProductCreated; + } + + set onProductDeleted( + handler: + | (( + event: WebhookEvent & { content: ProductDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onProductDeleted = handler; + } + + get onProductDeleted() { + return this._handlers.onProductDeleted; + } + + set onProductUpdated( + handler: + | (( + event: WebhookEvent & { content: ProductUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onProductUpdated = handler; + } + + get onProductUpdated() { + return this._handlers.onProductUpdated; + } + + set onPromotionalCreditsAdded( + handler: + | (( + event: WebhookEvent & { content: PromotionalCreditsAddedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPromotionalCreditsAdded = handler; + } + + get onPromotionalCreditsAdded() { + return this._handlers.onPromotionalCreditsAdded; + } + + set onPromotionalCreditsDeducted( + handler: + | (( + event: WebhookEvent & { content: PromotionalCreditsDeductedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPromotionalCreditsDeducted = handler; + } + + get onPromotionalCreditsDeducted() { + return this._handlers.onPromotionalCreditsDeducted; + } + + set onPurchaseCreated( + handler: + | (( + event: WebhookEvent & { content: PurchaseCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onPurchaseCreated = handler; + } + + get onPurchaseCreated() { + return this._handlers.onPurchaseCreated; + } + + set onQuoteCreated( + handler: + | (( + event: WebhookEvent & { content: QuoteCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onQuoteCreated = handler; + } + + get onQuoteCreated() { + return this._handlers.onQuoteCreated; + } + + set onQuoteDeleted( + handler: + | (( + event: WebhookEvent & { content: QuoteDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onQuoteDeleted = handler; + } + + get onQuoteDeleted() { + return this._handlers.onQuoteDeleted; + } + + set onQuoteUpdated( + handler: + | (( + event: WebhookEvent & { content: QuoteUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onQuoteUpdated = handler; + } + + get onQuoteUpdated() { + return this._handlers.onQuoteUpdated; + } + + set onRecordPurchaseFailed( + handler: + | (( + event: WebhookEvent & { content: RecordPurchaseFailedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onRecordPurchaseFailed = handler; + } + + get onRecordPurchaseFailed() { + return this._handlers.onRecordPurchaseFailed; + } + + set onRefundInitiated( + handler: + | (( + event: WebhookEvent & { content: RefundInitiatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onRefundInitiated = handler; + } + + get onRefundInitiated() { + return this._handlers.onRefundInitiated; + } + + set onRuleCreated( + handler: + | (( + event: WebhookEvent & { content: RuleCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onRuleCreated = handler; + } + + get onRuleCreated() { + return this._handlers.onRuleCreated; + } + + set onRuleDeleted( + handler: + | (( + event: WebhookEvent & { content: RuleDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onRuleDeleted = handler; + } + + get onRuleDeleted() { + return this._handlers.onRuleDeleted; + } + + set onRuleUpdated( + handler: + | (( + event: WebhookEvent & { content: RuleUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onRuleUpdated = handler; + } + + get onRuleUpdated() { + return this._handlers.onRuleUpdated; + } + + set onSalesOrderCreated( + handler: + | (( + event: WebhookEvent & { content: SalesOrderCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSalesOrderCreated = handler; + } + + get onSalesOrderCreated() { + return this._handlers.onSalesOrderCreated; + } + + set onSalesOrderUpdated( + handler: + | (( + event: WebhookEvent & { content: SalesOrderUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSalesOrderUpdated = handler; + } + + get onSalesOrderUpdated() { + return this._handlers.onSalesOrderUpdated; + } + + set onSubscriptionActivated( + handler: + | (( + event: WebhookEvent & { content: SubscriptionActivatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionActivated = handler; + } + + get onSubscriptionActivated() { + return this._handlers.onSubscriptionActivated; + } + + set onSubscriptionActivatedWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionActivatedWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionActivatedWithBackdating = handler; + } + + get onSubscriptionActivatedWithBackdating() { + return this._handlers.onSubscriptionActivatedWithBackdating; + } + + set onSubscriptionAdvanceInvoiceScheduleAdded( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleAddedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded = handler; + } + + get onSubscriptionAdvanceInvoiceScheduleAdded() { + return this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded; + } + + set onSubscriptionAdvanceInvoiceScheduleRemoved( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved = handler; + } + + get onSubscriptionAdvanceInvoiceScheduleRemoved() { + return this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved; + } + + set onSubscriptionAdvanceInvoiceScheduleUpdated( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleUpdatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated = handler; + } + + get onSubscriptionAdvanceInvoiceScheduleUpdated() { + return this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated; + } + + set onSubscriptionBusinessEntityChanged( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionBusinessEntityChangedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionBusinessEntityChanged = handler; + } + + get onSubscriptionBusinessEntityChanged() { + return this._handlers.onSubscriptionBusinessEntityChanged; + } + + set onSubscriptionCanceledWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionCanceledWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionCanceledWithBackdating = handler; + } + + get onSubscriptionCanceledWithBackdating() { + return this._handlers.onSubscriptionCanceledWithBackdating; + } + + set onSubscriptionCancellationReminder( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionCancellationReminderContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionCancellationReminder = handler; + } + + get onSubscriptionCancellationReminder() { + return this._handlers.onSubscriptionCancellationReminder; + } + + set onSubscriptionCancellationScheduled( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionCancellationScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionCancellationScheduled = handler; + } + + get onSubscriptionCancellationScheduled() { + return this._handlers.onSubscriptionCancellationScheduled; + } + + set onSubscriptionCancelled( + handler: + | (( + event: WebhookEvent & { content: SubscriptionCancelledContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionCancelled = handler; + } + + get onSubscriptionCancelled() { + return this._handlers.onSubscriptionCancelled; + } + + set onSubscriptionChanged( + handler: + | (( + event: WebhookEvent & { content: SubscriptionChangedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionChanged = handler; + } + + get onSubscriptionChanged() { + return this._handlers.onSubscriptionChanged; + } + + set onSubscriptionChangedWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionChangedWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionChangedWithBackdating = handler; + } + + get onSubscriptionChangedWithBackdating() { + return this._handlers.onSubscriptionChangedWithBackdating; + } + + set onSubscriptionChangesScheduled( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionChangesScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionChangesScheduled = handler; + } + + get onSubscriptionChangesScheduled() { + return this._handlers.onSubscriptionChangesScheduled; + } + + set onSubscriptionCreated( + handler: + | (( + event: WebhookEvent & { content: SubscriptionCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionCreated = handler; + } + + get onSubscriptionCreated() { + return this._handlers.onSubscriptionCreated; + } + + set onSubscriptionCreatedWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionCreatedWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionCreatedWithBackdating = handler; + } + + get onSubscriptionCreatedWithBackdating() { + return this._handlers.onSubscriptionCreatedWithBackdating; + } + + set onSubscriptionDeleted( + handler: + | (( + event: WebhookEvent & { content: SubscriptionDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionDeleted = handler; + } + + get onSubscriptionDeleted() { + return this._handlers.onSubscriptionDeleted; + } + + set onSubscriptionEntitlementsCreated( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionEntitlementsCreatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionEntitlementsCreated = handler; + } + + get onSubscriptionEntitlementsCreated() { + return this._handlers.onSubscriptionEntitlementsCreated; + } + + set onSubscriptionEntitlementsUpdated( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionEntitlementsUpdatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionEntitlementsUpdated = handler; + } + + get onSubscriptionEntitlementsUpdated() { + return this._handlers.onSubscriptionEntitlementsUpdated; + } + + set onSubscriptionItemsRenewed( + handler: + | (( + event: WebhookEvent & { content: SubscriptionItemsRenewedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionItemsRenewed = handler; + } + + get onSubscriptionItemsRenewed() { + return this._handlers.onSubscriptionItemsRenewed; + } + + set onSubscriptionMovedIn( + handler: + | (( + event: WebhookEvent & { content: SubscriptionMovedInContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionMovedIn = handler; + } + + get onSubscriptionMovedIn() { + return this._handlers.onSubscriptionMovedIn; + } + + set onSubscriptionMovedOut( + handler: + | (( + event: WebhookEvent & { content: SubscriptionMovedOutContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionMovedOut = handler; + } + + get onSubscriptionMovedOut() { + return this._handlers.onSubscriptionMovedOut; + } + + set onSubscriptionMovementFailed( + handler: + | (( + event: WebhookEvent & { content: SubscriptionMovementFailedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionMovementFailed = handler; + } + + get onSubscriptionMovementFailed() { + return this._handlers.onSubscriptionMovementFailed; + } + + set onSubscriptionPauseScheduled( + handler: + | (( + event: WebhookEvent & { content: SubscriptionPauseScheduledContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionPauseScheduled = handler; + } + + get onSubscriptionPauseScheduled() { + return this._handlers.onSubscriptionPauseScheduled; + } + + set onSubscriptionPaused( + handler: + | (( + event: WebhookEvent & { content: SubscriptionPausedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionPaused = handler; + } + + get onSubscriptionPaused() { + return this._handlers.onSubscriptionPaused; + } + + set onSubscriptionRampApplied( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRampAppliedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRampApplied = handler; + } + + get onSubscriptionRampApplied() { + return this._handlers.onSubscriptionRampApplied; + } + + set onSubscriptionRampCreated( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRampCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRampCreated = handler; + } + + get onSubscriptionRampCreated() { + return this._handlers.onSubscriptionRampCreated; + } + + set onSubscriptionRampDeleted( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRampDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRampDeleted = handler; + } + + get onSubscriptionRampDeleted() { + return this._handlers.onSubscriptionRampDeleted; + } + + set onSubscriptionRampDrafted( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRampDraftedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRampDrafted = handler; + } + + get onSubscriptionRampDrafted() { + return this._handlers.onSubscriptionRampDrafted; + } + + set onSubscriptionRampUpdated( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRampUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRampUpdated = handler; + } + + get onSubscriptionRampUpdated() { + return this._handlers.onSubscriptionRampUpdated; + } + + set onSubscriptionReactivated( + handler: + | (( + event: WebhookEvent & { content: SubscriptionReactivatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionReactivated = handler; + } + + get onSubscriptionReactivated() { + return this._handlers.onSubscriptionReactivated; + } + + set onSubscriptionReactivatedWithBackdating( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionReactivatedWithBackdatingContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionReactivatedWithBackdating = handler; + } + + get onSubscriptionReactivatedWithBackdating() { + return this._handlers.onSubscriptionReactivatedWithBackdating; + } + + set onSubscriptionRenewalReminder( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRenewalReminderContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRenewalReminder = handler; + } + + get onSubscriptionRenewalReminder() { + return this._handlers.onSubscriptionRenewalReminder; + } + + set onSubscriptionRenewed( + handler: + | (( + event: WebhookEvent & { content: SubscriptionRenewedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionRenewed = handler; + } + + get onSubscriptionRenewed() { + return this._handlers.onSubscriptionRenewed; + } + + set onSubscriptionResumed( + handler: + | (( + event: WebhookEvent & { content: SubscriptionResumedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionResumed = handler; + } + + get onSubscriptionResumed() { + return this._handlers.onSubscriptionResumed; + } + + set onSubscriptionResumptionScheduled( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionResumptionScheduledContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionResumptionScheduled = handler; + } + + get onSubscriptionResumptionScheduled() { + return this._handlers.onSubscriptionResumptionScheduled; + } + + set onSubscriptionScheduledCancellationRemoved( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionScheduledCancellationRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionScheduledCancellationRemoved = handler; + } + + get onSubscriptionScheduledCancellationRemoved() { + return this._handlers.onSubscriptionScheduledCancellationRemoved; + } + + set onSubscriptionScheduledChangesRemoved( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionScheduledChangesRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionScheduledChangesRemoved = handler; + } + + get onSubscriptionScheduledChangesRemoved() { + return this._handlers.onSubscriptionScheduledChangesRemoved; + } + + set onSubscriptionScheduledPauseRemoved( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionScheduledPauseRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionScheduledPauseRemoved = handler; + } + + get onSubscriptionScheduledPauseRemoved() { + return this._handlers.onSubscriptionScheduledPauseRemoved; + } + + set onSubscriptionScheduledResumptionRemoved( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionScheduledResumptionRemovedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionScheduledResumptionRemoved = handler; + } + + get onSubscriptionScheduledResumptionRemoved() { + return this._handlers.onSubscriptionScheduledResumptionRemoved; + } + + set onSubscriptionShippingAddressUpdated( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionShippingAddressUpdatedContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionShippingAddressUpdated = handler; + } + + get onSubscriptionShippingAddressUpdated() { + return this._handlers.onSubscriptionShippingAddressUpdated; + } + + set onSubscriptionStarted( + handler: + | (( + event: WebhookEvent & { content: SubscriptionStartedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionStarted = handler; + } + + get onSubscriptionStarted() { + return this._handlers.onSubscriptionStarted; + } + + set onSubscriptionTrialEndReminder( + handler: + | (( + event: WebhookEvent & { + content: SubscriptionTrialEndReminderContent; + }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionTrialEndReminder = handler; + } + + get onSubscriptionTrialEndReminder() { + return this._handlers.onSubscriptionTrialEndReminder; + } + + set onSubscriptionTrialExtended( + handler: + | (( + event: WebhookEvent & { content: SubscriptionTrialExtendedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onSubscriptionTrialExtended = handler; + } + + get onSubscriptionTrialExtended() { + return this._handlers.onSubscriptionTrialExtended; + } + + set onTaxWithheldDeleted( + handler: + | (( + event: WebhookEvent & { content: TaxWithheldDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTaxWithheldDeleted = handler; + } + + get onTaxWithheldDeleted() { + return this._handlers.onTaxWithheldDeleted; + } + + set onTaxWithheldRecorded( + handler: + | (( + event: WebhookEvent & { content: TaxWithheldRecordedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTaxWithheldRecorded = handler; + } + + get onTaxWithheldRecorded() { + return this._handlers.onTaxWithheldRecorded; + } + + set onTaxWithheldRefunded( + handler: + | (( + event: WebhookEvent & { content: TaxWithheldRefundedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTaxWithheldRefunded = handler; + } + + get onTaxWithheldRefunded() { + return this._handlers.onTaxWithheldRefunded; + } + + set onTokenConsumed( + handler: + | (( + event: WebhookEvent & { content: TokenConsumedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTokenConsumed = handler; + } + + get onTokenConsumed() { + return this._handlers.onTokenConsumed; + } + + set onTokenCreated( + handler: + | (( + event: WebhookEvent & { content: TokenCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTokenCreated = handler; + } + + get onTokenCreated() { + return this._handlers.onTokenCreated; + } + + set onTokenExpired( + handler: + | (( + event: WebhookEvent & { content: TokenExpiredContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTokenExpired = handler; + } + + get onTokenExpired() { + return this._handlers.onTokenExpired; + } + + set onTransactionCreated( + handler: + | (( + event: WebhookEvent & { content: TransactionCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTransactionCreated = handler; + } + + get onTransactionCreated() { + return this._handlers.onTransactionCreated; + } + + set onTransactionDeleted( + handler: + | (( + event: WebhookEvent & { content: TransactionDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTransactionDeleted = handler; + } + + get onTransactionDeleted() { + return this._handlers.onTransactionDeleted; + } + + set onTransactionUpdated( + handler: + | (( + event: WebhookEvent & { content: TransactionUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onTransactionUpdated = handler; + } + + get onTransactionUpdated() { + return this._handlers.onTransactionUpdated; + } + + set onUnbilledChargesCreated( + handler: + | (( + event: WebhookEvent & { content: UnbilledChargesCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onUnbilledChargesCreated = handler; + } + + get onUnbilledChargesCreated() { + return this._handlers.onUnbilledChargesCreated; + } + + set onUnbilledChargesDeleted( + handler: + | (( + event: WebhookEvent & { content: UnbilledChargesDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onUnbilledChargesDeleted = handler; + } + + get onUnbilledChargesDeleted() { + return this._handlers.onUnbilledChargesDeleted; + } + + set onUnbilledChargesInvoiced( + handler: + | (( + event: WebhookEvent & { content: UnbilledChargesInvoicedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onUnbilledChargesInvoiced = handler; + } + + get onUnbilledChargesInvoiced() { + return this._handlers.onUnbilledChargesInvoiced; + } + + set onUnbilledChargesVoided( + handler: + | (( + event: WebhookEvent & { content: UnbilledChargesVoidedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onUnbilledChargesVoided = handler; + } + + get onUnbilledChargesVoided() { + return this._handlers.onUnbilledChargesVoided; + } + + set onUsageFileIngested( + handler: + | (( + event: WebhookEvent & { content: UsageFileIngestedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onUsageFileIngested = handler; + } + + get onUsageFileIngested() { + return this._handlers.onUsageFileIngested; + } + + set onVariantCreated( + handler: + | (( + event: WebhookEvent & { content: VariantCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVariantCreated = handler; + } + + get onVariantCreated() { + return this._handlers.onVariantCreated; + } + + set onVariantDeleted( + handler: + | (( + event: WebhookEvent & { content: VariantDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVariantDeleted = handler; + } + + get onVariantDeleted() { + return this._handlers.onVariantDeleted; + } + + set onVariantUpdated( + handler: + | (( + event: WebhookEvent & { content: VariantUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVariantUpdated = handler; + } + + get onVariantUpdated() { + return this._handlers.onVariantUpdated; + } + + set onVirtualBankAccountAdded( + handler: + | (( + event: WebhookEvent & { content: VirtualBankAccountAddedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVirtualBankAccountAdded = handler; + } + + get onVirtualBankAccountAdded() { + return this._handlers.onVirtualBankAccountAdded; + } + + set onVirtualBankAccountDeleted( + handler: + | (( + event: WebhookEvent & { content: VirtualBankAccountDeletedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVirtualBankAccountDeleted = handler; + } + + get onVirtualBankAccountDeleted() { + return this._handlers.onVirtualBankAccountDeleted; + } + + set onVirtualBankAccountUpdated( + handler: + | (( + event: WebhookEvent & { content: VirtualBankAccountUpdatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVirtualBankAccountUpdated = handler; + } + + get onVirtualBankAccountUpdated() { + return this._handlers.onVirtualBankAccountUpdated; + } + + set onVoucherCreateFailed( + handler: + | (( + event: WebhookEvent & { content: VoucherCreateFailedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVoucherCreateFailed = handler; + } + + get onVoucherCreateFailed() { + return this._handlers.onVoucherCreateFailed; + } + + set onVoucherCreated( + handler: + | (( + event: WebhookEvent & { content: VoucherCreatedContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVoucherCreated = handler; + } + + get onVoucherCreated() { + return this._handlers.onVoucherCreated; + } + + set onVoucherExpired( + handler: + | (( + event: WebhookEvent & { content: VoucherExpiredContent }, + ) => Promise) + | undefined, + ) { + this._handlers.onVoucherExpired = handler; + } + + get onVoucherExpired() { + return this._handlers.onVoucherExpired; + } + + async handle( + body: string | object, + headers?: Record, + ): Promise { + try { + if (this.requestValidator && headers) { + this.requestValidator(headers); + } + + let event: WebhookEvent; + if (typeof body === 'string') { + event = JSON.parse(body); + } else { + event = body as WebhookEvent; + } + + const eventType = event.event_type; + + switch (eventType) { + case EventType.ADD_USAGES_REMINDER: + if (this._handlers.onAddUsagesReminder) { + await this._handlers.onAddUsagesReminder( + event as WebhookEvent & { content: AddUsagesReminderContent }, + ); + return; + } + break; + + case EventType.ADDON_CREATED: + if (this._handlers.onAddonCreated) { + await this._handlers.onAddonCreated( + event as WebhookEvent & { content: AddonCreatedContent }, + ); + return; + } + break; + + case EventType.ADDON_DELETED: + if (this._handlers.onAddonDeleted) { + await this._handlers.onAddonDeleted( + event as WebhookEvent & { content: AddonDeletedContent }, + ); + return; + } + break; + + case EventType.ADDON_UPDATED: + if (this._handlers.onAddonUpdated) { + await this._handlers.onAddonUpdated( + event as WebhookEvent & { content: AddonUpdatedContent }, + ); + return; + } + break; + + case EventType.ATTACHED_ITEM_CREATED: + if (this._handlers.onAttachedItemCreated) { + await this._handlers.onAttachedItemCreated( + event as WebhookEvent & { content: AttachedItemCreatedContent }, + ); + return; + } + break; + + case EventType.ATTACHED_ITEM_DELETED: + if (this._handlers.onAttachedItemDeleted) { + await this._handlers.onAttachedItemDeleted( + event as WebhookEvent & { content: AttachedItemDeletedContent }, + ); + return; + } + break; + + case EventType.ATTACHED_ITEM_UPDATED: + if (this._handlers.onAttachedItemUpdated) { + await this._handlers.onAttachedItemUpdated( + event as WebhookEvent & { content: AttachedItemUpdatedContent }, + ); + return; + } + break; + + case EventType.AUTHORIZATION_SUCCEEDED: + if (this._handlers.onAuthorizationSucceeded) { + await this._handlers.onAuthorizationSucceeded( + event as WebhookEvent & { + content: AuthorizationSucceededContent; + }, + ); + return; + } + break; + + case EventType.AUTHORIZATION_VOIDED: + if (this._handlers.onAuthorizationVoided) { + await this._handlers.onAuthorizationVoided( + event as WebhookEvent & { content: AuthorizationVoidedContent }, + ); + return; + } + break; + + case EventType.BUSINESS_ENTITY_CREATED: + if (this._handlers.onBusinessEntityCreated) { + await this._handlers.onBusinessEntityCreated( + event as WebhookEvent & { content: BusinessEntityCreatedContent }, + ); + return; + } + break; + + case EventType.BUSINESS_ENTITY_DELETED: + if (this._handlers.onBusinessEntityDeleted) { + await this._handlers.onBusinessEntityDeleted( + event as WebhookEvent & { content: BusinessEntityDeletedContent }, + ); + return; + } + break; + + case EventType.BUSINESS_ENTITY_UPDATED: + if (this._handlers.onBusinessEntityUpdated) { + await this._handlers.onBusinessEntityUpdated( + event as WebhookEvent & { content: BusinessEntityUpdatedContent }, + ); + return; + } + break; + + case EventType.CARD_ADDED: + if (this._handlers.onCardAdded) { + await this._handlers.onCardAdded( + event as WebhookEvent & { content: CardAddedContent }, + ); + return; + } + break; + + case EventType.CARD_DELETED: + if (this._handlers.onCardDeleted) { + await this._handlers.onCardDeleted( + event as WebhookEvent & { content: CardDeletedContent }, + ); + return; + } + break; + + case EventType.CARD_EXPIRED: + if (this._handlers.onCardExpired) { + await this._handlers.onCardExpired( + event as WebhookEvent & { content: CardExpiredContent }, + ); + return; + } + break; + + case EventType.CARD_EXPIRY_REMINDER: + if (this._handlers.onCardExpiryReminder) { + await this._handlers.onCardExpiryReminder( + event as WebhookEvent & { content: CardExpiryReminderContent }, + ); + return; + } + break; + + case EventType.CARD_UPDATED: + if (this._handlers.onCardUpdated) { + await this._handlers.onCardUpdated( + event as WebhookEvent & { content: CardUpdatedContent }, + ); + return; + } + break; + + case EventType.CONTRACT_TERM_CANCELLED: + if (this._handlers.onContractTermCancelled) { + await this._handlers.onContractTermCancelled( + event as WebhookEvent & { content: ContractTermCancelledContent }, + ); + return; + } + break; + + case EventType.CONTRACT_TERM_COMPLETED: + if (this._handlers.onContractTermCompleted) { + await this._handlers.onContractTermCompleted( + event as WebhookEvent & { content: ContractTermCompletedContent }, + ); + return; + } + break; + + case EventType.CONTRACT_TERM_CREATED: + if (this._handlers.onContractTermCreated) { + await this._handlers.onContractTermCreated( + event as WebhookEvent & { content: ContractTermCreatedContent }, + ); + return; + } + break; + + case EventType.CONTRACT_TERM_RENEWED: + if (this._handlers.onContractTermRenewed) { + await this._handlers.onContractTermRenewed( + event as WebhookEvent & { content: ContractTermRenewedContent }, + ); + return; + } + break; + + case EventType.CONTRACT_TERM_TERMINATED: + if (this._handlers.onContractTermTerminated) { + await this._handlers.onContractTermTerminated( + event as WebhookEvent & { + content: ContractTermTerminatedContent; + }, + ); + return; + } + break; + + case EventType.COUPON_CODES_ADDED: + if (this._handlers.onCouponCodesAdded) { + await this._handlers.onCouponCodesAdded( + event as WebhookEvent & { content: CouponCodesAddedContent }, + ); + return; + } + break; + + case EventType.COUPON_CODES_DELETED: + if (this._handlers.onCouponCodesDeleted) { + await this._handlers.onCouponCodesDeleted( + event as WebhookEvent & { content: CouponCodesDeletedContent }, + ); + return; + } + break; + + case EventType.COUPON_CODES_UPDATED: + if (this._handlers.onCouponCodesUpdated) { + await this._handlers.onCouponCodesUpdated( + event as WebhookEvent & { content: CouponCodesUpdatedContent }, + ); + return; + } + break; + + case EventType.COUPON_CREATED: + if (this._handlers.onCouponCreated) { + await this._handlers.onCouponCreated( + event as WebhookEvent & { content: CouponCreatedContent }, + ); + return; + } + break; + + case EventType.COUPON_DELETED: + if (this._handlers.onCouponDeleted) { + await this._handlers.onCouponDeleted( + event as WebhookEvent & { content: CouponDeletedContent }, + ); + return; + } + break; + + case EventType.COUPON_SET_CREATED: + if (this._handlers.onCouponSetCreated) { + await this._handlers.onCouponSetCreated( + event as WebhookEvent & { content: CouponSetCreatedContent }, + ); + return; + } + break; + + case EventType.COUPON_SET_DELETED: + if (this._handlers.onCouponSetDeleted) { + await this._handlers.onCouponSetDeleted( + event as WebhookEvent & { content: CouponSetDeletedContent }, + ); + return; + } + break; + + case EventType.COUPON_SET_UPDATED: + if (this._handlers.onCouponSetUpdated) { + await this._handlers.onCouponSetUpdated( + event as WebhookEvent & { content: CouponSetUpdatedContent }, + ); + return; + } + break; + + case EventType.COUPON_UPDATED: + if (this._handlers.onCouponUpdated) { + await this._handlers.onCouponUpdated( + event as WebhookEvent & { content: CouponUpdatedContent }, + ); + return; + } + break; + + case EventType.CREDIT_NOTE_CREATED: + if (this._handlers.onCreditNoteCreated) { + await this._handlers.onCreditNoteCreated( + event as WebhookEvent & { content: CreditNoteCreatedContent }, + ); + return; + } + break; + + case EventType.CREDIT_NOTE_CREATED_WITH_BACKDATING: + if (this._handlers.onCreditNoteCreatedWithBackdating) { + await this._handlers.onCreditNoteCreatedWithBackdating( + event as WebhookEvent & { + content: CreditNoteCreatedWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.CREDIT_NOTE_DELETED: + if (this._handlers.onCreditNoteDeleted) { + await this._handlers.onCreditNoteDeleted( + event as WebhookEvent & { content: CreditNoteDeletedContent }, + ); + return; + } + break; + + case EventType.CREDIT_NOTE_UPDATED: + if (this._handlers.onCreditNoteUpdated) { + await this._handlers.onCreditNoteUpdated( + event as WebhookEvent & { content: CreditNoteUpdatedContent }, + ); + return; + } + break; + + case EventType.CUSTOMER_BUSINESS_ENTITY_CHANGED: + if (this._handlers.onCustomerBusinessEntityChanged) { + await this._handlers.onCustomerBusinessEntityChanged( + event as WebhookEvent & { + content: CustomerBusinessEntityChangedContent; + }, + ); + return; + } + break; + + case EventType.CUSTOMER_CHANGED: + if (this._handlers.onCustomerChanged) { + await this._handlers.onCustomerChanged( + event as WebhookEvent & { content: CustomerChangedContent }, + ); + return; + } + break; + + case EventType.CUSTOMER_CREATED: + if (this._handlers.onCustomerCreated) { + await this._handlers.onCustomerCreated( + event as WebhookEvent & { content: CustomerCreatedContent }, + ); + return; + } + break; + + case EventType.CUSTOMER_DELETED: + if (this._handlers.onCustomerDeleted) { + await this._handlers.onCustomerDeleted( + event as WebhookEvent & { content: CustomerDeletedContent }, + ); + return; + } + break; + + case EventType.CUSTOMER_ENTITLEMENTS_UPDATED: + if (this._handlers.onCustomerEntitlementsUpdated) { + await this._handlers.onCustomerEntitlementsUpdated( + event as WebhookEvent & { + content: CustomerEntitlementsUpdatedContent; + }, + ); + return; + } + break; + + case EventType.CUSTOMER_MOVED_IN: + if (this._handlers.onCustomerMovedIn) { + await this._handlers.onCustomerMovedIn( + event as WebhookEvent & { content: CustomerMovedInContent }, + ); + return; + } + break; + + case EventType.CUSTOMER_MOVED_OUT: + if (this._handlers.onCustomerMovedOut) { + await this._handlers.onCustomerMovedOut( + event as WebhookEvent & { content: CustomerMovedOutContent }, + ); + return; + } + break; + + case EventType.DIFFERENTIAL_PRICE_CREATED: + if (this._handlers.onDifferentialPriceCreated) { + await this._handlers.onDifferentialPriceCreated( + event as WebhookEvent & { + content: DifferentialPriceCreatedContent; + }, + ); + return; + } + break; + + case EventType.DIFFERENTIAL_PRICE_DELETED: + if (this._handlers.onDifferentialPriceDeleted) { + await this._handlers.onDifferentialPriceDeleted( + event as WebhookEvent & { + content: DifferentialPriceDeletedContent; + }, + ); + return; + } + break; + + case EventType.DIFFERENTIAL_PRICE_UPDATED: + if (this._handlers.onDifferentialPriceUpdated) { + await this._handlers.onDifferentialPriceUpdated( + event as WebhookEvent & { + content: DifferentialPriceUpdatedContent; + }, + ); + return; + } + break; + + case EventType.DUNNING_UPDATED: + if (this._handlers.onDunningUpdated) { + await this._handlers.onDunningUpdated( + event as WebhookEvent & { content: DunningUpdatedContent }, + ); + return; + } + break; + + case EventType.ENTITLEMENT_OVERRIDES_AUTO_REMOVED: + if (this._handlers.onEntitlementOverridesAutoRemoved) { + await this._handlers.onEntitlementOverridesAutoRemoved( + event as WebhookEvent & { + content: EntitlementOverridesAutoRemovedContent; + }, + ); + return; + } + break; + + case EventType.ENTITLEMENT_OVERRIDES_REMOVED: + if (this._handlers.onEntitlementOverridesRemoved) { + await this._handlers.onEntitlementOverridesRemoved( + event as WebhookEvent & { + content: EntitlementOverridesRemovedContent; + }, + ); + return; + } + break; + + case EventType.ENTITLEMENT_OVERRIDES_UPDATED: + if (this._handlers.onEntitlementOverridesUpdated) { + await this._handlers.onEntitlementOverridesUpdated( + event as WebhookEvent & { + content: EntitlementOverridesUpdatedContent; + }, + ); + return; + } + break; + + case EventType.FEATURE_ACTIVATED: + if (this._handlers.onFeatureActivated) { + await this._handlers.onFeatureActivated( + event as WebhookEvent & { content: FeatureActivatedContent }, + ); + return; + } + break; + + case EventType.FEATURE_ARCHIVED: + if (this._handlers.onFeatureArchived) { + await this._handlers.onFeatureArchived( + event as WebhookEvent & { content: FeatureArchivedContent }, + ); + return; + } + break; + + case EventType.FEATURE_CREATED: + if (this._handlers.onFeatureCreated) { + await this._handlers.onFeatureCreated( + event as WebhookEvent & { content: FeatureCreatedContent }, + ); + return; + } + break; + + case EventType.FEATURE_DELETED: + if (this._handlers.onFeatureDeleted) { + await this._handlers.onFeatureDeleted( + event as WebhookEvent & { content: FeatureDeletedContent }, + ); + return; + } + break; + + case EventType.FEATURE_REACTIVATED: + if (this._handlers.onFeatureReactivated) { + await this._handlers.onFeatureReactivated( + event as WebhookEvent & { content: FeatureReactivatedContent }, + ); + return; + } + break; + + case EventType.FEATURE_UPDATED: + if (this._handlers.onFeatureUpdated) { + await this._handlers.onFeatureUpdated( + event as WebhookEvent & { content: FeatureUpdatedContent }, + ); + return; + } + break; + + case EventType.GIFT_CANCELLED: + if (this._handlers.onGiftCancelled) { + await this._handlers.onGiftCancelled( + event as WebhookEvent & { content: GiftCancelledContent }, + ); + return; + } + break; + + case EventType.GIFT_CLAIMED: + if (this._handlers.onGiftClaimed) { + await this._handlers.onGiftClaimed( + event as WebhookEvent & { content: GiftClaimedContent }, + ); + return; + } + break; + + case EventType.GIFT_EXPIRED: + if (this._handlers.onGiftExpired) { + await this._handlers.onGiftExpired( + event as WebhookEvent & { content: GiftExpiredContent }, + ); + return; + } + break; + + case EventType.GIFT_SCHEDULED: + if (this._handlers.onGiftScheduled) { + await this._handlers.onGiftScheduled( + event as WebhookEvent & { content: GiftScheduledContent }, + ); + return; + } + break; + + case EventType.GIFT_UNCLAIMED: + if (this._handlers.onGiftUnclaimed) { + await this._handlers.onGiftUnclaimed( + event as WebhookEvent & { content: GiftUnclaimedContent }, + ); + return; + } + break; + + case EventType.GIFT_UPDATED: + if (this._handlers.onGiftUpdated) { + await this._handlers.onGiftUpdated( + event as WebhookEvent & { content: GiftUpdatedContent }, + ); + return; + } + break; + + case EventType.HIERARCHY_CREATED: + if (this._handlers.onHierarchyCreated) { + await this._handlers.onHierarchyCreated( + event as WebhookEvent & { content: HierarchyCreatedContent }, + ); + return; + } + break; + + case EventType.HIERARCHY_DELETED: + if (this._handlers.onHierarchyDeleted) { + await this._handlers.onHierarchyDeleted( + event as WebhookEvent & { content: HierarchyDeletedContent }, + ); + return; + } + break; + + case EventType.INVOICE_DELETED: + if (this._handlers.onInvoiceDeleted) { + await this._handlers.onInvoiceDeleted( + event as WebhookEvent & { content: InvoiceDeletedContent }, + ); + return; + } + break; + + case EventType.INVOICE_GENERATED: + if (this._handlers.onInvoiceGenerated) { + await this._handlers.onInvoiceGenerated( + event as WebhookEvent & { content: InvoiceGeneratedContent }, + ); + return; + } + break; + + case EventType.INVOICE_GENERATED_WITH_BACKDATING: + if (this._handlers.onInvoiceGeneratedWithBackdating) { + await this._handlers.onInvoiceGeneratedWithBackdating( + event as WebhookEvent & { + content: InvoiceGeneratedWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.INVOICE_UPDATED: + if (this._handlers.onInvoiceUpdated) { + await this._handlers.onInvoiceUpdated( + event as WebhookEvent & { content: InvoiceUpdatedContent }, + ); + return; + } + break; + + case EventType.ITEM_CREATED: + if (this._handlers.onItemCreated) { + await this._handlers.onItemCreated( + event as WebhookEvent & { content: ItemCreatedContent }, + ); + return; + } + break; + + case EventType.ITEM_DELETED: + if (this._handlers.onItemDeleted) { + await this._handlers.onItemDeleted( + event as WebhookEvent & { content: ItemDeletedContent }, + ); + return; + } + break; + + case EventType.ITEM_ENTITLEMENTS_REMOVED: + if (this._handlers.onItemEntitlementsRemoved) { + await this._handlers.onItemEntitlementsRemoved( + event as WebhookEvent & { + content: ItemEntitlementsRemovedContent; + }, + ); + return; + } + break; + + case EventType.ITEM_ENTITLEMENTS_UPDATED: + if (this._handlers.onItemEntitlementsUpdated) { + await this._handlers.onItemEntitlementsUpdated( + event as WebhookEvent & { + content: ItemEntitlementsUpdatedContent; + }, + ); + return; + } + break; + + case EventType.ITEM_FAMILY_CREATED: + if (this._handlers.onItemFamilyCreated) { + await this._handlers.onItemFamilyCreated( + event as WebhookEvent & { content: ItemFamilyCreatedContent }, + ); + return; + } + break; + + case EventType.ITEM_FAMILY_DELETED: + if (this._handlers.onItemFamilyDeleted) { + await this._handlers.onItemFamilyDeleted( + event as WebhookEvent & { content: ItemFamilyDeletedContent }, + ); + return; + } + break; + + case EventType.ITEM_FAMILY_UPDATED: + if (this._handlers.onItemFamilyUpdated) { + await this._handlers.onItemFamilyUpdated( + event as WebhookEvent & { content: ItemFamilyUpdatedContent }, + ); + return; + } + break; + + case EventType.ITEM_PRICE_CREATED: + if (this._handlers.onItemPriceCreated) { + await this._handlers.onItemPriceCreated( + event as WebhookEvent & { content: ItemPriceCreatedContent }, + ); + return; + } + break; + + case EventType.ITEM_PRICE_DELETED: + if (this._handlers.onItemPriceDeleted) { + await this._handlers.onItemPriceDeleted( + event as WebhookEvent & { content: ItemPriceDeletedContent }, + ); + return; + } + break; + + case EventType.ITEM_PRICE_ENTITLEMENTS_REMOVED: + if (this._handlers.onItemPriceEntitlementsRemoved) { + await this._handlers.onItemPriceEntitlementsRemoved( + event as WebhookEvent & { + content: ItemPriceEntitlementsRemovedContent; + }, + ); + return; + } + break; + + case EventType.ITEM_PRICE_ENTITLEMENTS_UPDATED: + if (this._handlers.onItemPriceEntitlementsUpdated) { + await this._handlers.onItemPriceEntitlementsUpdated( + event as WebhookEvent & { + content: ItemPriceEntitlementsUpdatedContent; + }, + ); + return; + } + break; + + case EventType.ITEM_PRICE_UPDATED: + if (this._handlers.onItemPriceUpdated) { + await this._handlers.onItemPriceUpdated( + event as WebhookEvent & { content: ItemPriceUpdatedContent }, + ); + return; + } + break; + + case EventType.ITEM_UPDATED: + if (this._handlers.onItemUpdated) { + await this._handlers.onItemUpdated( + event as WebhookEvent & { content: ItemUpdatedContent }, + ); + return; + } + break; + + case EventType.MRR_UPDATED: + if (this._handlers.onMrrUpdated) { + await this._handlers.onMrrUpdated( + event as WebhookEvent & { content: MrrUpdatedContent }, + ); + return; + } + break; + + case EventType.NETD_PAYMENT_DUE_REMINDER: + if (this._handlers.onNetdPaymentDueReminder) { + await this._handlers.onNetdPaymentDueReminder( + event as WebhookEvent & { + content: NetdPaymentDueReminderContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_ONE_TIME_ORDER_CREATED: + if (this._handlers.onOmnichannelOneTimeOrderCreated) { + await this._handlers.onOmnichannelOneTimeOrderCreated( + event as WebhookEvent & { + content: OmnichannelOneTimeOrderCreatedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_ONE_TIME_ORDER_ITEM_CANCELLED: + if (this._handlers.onOmnichannelOneTimeOrderItemCancelled) { + await this._handlers.onOmnichannelOneTimeOrderItemCancelled( + event as WebhookEvent & { + content: OmnichannelOneTimeOrderItemCancelledContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_CREATED: + if (this._handlers.onOmnichannelSubscriptionCreated) { + await this._handlers.onOmnichannelSubscriptionCreated( + event as WebhookEvent & { + content: OmnichannelSubscriptionCreatedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_IMPORTED: + if (this._handlers.onOmnichannelSubscriptionImported) { + await this._handlers.onOmnichannelSubscriptionImported( + event as WebhookEvent & { + content: OmnichannelSubscriptionImportedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLATION_SCHEDULED: + if ( + this._handlers.onOmnichannelSubscriptionItemCancellationScheduled + ) { + await this._handlers.onOmnichannelSubscriptionItemCancellationScheduled( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemCancellationScheduledContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLED: + if (this._handlers.onOmnichannelSubscriptionItemCancelled) { + await this._handlers.onOmnichannelSubscriptionItemCancelled( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemCancelledContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGE_SCHEDULED: + if (this._handlers.onOmnichannelSubscriptionItemChangeScheduled) { + await this._handlers.onOmnichannelSubscriptionItemChangeScheduled( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemChangeScheduledContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGED: + if (this._handlers.onOmnichannelSubscriptionItemChanged) { + await this._handlers.onOmnichannelSubscriptionItemChanged( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemChangedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADE_SCHEDULED: + if (this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled) { + await this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemDowngradeScheduledContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADED: + if (this._handlers.onOmnichannelSubscriptionItemDowngraded) { + await this._handlers.onOmnichannelSubscriptionItemDowngraded( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemDowngradedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_EXPIRED: + if (this._handlers.onOmnichannelSubscriptionItemDunningExpired) { + await this._handlers.onOmnichannelSubscriptionItemDunningExpired( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemDunningExpiredContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_STARTED: + if (this._handlers.onOmnichannelSubscriptionItemDunningStarted) { + await this._handlers.onOmnichannelSubscriptionItemDunningStarted( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemDunningStartedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_EXPIRED: + if (this._handlers.onOmnichannelSubscriptionItemExpired) { + await this._handlers.onOmnichannelSubscriptionItemExpired( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemExpiredContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_EXPIRED: + if (this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired) { + await this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemGracePeriodExpiredContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_STARTED: + if (this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted) { + await this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemGracePeriodStartedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSE_SCHEDULED: + if (this._handlers.onOmnichannelSubscriptionItemPauseScheduled) { + await this._handlers.onOmnichannelSubscriptionItemPauseScheduled( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemPauseScheduledContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSED: + if (this._handlers.onOmnichannelSubscriptionItemPaused) { + await this._handlers.onOmnichannelSubscriptionItemPaused( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemPausedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_REACTIVATED: + if (this._handlers.onOmnichannelSubscriptionItemReactivated) { + await this._handlers.onOmnichannelSubscriptionItemReactivated( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemReactivatedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_RENEWED: + if (this._handlers.onOmnichannelSubscriptionItemRenewed) { + await this._handlers.onOmnichannelSubscriptionItemRenewed( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemRenewedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_RESUBSCRIBED: + if (this._handlers.onOmnichannelSubscriptionItemResubscribed) { + await this._handlers.onOmnichannelSubscriptionItemResubscribed( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemResubscribedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_RESUMED: + if (this._handlers.onOmnichannelSubscriptionItemResumed) { + await this._handlers.onOmnichannelSubscriptionItemResumed( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemResumedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CANCELLATION_REMOVED: + if ( + this._handlers + .onOmnichannelSubscriptionItemScheduledCancellationRemoved + ) { + await this._handlers.onOmnichannelSubscriptionItemScheduledCancellationRemoved( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CHANGE_REMOVED: + if ( + this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved + ) { + await this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledChangeRemovedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_DOWNGRADE_REMOVED: + if ( + this._handlers + .onOmnichannelSubscriptionItemScheduledDowngradeRemoved + ) { + await this._handlers.onOmnichannelSubscriptionItemScheduledDowngradeRemoved( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemScheduledDowngradeRemovedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_UPGRADED: + if (this._handlers.onOmnichannelSubscriptionItemUpgraded) { + await this._handlers.onOmnichannelSubscriptionItemUpgraded( + event as WebhookEvent & { + content: OmnichannelSubscriptionItemUpgradedContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_SUBSCRIPTION_MOVED_IN: + if (this._handlers.onOmnichannelSubscriptionMovedIn) { + await this._handlers.onOmnichannelSubscriptionMovedIn( + event as WebhookEvent & { + content: OmnichannelSubscriptionMovedInContent; + }, + ); + return; + } + break; + + case EventType.OMNICHANNEL_TRANSACTION_CREATED: + if (this._handlers.onOmnichannelTransactionCreated) { + await this._handlers.onOmnichannelTransactionCreated( + event as WebhookEvent & { + content: OmnichannelTransactionCreatedContent; + }, + ); + return; + } + break; + + case EventType.ORDER_CANCELLED: + if (this._handlers.onOrderCancelled) { + await this._handlers.onOrderCancelled( + event as WebhookEvent & { content: OrderCancelledContent }, + ); + return; + } + break; + + case EventType.ORDER_CREATED: + if (this._handlers.onOrderCreated) { + await this._handlers.onOrderCreated( + event as WebhookEvent & { content: OrderCreatedContent }, + ); + return; + } + break; + + case EventType.ORDER_DELETED: + if (this._handlers.onOrderDeleted) { + await this._handlers.onOrderDeleted( + event as WebhookEvent & { content: OrderDeletedContent }, + ); + return; + } + break; + + case EventType.ORDER_DELIVERED: + if (this._handlers.onOrderDelivered) { + await this._handlers.onOrderDelivered( + event as WebhookEvent & { content: OrderDeliveredContent }, + ); + return; + } + break; + + case EventType.ORDER_READY_TO_PROCESS: + if (this._handlers.onOrderReadyToProcess) { + await this._handlers.onOrderReadyToProcess( + event as WebhookEvent & { content: OrderReadyToProcessContent }, + ); + return; + } + break; + + case EventType.ORDER_READY_TO_SHIP: + if (this._handlers.onOrderReadyToShip) { + await this._handlers.onOrderReadyToShip( + event as WebhookEvent & { content: OrderReadyToShipContent }, + ); + return; + } + break; + + case EventType.ORDER_RESENT: + if (this._handlers.onOrderResent) { + await this._handlers.onOrderResent( + event as WebhookEvent & { content: OrderResentContent }, + ); + return; + } + break; + + case EventType.ORDER_RETURNED: + if (this._handlers.onOrderReturned) { + await this._handlers.onOrderReturned( + event as WebhookEvent & { content: OrderReturnedContent }, + ); + return; + } + break; + + case EventType.ORDER_UPDATED: + if (this._handlers.onOrderUpdated) { + await this._handlers.onOrderUpdated( + event as WebhookEvent & { content: OrderUpdatedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_FAILED: + if (this._handlers.onPaymentFailed) { + await this._handlers.onPaymentFailed( + event as WebhookEvent & { content: PaymentFailedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_INITIATED: + if (this._handlers.onPaymentInitiated) { + await this._handlers.onPaymentInitiated( + event as WebhookEvent & { content: PaymentInitiatedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_INTENT_CREATED: + if (this._handlers.onPaymentIntentCreated) { + await this._handlers.onPaymentIntentCreated( + event as WebhookEvent & { content: PaymentIntentCreatedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_INTENT_UPDATED: + if (this._handlers.onPaymentIntentUpdated) { + await this._handlers.onPaymentIntentUpdated( + event as WebhookEvent & { content: PaymentIntentUpdatedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_REFUNDED: + if (this._handlers.onPaymentRefunded) { + await this._handlers.onPaymentRefunded( + event as WebhookEvent & { content: PaymentRefundedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_SCHEDULE_SCHEME_CREATED: + if (this._handlers.onPaymentScheduleSchemeCreated) { + await this._handlers.onPaymentScheduleSchemeCreated( + event as WebhookEvent & { + content: PaymentScheduleSchemeCreatedContent; + }, + ); + return; + } + break; + + case EventType.PAYMENT_SCHEDULE_SCHEME_DELETED: + if (this._handlers.onPaymentScheduleSchemeDeleted) { + await this._handlers.onPaymentScheduleSchemeDeleted( + event as WebhookEvent & { + content: PaymentScheduleSchemeDeletedContent; + }, + ); + return; + } + break; + + case EventType.PAYMENT_SCHEDULES_CREATED: + if (this._handlers.onPaymentSchedulesCreated) { + await this._handlers.onPaymentSchedulesCreated( + event as WebhookEvent & { + content: PaymentSchedulesCreatedContent; + }, + ); + return; + } + break; + + case EventType.PAYMENT_SCHEDULES_UPDATED: + if (this._handlers.onPaymentSchedulesUpdated) { + await this._handlers.onPaymentSchedulesUpdated( + event as WebhookEvent & { + content: PaymentSchedulesUpdatedContent; + }, + ); + return; + } + break; + + case EventType.PAYMENT_SOURCE_ADDED: + if (this._handlers.onPaymentSourceAdded) { + await this._handlers.onPaymentSourceAdded( + event as WebhookEvent & { content: PaymentSourceAddedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_SOURCE_DELETED: + if (this._handlers.onPaymentSourceDeleted) { + await this._handlers.onPaymentSourceDeleted( + event as WebhookEvent & { content: PaymentSourceDeletedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_SOURCE_EXPIRED: + if (this._handlers.onPaymentSourceExpired) { + await this._handlers.onPaymentSourceExpired( + event as WebhookEvent & { content: PaymentSourceExpiredContent }, + ); + return; + } + break; + + case EventType.PAYMENT_SOURCE_EXPIRING: + if (this._handlers.onPaymentSourceExpiring) { + await this._handlers.onPaymentSourceExpiring( + event as WebhookEvent & { content: PaymentSourceExpiringContent }, + ); + return; + } + break; + + case EventType.PAYMENT_SOURCE_LOCALLY_DELETED: + if (this._handlers.onPaymentSourceLocallyDeleted) { + await this._handlers.onPaymentSourceLocallyDeleted( + event as WebhookEvent & { + content: PaymentSourceLocallyDeletedContent; + }, + ); + return; + } + break; + + case EventType.PAYMENT_SOURCE_UPDATED: + if (this._handlers.onPaymentSourceUpdated) { + await this._handlers.onPaymentSourceUpdated( + event as WebhookEvent & { content: PaymentSourceUpdatedContent }, + ); + return; + } + break; + + case EventType.PAYMENT_SUCCEEDED: + if (this._handlers.onPaymentSucceeded) { + await this._handlers.onPaymentSucceeded( + event as WebhookEvent & { content: PaymentSucceededContent }, + ); + return; + } + break; + + case EventType.PENDING_INVOICE_CREATED: + if (this._handlers.onPendingInvoiceCreated) { + await this._handlers.onPendingInvoiceCreated( + event as WebhookEvent & { content: PendingInvoiceCreatedContent }, + ); + return; + } + break; + + case EventType.PENDING_INVOICE_UPDATED: + if (this._handlers.onPendingInvoiceUpdated) { + await this._handlers.onPendingInvoiceUpdated( + event as WebhookEvent & { content: PendingInvoiceUpdatedContent }, + ); + return; + } + break; + + case EventType.PLAN_CREATED: + if (this._handlers.onPlanCreated) { + await this._handlers.onPlanCreated( + event as WebhookEvent & { content: PlanCreatedContent }, + ); + return; + } + break; + + case EventType.PLAN_DELETED: + if (this._handlers.onPlanDeleted) { + await this._handlers.onPlanDeleted( + event as WebhookEvent & { content: PlanDeletedContent }, + ); + return; + } + break; + + case EventType.PLAN_UPDATED: + if (this._handlers.onPlanUpdated) { + await this._handlers.onPlanUpdated( + event as WebhookEvent & { content: PlanUpdatedContent }, + ); + return; + } + break; + + case EventType.PRICE_VARIANT_CREATED: + if (this._handlers.onPriceVariantCreated) { + await this._handlers.onPriceVariantCreated( + event as WebhookEvent & { content: PriceVariantCreatedContent }, + ); + return; + } + break; + + case EventType.PRICE_VARIANT_DELETED: + if (this._handlers.onPriceVariantDeleted) { + await this._handlers.onPriceVariantDeleted( + event as WebhookEvent & { content: PriceVariantDeletedContent }, + ); + return; + } + break; + + case EventType.PRICE_VARIANT_UPDATED: + if (this._handlers.onPriceVariantUpdated) { + await this._handlers.onPriceVariantUpdated( + event as WebhookEvent & { content: PriceVariantUpdatedContent }, + ); + return; + } + break; + + case EventType.PRODUCT_CREATED: + if (this._handlers.onProductCreated) { + await this._handlers.onProductCreated( + event as WebhookEvent & { content: ProductCreatedContent }, + ); + return; + } + break; + + case EventType.PRODUCT_DELETED: + if (this._handlers.onProductDeleted) { + await this._handlers.onProductDeleted( + event as WebhookEvent & { content: ProductDeletedContent }, + ); + return; + } + break; + + case EventType.PRODUCT_UPDATED: + if (this._handlers.onProductUpdated) { + await this._handlers.onProductUpdated( + event as WebhookEvent & { content: ProductUpdatedContent }, + ); + return; + } + break; + + case EventType.PROMOTIONAL_CREDITS_ADDED: + if (this._handlers.onPromotionalCreditsAdded) { + await this._handlers.onPromotionalCreditsAdded( + event as WebhookEvent & { + content: PromotionalCreditsAddedContent; + }, + ); + return; + } + break; + + case EventType.PROMOTIONAL_CREDITS_DEDUCTED: + if (this._handlers.onPromotionalCreditsDeducted) { + await this._handlers.onPromotionalCreditsDeducted( + event as WebhookEvent & { + content: PromotionalCreditsDeductedContent; + }, + ); + return; + } + break; + + case EventType.PURCHASE_CREATED: + if (this._handlers.onPurchaseCreated) { + await this._handlers.onPurchaseCreated( + event as WebhookEvent & { content: PurchaseCreatedContent }, + ); + return; + } + break; + + case EventType.QUOTE_CREATED: + if (this._handlers.onQuoteCreated) { + await this._handlers.onQuoteCreated( + event as WebhookEvent & { content: QuoteCreatedContent }, + ); + return; + } + break; + + case EventType.QUOTE_DELETED: + if (this._handlers.onQuoteDeleted) { + await this._handlers.onQuoteDeleted( + event as WebhookEvent & { content: QuoteDeletedContent }, + ); + return; + } + break; + + case EventType.QUOTE_UPDATED: + if (this._handlers.onQuoteUpdated) { + await this._handlers.onQuoteUpdated( + event as WebhookEvent & { content: QuoteUpdatedContent }, + ); + return; + } + break; + + case EventType.RECORD_PURCHASE_FAILED: + if (this._handlers.onRecordPurchaseFailed) { + await this._handlers.onRecordPurchaseFailed( + event as WebhookEvent & { content: RecordPurchaseFailedContent }, + ); + return; + } + break; + + case EventType.REFUND_INITIATED: + if (this._handlers.onRefundInitiated) { + await this._handlers.onRefundInitiated( + event as WebhookEvent & { content: RefundInitiatedContent }, + ); + return; + } + break; + + case EventType.RULE_CREATED: + if (this._handlers.onRuleCreated) { + await this._handlers.onRuleCreated( + event as WebhookEvent & { content: RuleCreatedContent }, + ); + return; + } + break; + + case EventType.RULE_DELETED: + if (this._handlers.onRuleDeleted) { + await this._handlers.onRuleDeleted( + event as WebhookEvent & { content: RuleDeletedContent }, + ); + return; + } + break; + + case EventType.RULE_UPDATED: + if (this._handlers.onRuleUpdated) { + await this._handlers.onRuleUpdated( + event as WebhookEvent & { content: RuleUpdatedContent }, + ); + return; + } + break; + + case EventType.SALES_ORDER_CREATED: + if (this._handlers.onSalesOrderCreated) { + await this._handlers.onSalesOrderCreated( + event as WebhookEvent & { content: SalesOrderCreatedContent }, + ); + return; + } + break; + + case EventType.SALES_ORDER_UPDATED: + if (this._handlers.onSalesOrderUpdated) { + await this._handlers.onSalesOrderUpdated( + event as WebhookEvent & { content: SalesOrderUpdatedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ACTIVATED: + if (this._handlers.onSubscriptionActivated) { + await this._handlers.onSubscriptionActivated( + event as WebhookEvent & { content: SubscriptionActivatedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ACTIVATED_WITH_BACKDATING: + if (this._handlers.onSubscriptionActivatedWithBackdating) { + await this._handlers.onSubscriptionActivatedWithBackdating( + event as WebhookEvent & { + content: SubscriptionActivatedWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_ADDED: + if (this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded) { + await this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded( + event as WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleAddedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_REMOVED: + if (this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved) { + await this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved( + event as WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleRemovedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_UPDATED: + if (this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated) { + await this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated( + event as WebhookEvent & { + content: SubscriptionAdvanceInvoiceScheduleUpdatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_BUSINESS_ENTITY_CHANGED: + if (this._handlers.onSubscriptionBusinessEntityChanged) { + await this._handlers.onSubscriptionBusinessEntityChanged( + event as WebhookEvent & { + content: SubscriptionBusinessEntityChangedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CANCELED_WITH_BACKDATING: + if (this._handlers.onSubscriptionCanceledWithBackdating) { + await this._handlers.onSubscriptionCanceledWithBackdating( + event as WebhookEvent & { + content: SubscriptionCanceledWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CANCELLATION_REMINDER: + if (this._handlers.onSubscriptionCancellationReminder) { + await this._handlers.onSubscriptionCancellationReminder( + event as WebhookEvent & { + content: SubscriptionCancellationReminderContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CANCELLATION_SCHEDULED: + if (this._handlers.onSubscriptionCancellationScheduled) { + await this._handlers.onSubscriptionCancellationScheduled( + event as WebhookEvent & { + content: SubscriptionCancellationScheduledContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CANCELLED: + if (this._handlers.onSubscriptionCancelled) { + await this._handlers.onSubscriptionCancelled( + event as WebhookEvent & { content: SubscriptionCancelledContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CHANGED: + if (this._handlers.onSubscriptionChanged) { + await this._handlers.onSubscriptionChanged( + event as WebhookEvent & { content: SubscriptionChangedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CHANGED_WITH_BACKDATING: + if (this._handlers.onSubscriptionChangedWithBackdating) { + await this._handlers.onSubscriptionChangedWithBackdating( + event as WebhookEvent & { + content: SubscriptionChangedWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CHANGES_SCHEDULED: + if (this._handlers.onSubscriptionChangesScheduled) { + await this._handlers.onSubscriptionChangesScheduled( + event as WebhookEvent & { + content: SubscriptionChangesScheduledContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CREATED: + if (this._handlers.onSubscriptionCreated) { + await this._handlers.onSubscriptionCreated( + event as WebhookEvent & { content: SubscriptionCreatedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_CREATED_WITH_BACKDATING: + if (this._handlers.onSubscriptionCreatedWithBackdating) { + await this._handlers.onSubscriptionCreatedWithBackdating( + event as WebhookEvent & { + content: SubscriptionCreatedWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_DELETED: + if (this._handlers.onSubscriptionDeleted) { + await this._handlers.onSubscriptionDeleted( + event as WebhookEvent & { content: SubscriptionDeletedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ENTITLEMENTS_CREATED: + if (this._handlers.onSubscriptionEntitlementsCreated) { + await this._handlers.onSubscriptionEntitlementsCreated( + event as WebhookEvent & { + content: SubscriptionEntitlementsCreatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ENTITLEMENTS_UPDATED: + if (this._handlers.onSubscriptionEntitlementsUpdated) { + await this._handlers.onSubscriptionEntitlementsUpdated( + event as WebhookEvent & { + content: SubscriptionEntitlementsUpdatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_ITEMS_RENEWED: + if (this._handlers.onSubscriptionItemsRenewed) { + await this._handlers.onSubscriptionItemsRenewed( + event as WebhookEvent & { + content: SubscriptionItemsRenewedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_MOVED_IN: + if (this._handlers.onSubscriptionMovedIn) { + await this._handlers.onSubscriptionMovedIn( + event as WebhookEvent & { content: SubscriptionMovedInContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_MOVED_OUT: + if (this._handlers.onSubscriptionMovedOut) { + await this._handlers.onSubscriptionMovedOut( + event as WebhookEvent & { content: SubscriptionMovedOutContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_MOVEMENT_FAILED: + if (this._handlers.onSubscriptionMovementFailed) { + await this._handlers.onSubscriptionMovementFailed( + event as WebhookEvent & { + content: SubscriptionMovementFailedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_PAUSE_SCHEDULED: + if (this._handlers.onSubscriptionPauseScheduled) { + await this._handlers.onSubscriptionPauseScheduled( + event as WebhookEvent & { + content: SubscriptionPauseScheduledContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_PAUSED: + if (this._handlers.onSubscriptionPaused) { + await this._handlers.onSubscriptionPaused( + event as WebhookEvent & { content: SubscriptionPausedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RAMP_APPLIED: + if (this._handlers.onSubscriptionRampApplied) { + await this._handlers.onSubscriptionRampApplied( + event as WebhookEvent & { + content: SubscriptionRampAppliedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RAMP_CREATED: + if (this._handlers.onSubscriptionRampCreated) { + await this._handlers.onSubscriptionRampCreated( + event as WebhookEvent & { + content: SubscriptionRampCreatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RAMP_DELETED: + if (this._handlers.onSubscriptionRampDeleted) { + await this._handlers.onSubscriptionRampDeleted( + event as WebhookEvent & { + content: SubscriptionRampDeletedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RAMP_DRAFTED: + if (this._handlers.onSubscriptionRampDrafted) { + await this._handlers.onSubscriptionRampDrafted( + event as WebhookEvent & { + content: SubscriptionRampDraftedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RAMP_UPDATED: + if (this._handlers.onSubscriptionRampUpdated) { + await this._handlers.onSubscriptionRampUpdated( + event as WebhookEvent & { + content: SubscriptionRampUpdatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_REACTIVATED: + if (this._handlers.onSubscriptionReactivated) { + await this._handlers.onSubscriptionReactivated( + event as WebhookEvent & { + content: SubscriptionReactivatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_REACTIVATED_WITH_BACKDATING: + if (this._handlers.onSubscriptionReactivatedWithBackdating) { + await this._handlers.onSubscriptionReactivatedWithBackdating( + event as WebhookEvent & { + content: SubscriptionReactivatedWithBackdatingContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RENEWAL_REMINDER: + if (this._handlers.onSubscriptionRenewalReminder) { + await this._handlers.onSubscriptionRenewalReminder( + event as WebhookEvent & { + content: SubscriptionRenewalReminderContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RENEWED: + if (this._handlers.onSubscriptionRenewed) { + await this._handlers.onSubscriptionRenewed( + event as WebhookEvent & { content: SubscriptionRenewedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RESUMED: + if (this._handlers.onSubscriptionResumed) { + await this._handlers.onSubscriptionResumed( + event as WebhookEvent & { content: SubscriptionResumedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_RESUMPTION_SCHEDULED: + if (this._handlers.onSubscriptionResumptionScheduled) { + await this._handlers.onSubscriptionResumptionScheduled( + event as WebhookEvent & { + content: SubscriptionResumptionScheduledContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_SCHEDULED_CANCELLATION_REMOVED: + if (this._handlers.onSubscriptionScheduledCancellationRemoved) { + await this._handlers.onSubscriptionScheduledCancellationRemoved( + event as WebhookEvent & { + content: SubscriptionScheduledCancellationRemovedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_SCHEDULED_CHANGES_REMOVED: + if (this._handlers.onSubscriptionScheduledChangesRemoved) { + await this._handlers.onSubscriptionScheduledChangesRemoved( + event as WebhookEvent & { + content: SubscriptionScheduledChangesRemovedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_SCHEDULED_PAUSE_REMOVED: + if (this._handlers.onSubscriptionScheduledPauseRemoved) { + await this._handlers.onSubscriptionScheduledPauseRemoved( + event as WebhookEvent & { + content: SubscriptionScheduledPauseRemovedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_SCHEDULED_RESUMPTION_REMOVED: + if (this._handlers.onSubscriptionScheduledResumptionRemoved) { + await this._handlers.onSubscriptionScheduledResumptionRemoved( + event as WebhookEvent & { + content: SubscriptionScheduledResumptionRemovedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_SHIPPING_ADDRESS_UPDATED: + if (this._handlers.onSubscriptionShippingAddressUpdated) { + await this._handlers.onSubscriptionShippingAddressUpdated( + event as WebhookEvent & { + content: SubscriptionShippingAddressUpdatedContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_STARTED: + if (this._handlers.onSubscriptionStarted) { + await this._handlers.onSubscriptionStarted( + event as WebhookEvent & { content: SubscriptionStartedContent }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_TRIAL_END_REMINDER: + if (this._handlers.onSubscriptionTrialEndReminder) { + await this._handlers.onSubscriptionTrialEndReminder( + event as WebhookEvent & { + content: SubscriptionTrialEndReminderContent; + }, + ); + return; + } + break; + + case EventType.SUBSCRIPTION_TRIAL_EXTENDED: + if (this._handlers.onSubscriptionTrialExtended) { + await this._handlers.onSubscriptionTrialExtended( + event as WebhookEvent & { + content: SubscriptionTrialExtendedContent; + }, + ); + return; + } + break; + + case EventType.TAX_WITHHELD_DELETED: + if (this._handlers.onTaxWithheldDeleted) { + await this._handlers.onTaxWithheldDeleted( + event as WebhookEvent & { content: TaxWithheldDeletedContent }, + ); + return; + } + break; + + case EventType.TAX_WITHHELD_RECORDED: + if (this._handlers.onTaxWithheldRecorded) { + await this._handlers.onTaxWithheldRecorded( + event as WebhookEvent & { content: TaxWithheldRecordedContent }, + ); + return; + } + break; + + case EventType.TAX_WITHHELD_REFUNDED: + if (this._handlers.onTaxWithheldRefunded) { + await this._handlers.onTaxWithheldRefunded( + event as WebhookEvent & { content: TaxWithheldRefundedContent }, + ); + return; + } + break; + + case EventType.TOKEN_CONSUMED: + if (this._handlers.onTokenConsumed) { + await this._handlers.onTokenConsumed( + event as WebhookEvent & { content: TokenConsumedContent }, + ); + return; + } + break; + + case EventType.TOKEN_CREATED: + if (this._handlers.onTokenCreated) { + await this._handlers.onTokenCreated( + event as WebhookEvent & { content: TokenCreatedContent }, + ); + return; + } + break; + + case EventType.TOKEN_EXPIRED: + if (this._handlers.onTokenExpired) { + await this._handlers.onTokenExpired( + event as WebhookEvent & { content: TokenExpiredContent }, + ); + return; + } + break; + + case EventType.TRANSACTION_CREATED: + if (this._handlers.onTransactionCreated) { + await this._handlers.onTransactionCreated( + event as WebhookEvent & { content: TransactionCreatedContent }, + ); + return; + } + break; + + case EventType.TRANSACTION_DELETED: + if (this._handlers.onTransactionDeleted) { + await this._handlers.onTransactionDeleted( + event as WebhookEvent & { content: TransactionDeletedContent }, + ); + return; + } + break; + + case EventType.TRANSACTION_UPDATED: + if (this._handlers.onTransactionUpdated) { + await this._handlers.onTransactionUpdated( + event as WebhookEvent & { content: TransactionUpdatedContent }, + ); + return; + } + break; + + case EventType.UNBILLED_CHARGES_CREATED: + if (this._handlers.onUnbilledChargesCreated) { + await this._handlers.onUnbilledChargesCreated( + event as WebhookEvent & { + content: UnbilledChargesCreatedContent; + }, + ); + return; + } + break; + + case EventType.UNBILLED_CHARGES_DELETED: + if (this._handlers.onUnbilledChargesDeleted) { + await this._handlers.onUnbilledChargesDeleted( + event as WebhookEvent & { + content: UnbilledChargesDeletedContent; + }, + ); + return; + } + break; + + case EventType.UNBILLED_CHARGES_INVOICED: + if (this._handlers.onUnbilledChargesInvoiced) { + await this._handlers.onUnbilledChargesInvoiced( + event as WebhookEvent & { + content: UnbilledChargesInvoicedContent; + }, + ); + return; + } + break; + + case EventType.UNBILLED_CHARGES_VOIDED: + if (this._handlers.onUnbilledChargesVoided) { + await this._handlers.onUnbilledChargesVoided( + event as WebhookEvent & { content: UnbilledChargesVoidedContent }, + ); + return; + } + break; + + case EventType.USAGE_FILE_INGESTED: + if (this._handlers.onUsageFileIngested) { + await this._handlers.onUsageFileIngested( + event as WebhookEvent & { content: UsageFileIngestedContent }, + ); + return; + } + break; + + case EventType.VARIANT_CREATED: + if (this._handlers.onVariantCreated) { + await this._handlers.onVariantCreated( + event as WebhookEvent & { content: VariantCreatedContent }, + ); + return; + } + break; + + case EventType.VARIANT_DELETED: + if (this._handlers.onVariantDeleted) { + await this._handlers.onVariantDeleted( + event as WebhookEvent & { content: VariantDeletedContent }, + ); + return; + } + break; + + case EventType.VARIANT_UPDATED: + if (this._handlers.onVariantUpdated) { + await this._handlers.onVariantUpdated( + event as WebhookEvent & { content: VariantUpdatedContent }, + ); + return; + } + break; + + case EventType.VIRTUAL_BANK_ACCOUNT_ADDED: + if (this._handlers.onVirtualBankAccountAdded) { + await this._handlers.onVirtualBankAccountAdded( + event as WebhookEvent & { + content: VirtualBankAccountAddedContent; + }, + ); + return; + } + break; + + case EventType.VIRTUAL_BANK_ACCOUNT_DELETED: + if (this._handlers.onVirtualBankAccountDeleted) { + await this._handlers.onVirtualBankAccountDeleted( + event as WebhookEvent & { + content: VirtualBankAccountDeletedContent; + }, + ); + return; + } + break; + + case EventType.VIRTUAL_BANK_ACCOUNT_UPDATED: + if (this._handlers.onVirtualBankAccountUpdated) { + await this._handlers.onVirtualBankAccountUpdated( + event as WebhookEvent & { + content: VirtualBankAccountUpdatedContent; + }, + ); + return; + } + break; + + case EventType.VOUCHER_CREATE_FAILED: + if (this._handlers.onVoucherCreateFailed) { + await this._handlers.onVoucherCreateFailed( + event as WebhookEvent & { content: VoucherCreateFailedContent }, + ); + return; + } + break; + + case EventType.VOUCHER_CREATED: + if (this._handlers.onVoucherCreated) { + await this._handlers.onVoucherCreated( + event as WebhookEvent & { content: VoucherCreatedContent }, + ); + return; + } + break; + + case EventType.VOUCHER_EXPIRED: + if (this._handlers.onVoucherExpired) { + await this._handlers.onVoucherExpired( + event as WebhookEvent & { content: VoucherExpiredContent }, + ); + return; + } + break; + } + + if (this.onUnhandledEvent) { + await this.onUnhandledEvent(event); + } + } catch (err) { + if (this.onError) { + this.onError(err); + } else { + throw err; + } + } + } +} diff --git a/test/webhook.test.ts b/test/webhook.test.ts new file mode 100644 index 0000000..936c57c --- /dev/null +++ b/test/webhook.test.ts @@ -0,0 +1,189 @@ +import { expect } from 'chai'; +import { WebhookHandler } from '../src/resources/webhook/handler.js'; +import { EventType } from '../src/resources/webhook/event_types.js'; +import { basicAuthValidator } from '../src/resources/webhook/auth.js'; + +describe('WebhookHandler', () => { + const makeEventBody = (eventType: string, content: string = '{}') => { + return JSON.stringify({ + id: 'evt_test_1', + occurred_at: Math.floor(Date.now() / 1000), + event_type: eventType, + api_version: 'v2', + content: JSON.parse(content), + }); + }; + + it('should route to callback successfully', async () => { + let called = false; + const handler = new WebhookHandler(); + handler.onPendingInvoiceCreated = async (event) => { + called = true; + expect(event.id).to.not.be.empty; + expect(event.event_type).to.equal(EventType.PENDING_INVOICE_CREATED); + expect(event.content).to.not.be.null; + }; + + await handler.handle(makeEventBody('pending_invoice_created')); + expect(called).to.be.true; + }); + + it('should handle validator error', async () => { + let onErrorCalled = false; + const handler = new WebhookHandler(); + handler.requestValidator = () => { + throw new Error('bad signature'); + }; + handler.onError = (err) => { + onErrorCalled = true; + expect(err.message).to.equal('bad signature'); + }; + + await handler.handle(makeEventBody('pending_invoice_created'), {}); + expect(onErrorCalled).to.be.true; + }); + + it('should handle callback error', async () => { + let onErrorCalled = false; + const handler = new WebhookHandler(); + handler.onPendingInvoiceCreated = async () => { + throw new Error('user code failed'); + }; + handler.onError = (err) => { + onErrorCalled = true; + expect(err.message).to.equal('user code failed'); + }; + + await handler.handle(makeEventBody('pending_invoice_created')); + expect(onErrorCalled).to.be.true; + }); + + it('should handle unknown event', async () => { + let onUnhandledCalled = false; + const handler = new WebhookHandler(); + handler.onUnhandledEvent = async (event) => { + onUnhandledCalled = true; + expect(event.event_type).to.equal('non_existing_event'); + }; + + await handler.handle(makeEventBody('non_existing_event')); + expect(onUnhandledCalled).to.be.true; + }); + + it('should handle multiple event types', async () => { + let pendingInvoiceCalled = false; + let subscriptionCalled = false; + + const handler = new WebhookHandler(); + handler.onPendingInvoiceCreated = async () => { + pendingInvoiceCalled = true; + }; + handler.onSubscriptionCreated = async () => { + subscriptionCalled = true; + }; + + await handler.handle(makeEventBody('pending_invoice_created')); + expect(pendingInvoiceCalled).to.be.true; + expect(subscriptionCalled).to.be.false; + + pendingInvoiceCalled = false; + await handler.handle(makeEventBody('subscription_created')); + expect(pendingInvoiceCalled).to.be.false; + expect(subscriptionCalled).to.be.true; + }); + + it('should handle invalid JSON body', async () => { + let onErrorCalled = false; + const handler = new WebhookHandler(); + handler.onError = (err) => { + onErrorCalled = true; + }; + + await handler.handle('invalid json'); + expect(onErrorCalled).to.be.true; + }); + + it('should support custom validator', async () => { + let validatorCalled = false; + const handler = new WebhookHandler(); + handler.requestValidator = (headers) => { + validatorCalled = true; + if (headers?.['x-custom-header'] !== 'expected-value') { + throw new Error('missing required header'); + } + }; + + let onErrorCalled = false; + handler.onError = (err) => { + onErrorCalled = true; + expect(err.message).to.equal('missing required header'); + }; + + // Fail case + await handler.handle(makeEventBody('pending_invoice_created'), {}); + expect(validatorCalled).to.be.true; + expect(onErrorCalled).to.be.true; + + // Success case + validatorCalled = false; + onErrorCalled = false; + await handler.handle(makeEventBody('pending_invoice_created'), { + 'x-custom-header': 'expected-value', + }); + expect(validatorCalled).to.be.true; + expect(onErrorCalled).to.be.false; + }); +}); + +describe('BasicAuthValidator', () => { + const validator = basicAuthValidator((username, password) => { + return username === 'testuser' && password === 'testpass'; + }); + + it('should validate valid credentials', () => { + const auth = 'Basic ' + Buffer.from('testuser:testpass').toString('base64'); + expect(() => validator({ authorization: auth })).to.not.throw(); + }); + + it('should reject invalid credentials', () => { + const auth = 'Basic ' + Buffer.from('wrong:wrong').toString('base64'); + expect(() => validator({ authorization: auth })).to.throw( + 'Invalid credentials', + ); + }); + + it('should reject missing header', () => { + expect(() => validator({})).to.throw('Invalid authorization header'); + }); + + it('should reject invalid scheme', () => { + expect(() => validator({ authorization: 'Bearer token' })).to.throw( + 'Invalid authorization header', + ); + }); + + it('should reject invalid credentials format', () => { + // Node's Buffer.from() decodes base64 leniently, so this tests the credentials format check + expect(() => validator({ authorization: 'Basic invalid!!!' })).to.throw( + 'Invalid credentials', + ); + }); + + it('should integrate with WebhookHandler', async () => { + let callbackCalled = false; + const handler = new WebhookHandler(); + handler.requestValidator = validator; + handler.onPendingInvoiceCreated = async () => { + callbackCalled = true; + }; + + const auth = 'Basic ' + Buffer.from('testuser:testpass').toString('base64'); + const body = JSON.stringify({ + event_type: 'pending_invoice_created', + content: {}, + }); + + await handler.handle(body, { authorization: auth }); + expect(callbackCalled).to.be.true; + }); +}); diff --git a/tsconfig.json b/tsconfig.json index be0fef8..0dc8a91 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "noEmit": true, "types": [ - "node" + "node", + "mocha" ] }, "ts-node": { @@ -11,5 +12,6 @@ }, "include": [ "src/**/*.ts", + "test/**/*.ts" ] } \ No newline at end of file diff --git a/types/index.d.ts b/types/index.d.ts index faa4e65..4cb9f6c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -248,4 +248,35 @@ declare module 'chargebee' { virtualBankAccount: VirtualBankAccount.VirtualBankAccountResource; webhookEndpoint: WebhookEndpoint.WebhookEndpointResource; } + + // Webhook Handler + export class WebhookHandler { + constructor(handlers?: Record Promise>); + handle( + body: string | object, + headers?: Record, + ): Promise; + onUnhandledEvent?: (event: WebhookEvent) => Promise; + onError?: (error: any) => void; + requestValidator?: ( + headers: Record, + ) => void; + } + + // Webhook Auth + export function basicAuthValidator( + validateCredentials: (username: string, password: string) => boolean, + ): (headers: Record) => void; + + // Additional webhook content types not in WebhookEvent.d.ts + // Note: These use lowercase property names to match the actual webhook JSON structure + export type AddonCreatedContent = { + addon: Addon; + }; + export type AddonUpdatedContent = { + addon: Addon; + }; + export type AddonDeletedContent = { + addon: Addon; + }; } From 930e6b9c5b0bc8b108cdfbc8ecb52fbe762a865b Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Mon, 1 Dec 2025 13:17:35 +0530 Subject: [PATCH 02/11] moved to event emitter appraoach --- src/chargebee.cjs.ts | 5 +- src/chargebee.esm.ts | 9 +- src/resources/webhook/event_types.ts | 449 -- src/resources/webhook/handler.ts | 6719 +------------------------- test/webhook.test.ts | 163 +- types/index.d.ts | 10 +- 6 files changed, 186 insertions(+), 7169 deletions(-) delete mode 100644 src/resources/webhook/event_types.ts diff --git a/src/chargebee.cjs.ts b/src/chargebee.cjs.ts index 51996f5..2f2f19b 100644 --- a/src/chargebee.cjs.ts +++ b/src/chargebee.cjs.ts @@ -13,6 +13,5 @@ module.exports.default = Chargebee; module.exports.WebhookHandler = WebhookHandler; module.exports.basicAuthValidator = basicAuthValidator; -// Export webhook types (for TypeScript users) -export type * from './resources/webhook/content.js'; -export type * from './resources/webhook/event_types.js'; +// Export webhook types +export type { WebhookEvent } from './resources/webhook/content.js'; diff --git a/src/chargebee.esm.ts b/src/chargebee.esm.ts index 9053f33..d1a08df 100644 --- a/src/chargebee.esm.ts +++ b/src/chargebee.esm.ts @@ -6,10 +6,9 @@ const Chargebee = CreateChargebee(httpClient); export default Chargebee; -// Export webhook modules - runtime exports -export { WebhookHandler } from './resources/webhook/handler.js'; +// Export webhook modules +export { WebhookHandler, EventType } from './resources/webhook/handler.js'; export { basicAuthValidator } from './resources/webhook/auth.js'; -// Export webhook types only (no runtime impact) -export type * from './resources/webhook/content.js'; -export type * from './resources/webhook/event_types.js'; +// Export webhook types +export type { WebhookEvent } from './resources/webhook/content.js'; diff --git a/src/resources/webhook/event_types.ts b/src/resources/webhook/event_types.ts deleted file mode 100644 index f574712..0000000 --- a/src/resources/webhook/event_types.ts +++ /dev/null @@ -1,449 +0,0 @@ -export enum EventType { - ADD_USAGES_REMINDER = 'add_usages_reminder', - - ADDON_CREATED = 'addon_created', - - ADDON_DELETED = 'addon_deleted', - - ADDON_UPDATED = 'addon_updated', - - ATTACHED_ITEM_CREATED = 'attached_item_created', - - ATTACHED_ITEM_DELETED = 'attached_item_deleted', - - ATTACHED_ITEM_UPDATED = 'attached_item_updated', - - AUTHORIZATION_SUCCEEDED = 'authorization_succeeded', - - AUTHORIZATION_VOIDED = 'authorization_voided', - - BUSINESS_ENTITY_CREATED = 'business_entity_created', - - BUSINESS_ENTITY_DELETED = 'business_entity_deleted', - - BUSINESS_ENTITY_UPDATED = 'business_entity_updated', - - CARD_ADDED = 'card_added', - - CARD_DELETED = 'card_deleted', - - CARD_EXPIRED = 'card_expired', - - CARD_EXPIRY_REMINDER = 'card_expiry_reminder', - - CARD_UPDATED = 'card_updated', - - CONTRACT_TERM_CANCELLED = 'contract_term_cancelled', - - CONTRACT_TERM_COMPLETED = 'contract_term_completed', - - CONTRACT_TERM_CREATED = 'contract_term_created', - - CONTRACT_TERM_RENEWED = 'contract_term_renewed', - - CONTRACT_TERM_TERMINATED = 'contract_term_terminated', - - COUPON_CODES_ADDED = 'coupon_codes_added', - - COUPON_CODES_DELETED = 'coupon_codes_deleted', - - COUPON_CODES_UPDATED = 'coupon_codes_updated', - - COUPON_CREATED = 'coupon_created', - - COUPON_DELETED = 'coupon_deleted', - - COUPON_SET_CREATED = 'coupon_set_created', - - COUPON_SET_DELETED = 'coupon_set_deleted', - - COUPON_SET_UPDATED = 'coupon_set_updated', - - COUPON_UPDATED = 'coupon_updated', - - CREDIT_NOTE_CREATED = 'credit_note_created', - - CREDIT_NOTE_CREATED_WITH_BACKDATING = 'credit_note_created_with_backdating', - - CREDIT_NOTE_DELETED = 'credit_note_deleted', - - CREDIT_NOTE_UPDATED = 'credit_note_updated', - - CUSTOMER_BUSINESS_ENTITY_CHANGED = 'customer_business_entity_changed', - - CUSTOMER_CHANGED = 'customer_changed', - - CUSTOMER_CREATED = 'customer_created', - - CUSTOMER_DELETED = 'customer_deleted', - - CUSTOMER_ENTITLEMENTS_UPDATED = 'customer_entitlements_updated', - - CUSTOMER_MOVED_IN = 'customer_moved_in', - - CUSTOMER_MOVED_OUT = 'customer_moved_out', - - DIFFERENTIAL_PRICE_CREATED = 'differential_price_created', - - DIFFERENTIAL_PRICE_DELETED = 'differential_price_deleted', - - DIFFERENTIAL_PRICE_UPDATED = 'differential_price_updated', - - DUNNING_UPDATED = 'dunning_updated', - - ENTITLEMENT_OVERRIDES_AUTO_REMOVED = 'entitlement_overrides_auto_removed', - - ENTITLEMENT_OVERRIDES_REMOVED = 'entitlement_overrides_removed', - - ENTITLEMENT_OVERRIDES_UPDATED = 'entitlement_overrides_updated', - - FEATURE_ACTIVATED = 'feature_activated', - - FEATURE_ARCHIVED = 'feature_archived', - - FEATURE_CREATED = 'feature_created', - - FEATURE_DELETED = 'feature_deleted', - - FEATURE_REACTIVATED = 'feature_reactivated', - - FEATURE_UPDATED = 'feature_updated', - - GIFT_CANCELLED = 'gift_cancelled', - - GIFT_CLAIMED = 'gift_claimed', - - GIFT_EXPIRED = 'gift_expired', - - GIFT_SCHEDULED = 'gift_scheduled', - - GIFT_UNCLAIMED = 'gift_unclaimed', - - GIFT_UPDATED = 'gift_updated', - - HIERARCHY_CREATED = 'hierarchy_created', - - HIERARCHY_DELETED = 'hierarchy_deleted', - - INVOICE_DELETED = 'invoice_deleted', - - INVOICE_GENERATED = 'invoice_generated', - - INVOICE_GENERATED_WITH_BACKDATING = 'invoice_generated_with_backdating', - - INVOICE_UPDATED = 'invoice_updated', - - ITEM_CREATED = 'item_created', - - ITEM_DELETED = 'item_deleted', - - ITEM_ENTITLEMENTS_REMOVED = 'item_entitlements_removed', - - ITEM_ENTITLEMENTS_UPDATED = 'item_entitlements_updated', - - ITEM_FAMILY_CREATED = 'item_family_created', - - ITEM_FAMILY_DELETED = 'item_family_deleted', - - ITEM_FAMILY_UPDATED = 'item_family_updated', - - ITEM_PRICE_CREATED = 'item_price_created', - - ITEM_PRICE_DELETED = 'item_price_deleted', - - ITEM_PRICE_ENTITLEMENTS_REMOVED = 'item_price_entitlements_removed', - - ITEM_PRICE_ENTITLEMENTS_UPDATED = 'item_price_entitlements_updated', - - ITEM_PRICE_UPDATED = 'item_price_updated', - - ITEM_UPDATED = 'item_updated', - - MRR_UPDATED = 'mrr_updated', - - NETD_PAYMENT_DUE_REMINDER = 'netd_payment_due_reminder', - - OMNICHANNEL_ONE_TIME_ORDER_CREATED = 'omnichannel_one_time_order_created', - - OMNICHANNEL_ONE_TIME_ORDER_ITEM_CANCELLED = 'omnichannel_one_time_order_item_cancelled', - - OMNICHANNEL_SUBSCRIPTION_CREATED = 'omnichannel_subscription_created', - - OMNICHANNEL_SUBSCRIPTION_IMPORTED = 'omnichannel_subscription_imported', - - OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLATION_SCHEDULED = 'omnichannel_subscription_item_cancellation_scheduled', - - OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLED = 'omnichannel_subscription_item_cancelled', - - OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGE_SCHEDULED = 'omnichannel_subscription_item_change_scheduled', - - OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGED = 'omnichannel_subscription_item_changed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADE_SCHEDULED = 'omnichannel_subscription_item_downgrade_scheduled', - - OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADED = 'omnichannel_subscription_item_downgraded', - - OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_EXPIRED = 'omnichannel_subscription_item_dunning_expired', - - OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_STARTED = 'omnichannel_subscription_item_dunning_started', - - OMNICHANNEL_SUBSCRIPTION_ITEM_EXPIRED = 'omnichannel_subscription_item_expired', - - OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_EXPIRED = 'omnichannel_subscription_item_grace_period_expired', - - OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_STARTED = 'omnichannel_subscription_item_grace_period_started', - - OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSE_SCHEDULED = 'omnichannel_subscription_item_pause_scheduled', - - OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSED = 'omnichannel_subscription_item_paused', - - OMNICHANNEL_SUBSCRIPTION_ITEM_REACTIVATED = 'omnichannel_subscription_item_reactivated', - - OMNICHANNEL_SUBSCRIPTION_ITEM_RENEWED = 'omnichannel_subscription_item_renewed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_RESUBSCRIBED = 'omnichannel_subscription_item_resubscribed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_RESUMED = 'omnichannel_subscription_item_resumed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CANCELLATION_REMOVED = 'omnichannel_subscription_item_scheduled_cancellation_removed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CHANGE_REMOVED = 'omnichannel_subscription_item_scheduled_change_removed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_DOWNGRADE_REMOVED = 'omnichannel_subscription_item_scheduled_downgrade_removed', - - OMNICHANNEL_SUBSCRIPTION_ITEM_UPGRADED = 'omnichannel_subscription_item_upgraded', - - OMNICHANNEL_SUBSCRIPTION_MOVED_IN = 'omnichannel_subscription_moved_in', - - OMNICHANNEL_TRANSACTION_CREATED = 'omnichannel_transaction_created', - - ORDER_CANCELLED = 'order_cancelled', - - ORDER_CREATED = 'order_created', - - ORDER_DELETED = 'order_deleted', - - ORDER_DELIVERED = 'order_delivered', - - ORDER_READY_TO_PROCESS = 'order_ready_to_process', - - ORDER_READY_TO_SHIP = 'order_ready_to_ship', - - ORDER_RESENT = 'order_resent', - - ORDER_RETURNED = 'order_returned', - - ORDER_UPDATED = 'order_updated', - - PAYMENT_FAILED = 'payment_failed', - - PAYMENT_INITIATED = 'payment_initiated', - - PAYMENT_INTENT_CREATED = 'payment_intent_created', - - PAYMENT_INTENT_UPDATED = 'payment_intent_updated', - - PAYMENT_REFUNDED = 'payment_refunded', - - PAYMENT_SCHEDULE_SCHEME_CREATED = 'payment_schedule_scheme_created', - - PAYMENT_SCHEDULE_SCHEME_DELETED = 'payment_schedule_scheme_deleted', - - PAYMENT_SCHEDULES_CREATED = 'payment_schedules_created', - - PAYMENT_SCHEDULES_UPDATED = 'payment_schedules_updated', - - PAYMENT_SOURCE_ADDED = 'payment_source_added', - - PAYMENT_SOURCE_DELETED = 'payment_source_deleted', - - PAYMENT_SOURCE_EXPIRED = 'payment_source_expired', - - PAYMENT_SOURCE_EXPIRING = 'payment_source_expiring', - - PAYMENT_SOURCE_LOCALLY_DELETED = 'payment_source_locally_deleted', - - PAYMENT_SOURCE_UPDATED = 'payment_source_updated', - - PAYMENT_SUCCEEDED = 'payment_succeeded', - - PENDING_INVOICE_CREATED = 'pending_invoice_created', - - PENDING_INVOICE_UPDATED = 'pending_invoice_updated', - - PLAN_CREATED = 'plan_created', - - PLAN_DELETED = 'plan_deleted', - - PLAN_UPDATED = 'plan_updated', - - PRICE_VARIANT_CREATED = 'price_variant_created', - - PRICE_VARIANT_DELETED = 'price_variant_deleted', - - PRICE_VARIANT_UPDATED = 'price_variant_updated', - - PRODUCT_CREATED = 'product_created', - - PRODUCT_DELETED = 'product_deleted', - - PRODUCT_UPDATED = 'product_updated', - - PROMOTIONAL_CREDITS_ADDED = 'promotional_credits_added', - - PROMOTIONAL_CREDITS_DEDUCTED = 'promotional_credits_deducted', - - PURCHASE_CREATED = 'purchase_created', - - QUOTE_CREATED = 'quote_created', - - QUOTE_DELETED = 'quote_deleted', - - QUOTE_UPDATED = 'quote_updated', - - RECORD_PURCHASE_FAILED = 'record_purchase_failed', - - REFUND_INITIATED = 'refund_initiated', - - RULE_CREATED = 'rule_created', - - RULE_DELETED = 'rule_deleted', - - RULE_UPDATED = 'rule_updated', - - SALES_ORDER_CREATED = 'sales_order_created', - - SALES_ORDER_UPDATED = 'sales_order_updated', - - SUBSCRIPTION_ACTIVATED = 'subscription_activated', - - SUBSCRIPTION_ACTIVATED_WITH_BACKDATING = 'subscription_activated_with_backdating', - - SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_ADDED = 'subscription_advance_invoice_schedule_added', - - SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_REMOVED = 'subscription_advance_invoice_schedule_removed', - - SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_UPDATED = 'subscription_advance_invoice_schedule_updated', - - SUBSCRIPTION_BUSINESS_ENTITY_CHANGED = 'subscription_business_entity_changed', - - SUBSCRIPTION_CANCELED_WITH_BACKDATING = 'subscription_canceled_with_backdating', - - SUBSCRIPTION_CANCELLATION_REMINDER = 'subscription_cancellation_reminder', - - SUBSCRIPTION_CANCELLATION_SCHEDULED = 'subscription_cancellation_scheduled', - - SUBSCRIPTION_CANCELLED = 'subscription_cancelled', - - SUBSCRIPTION_CHANGED = 'subscription_changed', - - SUBSCRIPTION_CHANGED_WITH_BACKDATING = 'subscription_changed_with_backdating', - - SUBSCRIPTION_CHANGES_SCHEDULED = 'subscription_changes_scheduled', - - SUBSCRIPTION_CREATED = 'subscription_created', - - SUBSCRIPTION_CREATED_WITH_BACKDATING = 'subscription_created_with_backdating', - - SUBSCRIPTION_DELETED = 'subscription_deleted', - - SUBSCRIPTION_ENTITLEMENTS_CREATED = 'subscription_entitlements_created', - - SUBSCRIPTION_ENTITLEMENTS_UPDATED = 'subscription_entitlements_updated', - - SUBSCRIPTION_ITEMS_RENEWED = 'subscription_items_renewed', - - SUBSCRIPTION_MOVED_IN = 'subscription_moved_in', - - SUBSCRIPTION_MOVED_OUT = 'subscription_moved_out', - - SUBSCRIPTION_MOVEMENT_FAILED = 'subscription_movement_failed', - - SUBSCRIPTION_PAUSE_SCHEDULED = 'subscription_pause_scheduled', - - SUBSCRIPTION_PAUSED = 'subscription_paused', - - SUBSCRIPTION_RAMP_APPLIED = 'subscription_ramp_applied', - - SUBSCRIPTION_RAMP_CREATED = 'subscription_ramp_created', - - SUBSCRIPTION_RAMP_DELETED = 'subscription_ramp_deleted', - - SUBSCRIPTION_RAMP_DRAFTED = 'subscription_ramp_drafted', - - SUBSCRIPTION_RAMP_UPDATED = 'subscription_ramp_updated', - - SUBSCRIPTION_REACTIVATED = 'subscription_reactivated', - - SUBSCRIPTION_REACTIVATED_WITH_BACKDATING = 'subscription_reactivated_with_backdating', - - SUBSCRIPTION_RENEWAL_REMINDER = 'subscription_renewal_reminder', - - SUBSCRIPTION_RENEWED = 'subscription_renewed', - - SUBSCRIPTION_RESUMED = 'subscription_resumed', - - SUBSCRIPTION_RESUMPTION_SCHEDULED = 'subscription_resumption_scheduled', - - SUBSCRIPTION_SCHEDULED_CANCELLATION_REMOVED = 'subscription_scheduled_cancellation_removed', - - SUBSCRIPTION_SCHEDULED_CHANGES_REMOVED = 'subscription_scheduled_changes_removed', - - SUBSCRIPTION_SCHEDULED_PAUSE_REMOVED = 'subscription_scheduled_pause_removed', - - SUBSCRIPTION_SCHEDULED_RESUMPTION_REMOVED = 'subscription_scheduled_resumption_removed', - - SUBSCRIPTION_SHIPPING_ADDRESS_UPDATED = 'subscription_shipping_address_updated', - - SUBSCRIPTION_STARTED = 'subscription_started', - - SUBSCRIPTION_TRIAL_END_REMINDER = 'subscription_trial_end_reminder', - - SUBSCRIPTION_TRIAL_EXTENDED = 'subscription_trial_extended', - - TAX_WITHHELD_DELETED = 'tax_withheld_deleted', - - TAX_WITHHELD_RECORDED = 'tax_withheld_recorded', - - TAX_WITHHELD_REFUNDED = 'tax_withheld_refunded', - - TOKEN_CONSUMED = 'token_consumed', - - TOKEN_CREATED = 'token_created', - - TOKEN_EXPIRED = 'token_expired', - - TRANSACTION_CREATED = 'transaction_created', - - TRANSACTION_DELETED = 'transaction_deleted', - - TRANSACTION_UPDATED = 'transaction_updated', - - UNBILLED_CHARGES_CREATED = 'unbilled_charges_created', - - UNBILLED_CHARGES_DELETED = 'unbilled_charges_deleted', - - UNBILLED_CHARGES_INVOICED = 'unbilled_charges_invoiced', - - UNBILLED_CHARGES_VOIDED = 'unbilled_charges_voided', - - USAGE_FILE_INGESTED = 'usage_file_ingested', - - VARIANT_CREATED = 'variant_created', - - VARIANT_DELETED = 'variant_deleted', - - VARIANT_UPDATED = 'variant_updated', - - VIRTUAL_BANK_ACCOUNT_ADDED = 'virtual_bank_account_added', - - VIRTUAL_BANK_ACCOUNT_DELETED = 'virtual_bank_account_deleted', - - VIRTUAL_BANK_ACCOUNT_UPDATED = 'virtual_bank_account_updated', - - VOUCHER_CREATE_FAILED = 'voucher_create_failed', - - VOUCHER_CREATED = 'voucher_created', - - VOUCHER_EXPIRED = 'voucher_expired', -} diff --git a/src/resources/webhook/handler.ts b/src/resources/webhook/handler.ts index 33f618a..0d8499e 100644 --- a/src/resources/webhook/handler.ts +++ b/src/resources/webhook/handler.ts @@ -1,6700 +1,73 @@ -import { EventType } from './event_types.js'; -import { - AddUsagesReminderContent, - AddonCreatedContent, - AddonDeletedContent, - AddonUpdatedContent, - AttachedItemCreatedContent, - AttachedItemDeletedContent, - AttachedItemUpdatedContent, - AuthorizationSucceededContent, - AuthorizationVoidedContent, - BusinessEntityCreatedContent, - BusinessEntityDeletedContent, - BusinessEntityUpdatedContent, - CardAddedContent, - CardDeletedContent, - CardExpiredContent, - CardExpiryReminderContent, - CardUpdatedContent, - ContractTermCancelledContent, - ContractTermCompletedContent, - ContractTermCreatedContent, - ContractTermRenewedContent, - ContractTermTerminatedContent, - CouponCodesAddedContent, - CouponCodesDeletedContent, - CouponCodesUpdatedContent, - CouponCreatedContent, - CouponDeletedContent, - CouponSetCreatedContent, - CouponSetDeletedContent, - CouponSetUpdatedContent, - CouponUpdatedContent, - CreditNoteCreatedContent, - CreditNoteCreatedWithBackdatingContent, - CreditNoteDeletedContent, - CreditNoteUpdatedContent, - CustomerBusinessEntityChangedContent, - CustomerChangedContent, - CustomerCreatedContent, - CustomerDeletedContent, - CustomerEntitlementsUpdatedContent, - CustomerMovedInContent, - CustomerMovedOutContent, - DifferentialPriceCreatedContent, - DifferentialPriceDeletedContent, - DifferentialPriceUpdatedContent, - DunningUpdatedContent, - EntitlementOverridesAutoRemovedContent, - EntitlementOverridesRemovedContent, - EntitlementOverridesUpdatedContent, - FeatureActivatedContent, - FeatureArchivedContent, - FeatureCreatedContent, - FeatureDeletedContent, - FeatureReactivatedContent, - FeatureUpdatedContent, - GiftCancelledContent, - GiftClaimedContent, - GiftExpiredContent, - GiftScheduledContent, - GiftUnclaimedContent, - GiftUpdatedContent, - HierarchyCreatedContent, - HierarchyDeletedContent, - InvoiceDeletedContent, - InvoiceGeneratedContent, - InvoiceGeneratedWithBackdatingContent, - InvoiceUpdatedContent, - ItemCreatedContent, - ItemDeletedContent, - ItemEntitlementsRemovedContent, - ItemEntitlementsUpdatedContent, - ItemFamilyCreatedContent, - ItemFamilyDeletedContent, - ItemFamilyUpdatedContent, - ItemPriceCreatedContent, - ItemPriceDeletedContent, - ItemPriceEntitlementsRemovedContent, - ItemPriceEntitlementsUpdatedContent, - ItemPriceUpdatedContent, - ItemUpdatedContent, - MrrUpdatedContent, - NetdPaymentDueReminderContent, - OmnichannelOneTimeOrderCreatedContent, - OmnichannelOneTimeOrderItemCancelledContent, - OmnichannelSubscriptionCreatedContent, - OmnichannelSubscriptionImportedContent, - OmnichannelSubscriptionItemCancellationScheduledContent, - OmnichannelSubscriptionItemCancelledContent, - OmnichannelSubscriptionItemChangeScheduledContent, - OmnichannelSubscriptionItemChangedContent, - OmnichannelSubscriptionItemDowngradeScheduledContent, - OmnichannelSubscriptionItemDowngradedContent, - OmnichannelSubscriptionItemDunningExpiredContent, - OmnichannelSubscriptionItemDunningStartedContent, - OmnichannelSubscriptionItemExpiredContent, - OmnichannelSubscriptionItemGracePeriodExpiredContent, - OmnichannelSubscriptionItemGracePeriodStartedContent, - OmnichannelSubscriptionItemPauseScheduledContent, - OmnichannelSubscriptionItemPausedContent, - OmnichannelSubscriptionItemReactivatedContent, - OmnichannelSubscriptionItemRenewedContent, - OmnichannelSubscriptionItemResubscribedContent, - OmnichannelSubscriptionItemResumedContent, - OmnichannelSubscriptionItemScheduledCancellationRemovedContent, - OmnichannelSubscriptionItemScheduledChangeRemovedContent, - OmnichannelSubscriptionItemScheduledDowngradeRemovedContent, - OmnichannelSubscriptionItemUpgradedContent, - OmnichannelSubscriptionMovedInContent, - OmnichannelTransactionCreatedContent, - OrderCancelledContent, - OrderCreatedContent, - OrderDeletedContent, - OrderDeliveredContent, - OrderReadyToProcessContent, - OrderReadyToShipContent, - OrderResentContent, - OrderReturnedContent, - OrderUpdatedContent, - PaymentFailedContent, - PaymentInitiatedContent, - PaymentIntentCreatedContent, - PaymentIntentUpdatedContent, - PaymentRefundedContent, - PaymentScheduleSchemeCreatedContent, - PaymentScheduleSchemeDeletedContent, - PaymentSchedulesCreatedContent, - PaymentSchedulesUpdatedContent, - PaymentSourceAddedContent, - PaymentSourceDeletedContent, - PaymentSourceExpiredContent, - PaymentSourceExpiringContent, - PaymentSourceLocallyDeletedContent, - PaymentSourceUpdatedContent, - PaymentSucceededContent, - PendingInvoiceCreatedContent, - PendingInvoiceUpdatedContent, - PlanCreatedContent, - PlanDeletedContent, - PlanUpdatedContent, - PriceVariantCreatedContent, - PriceVariantDeletedContent, - PriceVariantUpdatedContent, - ProductCreatedContent, - ProductDeletedContent, - ProductUpdatedContent, - PromotionalCreditsAddedContent, - PromotionalCreditsDeductedContent, - PurchaseCreatedContent, - QuoteCreatedContent, - QuoteDeletedContent, - QuoteUpdatedContent, - RecordPurchaseFailedContent, - RefundInitiatedContent, - RuleCreatedContent, - RuleDeletedContent, - RuleUpdatedContent, - SalesOrderCreatedContent, - SalesOrderUpdatedContent, - SubscriptionActivatedContent, - SubscriptionActivatedWithBackdatingContent, - SubscriptionAdvanceInvoiceScheduleAddedContent, - SubscriptionAdvanceInvoiceScheduleRemovedContent, - SubscriptionAdvanceInvoiceScheduleUpdatedContent, - SubscriptionBusinessEntityChangedContent, - SubscriptionCanceledWithBackdatingContent, - SubscriptionCancellationReminderContent, - SubscriptionCancellationScheduledContent, - SubscriptionCancelledContent, - SubscriptionChangedContent, - SubscriptionChangedWithBackdatingContent, - SubscriptionChangesScheduledContent, - SubscriptionCreatedContent, - SubscriptionCreatedWithBackdatingContent, - SubscriptionDeletedContent, - SubscriptionEntitlementsCreatedContent, - SubscriptionEntitlementsUpdatedContent, - SubscriptionItemsRenewedContent, - SubscriptionMovedInContent, - SubscriptionMovedOutContent, - SubscriptionMovementFailedContent, - SubscriptionPauseScheduledContent, - SubscriptionPausedContent, - SubscriptionRampAppliedContent, - SubscriptionRampCreatedContent, - SubscriptionRampDeletedContent, - SubscriptionRampDraftedContent, - SubscriptionRampUpdatedContent, - SubscriptionReactivatedContent, - SubscriptionReactivatedWithBackdatingContent, - SubscriptionRenewalReminderContent, - SubscriptionRenewedContent, - SubscriptionResumedContent, - SubscriptionResumptionScheduledContent, - SubscriptionScheduledCancellationRemovedContent, - SubscriptionScheduledChangesRemovedContent, - SubscriptionScheduledPauseRemovedContent, - SubscriptionScheduledResumptionRemovedContent, - SubscriptionShippingAddressUpdatedContent, - SubscriptionStartedContent, - SubscriptionTrialEndReminderContent, - SubscriptionTrialExtendedContent, - TaxWithheldDeletedContent, - TaxWithheldRecordedContent, - TaxWithheldRefundedContent, - TokenConsumedContent, - TokenCreatedContent, - TokenExpiredContent, - TransactionCreatedContent, - TransactionDeletedContent, - TransactionUpdatedContent, - UnbilledChargesCreatedContent, - UnbilledChargesDeletedContent, - UnbilledChargesInvoicedContent, - UnbilledChargesVoidedContent, - UsageFileIngestedContent, - VariantCreatedContent, - VariantDeletedContent, - VariantUpdatedContent, - VirtualBankAccountAddedContent, - VirtualBankAccountDeletedContent, - VirtualBankAccountUpdatedContent, - VoucherCreateFailedContent, - VoucherCreatedContent, - VoucherExpiredContent, - WebhookEvent, -} from './content.js'; +import { EventEmitter } from 'node:events'; +import { WebhookEvent } from './content.js'; -export interface WebhookHandlers { - onAddUsagesReminder?: ( - event: WebhookEvent & { content: AddUsagesReminderContent }, - ) => Promise; +export type EventType = import('chargebee').EventTypeEnum; - onAddonCreated?: ( - event: WebhookEvent & { content: AddonCreatedContent }, - ) => Promise; - - onAddonDeleted?: ( - event: WebhookEvent & { content: AddonDeletedContent }, - ) => Promise; - - onAddonUpdated?: ( - event: WebhookEvent & { content: AddonUpdatedContent }, - ) => Promise; - - onAttachedItemCreated?: ( - event: WebhookEvent & { content: AttachedItemCreatedContent }, - ) => Promise; - - onAttachedItemDeleted?: ( - event: WebhookEvent & { content: AttachedItemDeletedContent }, - ) => Promise; - - onAttachedItemUpdated?: ( - event: WebhookEvent & { content: AttachedItemUpdatedContent }, - ) => Promise; - - onAuthorizationSucceeded?: ( - event: WebhookEvent & { content: AuthorizationSucceededContent }, - ) => Promise; - - onAuthorizationVoided?: ( - event: WebhookEvent & { content: AuthorizationVoidedContent }, - ) => Promise; - - onBusinessEntityCreated?: ( - event: WebhookEvent & { content: BusinessEntityCreatedContent }, - ) => Promise; - - onBusinessEntityDeleted?: ( - event: WebhookEvent & { content: BusinessEntityDeletedContent }, - ) => Promise; - - onBusinessEntityUpdated?: ( - event: WebhookEvent & { content: BusinessEntityUpdatedContent }, - ) => Promise; - - onCardAdded?: ( - event: WebhookEvent & { content: CardAddedContent }, - ) => Promise; - - onCardDeleted?: ( - event: WebhookEvent & { content: CardDeletedContent }, - ) => Promise; - - onCardExpired?: ( - event: WebhookEvent & { content: CardExpiredContent }, - ) => Promise; - - onCardExpiryReminder?: ( - event: WebhookEvent & { content: CardExpiryReminderContent }, - ) => Promise; - - onCardUpdated?: ( - event: WebhookEvent & { content: CardUpdatedContent }, - ) => Promise; - - onContractTermCancelled?: ( - event: WebhookEvent & { content: ContractTermCancelledContent }, - ) => Promise; - - onContractTermCompleted?: ( - event: WebhookEvent & { content: ContractTermCompletedContent }, - ) => Promise; - - onContractTermCreated?: ( - event: WebhookEvent & { content: ContractTermCreatedContent }, - ) => Promise; - - onContractTermRenewed?: ( - event: WebhookEvent & { content: ContractTermRenewedContent }, - ) => Promise; - - onContractTermTerminated?: ( - event: WebhookEvent & { content: ContractTermTerminatedContent }, - ) => Promise; - - onCouponCodesAdded?: ( - event: WebhookEvent & { content: CouponCodesAddedContent }, - ) => Promise; - - onCouponCodesDeleted?: ( - event: WebhookEvent & { content: CouponCodesDeletedContent }, - ) => Promise; - - onCouponCodesUpdated?: ( - event: WebhookEvent & { content: CouponCodesUpdatedContent }, - ) => Promise; - - onCouponCreated?: ( - event: WebhookEvent & { content: CouponCreatedContent }, - ) => Promise; - - onCouponDeleted?: ( - event: WebhookEvent & { content: CouponDeletedContent }, - ) => Promise; - - onCouponSetCreated?: ( - event: WebhookEvent & { content: CouponSetCreatedContent }, - ) => Promise; - - onCouponSetDeleted?: ( - event: WebhookEvent & { content: CouponSetDeletedContent }, - ) => Promise; - - onCouponSetUpdated?: ( - event: WebhookEvent & { content: CouponSetUpdatedContent }, - ) => Promise; - - onCouponUpdated?: ( - event: WebhookEvent & { content: CouponUpdatedContent }, - ) => Promise; - - onCreditNoteCreated?: ( - event: WebhookEvent & { content: CreditNoteCreatedContent }, - ) => Promise; - - onCreditNoteCreatedWithBackdating?: ( - event: WebhookEvent & { content: CreditNoteCreatedWithBackdatingContent }, - ) => Promise; - - onCreditNoteDeleted?: ( - event: WebhookEvent & { content: CreditNoteDeletedContent }, - ) => Promise; - - onCreditNoteUpdated?: ( - event: WebhookEvent & { content: CreditNoteUpdatedContent }, - ) => Promise; - - onCustomerBusinessEntityChanged?: ( - event: WebhookEvent & { content: CustomerBusinessEntityChangedContent }, - ) => Promise; - - onCustomerChanged?: ( - event: WebhookEvent & { content: CustomerChangedContent }, - ) => Promise; - - onCustomerCreated?: ( - event: WebhookEvent & { content: CustomerCreatedContent }, - ) => Promise; - - onCustomerDeleted?: ( - event: WebhookEvent & { content: CustomerDeletedContent }, - ) => Promise; - - onCustomerEntitlementsUpdated?: ( - event: WebhookEvent & { content: CustomerEntitlementsUpdatedContent }, - ) => Promise; - - onCustomerMovedIn?: ( - event: WebhookEvent & { content: CustomerMovedInContent }, - ) => Promise; - - onCustomerMovedOut?: ( - event: WebhookEvent & { content: CustomerMovedOutContent }, - ) => Promise; - - onDifferentialPriceCreated?: ( - event: WebhookEvent & { content: DifferentialPriceCreatedContent }, - ) => Promise; - - onDifferentialPriceDeleted?: ( - event: WebhookEvent & { content: DifferentialPriceDeletedContent }, - ) => Promise; - - onDifferentialPriceUpdated?: ( - event: WebhookEvent & { content: DifferentialPriceUpdatedContent }, - ) => Promise; - - onDunningUpdated?: ( - event: WebhookEvent & { content: DunningUpdatedContent }, - ) => Promise; - - onEntitlementOverridesAutoRemoved?: ( - event: WebhookEvent & { content: EntitlementOverridesAutoRemovedContent }, - ) => Promise; - - onEntitlementOverridesRemoved?: ( - event: WebhookEvent & { content: EntitlementOverridesRemovedContent }, - ) => Promise; - - onEntitlementOverridesUpdated?: ( - event: WebhookEvent & { content: EntitlementOverridesUpdatedContent }, - ) => Promise; - - onFeatureActivated?: ( - event: WebhookEvent & { content: FeatureActivatedContent }, - ) => Promise; - - onFeatureArchived?: ( - event: WebhookEvent & { content: FeatureArchivedContent }, - ) => Promise; - - onFeatureCreated?: ( - event: WebhookEvent & { content: FeatureCreatedContent }, - ) => Promise; - - onFeatureDeleted?: ( - event: WebhookEvent & { content: FeatureDeletedContent }, - ) => Promise; - - onFeatureReactivated?: ( - event: WebhookEvent & { content: FeatureReactivatedContent }, - ) => Promise; - - onFeatureUpdated?: ( - event: WebhookEvent & { content: FeatureUpdatedContent }, - ) => Promise; - - onGiftCancelled?: ( - event: WebhookEvent & { content: GiftCancelledContent }, - ) => Promise; - - onGiftClaimed?: ( - event: WebhookEvent & { content: GiftClaimedContent }, - ) => Promise; - - onGiftExpired?: ( - event: WebhookEvent & { content: GiftExpiredContent }, - ) => Promise; - - onGiftScheduled?: ( - event: WebhookEvent & { content: GiftScheduledContent }, - ) => Promise; - - onGiftUnclaimed?: ( - event: WebhookEvent & { content: GiftUnclaimedContent }, - ) => Promise; - - onGiftUpdated?: ( - event: WebhookEvent & { content: GiftUpdatedContent }, - ) => Promise; - - onHierarchyCreated?: ( - event: WebhookEvent & { content: HierarchyCreatedContent }, - ) => Promise; - - onHierarchyDeleted?: ( - event: WebhookEvent & { content: HierarchyDeletedContent }, - ) => Promise; - - onInvoiceDeleted?: ( - event: WebhookEvent & { content: InvoiceDeletedContent }, - ) => Promise; - - onInvoiceGenerated?: ( - event: WebhookEvent & { content: InvoiceGeneratedContent }, - ) => Promise; - - onInvoiceGeneratedWithBackdating?: ( - event: WebhookEvent & { content: InvoiceGeneratedWithBackdatingContent }, - ) => Promise; - - onInvoiceUpdated?: ( - event: WebhookEvent & { content: InvoiceUpdatedContent }, - ) => Promise; - - onItemCreated?: ( - event: WebhookEvent & { content: ItemCreatedContent }, - ) => Promise; - - onItemDeleted?: ( - event: WebhookEvent & { content: ItemDeletedContent }, - ) => Promise; - - onItemEntitlementsRemoved?: ( - event: WebhookEvent & { content: ItemEntitlementsRemovedContent }, - ) => Promise; - - onItemEntitlementsUpdated?: ( - event: WebhookEvent & { content: ItemEntitlementsUpdatedContent }, - ) => Promise; - - onItemFamilyCreated?: ( - event: WebhookEvent & { content: ItemFamilyCreatedContent }, - ) => Promise; - - onItemFamilyDeleted?: ( - event: WebhookEvent & { content: ItemFamilyDeletedContent }, - ) => Promise; - - onItemFamilyUpdated?: ( - event: WebhookEvent & { content: ItemFamilyUpdatedContent }, - ) => Promise; - - onItemPriceCreated?: ( - event: WebhookEvent & { content: ItemPriceCreatedContent }, - ) => Promise; - - onItemPriceDeleted?: ( - event: WebhookEvent & { content: ItemPriceDeletedContent }, - ) => Promise; - - onItemPriceEntitlementsRemoved?: ( - event: WebhookEvent & { content: ItemPriceEntitlementsRemovedContent }, - ) => Promise; - - onItemPriceEntitlementsUpdated?: ( - event: WebhookEvent & { content: ItemPriceEntitlementsUpdatedContent }, - ) => Promise; - - onItemPriceUpdated?: ( - event: WebhookEvent & { content: ItemPriceUpdatedContent }, - ) => Promise; - - onItemUpdated?: ( - event: WebhookEvent & { content: ItemUpdatedContent }, - ) => Promise; - - onMrrUpdated?: ( - event: WebhookEvent & { content: MrrUpdatedContent }, - ) => Promise; - - onNetdPaymentDueReminder?: ( - event: WebhookEvent & { content: NetdPaymentDueReminderContent }, - ) => Promise; - - onOmnichannelOneTimeOrderCreated?: ( - event: WebhookEvent & { content: OmnichannelOneTimeOrderCreatedContent }, - ) => Promise; - - onOmnichannelOneTimeOrderItemCancelled?: ( - event: WebhookEvent & { - content: OmnichannelOneTimeOrderItemCancelledContent; - }, - ) => Promise; - - onOmnichannelSubscriptionCreated?: ( - event: WebhookEvent & { content: OmnichannelSubscriptionCreatedContent }, - ) => Promise; - - onOmnichannelSubscriptionImported?: ( - event: WebhookEvent & { content: OmnichannelSubscriptionImportedContent }, - ) => Promise; - - onOmnichannelSubscriptionItemCancellationScheduled?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemCancellationScheduledContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemCancelled?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemCancelledContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemChangeScheduled?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemChangeScheduledContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemChanged?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemChangedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemDowngradeScheduled?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDowngradeScheduledContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemDowngraded?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDowngradedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemDunningExpired?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDunningExpiredContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemDunningStarted?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDunningStartedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemExpired?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemExpiredContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemGracePeriodExpired?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemGracePeriodExpiredContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemGracePeriodStarted?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemGracePeriodStartedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemPauseScheduled?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemPauseScheduledContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemPaused?: ( - event: WebhookEvent & { content: OmnichannelSubscriptionItemPausedContent }, - ) => Promise; - - onOmnichannelSubscriptionItemReactivated?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemReactivatedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemRenewed?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemRenewedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemResubscribed?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemResubscribedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemResumed?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemResumedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemScheduledCancellationRemoved?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemScheduledChangeRemoved?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledChangeRemovedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemScheduledDowngradeRemoved?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledDowngradeRemovedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionItemUpgraded?: ( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemUpgradedContent; - }, - ) => Promise; - - onOmnichannelSubscriptionMovedIn?: ( - event: WebhookEvent & { content: OmnichannelSubscriptionMovedInContent }, - ) => Promise; - - onOmnichannelTransactionCreated?: ( - event: WebhookEvent & { content: OmnichannelTransactionCreatedContent }, - ) => Promise; - - onOrderCancelled?: ( - event: WebhookEvent & { content: OrderCancelledContent }, - ) => Promise; - - onOrderCreated?: ( - event: WebhookEvent & { content: OrderCreatedContent }, - ) => Promise; - - onOrderDeleted?: ( - event: WebhookEvent & { content: OrderDeletedContent }, - ) => Promise; - - onOrderDelivered?: ( - event: WebhookEvent & { content: OrderDeliveredContent }, - ) => Promise; - - onOrderReadyToProcess?: ( - event: WebhookEvent & { content: OrderReadyToProcessContent }, - ) => Promise; - - onOrderReadyToShip?: ( - event: WebhookEvent & { content: OrderReadyToShipContent }, - ) => Promise; - - onOrderResent?: ( - event: WebhookEvent & { content: OrderResentContent }, - ) => Promise; - - onOrderReturned?: ( - event: WebhookEvent & { content: OrderReturnedContent }, - ) => Promise; - - onOrderUpdated?: ( - event: WebhookEvent & { content: OrderUpdatedContent }, - ) => Promise; - - onPaymentFailed?: ( - event: WebhookEvent & { content: PaymentFailedContent }, - ) => Promise; - - onPaymentInitiated?: ( - event: WebhookEvent & { content: PaymentInitiatedContent }, - ) => Promise; - - onPaymentIntentCreated?: ( - event: WebhookEvent & { content: PaymentIntentCreatedContent }, - ) => Promise; - - onPaymentIntentUpdated?: ( - event: WebhookEvent & { content: PaymentIntentUpdatedContent }, - ) => Promise; - - onPaymentRefunded?: ( - event: WebhookEvent & { content: PaymentRefundedContent }, - ) => Promise; - - onPaymentScheduleSchemeCreated?: ( - event: WebhookEvent & { content: PaymentScheduleSchemeCreatedContent }, - ) => Promise; - - onPaymentScheduleSchemeDeleted?: ( - event: WebhookEvent & { content: PaymentScheduleSchemeDeletedContent }, - ) => Promise; - - onPaymentSchedulesCreated?: ( - event: WebhookEvent & { content: PaymentSchedulesCreatedContent }, - ) => Promise; - - onPaymentSchedulesUpdated?: ( - event: WebhookEvent & { content: PaymentSchedulesUpdatedContent }, - ) => Promise; - - onPaymentSourceAdded?: ( - event: WebhookEvent & { content: PaymentSourceAddedContent }, - ) => Promise; - - onPaymentSourceDeleted?: ( - event: WebhookEvent & { content: PaymentSourceDeletedContent }, - ) => Promise; - - onPaymentSourceExpired?: ( - event: WebhookEvent & { content: PaymentSourceExpiredContent }, - ) => Promise; - - onPaymentSourceExpiring?: ( - event: WebhookEvent & { content: PaymentSourceExpiringContent }, - ) => Promise; - - onPaymentSourceLocallyDeleted?: ( - event: WebhookEvent & { content: PaymentSourceLocallyDeletedContent }, - ) => Promise; - - onPaymentSourceUpdated?: ( - event: WebhookEvent & { content: PaymentSourceUpdatedContent }, - ) => Promise; - - onPaymentSucceeded?: ( - event: WebhookEvent & { content: PaymentSucceededContent }, - ) => Promise; - - onPendingInvoiceCreated?: ( - event: WebhookEvent & { content: PendingInvoiceCreatedContent }, - ) => Promise; - - onPendingInvoiceUpdated?: ( - event: WebhookEvent & { content: PendingInvoiceUpdatedContent }, - ) => Promise; - - onPlanCreated?: ( - event: WebhookEvent & { content: PlanCreatedContent }, - ) => Promise; - - onPlanDeleted?: ( - event: WebhookEvent & { content: PlanDeletedContent }, - ) => Promise; - - onPlanUpdated?: ( - event: WebhookEvent & { content: PlanUpdatedContent }, - ) => Promise; - - onPriceVariantCreated?: ( - event: WebhookEvent & { content: PriceVariantCreatedContent }, - ) => Promise; - - onPriceVariantDeleted?: ( - event: WebhookEvent & { content: PriceVariantDeletedContent }, - ) => Promise; - - onPriceVariantUpdated?: ( - event: WebhookEvent & { content: PriceVariantUpdatedContent }, - ) => Promise; - - onProductCreated?: ( - event: WebhookEvent & { content: ProductCreatedContent }, - ) => Promise; - - onProductDeleted?: ( - event: WebhookEvent & { content: ProductDeletedContent }, - ) => Promise; - - onProductUpdated?: ( - event: WebhookEvent & { content: ProductUpdatedContent }, - ) => Promise; - - onPromotionalCreditsAdded?: ( - event: WebhookEvent & { content: PromotionalCreditsAddedContent }, - ) => Promise; - - onPromotionalCreditsDeducted?: ( - event: WebhookEvent & { content: PromotionalCreditsDeductedContent }, - ) => Promise; - - onPurchaseCreated?: ( - event: WebhookEvent & { content: PurchaseCreatedContent }, - ) => Promise; - - onQuoteCreated?: ( - event: WebhookEvent & { content: QuoteCreatedContent }, - ) => Promise; - - onQuoteDeleted?: ( - event: WebhookEvent & { content: QuoteDeletedContent }, - ) => Promise; - - onQuoteUpdated?: ( - event: WebhookEvent & { content: QuoteUpdatedContent }, - ) => Promise; - - onRecordPurchaseFailed?: ( - event: WebhookEvent & { content: RecordPurchaseFailedContent }, - ) => Promise; - - onRefundInitiated?: ( - event: WebhookEvent & { content: RefundInitiatedContent }, - ) => Promise; - - onRuleCreated?: ( - event: WebhookEvent & { content: RuleCreatedContent }, - ) => Promise; - - onRuleDeleted?: ( - event: WebhookEvent & { content: RuleDeletedContent }, - ) => Promise; - - onRuleUpdated?: ( - event: WebhookEvent & { content: RuleUpdatedContent }, - ) => Promise; - - onSalesOrderCreated?: ( - event: WebhookEvent & { content: SalesOrderCreatedContent }, - ) => Promise; - - onSalesOrderUpdated?: ( - event: WebhookEvent & { content: SalesOrderUpdatedContent }, - ) => Promise; - - onSubscriptionActivated?: ( - event: WebhookEvent & { content: SubscriptionActivatedContent }, - ) => Promise; - - onSubscriptionActivatedWithBackdating?: ( - event: WebhookEvent & { - content: SubscriptionActivatedWithBackdatingContent; - }, - ) => Promise; - - onSubscriptionAdvanceInvoiceScheduleAdded?: ( - event: WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleAddedContent; - }, - ) => Promise; - - onSubscriptionAdvanceInvoiceScheduleRemoved?: ( - event: WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleRemovedContent; - }, - ) => Promise; - - onSubscriptionAdvanceInvoiceScheduleUpdated?: ( - event: WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleUpdatedContent; - }, - ) => Promise; - - onSubscriptionBusinessEntityChanged?: ( - event: WebhookEvent & { content: SubscriptionBusinessEntityChangedContent }, - ) => Promise; - - onSubscriptionCanceledWithBackdating?: ( - event: WebhookEvent & { - content: SubscriptionCanceledWithBackdatingContent; - }, - ) => Promise; - - onSubscriptionCancellationReminder?: ( - event: WebhookEvent & { content: SubscriptionCancellationReminderContent }, - ) => Promise; - - onSubscriptionCancellationScheduled?: ( - event: WebhookEvent & { content: SubscriptionCancellationScheduledContent }, - ) => Promise; - - onSubscriptionCancelled?: ( - event: WebhookEvent & { content: SubscriptionCancelledContent }, - ) => Promise; - - onSubscriptionChanged?: ( - event: WebhookEvent & { content: SubscriptionChangedContent }, - ) => Promise; - - onSubscriptionChangedWithBackdating?: ( - event: WebhookEvent & { content: SubscriptionChangedWithBackdatingContent }, - ) => Promise; - - onSubscriptionChangesScheduled?: ( - event: WebhookEvent & { content: SubscriptionChangesScheduledContent }, - ) => Promise; - - onSubscriptionCreated?: ( - event: WebhookEvent & { content: SubscriptionCreatedContent }, - ) => Promise; - - onSubscriptionCreatedWithBackdating?: ( - event: WebhookEvent & { content: SubscriptionCreatedWithBackdatingContent }, - ) => Promise; - - onSubscriptionDeleted?: ( - event: WebhookEvent & { content: SubscriptionDeletedContent }, - ) => Promise; - - onSubscriptionEntitlementsCreated?: ( - event: WebhookEvent & { content: SubscriptionEntitlementsCreatedContent }, - ) => Promise; - - onSubscriptionEntitlementsUpdated?: ( - event: WebhookEvent & { content: SubscriptionEntitlementsUpdatedContent }, - ) => Promise; - - onSubscriptionItemsRenewed?: ( - event: WebhookEvent & { content: SubscriptionItemsRenewedContent }, - ) => Promise; - - onSubscriptionMovedIn?: ( - event: WebhookEvent & { content: SubscriptionMovedInContent }, - ) => Promise; - - onSubscriptionMovedOut?: ( - event: WebhookEvent & { content: SubscriptionMovedOutContent }, - ) => Promise; - - onSubscriptionMovementFailed?: ( - event: WebhookEvent & { content: SubscriptionMovementFailedContent }, - ) => Promise; - - onSubscriptionPauseScheduled?: ( - event: WebhookEvent & { content: SubscriptionPauseScheduledContent }, - ) => Promise; - - onSubscriptionPaused?: ( - event: WebhookEvent & { content: SubscriptionPausedContent }, - ) => Promise; - - onSubscriptionRampApplied?: ( - event: WebhookEvent & { content: SubscriptionRampAppliedContent }, - ) => Promise; - - onSubscriptionRampCreated?: ( - event: WebhookEvent & { content: SubscriptionRampCreatedContent }, - ) => Promise; - - onSubscriptionRampDeleted?: ( - event: WebhookEvent & { content: SubscriptionRampDeletedContent }, - ) => Promise; - - onSubscriptionRampDrafted?: ( - event: WebhookEvent & { content: SubscriptionRampDraftedContent }, - ) => Promise; - - onSubscriptionRampUpdated?: ( - event: WebhookEvent & { content: SubscriptionRampUpdatedContent }, - ) => Promise; - - onSubscriptionReactivated?: ( - event: WebhookEvent & { content: SubscriptionReactivatedContent }, - ) => Promise; - - onSubscriptionReactivatedWithBackdating?: ( - event: WebhookEvent & { - content: SubscriptionReactivatedWithBackdatingContent; - }, - ) => Promise; - - onSubscriptionRenewalReminder?: ( - event: WebhookEvent & { content: SubscriptionRenewalReminderContent }, - ) => Promise; - - onSubscriptionRenewed?: ( - event: WebhookEvent & { content: SubscriptionRenewedContent }, - ) => Promise; - - onSubscriptionResumed?: ( - event: WebhookEvent & { content: SubscriptionResumedContent }, - ) => Promise; - - onSubscriptionResumptionScheduled?: ( - event: WebhookEvent & { content: SubscriptionResumptionScheduledContent }, - ) => Promise; - - onSubscriptionScheduledCancellationRemoved?: ( - event: WebhookEvent & { - content: SubscriptionScheduledCancellationRemovedContent; - }, - ) => Promise; - - onSubscriptionScheduledChangesRemoved?: ( - event: WebhookEvent & { - content: SubscriptionScheduledChangesRemovedContent; - }, - ) => Promise; - - onSubscriptionScheduledPauseRemoved?: ( - event: WebhookEvent & { content: SubscriptionScheduledPauseRemovedContent }, - ) => Promise; - - onSubscriptionScheduledResumptionRemoved?: ( - event: WebhookEvent & { - content: SubscriptionScheduledResumptionRemovedContent; - }, - ) => Promise; - - onSubscriptionShippingAddressUpdated?: ( - event: WebhookEvent & { - content: SubscriptionShippingAddressUpdatedContent; - }, - ) => Promise; - - onSubscriptionStarted?: ( - event: WebhookEvent & { content: SubscriptionStartedContent }, - ) => Promise; - - onSubscriptionTrialEndReminder?: ( - event: WebhookEvent & { content: SubscriptionTrialEndReminderContent }, - ) => Promise; - - onSubscriptionTrialExtended?: ( - event: WebhookEvent & { content: SubscriptionTrialExtendedContent }, - ) => Promise; - - onTaxWithheldDeleted?: ( - event: WebhookEvent & { content: TaxWithheldDeletedContent }, - ) => Promise; - - onTaxWithheldRecorded?: ( - event: WebhookEvent & { content: TaxWithheldRecordedContent }, - ) => Promise; - - onTaxWithheldRefunded?: ( - event: WebhookEvent & { content: TaxWithheldRefundedContent }, - ) => Promise; - - onTokenConsumed?: ( - event: WebhookEvent & { content: TokenConsumedContent }, - ) => Promise; - - onTokenCreated?: ( - event: WebhookEvent & { content: TokenCreatedContent }, - ) => Promise; - - onTokenExpired?: ( - event: WebhookEvent & { content: TokenExpiredContent }, - ) => Promise; - - onTransactionCreated?: ( - event: WebhookEvent & { content: TransactionCreatedContent }, - ) => Promise; - - onTransactionDeleted?: ( - event: WebhookEvent & { content: TransactionDeletedContent }, - ) => Promise; - - onTransactionUpdated?: ( - event: WebhookEvent & { content: TransactionUpdatedContent }, - ) => Promise; - - onUnbilledChargesCreated?: ( - event: WebhookEvent & { content: UnbilledChargesCreatedContent }, - ) => Promise; - - onUnbilledChargesDeleted?: ( - event: WebhookEvent & { content: UnbilledChargesDeletedContent }, - ) => Promise; - - onUnbilledChargesInvoiced?: ( - event: WebhookEvent & { content: UnbilledChargesInvoicedContent }, - ) => Promise; - - onUnbilledChargesVoided?: ( - event: WebhookEvent & { content: UnbilledChargesVoidedContent }, - ) => Promise; - - onUsageFileIngested?: ( - event: WebhookEvent & { content: UsageFileIngestedContent }, - ) => Promise; - - onVariantCreated?: ( - event: WebhookEvent & { content: VariantCreatedContent }, - ) => Promise; - - onVariantDeleted?: ( - event: WebhookEvent & { content: VariantDeletedContent }, - ) => Promise; - - onVariantUpdated?: ( - event: WebhookEvent & { content: VariantUpdatedContent }, - ) => Promise; - - onVirtualBankAccountAdded?: ( - event: WebhookEvent & { content: VirtualBankAccountAddedContent }, - ) => Promise; - - onVirtualBankAccountDeleted?: ( - event: WebhookEvent & { content: VirtualBankAccountDeletedContent }, - ) => Promise; - - onVirtualBankAccountUpdated?: ( - event: WebhookEvent & { content: VirtualBankAccountUpdatedContent }, - ) => Promise; - - onVoucherCreateFailed?: ( - event: WebhookEvent & { content: VoucherCreateFailedContent }, - ) => Promise; - - onVoucherCreated?: ( - event: WebhookEvent & { content: VoucherCreatedContent }, - ) => Promise; - - onVoucherExpired?: ( - event: WebhookEvent & { content: VoucherExpiredContent }, - ) => Promise; -} - -export class WebhookHandler { - private _handlers: WebhookHandlers = {}; - - /** - * Optional callback for unhandled events. - */ - onUnhandledEvent?: (event: WebhookEvent) => Promise; - - /** - * Optional callback for errors during processing. - */ - onError?: (error: any) => void; - - /** - * Optional validator for request headers. - */ - requestValidator?: ( - headers: Record, - ) => void; - - constructor(handlers: WebhookHandlers = {}) { - this._handlers = handlers; - } - - set onAddUsagesReminder( - handler: - | (( - event: WebhookEvent & { content: AddUsagesReminderContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAddUsagesReminder = handler; - } - - get onAddUsagesReminder() { - return this._handlers.onAddUsagesReminder; - } - - set onAddonCreated( - handler: - | (( - event: WebhookEvent & { content: AddonCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAddonCreated = handler; - } - - get onAddonCreated() { - return this._handlers.onAddonCreated; - } - - set onAddonDeleted( - handler: - | (( - event: WebhookEvent & { content: AddonDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAddonDeleted = handler; - } - - get onAddonDeleted() { - return this._handlers.onAddonDeleted; - } - - set onAddonUpdated( - handler: - | (( - event: WebhookEvent & { content: AddonUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAddonUpdated = handler; - } - - get onAddonUpdated() { - return this._handlers.onAddonUpdated; - } - - set onAttachedItemCreated( - handler: - | (( - event: WebhookEvent & { content: AttachedItemCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAttachedItemCreated = handler; - } - - get onAttachedItemCreated() { - return this._handlers.onAttachedItemCreated; - } - - set onAttachedItemDeleted( - handler: - | (( - event: WebhookEvent & { content: AttachedItemDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAttachedItemDeleted = handler; - } - - get onAttachedItemDeleted() { - return this._handlers.onAttachedItemDeleted; - } - - set onAttachedItemUpdated( - handler: - | (( - event: WebhookEvent & { content: AttachedItemUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAttachedItemUpdated = handler; - } - - get onAttachedItemUpdated() { - return this._handlers.onAttachedItemUpdated; - } - - set onAuthorizationSucceeded( - handler: - | (( - event: WebhookEvent & { content: AuthorizationSucceededContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAuthorizationSucceeded = handler; - } - - get onAuthorizationSucceeded() { - return this._handlers.onAuthorizationSucceeded; - } - - set onAuthorizationVoided( - handler: - | (( - event: WebhookEvent & { content: AuthorizationVoidedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onAuthorizationVoided = handler; - } - - get onAuthorizationVoided() { - return this._handlers.onAuthorizationVoided; - } - - set onBusinessEntityCreated( - handler: - | (( - event: WebhookEvent & { content: BusinessEntityCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onBusinessEntityCreated = handler; - } - - get onBusinessEntityCreated() { - return this._handlers.onBusinessEntityCreated; - } - - set onBusinessEntityDeleted( - handler: - | (( - event: WebhookEvent & { content: BusinessEntityDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onBusinessEntityDeleted = handler; - } - - get onBusinessEntityDeleted() { - return this._handlers.onBusinessEntityDeleted; - } - - set onBusinessEntityUpdated( - handler: - | (( - event: WebhookEvent & { content: BusinessEntityUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onBusinessEntityUpdated = handler; - } - - get onBusinessEntityUpdated() { - return this._handlers.onBusinessEntityUpdated; - } - - set onCardAdded( - handler: - | ((event: WebhookEvent & { content: CardAddedContent }) => Promise) - | undefined, - ) { - this._handlers.onCardAdded = handler; - } - - get onCardAdded() { - return this._handlers.onCardAdded; - } - - set onCardDeleted( - handler: - | (( - event: WebhookEvent & { content: CardDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCardDeleted = handler; - } - - get onCardDeleted() { - return this._handlers.onCardDeleted; - } - - set onCardExpired( - handler: - | (( - event: WebhookEvent & { content: CardExpiredContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCardExpired = handler; - } - - get onCardExpired() { - return this._handlers.onCardExpired; - } - - set onCardExpiryReminder( - handler: - | (( - event: WebhookEvent & { content: CardExpiryReminderContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCardExpiryReminder = handler; - } - - get onCardExpiryReminder() { - return this._handlers.onCardExpiryReminder; - } - - set onCardUpdated( - handler: - | (( - event: WebhookEvent & { content: CardUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCardUpdated = handler; - } - - get onCardUpdated() { - return this._handlers.onCardUpdated; - } - - set onContractTermCancelled( - handler: - | (( - event: WebhookEvent & { content: ContractTermCancelledContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onContractTermCancelled = handler; - } - - get onContractTermCancelled() { - return this._handlers.onContractTermCancelled; - } - - set onContractTermCompleted( - handler: - | (( - event: WebhookEvent & { content: ContractTermCompletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onContractTermCompleted = handler; - } - - get onContractTermCompleted() { - return this._handlers.onContractTermCompleted; - } - - set onContractTermCreated( - handler: - | (( - event: WebhookEvent & { content: ContractTermCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onContractTermCreated = handler; - } - - get onContractTermCreated() { - return this._handlers.onContractTermCreated; - } - - set onContractTermRenewed( - handler: - | (( - event: WebhookEvent & { content: ContractTermRenewedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onContractTermRenewed = handler; - } - - get onContractTermRenewed() { - return this._handlers.onContractTermRenewed; - } - - set onContractTermTerminated( - handler: - | (( - event: WebhookEvent & { content: ContractTermTerminatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onContractTermTerminated = handler; - } - - get onContractTermTerminated() { - return this._handlers.onContractTermTerminated; - } - - set onCouponCodesAdded( - handler: - | (( - event: WebhookEvent & { content: CouponCodesAddedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponCodesAdded = handler; - } - - get onCouponCodesAdded() { - return this._handlers.onCouponCodesAdded; - } - - set onCouponCodesDeleted( - handler: - | (( - event: WebhookEvent & { content: CouponCodesDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponCodesDeleted = handler; - } - - get onCouponCodesDeleted() { - return this._handlers.onCouponCodesDeleted; - } - - set onCouponCodesUpdated( - handler: - | (( - event: WebhookEvent & { content: CouponCodesUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponCodesUpdated = handler; - } - - get onCouponCodesUpdated() { - return this._handlers.onCouponCodesUpdated; - } - - set onCouponCreated( - handler: - | (( - event: WebhookEvent & { content: CouponCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponCreated = handler; - } - - get onCouponCreated() { - return this._handlers.onCouponCreated; - } - - set onCouponDeleted( - handler: - | (( - event: WebhookEvent & { content: CouponDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponDeleted = handler; - } - - get onCouponDeleted() { - return this._handlers.onCouponDeleted; - } - - set onCouponSetCreated( - handler: - | (( - event: WebhookEvent & { content: CouponSetCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponSetCreated = handler; - } - - get onCouponSetCreated() { - return this._handlers.onCouponSetCreated; - } - - set onCouponSetDeleted( - handler: - | (( - event: WebhookEvent & { content: CouponSetDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponSetDeleted = handler; - } - - get onCouponSetDeleted() { - return this._handlers.onCouponSetDeleted; - } - - set onCouponSetUpdated( - handler: - | (( - event: WebhookEvent & { content: CouponSetUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponSetUpdated = handler; - } - - get onCouponSetUpdated() { - return this._handlers.onCouponSetUpdated; - } - - set onCouponUpdated( - handler: - | (( - event: WebhookEvent & { content: CouponUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCouponUpdated = handler; - } - - get onCouponUpdated() { - return this._handlers.onCouponUpdated; - } - - set onCreditNoteCreated( - handler: - | (( - event: WebhookEvent & { content: CreditNoteCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCreditNoteCreated = handler; - } - - get onCreditNoteCreated() { - return this._handlers.onCreditNoteCreated; - } - - set onCreditNoteCreatedWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: CreditNoteCreatedWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onCreditNoteCreatedWithBackdating = handler; - } - - get onCreditNoteCreatedWithBackdating() { - return this._handlers.onCreditNoteCreatedWithBackdating; - } - - set onCreditNoteDeleted( - handler: - | (( - event: WebhookEvent & { content: CreditNoteDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCreditNoteDeleted = handler; - } - - get onCreditNoteDeleted() { - return this._handlers.onCreditNoteDeleted; - } - - set onCreditNoteUpdated( - handler: - | (( - event: WebhookEvent & { content: CreditNoteUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCreditNoteUpdated = handler; - } - - get onCreditNoteUpdated() { - return this._handlers.onCreditNoteUpdated; - } - - set onCustomerBusinessEntityChanged( - handler: - | (( - event: WebhookEvent & { - content: CustomerBusinessEntityChangedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerBusinessEntityChanged = handler; - } - - get onCustomerBusinessEntityChanged() { - return this._handlers.onCustomerBusinessEntityChanged; - } - - set onCustomerChanged( - handler: - | (( - event: WebhookEvent & { content: CustomerChangedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerChanged = handler; - } - - get onCustomerChanged() { - return this._handlers.onCustomerChanged; - } - - set onCustomerCreated( - handler: - | (( - event: WebhookEvent & { content: CustomerCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerCreated = handler; - } - - get onCustomerCreated() { - return this._handlers.onCustomerCreated; - } - - set onCustomerDeleted( - handler: - | (( - event: WebhookEvent & { content: CustomerDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerDeleted = handler; - } - - get onCustomerDeleted() { - return this._handlers.onCustomerDeleted; - } - - set onCustomerEntitlementsUpdated( - handler: - | (( - event: WebhookEvent & { content: CustomerEntitlementsUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerEntitlementsUpdated = handler; - } - - get onCustomerEntitlementsUpdated() { - return this._handlers.onCustomerEntitlementsUpdated; - } - - set onCustomerMovedIn( - handler: - | (( - event: WebhookEvent & { content: CustomerMovedInContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerMovedIn = handler; - } - - get onCustomerMovedIn() { - return this._handlers.onCustomerMovedIn; - } - - set onCustomerMovedOut( - handler: - | (( - event: WebhookEvent & { content: CustomerMovedOutContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onCustomerMovedOut = handler; - } - - get onCustomerMovedOut() { - return this._handlers.onCustomerMovedOut; - } - - set onDifferentialPriceCreated( - handler: - | (( - event: WebhookEvent & { content: DifferentialPriceCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onDifferentialPriceCreated = handler; - } - - get onDifferentialPriceCreated() { - return this._handlers.onDifferentialPriceCreated; - } - - set onDifferentialPriceDeleted( - handler: - | (( - event: WebhookEvent & { content: DifferentialPriceDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onDifferentialPriceDeleted = handler; - } - - get onDifferentialPriceDeleted() { - return this._handlers.onDifferentialPriceDeleted; - } - - set onDifferentialPriceUpdated( - handler: - | (( - event: WebhookEvent & { content: DifferentialPriceUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onDifferentialPriceUpdated = handler; - } - - get onDifferentialPriceUpdated() { - return this._handlers.onDifferentialPriceUpdated; - } - - set onDunningUpdated( - handler: - | (( - event: WebhookEvent & { content: DunningUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onDunningUpdated = handler; - } - - get onDunningUpdated() { - return this._handlers.onDunningUpdated; - } - - set onEntitlementOverridesAutoRemoved( - handler: - | (( - event: WebhookEvent & { - content: EntitlementOverridesAutoRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onEntitlementOverridesAutoRemoved = handler; - } - - get onEntitlementOverridesAutoRemoved() { - return this._handlers.onEntitlementOverridesAutoRemoved; - } - - set onEntitlementOverridesRemoved( - handler: - | (( - event: WebhookEvent & { content: EntitlementOverridesRemovedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onEntitlementOverridesRemoved = handler; - } - - get onEntitlementOverridesRemoved() { - return this._handlers.onEntitlementOverridesRemoved; - } - - set onEntitlementOverridesUpdated( - handler: - | (( - event: WebhookEvent & { content: EntitlementOverridesUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onEntitlementOverridesUpdated = handler; - } - - get onEntitlementOverridesUpdated() { - return this._handlers.onEntitlementOverridesUpdated; - } - - set onFeatureActivated( - handler: - | (( - event: WebhookEvent & { content: FeatureActivatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onFeatureActivated = handler; - } - - get onFeatureActivated() { - return this._handlers.onFeatureActivated; - } - - set onFeatureArchived( - handler: - | (( - event: WebhookEvent & { content: FeatureArchivedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onFeatureArchived = handler; - } - - get onFeatureArchived() { - return this._handlers.onFeatureArchived; - } - - set onFeatureCreated( - handler: - | (( - event: WebhookEvent & { content: FeatureCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onFeatureCreated = handler; - } - - get onFeatureCreated() { - return this._handlers.onFeatureCreated; - } - - set onFeatureDeleted( - handler: - | (( - event: WebhookEvent & { content: FeatureDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onFeatureDeleted = handler; - } - - get onFeatureDeleted() { - return this._handlers.onFeatureDeleted; - } - - set onFeatureReactivated( - handler: - | (( - event: WebhookEvent & { content: FeatureReactivatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onFeatureReactivated = handler; - } - - get onFeatureReactivated() { - return this._handlers.onFeatureReactivated; - } - - set onFeatureUpdated( - handler: - | (( - event: WebhookEvent & { content: FeatureUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onFeatureUpdated = handler; - } - - get onFeatureUpdated() { - return this._handlers.onFeatureUpdated; - } - - set onGiftCancelled( - handler: - | (( - event: WebhookEvent & { content: GiftCancelledContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onGiftCancelled = handler; - } - - get onGiftCancelled() { - return this._handlers.onGiftCancelled; - } - - set onGiftClaimed( - handler: - | (( - event: WebhookEvent & { content: GiftClaimedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onGiftClaimed = handler; - } - - get onGiftClaimed() { - return this._handlers.onGiftClaimed; - } - - set onGiftExpired( - handler: - | (( - event: WebhookEvent & { content: GiftExpiredContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onGiftExpired = handler; - } - - get onGiftExpired() { - return this._handlers.onGiftExpired; - } - - set onGiftScheduled( - handler: - | (( - event: WebhookEvent & { content: GiftScheduledContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onGiftScheduled = handler; - } - - get onGiftScheduled() { - return this._handlers.onGiftScheduled; - } - - set onGiftUnclaimed( - handler: - | (( - event: WebhookEvent & { content: GiftUnclaimedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onGiftUnclaimed = handler; - } - - get onGiftUnclaimed() { - return this._handlers.onGiftUnclaimed; - } - - set onGiftUpdated( - handler: - | (( - event: WebhookEvent & { content: GiftUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onGiftUpdated = handler; - } - - get onGiftUpdated() { - return this._handlers.onGiftUpdated; - } - - set onHierarchyCreated( - handler: - | (( - event: WebhookEvent & { content: HierarchyCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onHierarchyCreated = handler; - } - - get onHierarchyCreated() { - return this._handlers.onHierarchyCreated; - } - - set onHierarchyDeleted( - handler: - | (( - event: WebhookEvent & { content: HierarchyDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onHierarchyDeleted = handler; - } - - get onHierarchyDeleted() { - return this._handlers.onHierarchyDeleted; - } - - set onInvoiceDeleted( - handler: - | (( - event: WebhookEvent & { content: InvoiceDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onInvoiceDeleted = handler; - } - - get onInvoiceDeleted() { - return this._handlers.onInvoiceDeleted; - } - - set onInvoiceGenerated( - handler: - | (( - event: WebhookEvent & { content: InvoiceGeneratedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onInvoiceGenerated = handler; - } - - get onInvoiceGenerated() { - return this._handlers.onInvoiceGenerated; - } - - set onInvoiceGeneratedWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: InvoiceGeneratedWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onInvoiceGeneratedWithBackdating = handler; - } - - get onInvoiceGeneratedWithBackdating() { - return this._handlers.onInvoiceGeneratedWithBackdating; - } - - set onInvoiceUpdated( - handler: - | (( - event: WebhookEvent & { content: InvoiceUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onInvoiceUpdated = handler; - } - - get onInvoiceUpdated() { - return this._handlers.onInvoiceUpdated; - } - - set onItemCreated( - handler: - | (( - event: WebhookEvent & { content: ItemCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemCreated = handler; - } - - get onItemCreated() { - return this._handlers.onItemCreated; - } - - set onItemDeleted( - handler: - | (( - event: WebhookEvent & { content: ItemDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemDeleted = handler; - } - - get onItemDeleted() { - return this._handlers.onItemDeleted; - } - - set onItemEntitlementsRemoved( - handler: - | (( - event: WebhookEvent & { content: ItemEntitlementsRemovedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemEntitlementsRemoved = handler; - } - - get onItemEntitlementsRemoved() { - return this._handlers.onItemEntitlementsRemoved; - } - - set onItemEntitlementsUpdated( - handler: - | (( - event: WebhookEvent & { content: ItemEntitlementsUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemEntitlementsUpdated = handler; - } - - get onItemEntitlementsUpdated() { - return this._handlers.onItemEntitlementsUpdated; - } - - set onItemFamilyCreated( - handler: - | (( - event: WebhookEvent & { content: ItemFamilyCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemFamilyCreated = handler; - } - - get onItemFamilyCreated() { - return this._handlers.onItemFamilyCreated; - } - - set onItemFamilyDeleted( - handler: - | (( - event: WebhookEvent & { content: ItemFamilyDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemFamilyDeleted = handler; - } - - get onItemFamilyDeleted() { - return this._handlers.onItemFamilyDeleted; - } - - set onItemFamilyUpdated( - handler: - | (( - event: WebhookEvent & { content: ItemFamilyUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemFamilyUpdated = handler; - } - - get onItemFamilyUpdated() { - return this._handlers.onItemFamilyUpdated; - } - - set onItemPriceCreated( - handler: - | (( - event: WebhookEvent & { content: ItemPriceCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemPriceCreated = handler; - } - - get onItemPriceCreated() { - return this._handlers.onItemPriceCreated; - } - - set onItemPriceDeleted( - handler: - | (( - event: WebhookEvent & { content: ItemPriceDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemPriceDeleted = handler; - } - - get onItemPriceDeleted() { - return this._handlers.onItemPriceDeleted; - } - - set onItemPriceEntitlementsRemoved( - handler: - | (( - event: WebhookEvent & { - content: ItemPriceEntitlementsRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemPriceEntitlementsRemoved = handler; - } - - get onItemPriceEntitlementsRemoved() { - return this._handlers.onItemPriceEntitlementsRemoved; - } - - set onItemPriceEntitlementsUpdated( - handler: - | (( - event: WebhookEvent & { - content: ItemPriceEntitlementsUpdatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemPriceEntitlementsUpdated = handler; - } - - get onItemPriceEntitlementsUpdated() { - return this._handlers.onItemPriceEntitlementsUpdated; - } - - set onItemPriceUpdated( - handler: - | (( - event: WebhookEvent & { content: ItemPriceUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemPriceUpdated = handler; - } - - get onItemPriceUpdated() { - return this._handlers.onItemPriceUpdated; - } - - set onItemUpdated( - handler: - | (( - event: WebhookEvent & { content: ItemUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onItemUpdated = handler; - } - - get onItemUpdated() { - return this._handlers.onItemUpdated; - } - - set onMrrUpdated( - handler: - | (( - event: WebhookEvent & { content: MrrUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onMrrUpdated = handler; - } - - get onMrrUpdated() { - return this._handlers.onMrrUpdated; - } - - set onNetdPaymentDueReminder( - handler: - | (( - event: WebhookEvent & { content: NetdPaymentDueReminderContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onNetdPaymentDueReminder = handler; - } - - get onNetdPaymentDueReminder() { - return this._handlers.onNetdPaymentDueReminder; - } - - set onOmnichannelOneTimeOrderCreated( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelOneTimeOrderCreatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelOneTimeOrderCreated = handler; - } - - get onOmnichannelOneTimeOrderCreated() { - return this._handlers.onOmnichannelOneTimeOrderCreated; - } - - set onOmnichannelOneTimeOrderItemCancelled( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelOneTimeOrderItemCancelledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelOneTimeOrderItemCancelled = handler; - } - - get onOmnichannelOneTimeOrderItemCancelled() { - return this._handlers.onOmnichannelOneTimeOrderItemCancelled; - } - - set onOmnichannelSubscriptionCreated( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionCreatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionCreated = handler; - } - - get onOmnichannelSubscriptionCreated() { - return this._handlers.onOmnichannelSubscriptionCreated; - } - - set onOmnichannelSubscriptionImported( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionImportedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionImported = handler; - } - - get onOmnichannelSubscriptionImported() { - return this._handlers.onOmnichannelSubscriptionImported; - } - - set onOmnichannelSubscriptionItemCancellationScheduled( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemCancellationScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemCancellationScheduled = handler; - } - - get onOmnichannelSubscriptionItemCancellationScheduled() { - return this._handlers.onOmnichannelSubscriptionItemCancellationScheduled; - } - - set onOmnichannelSubscriptionItemCancelled( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemCancelledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemCancelled = handler; - } - - get onOmnichannelSubscriptionItemCancelled() { - return this._handlers.onOmnichannelSubscriptionItemCancelled; - } - - set onOmnichannelSubscriptionItemChangeScheduled( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemChangeScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemChangeScheduled = handler; - } - - get onOmnichannelSubscriptionItemChangeScheduled() { - return this._handlers.onOmnichannelSubscriptionItemChangeScheduled; - } - - set onOmnichannelSubscriptionItemChanged( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemChangedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemChanged = handler; - } - - get onOmnichannelSubscriptionItemChanged() { - return this._handlers.onOmnichannelSubscriptionItemChanged; - } - - set onOmnichannelSubscriptionItemDowngradeScheduled( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDowngradeScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled = handler; - } - - get onOmnichannelSubscriptionItemDowngradeScheduled() { - return this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled; - } - - set onOmnichannelSubscriptionItemDowngraded( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDowngradedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemDowngraded = handler; - } - - get onOmnichannelSubscriptionItemDowngraded() { - return this._handlers.onOmnichannelSubscriptionItemDowngraded; - } - - set onOmnichannelSubscriptionItemDunningExpired( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDunningExpiredContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemDunningExpired = handler; - } - - get onOmnichannelSubscriptionItemDunningExpired() { - return this._handlers.onOmnichannelSubscriptionItemDunningExpired; - } - - set onOmnichannelSubscriptionItemDunningStarted( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemDunningStartedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemDunningStarted = handler; - } - - get onOmnichannelSubscriptionItemDunningStarted() { - return this._handlers.onOmnichannelSubscriptionItemDunningStarted; - } - - set onOmnichannelSubscriptionItemExpired( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemExpiredContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemExpired = handler; - } - - get onOmnichannelSubscriptionItemExpired() { - return this._handlers.onOmnichannelSubscriptionItemExpired; - } - - set onOmnichannelSubscriptionItemGracePeriodExpired( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemGracePeriodExpiredContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired = handler; - } - - get onOmnichannelSubscriptionItemGracePeriodExpired() { - return this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired; - } - - set onOmnichannelSubscriptionItemGracePeriodStarted( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemGracePeriodStartedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted = handler; - } - - get onOmnichannelSubscriptionItemGracePeriodStarted() { - return this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted; - } - - set onOmnichannelSubscriptionItemPauseScheduled( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemPauseScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemPauseScheduled = handler; - } - - get onOmnichannelSubscriptionItemPauseScheduled() { - return this._handlers.onOmnichannelSubscriptionItemPauseScheduled; - } - - set onOmnichannelSubscriptionItemPaused( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemPausedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemPaused = handler; - } - - get onOmnichannelSubscriptionItemPaused() { - return this._handlers.onOmnichannelSubscriptionItemPaused; - } - - set onOmnichannelSubscriptionItemReactivated( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemReactivatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemReactivated = handler; - } - - get onOmnichannelSubscriptionItemReactivated() { - return this._handlers.onOmnichannelSubscriptionItemReactivated; - } - - set onOmnichannelSubscriptionItemRenewed( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemRenewedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemRenewed = handler; - } - - get onOmnichannelSubscriptionItemRenewed() { - return this._handlers.onOmnichannelSubscriptionItemRenewed; - } - - set onOmnichannelSubscriptionItemResubscribed( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemResubscribedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemResubscribed = handler; - } - - get onOmnichannelSubscriptionItemResubscribed() { - return this._handlers.onOmnichannelSubscriptionItemResubscribed; - } - - set onOmnichannelSubscriptionItemResumed( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemResumedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemResumed = handler; - } - - get onOmnichannelSubscriptionItemResumed() { - return this._handlers.onOmnichannelSubscriptionItemResumed; - } - - set onOmnichannelSubscriptionItemScheduledCancellationRemoved( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemScheduledCancellationRemoved = - handler; - } - - get onOmnichannelSubscriptionItemScheduledCancellationRemoved() { - return this._handlers - .onOmnichannelSubscriptionItemScheduledCancellationRemoved; - } - - set onOmnichannelSubscriptionItemScheduledChangeRemoved( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledChangeRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved = - handler; - } - - get onOmnichannelSubscriptionItemScheduledChangeRemoved() { - return this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved; - } - - set onOmnichannelSubscriptionItemScheduledDowngradeRemoved( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledDowngradeRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemScheduledDowngradeRemoved = - handler; - } - - get onOmnichannelSubscriptionItemScheduledDowngradeRemoved() { - return this._handlers - .onOmnichannelSubscriptionItemScheduledDowngradeRemoved; - } - - set onOmnichannelSubscriptionItemUpgraded( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionItemUpgradedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionItemUpgraded = handler; - } - - get onOmnichannelSubscriptionItemUpgraded() { - return this._handlers.onOmnichannelSubscriptionItemUpgraded; - } - - set onOmnichannelSubscriptionMovedIn( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelSubscriptionMovedInContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelSubscriptionMovedIn = handler; - } - - get onOmnichannelSubscriptionMovedIn() { - return this._handlers.onOmnichannelSubscriptionMovedIn; - } - - set onOmnichannelTransactionCreated( - handler: - | (( - event: WebhookEvent & { - content: OmnichannelTransactionCreatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onOmnichannelTransactionCreated = handler; - } - - get onOmnichannelTransactionCreated() { - return this._handlers.onOmnichannelTransactionCreated; - } - - set onOrderCancelled( - handler: - | (( - event: WebhookEvent & { content: OrderCancelledContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderCancelled = handler; - } - - get onOrderCancelled() { - return this._handlers.onOrderCancelled; - } - - set onOrderCreated( - handler: - | (( - event: WebhookEvent & { content: OrderCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderCreated = handler; - } - - get onOrderCreated() { - return this._handlers.onOrderCreated; - } - - set onOrderDeleted( - handler: - | (( - event: WebhookEvent & { content: OrderDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderDeleted = handler; - } - - get onOrderDeleted() { - return this._handlers.onOrderDeleted; - } - - set onOrderDelivered( - handler: - | (( - event: WebhookEvent & { content: OrderDeliveredContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderDelivered = handler; - } - - get onOrderDelivered() { - return this._handlers.onOrderDelivered; - } - - set onOrderReadyToProcess( - handler: - | (( - event: WebhookEvent & { content: OrderReadyToProcessContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderReadyToProcess = handler; - } - - get onOrderReadyToProcess() { - return this._handlers.onOrderReadyToProcess; - } - - set onOrderReadyToShip( - handler: - | (( - event: WebhookEvent & { content: OrderReadyToShipContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderReadyToShip = handler; - } - - get onOrderReadyToShip() { - return this._handlers.onOrderReadyToShip; - } - - set onOrderResent( - handler: - | (( - event: WebhookEvent & { content: OrderResentContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderResent = handler; - } - - get onOrderResent() { - return this._handlers.onOrderResent; - } - - set onOrderReturned( - handler: - | (( - event: WebhookEvent & { content: OrderReturnedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderReturned = handler; - } - - get onOrderReturned() { - return this._handlers.onOrderReturned; - } - - set onOrderUpdated( - handler: - | (( - event: WebhookEvent & { content: OrderUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onOrderUpdated = handler; - } - - get onOrderUpdated() { - return this._handlers.onOrderUpdated; - } - - set onPaymentFailed( - handler: - | (( - event: WebhookEvent & { content: PaymentFailedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentFailed = handler; - } - - get onPaymentFailed() { - return this._handlers.onPaymentFailed; - } - - set onPaymentInitiated( - handler: - | (( - event: WebhookEvent & { content: PaymentInitiatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentInitiated = handler; - } - - get onPaymentInitiated() { - return this._handlers.onPaymentInitiated; - } - - set onPaymentIntentCreated( - handler: - | (( - event: WebhookEvent & { content: PaymentIntentCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentIntentCreated = handler; - } - - get onPaymentIntentCreated() { - return this._handlers.onPaymentIntentCreated; - } - - set onPaymentIntentUpdated( - handler: - | (( - event: WebhookEvent & { content: PaymentIntentUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentIntentUpdated = handler; - } - - get onPaymentIntentUpdated() { - return this._handlers.onPaymentIntentUpdated; - } - - set onPaymentRefunded( - handler: - | (( - event: WebhookEvent & { content: PaymentRefundedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentRefunded = handler; - } - - get onPaymentRefunded() { - return this._handlers.onPaymentRefunded; - } - - set onPaymentScheduleSchemeCreated( - handler: - | (( - event: WebhookEvent & { - content: PaymentScheduleSchemeCreatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentScheduleSchemeCreated = handler; - } - - get onPaymentScheduleSchemeCreated() { - return this._handlers.onPaymentScheduleSchemeCreated; - } - - set onPaymentScheduleSchemeDeleted( - handler: - | (( - event: WebhookEvent & { - content: PaymentScheduleSchemeDeletedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentScheduleSchemeDeleted = handler; - } - - get onPaymentScheduleSchemeDeleted() { - return this._handlers.onPaymentScheduleSchemeDeleted; - } - - set onPaymentSchedulesCreated( - handler: - | (( - event: WebhookEvent & { content: PaymentSchedulesCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSchedulesCreated = handler; - } - - get onPaymentSchedulesCreated() { - return this._handlers.onPaymentSchedulesCreated; - } - - set onPaymentSchedulesUpdated( - handler: - | (( - event: WebhookEvent & { content: PaymentSchedulesUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSchedulesUpdated = handler; - } - - get onPaymentSchedulesUpdated() { - return this._handlers.onPaymentSchedulesUpdated; - } - - set onPaymentSourceAdded( - handler: - | (( - event: WebhookEvent & { content: PaymentSourceAddedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSourceAdded = handler; - } - - get onPaymentSourceAdded() { - return this._handlers.onPaymentSourceAdded; - } - - set onPaymentSourceDeleted( - handler: - | (( - event: WebhookEvent & { content: PaymentSourceDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSourceDeleted = handler; - } - - get onPaymentSourceDeleted() { - return this._handlers.onPaymentSourceDeleted; - } - - set onPaymentSourceExpired( - handler: - | (( - event: WebhookEvent & { content: PaymentSourceExpiredContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSourceExpired = handler; - } - - get onPaymentSourceExpired() { - return this._handlers.onPaymentSourceExpired; - } - - set onPaymentSourceExpiring( - handler: - | (( - event: WebhookEvent & { content: PaymentSourceExpiringContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSourceExpiring = handler; - } - - get onPaymentSourceExpiring() { - return this._handlers.onPaymentSourceExpiring; - } - - set onPaymentSourceLocallyDeleted( - handler: - | (( - event: WebhookEvent & { content: PaymentSourceLocallyDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSourceLocallyDeleted = handler; - } - - get onPaymentSourceLocallyDeleted() { - return this._handlers.onPaymentSourceLocallyDeleted; - } - - set onPaymentSourceUpdated( - handler: - | (( - event: WebhookEvent & { content: PaymentSourceUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSourceUpdated = handler; - } - - get onPaymentSourceUpdated() { - return this._handlers.onPaymentSourceUpdated; - } - - set onPaymentSucceeded( - handler: - | (( - event: WebhookEvent & { content: PaymentSucceededContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPaymentSucceeded = handler; - } - - get onPaymentSucceeded() { - return this._handlers.onPaymentSucceeded; - } - - set onPendingInvoiceCreated( - handler: - | (( - event: WebhookEvent & { content: PendingInvoiceCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPendingInvoiceCreated = handler; - } - - get onPendingInvoiceCreated() { - return this._handlers.onPendingInvoiceCreated; - } - - set onPendingInvoiceUpdated( - handler: - | (( - event: WebhookEvent & { content: PendingInvoiceUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPendingInvoiceUpdated = handler; - } - - get onPendingInvoiceUpdated() { - return this._handlers.onPendingInvoiceUpdated; - } - - set onPlanCreated( - handler: - | (( - event: WebhookEvent & { content: PlanCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPlanCreated = handler; - } - - get onPlanCreated() { - return this._handlers.onPlanCreated; - } - - set onPlanDeleted( - handler: - | (( - event: WebhookEvent & { content: PlanDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPlanDeleted = handler; - } - - get onPlanDeleted() { - return this._handlers.onPlanDeleted; - } - - set onPlanUpdated( - handler: - | (( - event: WebhookEvent & { content: PlanUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPlanUpdated = handler; - } - - get onPlanUpdated() { - return this._handlers.onPlanUpdated; - } - - set onPriceVariantCreated( - handler: - | (( - event: WebhookEvent & { content: PriceVariantCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPriceVariantCreated = handler; - } - - get onPriceVariantCreated() { - return this._handlers.onPriceVariantCreated; - } - - set onPriceVariantDeleted( - handler: - | (( - event: WebhookEvent & { content: PriceVariantDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPriceVariantDeleted = handler; - } - - get onPriceVariantDeleted() { - return this._handlers.onPriceVariantDeleted; - } - - set onPriceVariantUpdated( - handler: - | (( - event: WebhookEvent & { content: PriceVariantUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPriceVariantUpdated = handler; - } - - get onPriceVariantUpdated() { - return this._handlers.onPriceVariantUpdated; - } - - set onProductCreated( - handler: - | (( - event: WebhookEvent & { content: ProductCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onProductCreated = handler; - } - - get onProductCreated() { - return this._handlers.onProductCreated; - } - - set onProductDeleted( - handler: - | (( - event: WebhookEvent & { content: ProductDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onProductDeleted = handler; - } - - get onProductDeleted() { - return this._handlers.onProductDeleted; - } - - set onProductUpdated( - handler: - | (( - event: WebhookEvent & { content: ProductUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onProductUpdated = handler; - } - - get onProductUpdated() { - return this._handlers.onProductUpdated; - } - - set onPromotionalCreditsAdded( - handler: - | (( - event: WebhookEvent & { content: PromotionalCreditsAddedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPromotionalCreditsAdded = handler; - } - - get onPromotionalCreditsAdded() { - return this._handlers.onPromotionalCreditsAdded; - } - - set onPromotionalCreditsDeducted( - handler: - | (( - event: WebhookEvent & { content: PromotionalCreditsDeductedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPromotionalCreditsDeducted = handler; - } - - get onPromotionalCreditsDeducted() { - return this._handlers.onPromotionalCreditsDeducted; - } - - set onPurchaseCreated( - handler: - | (( - event: WebhookEvent & { content: PurchaseCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onPurchaseCreated = handler; - } - - get onPurchaseCreated() { - return this._handlers.onPurchaseCreated; - } - - set onQuoteCreated( - handler: - | (( - event: WebhookEvent & { content: QuoteCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onQuoteCreated = handler; - } - - get onQuoteCreated() { - return this._handlers.onQuoteCreated; - } - - set onQuoteDeleted( - handler: - | (( - event: WebhookEvent & { content: QuoteDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onQuoteDeleted = handler; - } - - get onQuoteDeleted() { - return this._handlers.onQuoteDeleted; - } - - set onQuoteUpdated( - handler: - | (( - event: WebhookEvent & { content: QuoteUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onQuoteUpdated = handler; - } - - get onQuoteUpdated() { - return this._handlers.onQuoteUpdated; - } - - set onRecordPurchaseFailed( - handler: - | (( - event: WebhookEvent & { content: RecordPurchaseFailedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onRecordPurchaseFailed = handler; - } - - get onRecordPurchaseFailed() { - return this._handlers.onRecordPurchaseFailed; - } - - set onRefundInitiated( - handler: - | (( - event: WebhookEvent & { content: RefundInitiatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onRefundInitiated = handler; - } - - get onRefundInitiated() { - return this._handlers.onRefundInitiated; - } - - set onRuleCreated( - handler: - | (( - event: WebhookEvent & { content: RuleCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onRuleCreated = handler; - } - - get onRuleCreated() { - return this._handlers.onRuleCreated; - } - - set onRuleDeleted( - handler: - | (( - event: WebhookEvent & { content: RuleDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onRuleDeleted = handler; - } - - get onRuleDeleted() { - return this._handlers.onRuleDeleted; - } - - set onRuleUpdated( - handler: - | (( - event: WebhookEvent & { content: RuleUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onRuleUpdated = handler; - } - - get onRuleUpdated() { - return this._handlers.onRuleUpdated; - } - - set onSalesOrderCreated( - handler: - | (( - event: WebhookEvent & { content: SalesOrderCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSalesOrderCreated = handler; - } - - get onSalesOrderCreated() { - return this._handlers.onSalesOrderCreated; - } - - set onSalesOrderUpdated( - handler: - | (( - event: WebhookEvent & { content: SalesOrderUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSalesOrderUpdated = handler; - } - - get onSalesOrderUpdated() { - return this._handlers.onSalesOrderUpdated; - } - - set onSubscriptionActivated( - handler: - | (( - event: WebhookEvent & { content: SubscriptionActivatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionActivated = handler; - } - - get onSubscriptionActivated() { - return this._handlers.onSubscriptionActivated; - } - - set onSubscriptionActivatedWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionActivatedWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionActivatedWithBackdating = handler; - } - - get onSubscriptionActivatedWithBackdating() { - return this._handlers.onSubscriptionActivatedWithBackdating; - } - - set onSubscriptionAdvanceInvoiceScheduleAdded( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleAddedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded = handler; - } - - get onSubscriptionAdvanceInvoiceScheduleAdded() { - return this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded; - } - - set onSubscriptionAdvanceInvoiceScheduleRemoved( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved = handler; - } - - get onSubscriptionAdvanceInvoiceScheduleRemoved() { - return this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved; - } - - set onSubscriptionAdvanceInvoiceScheduleUpdated( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleUpdatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated = handler; - } - - get onSubscriptionAdvanceInvoiceScheduleUpdated() { - return this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated; - } - - set onSubscriptionBusinessEntityChanged( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionBusinessEntityChangedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionBusinessEntityChanged = handler; - } - - get onSubscriptionBusinessEntityChanged() { - return this._handlers.onSubscriptionBusinessEntityChanged; - } - - set onSubscriptionCanceledWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionCanceledWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionCanceledWithBackdating = handler; - } - - get onSubscriptionCanceledWithBackdating() { - return this._handlers.onSubscriptionCanceledWithBackdating; - } - - set onSubscriptionCancellationReminder( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionCancellationReminderContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionCancellationReminder = handler; - } - - get onSubscriptionCancellationReminder() { - return this._handlers.onSubscriptionCancellationReminder; - } - - set onSubscriptionCancellationScheduled( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionCancellationScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionCancellationScheduled = handler; - } - - get onSubscriptionCancellationScheduled() { - return this._handlers.onSubscriptionCancellationScheduled; - } - - set onSubscriptionCancelled( - handler: - | (( - event: WebhookEvent & { content: SubscriptionCancelledContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionCancelled = handler; - } - - get onSubscriptionCancelled() { - return this._handlers.onSubscriptionCancelled; - } - - set onSubscriptionChanged( - handler: - | (( - event: WebhookEvent & { content: SubscriptionChangedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionChanged = handler; - } - - get onSubscriptionChanged() { - return this._handlers.onSubscriptionChanged; - } - - set onSubscriptionChangedWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionChangedWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionChangedWithBackdating = handler; - } - - get onSubscriptionChangedWithBackdating() { - return this._handlers.onSubscriptionChangedWithBackdating; - } - - set onSubscriptionChangesScheduled( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionChangesScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionChangesScheduled = handler; - } - - get onSubscriptionChangesScheduled() { - return this._handlers.onSubscriptionChangesScheduled; - } - - set onSubscriptionCreated( - handler: - | (( - event: WebhookEvent & { content: SubscriptionCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionCreated = handler; - } - - get onSubscriptionCreated() { - return this._handlers.onSubscriptionCreated; - } - - set onSubscriptionCreatedWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionCreatedWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionCreatedWithBackdating = handler; - } - - get onSubscriptionCreatedWithBackdating() { - return this._handlers.onSubscriptionCreatedWithBackdating; - } - - set onSubscriptionDeleted( - handler: - | (( - event: WebhookEvent & { content: SubscriptionDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionDeleted = handler; - } - - get onSubscriptionDeleted() { - return this._handlers.onSubscriptionDeleted; - } - - set onSubscriptionEntitlementsCreated( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionEntitlementsCreatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionEntitlementsCreated = handler; - } - - get onSubscriptionEntitlementsCreated() { - return this._handlers.onSubscriptionEntitlementsCreated; - } - - set onSubscriptionEntitlementsUpdated( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionEntitlementsUpdatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionEntitlementsUpdated = handler; - } - - get onSubscriptionEntitlementsUpdated() { - return this._handlers.onSubscriptionEntitlementsUpdated; - } - - set onSubscriptionItemsRenewed( - handler: - | (( - event: WebhookEvent & { content: SubscriptionItemsRenewedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionItemsRenewed = handler; - } - - get onSubscriptionItemsRenewed() { - return this._handlers.onSubscriptionItemsRenewed; - } - - set onSubscriptionMovedIn( - handler: - | (( - event: WebhookEvent & { content: SubscriptionMovedInContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionMovedIn = handler; - } - - get onSubscriptionMovedIn() { - return this._handlers.onSubscriptionMovedIn; - } - - set onSubscriptionMovedOut( - handler: - | (( - event: WebhookEvent & { content: SubscriptionMovedOutContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionMovedOut = handler; - } - - get onSubscriptionMovedOut() { - return this._handlers.onSubscriptionMovedOut; - } - - set onSubscriptionMovementFailed( - handler: - | (( - event: WebhookEvent & { content: SubscriptionMovementFailedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionMovementFailed = handler; - } - - get onSubscriptionMovementFailed() { - return this._handlers.onSubscriptionMovementFailed; - } - - set onSubscriptionPauseScheduled( - handler: - | (( - event: WebhookEvent & { content: SubscriptionPauseScheduledContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionPauseScheduled = handler; - } - - get onSubscriptionPauseScheduled() { - return this._handlers.onSubscriptionPauseScheduled; - } - - set onSubscriptionPaused( - handler: - | (( - event: WebhookEvent & { content: SubscriptionPausedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionPaused = handler; - } - - get onSubscriptionPaused() { - return this._handlers.onSubscriptionPaused; - } - - set onSubscriptionRampApplied( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRampAppliedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRampApplied = handler; - } - - get onSubscriptionRampApplied() { - return this._handlers.onSubscriptionRampApplied; - } - - set onSubscriptionRampCreated( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRampCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRampCreated = handler; - } - - get onSubscriptionRampCreated() { - return this._handlers.onSubscriptionRampCreated; - } - - set onSubscriptionRampDeleted( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRampDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRampDeleted = handler; - } - - get onSubscriptionRampDeleted() { - return this._handlers.onSubscriptionRampDeleted; - } - - set onSubscriptionRampDrafted( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRampDraftedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRampDrafted = handler; - } - - get onSubscriptionRampDrafted() { - return this._handlers.onSubscriptionRampDrafted; - } - - set onSubscriptionRampUpdated( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRampUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRampUpdated = handler; - } - - get onSubscriptionRampUpdated() { - return this._handlers.onSubscriptionRampUpdated; - } - - set onSubscriptionReactivated( - handler: - | (( - event: WebhookEvent & { content: SubscriptionReactivatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionReactivated = handler; - } - - get onSubscriptionReactivated() { - return this._handlers.onSubscriptionReactivated; - } - - set onSubscriptionReactivatedWithBackdating( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionReactivatedWithBackdatingContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionReactivatedWithBackdating = handler; - } - - get onSubscriptionReactivatedWithBackdating() { - return this._handlers.onSubscriptionReactivatedWithBackdating; - } - - set onSubscriptionRenewalReminder( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRenewalReminderContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRenewalReminder = handler; - } - - get onSubscriptionRenewalReminder() { - return this._handlers.onSubscriptionRenewalReminder; - } - - set onSubscriptionRenewed( - handler: - | (( - event: WebhookEvent & { content: SubscriptionRenewedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionRenewed = handler; - } - - get onSubscriptionRenewed() { - return this._handlers.onSubscriptionRenewed; - } - - set onSubscriptionResumed( - handler: - | (( - event: WebhookEvent & { content: SubscriptionResumedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionResumed = handler; - } - - get onSubscriptionResumed() { - return this._handlers.onSubscriptionResumed; - } - - set onSubscriptionResumptionScheduled( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionResumptionScheduledContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionResumptionScheduled = handler; - } - - get onSubscriptionResumptionScheduled() { - return this._handlers.onSubscriptionResumptionScheduled; - } - - set onSubscriptionScheduledCancellationRemoved( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionScheduledCancellationRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionScheduledCancellationRemoved = handler; - } - - get onSubscriptionScheduledCancellationRemoved() { - return this._handlers.onSubscriptionScheduledCancellationRemoved; - } - - set onSubscriptionScheduledChangesRemoved( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionScheduledChangesRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionScheduledChangesRemoved = handler; - } - - get onSubscriptionScheduledChangesRemoved() { - return this._handlers.onSubscriptionScheduledChangesRemoved; - } - - set onSubscriptionScheduledPauseRemoved( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionScheduledPauseRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionScheduledPauseRemoved = handler; - } - - get onSubscriptionScheduledPauseRemoved() { - return this._handlers.onSubscriptionScheduledPauseRemoved; - } - - set onSubscriptionScheduledResumptionRemoved( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionScheduledResumptionRemovedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionScheduledResumptionRemoved = handler; - } - - get onSubscriptionScheduledResumptionRemoved() { - return this._handlers.onSubscriptionScheduledResumptionRemoved; - } - - set onSubscriptionShippingAddressUpdated( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionShippingAddressUpdatedContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionShippingAddressUpdated = handler; - } - - get onSubscriptionShippingAddressUpdated() { - return this._handlers.onSubscriptionShippingAddressUpdated; - } - - set onSubscriptionStarted( - handler: - | (( - event: WebhookEvent & { content: SubscriptionStartedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionStarted = handler; - } - - get onSubscriptionStarted() { - return this._handlers.onSubscriptionStarted; - } - - set onSubscriptionTrialEndReminder( - handler: - | (( - event: WebhookEvent & { - content: SubscriptionTrialEndReminderContent; - }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionTrialEndReminder = handler; - } - - get onSubscriptionTrialEndReminder() { - return this._handlers.onSubscriptionTrialEndReminder; - } - - set onSubscriptionTrialExtended( - handler: - | (( - event: WebhookEvent & { content: SubscriptionTrialExtendedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onSubscriptionTrialExtended = handler; - } - - get onSubscriptionTrialExtended() { - return this._handlers.onSubscriptionTrialExtended; - } - - set onTaxWithheldDeleted( - handler: - | (( - event: WebhookEvent & { content: TaxWithheldDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTaxWithheldDeleted = handler; - } - - get onTaxWithheldDeleted() { - return this._handlers.onTaxWithheldDeleted; - } - - set onTaxWithheldRecorded( - handler: - | (( - event: WebhookEvent & { content: TaxWithheldRecordedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTaxWithheldRecorded = handler; - } - - get onTaxWithheldRecorded() { - return this._handlers.onTaxWithheldRecorded; - } - - set onTaxWithheldRefunded( - handler: - | (( - event: WebhookEvent & { content: TaxWithheldRefundedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTaxWithheldRefunded = handler; - } - - get onTaxWithheldRefunded() { - return this._handlers.onTaxWithheldRefunded; - } - - set onTokenConsumed( - handler: - | (( - event: WebhookEvent & { content: TokenConsumedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTokenConsumed = handler; - } - - get onTokenConsumed() { - return this._handlers.onTokenConsumed; - } - - set onTokenCreated( - handler: - | (( - event: WebhookEvent & { content: TokenCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTokenCreated = handler; - } - - get onTokenCreated() { - return this._handlers.onTokenCreated; - } - - set onTokenExpired( - handler: - | (( - event: WebhookEvent & { content: TokenExpiredContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTokenExpired = handler; - } - - get onTokenExpired() { - return this._handlers.onTokenExpired; - } - - set onTransactionCreated( - handler: - | (( - event: WebhookEvent & { content: TransactionCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTransactionCreated = handler; - } - - get onTransactionCreated() { - return this._handlers.onTransactionCreated; - } - - set onTransactionDeleted( - handler: - | (( - event: WebhookEvent & { content: TransactionDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTransactionDeleted = handler; - } - - get onTransactionDeleted() { - return this._handlers.onTransactionDeleted; - } - - set onTransactionUpdated( - handler: - | (( - event: WebhookEvent & { content: TransactionUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onTransactionUpdated = handler; - } - - get onTransactionUpdated() { - return this._handlers.onTransactionUpdated; - } - - set onUnbilledChargesCreated( - handler: - | (( - event: WebhookEvent & { content: UnbilledChargesCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onUnbilledChargesCreated = handler; - } - - get onUnbilledChargesCreated() { - return this._handlers.onUnbilledChargesCreated; - } - - set onUnbilledChargesDeleted( - handler: - | (( - event: WebhookEvent & { content: UnbilledChargesDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onUnbilledChargesDeleted = handler; - } - - get onUnbilledChargesDeleted() { - return this._handlers.onUnbilledChargesDeleted; - } - - set onUnbilledChargesInvoiced( - handler: - | (( - event: WebhookEvent & { content: UnbilledChargesInvoicedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onUnbilledChargesInvoiced = handler; - } - - get onUnbilledChargesInvoiced() { - return this._handlers.onUnbilledChargesInvoiced; - } - - set onUnbilledChargesVoided( - handler: - | (( - event: WebhookEvent & { content: UnbilledChargesVoidedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onUnbilledChargesVoided = handler; - } - - get onUnbilledChargesVoided() { - return this._handlers.onUnbilledChargesVoided; - } - - set onUsageFileIngested( - handler: - | (( - event: WebhookEvent & { content: UsageFileIngestedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onUsageFileIngested = handler; - } - - get onUsageFileIngested() { - return this._handlers.onUsageFileIngested; - } - - set onVariantCreated( - handler: - | (( - event: WebhookEvent & { content: VariantCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVariantCreated = handler; - } - - get onVariantCreated() { - return this._handlers.onVariantCreated; - } - - set onVariantDeleted( - handler: - | (( - event: WebhookEvent & { content: VariantDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVariantDeleted = handler; - } - - get onVariantDeleted() { - return this._handlers.onVariantDeleted; - } - - set onVariantUpdated( - handler: - | (( - event: WebhookEvent & { content: VariantUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVariantUpdated = handler; - } - - get onVariantUpdated() { - return this._handlers.onVariantUpdated; - } - - set onVirtualBankAccountAdded( - handler: - | (( - event: WebhookEvent & { content: VirtualBankAccountAddedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVirtualBankAccountAdded = handler; - } - - get onVirtualBankAccountAdded() { - return this._handlers.onVirtualBankAccountAdded; - } - - set onVirtualBankAccountDeleted( - handler: - | (( - event: WebhookEvent & { content: VirtualBankAccountDeletedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVirtualBankAccountDeleted = handler; - } - - get onVirtualBankAccountDeleted() { - return this._handlers.onVirtualBankAccountDeleted; - } - - set onVirtualBankAccountUpdated( - handler: - | (( - event: WebhookEvent & { content: VirtualBankAccountUpdatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVirtualBankAccountUpdated = handler; - } - - get onVirtualBankAccountUpdated() { - return this._handlers.onVirtualBankAccountUpdated; - } +export interface WebhookEventMap extends Record { + unhandled_event: WebhookEvent; + error: unknown; +} - set onVoucherCreateFailed( - handler: - | (( - event: WebhookEvent & { content: VoucherCreateFailedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVoucherCreateFailed = handler; - } +export type WebhookEventListener = ( + event: WebhookEventMap[K], +) => Promise | void; - get onVoucherCreateFailed() { - return this._handlers.onVoucherCreateFailed; - } +export class WebhookHandler extends EventEmitter { + requestValidator?: ( + headers: Record, + ) => void; - set onVoucherCreated( - handler: - | (( - event: WebhookEvent & { content: VoucherCreatedContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVoucherCreated = handler; + on( + eventName: K, + listener: WebhookEventListener, + ): this { + return super.on(eventName, listener as (...args: unknown[]) => void); } - get onVoucherCreated() { - return this._handlers.onVoucherCreated; + once( + eventName: K, + listener: WebhookEventListener, + ): this { + return super.once(eventName, listener as (...args: unknown[]) => void); } - set onVoucherExpired( - handler: - | (( - event: WebhookEvent & { content: VoucherExpiredContent }, - ) => Promise) - | undefined, - ) { - this._handlers.onVoucherExpired = handler; + off( + eventName: K, + listener: WebhookEventListener, + ): this { + return super.off(eventName, listener as (...args: unknown[]) => void); } - get onVoucherExpired() { - return this._handlers.onVoucherExpired; + emit( + eventName: K, + event: WebhookEventMap[K], + ): boolean { + return super.emit(eventName, event); } - async handle( + handle( body: string | object, headers?: Record, - ): Promise { + ): void { try { if (this.requestValidator && headers) { this.requestValidator(headers); } - let event: WebhookEvent; - if (typeof body === 'string') { - event = JSON.parse(body); - } else { - event = body as WebhookEvent; - } - - const eventType = event.event_type; - - switch (eventType) { - case EventType.ADD_USAGES_REMINDER: - if (this._handlers.onAddUsagesReminder) { - await this._handlers.onAddUsagesReminder( - event as WebhookEvent & { content: AddUsagesReminderContent }, - ); - return; - } - break; - - case EventType.ADDON_CREATED: - if (this._handlers.onAddonCreated) { - await this._handlers.onAddonCreated( - event as WebhookEvent & { content: AddonCreatedContent }, - ); - return; - } - break; - - case EventType.ADDON_DELETED: - if (this._handlers.onAddonDeleted) { - await this._handlers.onAddonDeleted( - event as WebhookEvent & { content: AddonDeletedContent }, - ); - return; - } - break; - - case EventType.ADDON_UPDATED: - if (this._handlers.onAddonUpdated) { - await this._handlers.onAddonUpdated( - event as WebhookEvent & { content: AddonUpdatedContent }, - ); - return; - } - break; - - case EventType.ATTACHED_ITEM_CREATED: - if (this._handlers.onAttachedItemCreated) { - await this._handlers.onAttachedItemCreated( - event as WebhookEvent & { content: AttachedItemCreatedContent }, - ); - return; - } - break; - - case EventType.ATTACHED_ITEM_DELETED: - if (this._handlers.onAttachedItemDeleted) { - await this._handlers.onAttachedItemDeleted( - event as WebhookEvent & { content: AttachedItemDeletedContent }, - ); - return; - } - break; - - case EventType.ATTACHED_ITEM_UPDATED: - if (this._handlers.onAttachedItemUpdated) { - await this._handlers.onAttachedItemUpdated( - event as WebhookEvent & { content: AttachedItemUpdatedContent }, - ); - return; - } - break; - - case EventType.AUTHORIZATION_SUCCEEDED: - if (this._handlers.onAuthorizationSucceeded) { - await this._handlers.onAuthorizationSucceeded( - event as WebhookEvent & { - content: AuthorizationSucceededContent; - }, - ); - return; - } - break; - - case EventType.AUTHORIZATION_VOIDED: - if (this._handlers.onAuthorizationVoided) { - await this._handlers.onAuthorizationVoided( - event as WebhookEvent & { content: AuthorizationVoidedContent }, - ); - return; - } - break; - - case EventType.BUSINESS_ENTITY_CREATED: - if (this._handlers.onBusinessEntityCreated) { - await this._handlers.onBusinessEntityCreated( - event as WebhookEvent & { content: BusinessEntityCreatedContent }, - ); - return; - } - break; - - case EventType.BUSINESS_ENTITY_DELETED: - if (this._handlers.onBusinessEntityDeleted) { - await this._handlers.onBusinessEntityDeleted( - event as WebhookEvent & { content: BusinessEntityDeletedContent }, - ); - return; - } - break; - - case EventType.BUSINESS_ENTITY_UPDATED: - if (this._handlers.onBusinessEntityUpdated) { - await this._handlers.onBusinessEntityUpdated( - event as WebhookEvent & { content: BusinessEntityUpdatedContent }, - ); - return; - } - break; - - case EventType.CARD_ADDED: - if (this._handlers.onCardAdded) { - await this._handlers.onCardAdded( - event as WebhookEvent & { content: CardAddedContent }, - ); - return; - } - break; - - case EventType.CARD_DELETED: - if (this._handlers.onCardDeleted) { - await this._handlers.onCardDeleted( - event as WebhookEvent & { content: CardDeletedContent }, - ); - return; - } - break; - - case EventType.CARD_EXPIRED: - if (this._handlers.onCardExpired) { - await this._handlers.onCardExpired( - event as WebhookEvent & { content: CardExpiredContent }, - ); - return; - } - break; - - case EventType.CARD_EXPIRY_REMINDER: - if (this._handlers.onCardExpiryReminder) { - await this._handlers.onCardExpiryReminder( - event as WebhookEvent & { content: CardExpiryReminderContent }, - ); - return; - } - break; - - case EventType.CARD_UPDATED: - if (this._handlers.onCardUpdated) { - await this._handlers.onCardUpdated( - event as WebhookEvent & { content: CardUpdatedContent }, - ); - return; - } - break; - - case EventType.CONTRACT_TERM_CANCELLED: - if (this._handlers.onContractTermCancelled) { - await this._handlers.onContractTermCancelled( - event as WebhookEvent & { content: ContractTermCancelledContent }, - ); - return; - } - break; - - case EventType.CONTRACT_TERM_COMPLETED: - if (this._handlers.onContractTermCompleted) { - await this._handlers.onContractTermCompleted( - event as WebhookEvent & { content: ContractTermCompletedContent }, - ); - return; - } - break; - - case EventType.CONTRACT_TERM_CREATED: - if (this._handlers.onContractTermCreated) { - await this._handlers.onContractTermCreated( - event as WebhookEvent & { content: ContractTermCreatedContent }, - ); - return; - } - break; - - case EventType.CONTRACT_TERM_RENEWED: - if (this._handlers.onContractTermRenewed) { - await this._handlers.onContractTermRenewed( - event as WebhookEvent & { content: ContractTermRenewedContent }, - ); - return; - } - break; - - case EventType.CONTRACT_TERM_TERMINATED: - if (this._handlers.onContractTermTerminated) { - await this._handlers.onContractTermTerminated( - event as WebhookEvent & { - content: ContractTermTerminatedContent; - }, - ); - return; - } - break; - - case EventType.COUPON_CODES_ADDED: - if (this._handlers.onCouponCodesAdded) { - await this._handlers.onCouponCodesAdded( - event as WebhookEvent & { content: CouponCodesAddedContent }, - ); - return; - } - break; - - case EventType.COUPON_CODES_DELETED: - if (this._handlers.onCouponCodesDeleted) { - await this._handlers.onCouponCodesDeleted( - event as WebhookEvent & { content: CouponCodesDeletedContent }, - ); - return; - } - break; - - case EventType.COUPON_CODES_UPDATED: - if (this._handlers.onCouponCodesUpdated) { - await this._handlers.onCouponCodesUpdated( - event as WebhookEvent & { content: CouponCodesUpdatedContent }, - ); - return; - } - break; - - case EventType.COUPON_CREATED: - if (this._handlers.onCouponCreated) { - await this._handlers.onCouponCreated( - event as WebhookEvent & { content: CouponCreatedContent }, - ); - return; - } - break; - - case EventType.COUPON_DELETED: - if (this._handlers.onCouponDeleted) { - await this._handlers.onCouponDeleted( - event as WebhookEvent & { content: CouponDeletedContent }, - ); - return; - } - break; - - case EventType.COUPON_SET_CREATED: - if (this._handlers.onCouponSetCreated) { - await this._handlers.onCouponSetCreated( - event as WebhookEvent & { content: CouponSetCreatedContent }, - ); - return; - } - break; - - case EventType.COUPON_SET_DELETED: - if (this._handlers.onCouponSetDeleted) { - await this._handlers.onCouponSetDeleted( - event as WebhookEvent & { content: CouponSetDeletedContent }, - ); - return; - } - break; - - case EventType.COUPON_SET_UPDATED: - if (this._handlers.onCouponSetUpdated) { - await this._handlers.onCouponSetUpdated( - event as WebhookEvent & { content: CouponSetUpdatedContent }, - ); - return; - } - break; - - case EventType.COUPON_UPDATED: - if (this._handlers.onCouponUpdated) { - await this._handlers.onCouponUpdated( - event as WebhookEvent & { content: CouponUpdatedContent }, - ); - return; - } - break; - - case EventType.CREDIT_NOTE_CREATED: - if (this._handlers.onCreditNoteCreated) { - await this._handlers.onCreditNoteCreated( - event as WebhookEvent & { content: CreditNoteCreatedContent }, - ); - return; - } - break; - - case EventType.CREDIT_NOTE_CREATED_WITH_BACKDATING: - if (this._handlers.onCreditNoteCreatedWithBackdating) { - await this._handlers.onCreditNoteCreatedWithBackdating( - event as WebhookEvent & { - content: CreditNoteCreatedWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.CREDIT_NOTE_DELETED: - if (this._handlers.onCreditNoteDeleted) { - await this._handlers.onCreditNoteDeleted( - event as WebhookEvent & { content: CreditNoteDeletedContent }, - ); - return; - } - break; - - case EventType.CREDIT_NOTE_UPDATED: - if (this._handlers.onCreditNoteUpdated) { - await this._handlers.onCreditNoteUpdated( - event as WebhookEvent & { content: CreditNoteUpdatedContent }, - ); - return; - } - break; - - case EventType.CUSTOMER_BUSINESS_ENTITY_CHANGED: - if (this._handlers.onCustomerBusinessEntityChanged) { - await this._handlers.onCustomerBusinessEntityChanged( - event as WebhookEvent & { - content: CustomerBusinessEntityChangedContent; - }, - ); - return; - } - break; - - case EventType.CUSTOMER_CHANGED: - if (this._handlers.onCustomerChanged) { - await this._handlers.onCustomerChanged( - event as WebhookEvent & { content: CustomerChangedContent }, - ); - return; - } - break; - - case EventType.CUSTOMER_CREATED: - if (this._handlers.onCustomerCreated) { - await this._handlers.onCustomerCreated( - event as WebhookEvent & { content: CustomerCreatedContent }, - ); - return; - } - break; - - case EventType.CUSTOMER_DELETED: - if (this._handlers.onCustomerDeleted) { - await this._handlers.onCustomerDeleted( - event as WebhookEvent & { content: CustomerDeletedContent }, - ); - return; - } - break; - - case EventType.CUSTOMER_ENTITLEMENTS_UPDATED: - if (this._handlers.onCustomerEntitlementsUpdated) { - await this._handlers.onCustomerEntitlementsUpdated( - event as WebhookEvent & { - content: CustomerEntitlementsUpdatedContent; - }, - ); - return; - } - break; - - case EventType.CUSTOMER_MOVED_IN: - if (this._handlers.onCustomerMovedIn) { - await this._handlers.onCustomerMovedIn( - event as WebhookEvent & { content: CustomerMovedInContent }, - ); - return; - } - break; - - case EventType.CUSTOMER_MOVED_OUT: - if (this._handlers.onCustomerMovedOut) { - await this._handlers.onCustomerMovedOut( - event as WebhookEvent & { content: CustomerMovedOutContent }, - ); - return; - } - break; - - case EventType.DIFFERENTIAL_PRICE_CREATED: - if (this._handlers.onDifferentialPriceCreated) { - await this._handlers.onDifferentialPriceCreated( - event as WebhookEvent & { - content: DifferentialPriceCreatedContent; - }, - ); - return; - } - break; - - case EventType.DIFFERENTIAL_PRICE_DELETED: - if (this._handlers.onDifferentialPriceDeleted) { - await this._handlers.onDifferentialPriceDeleted( - event as WebhookEvent & { - content: DifferentialPriceDeletedContent; - }, - ); - return; - } - break; - - case EventType.DIFFERENTIAL_PRICE_UPDATED: - if (this._handlers.onDifferentialPriceUpdated) { - await this._handlers.onDifferentialPriceUpdated( - event as WebhookEvent & { - content: DifferentialPriceUpdatedContent; - }, - ); - return; - } - break; - - case EventType.DUNNING_UPDATED: - if (this._handlers.onDunningUpdated) { - await this._handlers.onDunningUpdated( - event as WebhookEvent & { content: DunningUpdatedContent }, - ); - return; - } - break; - - case EventType.ENTITLEMENT_OVERRIDES_AUTO_REMOVED: - if (this._handlers.onEntitlementOverridesAutoRemoved) { - await this._handlers.onEntitlementOverridesAutoRemoved( - event as WebhookEvent & { - content: EntitlementOverridesAutoRemovedContent; - }, - ); - return; - } - break; - - case EventType.ENTITLEMENT_OVERRIDES_REMOVED: - if (this._handlers.onEntitlementOverridesRemoved) { - await this._handlers.onEntitlementOverridesRemoved( - event as WebhookEvent & { - content: EntitlementOverridesRemovedContent; - }, - ); - return; - } - break; - - case EventType.ENTITLEMENT_OVERRIDES_UPDATED: - if (this._handlers.onEntitlementOverridesUpdated) { - await this._handlers.onEntitlementOverridesUpdated( - event as WebhookEvent & { - content: EntitlementOverridesUpdatedContent; - }, - ); - return; - } - break; - - case EventType.FEATURE_ACTIVATED: - if (this._handlers.onFeatureActivated) { - await this._handlers.onFeatureActivated( - event as WebhookEvent & { content: FeatureActivatedContent }, - ); - return; - } - break; - - case EventType.FEATURE_ARCHIVED: - if (this._handlers.onFeatureArchived) { - await this._handlers.onFeatureArchived( - event as WebhookEvent & { content: FeatureArchivedContent }, - ); - return; - } - break; - - case EventType.FEATURE_CREATED: - if (this._handlers.onFeatureCreated) { - await this._handlers.onFeatureCreated( - event as WebhookEvent & { content: FeatureCreatedContent }, - ); - return; - } - break; - - case EventType.FEATURE_DELETED: - if (this._handlers.onFeatureDeleted) { - await this._handlers.onFeatureDeleted( - event as WebhookEvent & { content: FeatureDeletedContent }, - ); - return; - } - break; - - case EventType.FEATURE_REACTIVATED: - if (this._handlers.onFeatureReactivated) { - await this._handlers.onFeatureReactivated( - event as WebhookEvent & { content: FeatureReactivatedContent }, - ); - return; - } - break; - - case EventType.FEATURE_UPDATED: - if (this._handlers.onFeatureUpdated) { - await this._handlers.onFeatureUpdated( - event as WebhookEvent & { content: FeatureUpdatedContent }, - ); - return; - } - break; - - case EventType.GIFT_CANCELLED: - if (this._handlers.onGiftCancelled) { - await this._handlers.onGiftCancelled( - event as WebhookEvent & { content: GiftCancelledContent }, - ); - return; - } - break; - - case EventType.GIFT_CLAIMED: - if (this._handlers.onGiftClaimed) { - await this._handlers.onGiftClaimed( - event as WebhookEvent & { content: GiftClaimedContent }, - ); - return; - } - break; - - case EventType.GIFT_EXPIRED: - if (this._handlers.onGiftExpired) { - await this._handlers.onGiftExpired( - event as WebhookEvent & { content: GiftExpiredContent }, - ); - return; - } - break; - - case EventType.GIFT_SCHEDULED: - if (this._handlers.onGiftScheduled) { - await this._handlers.onGiftScheduled( - event as WebhookEvent & { content: GiftScheduledContent }, - ); - return; - } - break; - - case EventType.GIFT_UNCLAIMED: - if (this._handlers.onGiftUnclaimed) { - await this._handlers.onGiftUnclaimed( - event as WebhookEvent & { content: GiftUnclaimedContent }, - ); - return; - } - break; - - case EventType.GIFT_UPDATED: - if (this._handlers.onGiftUpdated) { - await this._handlers.onGiftUpdated( - event as WebhookEvent & { content: GiftUpdatedContent }, - ); - return; - } - break; - - case EventType.HIERARCHY_CREATED: - if (this._handlers.onHierarchyCreated) { - await this._handlers.onHierarchyCreated( - event as WebhookEvent & { content: HierarchyCreatedContent }, - ); - return; - } - break; - - case EventType.HIERARCHY_DELETED: - if (this._handlers.onHierarchyDeleted) { - await this._handlers.onHierarchyDeleted( - event as WebhookEvent & { content: HierarchyDeletedContent }, - ); - return; - } - break; - - case EventType.INVOICE_DELETED: - if (this._handlers.onInvoiceDeleted) { - await this._handlers.onInvoiceDeleted( - event as WebhookEvent & { content: InvoiceDeletedContent }, - ); - return; - } - break; - - case EventType.INVOICE_GENERATED: - if (this._handlers.onInvoiceGenerated) { - await this._handlers.onInvoiceGenerated( - event as WebhookEvent & { content: InvoiceGeneratedContent }, - ); - return; - } - break; - - case EventType.INVOICE_GENERATED_WITH_BACKDATING: - if (this._handlers.onInvoiceGeneratedWithBackdating) { - await this._handlers.onInvoiceGeneratedWithBackdating( - event as WebhookEvent & { - content: InvoiceGeneratedWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.INVOICE_UPDATED: - if (this._handlers.onInvoiceUpdated) { - await this._handlers.onInvoiceUpdated( - event as WebhookEvent & { content: InvoiceUpdatedContent }, - ); - return; - } - break; - - case EventType.ITEM_CREATED: - if (this._handlers.onItemCreated) { - await this._handlers.onItemCreated( - event as WebhookEvent & { content: ItemCreatedContent }, - ); - return; - } - break; - - case EventType.ITEM_DELETED: - if (this._handlers.onItemDeleted) { - await this._handlers.onItemDeleted( - event as WebhookEvent & { content: ItemDeletedContent }, - ); - return; - } - break; - - case EventType.ITEM_ENTITLEMENTS_REMOVED: - if (this._handlers.onItemEntitlementsRemoved) { - await this._handlers.onItemEntitlementsRemoved( - event as WebhookEvent & { - content: ItemEntitlementsRemovedContent; - }, - ); - return; - } - break; - - case EventType.ITEM_ENTITLEMENTS_UPDATED: - if (this._handlers.onItemEntitlementsUpdated) { - await this._handlers.onItemEntitlementsUpdated( - event as WebhookEvent & { - content: ItemEntitlementsUpdatedContent; - }, - ); - return; - } - break; - - case EventType.ITEM_FAMILY_CREATED: - if (this._handlers.onItemFamilyCreated) { - await this._handlers.onItemFamilyCreated( - event as WebhookEvent & { content: ItemFamilyCreatedContent }, - ); - return; - } - break; - - case EventType.ITEM_FAMILY_DELETED: - if (this._handlers.onItemFamilyDeleted) { - await this._handlers.onItemFamilyDeleted( - event as WebhookEvent & { content: ItemFamilyDeletedContent }, - ); - return; - } - break; - - case EventType.ITEM_FAMILY_UPDATED: - if (this._handlers.onItemFamilyUpdated) { - await this._handlers.onItemFamilyUpdated( - event as WebhookEvent & { content: ItemFamilyUpdatedContent }, - ); - return; - } - break; - - case EventType.ITEM_PRICE_CREATED: - if (this._handlers.onItemPriceCreated) { - await this._handlers.onItemPriceCreated( - event as WebhookEvent & { content: ItemPriceCreatedContent }, - ); - return; - } - break; - - case EventType.ITEM_PRICE_DELETED: - if (this._handlers.onItemPriceDeleted) { - await this._handlers.onItemPriceDeleted( - event as WebhookEvent & { content: ItemPriceDeletedContent }, - ); - return; - } - break; - - case EventType.ITEM_PRICE_ENTITLEMENTS_REMOVED: - if (this._handlers.onItemPriceEntitlementsRemoved) { - await this._handlers.onItemPriceEntitlementsRemoved( - event as WebhookEvent & { - content: ItemPriceEntitlementsRemovedContent; - }, - ); - return; - } - break; - - case EventType.ITEM_PRICE_ENTITLEMENTS_UPDATED: - if (this._handlers.onItemPriceEntitlementsUpdated) { - await this._handlers.onItemPriceEntitlementsUpdated( - event as WebhookEvent & { - content: ItemPriceEntitlementsUpdatedContent; - }, - ); - return; - } - break; - - case EventType.ITEM_PRICE_UPDATED: - if (this._handlers.onItemPriceUpdated) { - await this._handlers.onItemPriceUpdated( - event as WebhookEvent & { content: ItemPriceUpdatedContent }, - ); - return; - } - break; - - case EventType.ITEM_UPDATED: - if (this._handlers.onItemUpdated) { - await this._handlers.onItemUpdated( - event as WebhookEvent & { content: ItemUpdatedContent }, - ); - return; - } - break; - - case EventType.MRR_UPDATED: - if (this._handlers.onMrrUpdated) { - await this._handlers.onMrrUpdated( - event as WebhookEvent & { content: MrrUpdatedContent }, - ); - return; - } - break; - - case EventType.NETD_PAYMENT_DUE_REMINDER: - if (this._handlers.onNetdPaymentDueReminder) { - await this._handlers.onNetdPaymentDueReminder( - event as WebhookEvent & { - content: NetdPaymentDueReminderContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_ONE_TIME_ORDER_CREATED: - if (this._handlers.onOmnichannelOneTimeOrderCreated) { - await this._handlers.onOmnichannelOneTimeOrderCreated( - event as WebhookEvent & { - content: OmnichannelOneTimeOrderCreatedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_ONE_TIME_ORDER_ITEM_CANCELLED: - if (this._handlers.onOmnichannelOneTimeOrderItemCancelled) { - await this._handlers.onOmnichannelOneTimeOrderItemCancelled( - event as WebhookEvent & { - content: OmnichannelOneTimeOrderItemCancelledContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_CREATED: - if (this._handlers.onOmnichannelSubscriptionCreated) { - await this._handlers.onOmnichannelSubscriptionCreated( - event as WebhookEvent & { - content: OmnichannelSubscriptionCreatedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_IMPORTED: - if (this._handlers.onOmnichannelSubscriptionImported) { - await this._handlers.onOmnichannelSubscriptionImported( - event as WebhookEvent & { - content: OmnichannelSubscriptionImportedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLATION_SCHEDULED: - if ( - this._handlers.onOmnichannelSubscriptionItemCancellationScheduled - ) { - await this._handlers.onOmnichannelSubscriptionItemCancellationScheduled( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemCancellationScheduledContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CANCELLED: - if (this._handlers.onOmnichannelSubscriptionItemCancelled) { - await this._handlers.onOmnichannelSubscriptionItemCancelled( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemCancelledContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGE_SCHEDULED: - if (this._handlers.onOmnichannelSubscriptionItemChangeScheduled) { - await this._handlers.onOmnichannelSubscriptionItemChangeScheduled( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemChangeScheduledContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_CHANGED: - if (this._handlers.onOmnichannelSubscriptionItemChanged) { - await this._handlers.onOmnichannelSubscriptionItemChanged( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemChangedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADE_SCHEDULED: - if (this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled) { - await this._handlers.onOmnichannelSubscriptionItemDowngradeScheduled( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemDowngradeScheduledContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DOWNGRADED: - if (this._handlers.onOmnichannelSubscriptionItemDowngraded) { - await this._handlers.onOmnichannelSubscriptionItemDowngraded( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemDowngradedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_EXPIRED: - if (this._handlers.onOmnichannelSubscriptionItemDunningExpired) { - await this._handlers.onOmnichannelSubscriptionItemDunningExpired( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemDunningExpiredContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_STARTED: - if (this._handlers.onOmnichannelSubscriptionItemDunningStarted) { - await this._handlers.onOmnichannelSubscriptionItemDunningStarted( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemDunningStartedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_EXPIRED: - if (this._handlers.onOmnichannelSubscriptionItemExpired) { - await this._handlers.onOmnichannelSubscriptionItemExpired( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemExpiredContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_EXPIRED: - if (this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired) { - await this._handlers.onOmnichannelSubscriptionItemGracePeriodExpired( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemGracePeriodExpiredContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_STARTED: - if (this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted) { - await this._handlers.onOmnichannelSubscriptionItemGracePeriodStarted( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemGracePeriodStartedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSE_SCHEDULED: - if (this._handlers.onOmnichannelSubscriptionItemPauseScheduled) { - await this._handlers.onOmnichannelSubscriptionItemPauseScheduled( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemPauseScheduledContent; - }, - ); - return; - } - break; + const event: WebhookEvent = + typeof body === 'string' ? JSON.parse(body) : (body as WebhookEvent); - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_PAUSED: - if (this._handlers.onOmnichannelSubscriptionItemPaused) { - await this._handlers.onOmnichannelSubscriptionItemPaused( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemPausedContent; - }, - ); - return; - } - break; + const eventType = event.event_type as keyof WebhookEventMap; - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_REACTIVATED: - if (this._handlers.onOmnichannelSubscriptionItemReactivated) { - await this._handlers.onOmnichannelSubscriptionItemReactivated( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemReactivatedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_RENEWED: - if (this._handlers.onOmnichannelSubscriptionItemRenewed) { - await this._handlers.onOmnichannelSubscriptionItemRenewed( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemRenewedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_RESUBSCRIBED: - if (this._handlers.onOmnichannelSubscriptionItemResubscribed) { - await this._handlers.onOmnichannelSubscriptionItemResubscribed( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemResubscribedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_RESUMED: - if (this._handlers.onOmnichannelSubscriptionItemResumed) { - await this._handlers.onOmnichannelSubscriptionItemResumed( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemResumedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CANCELLATION_REMOVED: - if ( - this._handlers - .onOmnichannelSubscriptionItemScheduledCancellationRemoved - ) { - await this._handlers.onOmnichannelSubscriptionItemScheduledCancellationRemoved( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_CHANGE_REMOVED: - if ( - this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved - ) { - await this._handlers.onOmnichannelSubscriptionItemScheduledChangeRemoved( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledChangeRemovedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_SCHEDULED_DOWNGRADE_REMOVED: - if ( - this._handlers - .onOmnichannelSubscriptionItemScheduledDowngradeRemoved - ) { - await this._handlers.onOmnichannelSubscriptionItemScheduledDowngradeRemoved( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemScheduledDowngradeRemovedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_ITEM_UPGRADED: - if (this._handlers.onOmnichannelSubscriptionItemUpgraded) { - await this._handlers.onOmnichannelSubscriptionItemUpgraded( - event as WebhookEvent & { - content: OmnichannelSubscriptionItemUpgradedContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_SUBSCRIPTION_MOVED_IN: - if (this._handlers.onOmnichannelSubscriptionMovedIn) { - await this._handlers.onOmnichannelSubscriptionMovedIn( - event as WebhookEvent & { - content: OmnichannelSubscriptionMovedInContent; - }, - ); - return; - } - break; - - case EventType.OMNICHANNEL_TRANSACTION_CREATED: - if (this._handlers.onOmnichannelTransactionCreated) { - await this._handlers.onOmnichannelTransactionCreated( - event as WebhookEvent & { - content: OmnichannelTransactionCreatedContent; - }, - ); - return; - } - break; - - case EventType.ORDER_CANCELLED: - if (this._handlers.onOrderCancelled) { - await this._handlers.onOrderCancelled( - event as WebhookEvent & { content: OrderCancelledContent }, - ); - return; - } - break; - - case EventType.ORDER_CREATED: - if (this._handlers.onOrderCreated) { - await this._handlers.onOrderCreated( - event as WebhookEvent & { content: OrderCreatedContent }, - ); - return; - } - break; - - case EventType.ORDER_DELETED: - if (this._handlers.onOrderDeleted) { - await this._handlers.onOrderDeleted( - event as WebhookEvent & { content: OrderDeletedContent }, - ); - return; - } - break; - - case EventType.ORDER_DELIVERED: - if (this._handlers.onOrderDelivered) { - await this._handlers.onOrderDelivered( - event as WebhookEvent & { content: OrderDeliveredContent }, - ); - return; - } - break; - - case EventType.ORDER_READY_TO_PROCESS: - if (this._handlers.onOrderReadyToProcess) { - await this._handlers.onOrderReadyToProcess( - event as WebhookEvent & { content: OrderReadyToProcessContent }, - ); - return; - } - break; - - case EventType.ORDER_READY_TO_SHIP: - if (this._handlers.onOrderReadyToShip) { - await this._handlers.onOrderReadyToShip( - event as WebhookEvent & { content: OrderReadyToShipContent }, - ); - return; - } - break; - - case EventType.ORDER_RESENT: - if (this._handlers.onOrderResent) { - await this._handlers.onOrderResent( - event as WebhookEvent & { content: OrderResentContent }, - ); - return; - } - break; - - case EventType.ORDER_RETURNED: - if (this._handlers.onOrderReturned) { - await this._handlers.onOrderReturned( - event as WebhookEvent & { content: OrderReturnedContent }, - ); - return; - } - break; - - case EventType.ORDER_UPDATED: - if (this._handlers.onOrderUpdated) { - await this._handlers.onOrderUpdated( - event as WebhookEvent & { content: OrderUpdatedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_FAILED: - if (this._handlers.onPaymentFailed) { - await this._handlers.onPaymentFailed( - event as WebhookEvent & { content: PaymentFailedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_INITIATED: - if (this._handlers.onPaymentInitiated) { - await this._handlers.onPaymentInitiated( - event as WebhookEvent & { content: PaymentInitiatedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_INTENT_CREATED: - if (this._handlers.onPaymentIntentCreated) { - await this._handlers.onPaymentIntentCreated( - event as WebhookEvent & { content: PaymentIntentCreatedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_INTENT_UPDATED: - if (this._handlers.onPaymentIntentUpdated) { - await this._handlers.onPaymentIntentUpdated( - event as WebhookEvent & { content: PaymentIntentUpdatedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_REFUNDED: - if (this._handlers.onPaymentRefunded) { - await this._handlers.onPaymentRefunded( - event as WebhookEvent & { content: PaymentRefundedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_SCHEDULE_SCHEME_CREATED: - if (this._handlers.onPaymentScheduleSchemeCreated) { - await this._handlers.onPaymentScheduleSchemeCreated( - event as WebhookEvent & { - content: PaymentScheduleSchemeCreatedContent; - }, - ); - return; - } - break; - - case EventType.PAYMENT_SCHEDULE_SCHEME_DELETED: - if (this._handlers.onPaymentScheduleSchemeDeleted) { - await this._handlers.onPaymentScheduleSchemeDeleted( - event as WebhookEvent & { - content: PaymentScheduleSchemeDeletedContent; - }, - ); - return; - } - break; - - case EventType.PAYMENT_SCHEDULES_CREATED: - if (this._handlers.onPaymentSchedulesCreated) { - await this._handlers.onPaymentSchedulesCreated( - event as WebhookEvent & { - content: PaymentSchedulesCreatedContent; - }, - ); - return; - } - break; - - case EventType.PAYMENT_SCHEDULES_UPDATED: - if (this._handlers.onPaymentSchedulesUpdated) { - await this._handlers.onPaymentSchedulesUpdated( - event as WebhookEvent & { - content: PaymentSchedulesUpdatedContent; - }, - ); - return; - } - break; - - case EventType.PAYMENT_SOURCE_ADDED: - if (this._handlers.onPaymentSourceAdded) { - await this._handlers.onPaymentSourceAdded( - event as WebhookEvent & { content: PaymentSourceAddedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_SOURCE_DELETED: - if (this._handlers.onPaymentSourceDeleted) { - await this._handlers.onPaymentSourceDeleted( - event as WebhookEvent & { content: PaymentSourceDeletedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_SOURCE_EXPIRED: - if (this._handlers.onPaymentSourceExpired) { - await this._handlers.onPaymentSourceExpired( - event as WebhookEvent & { content: PaymentSourceExpiredContent }, - ); - return; - } - break; - - case EventType.PAYMENT_SOURCE_EXPIRING: - if (this._handlers.onPaymentSourceExpiring) { - await this._handlers.onPaymentSourceExpiring( - event as WebhookEvent & { content: PaymentSourceExpiringContent }, - ); - return; - } - break; - - case EventType.PAYMENT_SOURCE_LOCALLY_DELETED: - if (this._handlers.onPaymentSourceLocallyDeleted) { - await this._handlers.onPaymentSourceLocallyDeleted( - event as WebhookEvent & { - content: PaymentSourceLocallyDeletedContent; - }, - ); - return; - } - break; - - case EventType.PAYMENT_SOURCE_UPDATED: - if (this._handlers.onPaymentSourceUpdated) { - await this._handlers.onPaymentSourceUpdated( - event as WebhookEvent & { content: PaymentSourceUpdatedContent }, - ); - return; - } - break; - - case EventType.PAYMENT_SUCCEEDED: - if (this._handlers.onPaymentSucceeded) { - await this._handlers.onPaymentSucceeded( - event as WebhookEvent & { content: PaymentSucceededContent }, - ); - return; - } - break; - - case EventType.PENDING_INVOICE_CREATED: - if (this._handlers.onPendingInvoiceCreated) { - await this._handlers.onPendingInvoiceCreated( - event as WebhookEvent & { content: PendingInvoiceCreatedContent }, - ); - return; - } - break; - - case EventType.PENDING_INVOICE_UPDATED: - if (this._handlers.onPendingInvoiceUpdated) { - await this._handlers.onPendingInvoiceUpdated( - event as WebhookEvent & { content: PendingInvoiceUpdatedContent }, - ); - return; - } - break; - - case EventType.PLAN_CREATED: - if (this._handlers.onPlanCreated) { - await this._handlers.onPlanCreated( - event as WebhookEvent & { content: PlanCreatedContent }, - ); - return; - } - break; - - case EventType.PLAN_DELETED: - if (this._handlers.onPlanDeleted) { - await this._handlers.onPlanDeleted( - event as WebhookEvent & { content: PlanDeletedContent }, - ); - return; - } - break; - - case EventType.PLAN_UPDATED: - if (this._handlers.onPlanUpdated) { - await this._handlers.onPlanUpdated( - event as WebhookEvent & { content: PlanUpdatedContent }, - ); - return; - } - break; - - case EventType.PRICE_VARIANT_CREATED: - if (this._handlers.onPriceVariantCreated) { - await this._handlers.onPriceVariantCreated( - event as WebhookEvent & { content: PriceVariantCreatedContent }, - ); - return; - } - break; - - case EventType.PRICE_VARIANT_DELETED: - if (this._handlers.onPriceVariantDeleted) { - await this._handlers.onPriceVariantDeleted( - event as WebhookEvent & { content: PriceVariantDeletedContent }, - ); - return; - } - break; - - case EventType.PRICE_VARIANT_UPDATED: - if (this._handlers.onPriceVariantUpdated) { - await this._handlers.onPriceVariantUpdated( - event as WebhookEvent & { content: PriceVariantUpdatedContent }, - ); - return; - } - break; - - case EventType.PRODUCT_CREATED: - if (this._handlers.onProductCreated) { - await this._handlers.onProductCreated( - event as WebhookEvent & { content: ProductCreatedContent }, - ); - return; - } - break; - - case EventType.PRODUCT_DELETED: - if (this._handlers.onProductDeleted) { - await this._handlers.onProductDeleted( - event as WebhookEvent & { content: ProductDeletedContent }, - ); - return; - } - break; - - case EventType.PRODUCT_UPDATED: - if (this._handlers.onProductUpdated) { - await this._handlers.onProductUpdated( - event as WebhookEvent & { content: ProductUpdatedContent }, - ); - return; - } - break; - - case EventType.PROMOTIONAL_CREDITS_ADDED: - if (this._handlers.onPromotionalCreditsAdded) { - await this._handlers.onPromotionalCreditsAdded( - event as WebhookEvent & { - content: PromotionalCreditsAddedContent; - }, - ); - return; - } - break; - - case EventType.PROMOTIONAL_CREDITS_DEDUCTED: - if (this._handlers.onPromotionalCreditsDeducted) { - await this._handlers.onPromotionalCreditsDeducted( - event as WebhookEvent & { - content: PromotionalCreditsDeductedContent; - }, - ); - return; - } - break; - - case EventType.PURCHASE_CREATED: - if (this._handlers.onPurchaseCreated) { - await this._handlers.onPurchaseCreated( - event as WebhookEvent & { content: PurchaseCreatedContent }, - ); - return; - } - break; - - case EventType.QUOTE_CREATED: - if (this._handlers.onQuoteCreated) { - await this._handlers.onQuoteCreated( - event as WebhookEvent & { content: QuoteCreatedContent }, - ); - return; - } - break; - - case EventType.QUOTE_DELETED: - if (this._handlers.onQuoteDeleted) { - await this._handlers.onQuoteDeleted( - event as WebhookEvent & { content: QuoteDeletedContent }, - ); - return; - } - break; - - case EventType.QUOTE_UPDATED: - if (this._handlers.onQuoteUpdated) { - await this._handlers.onQuoteUpdated( - event as WebhookEvent & { content: QuoteUpdatedContent }, - ); - return; - } - break; - - case EventType.RECORD_PURCHASE_FAILED: - if (this._handlers.onRecordPurchaseFailed) { - await this._handlers.onRecordPurchaseFailed( - event as WebhookEvent & { content: RecordPurchaseFailedContent }, - ); - return; - } - break; - - case EventType.REFUND_INITIATED: - if (this._handlers.onRefundInitiated) { - await this._handlers.onRefundInitiated( - event as WebhookEvent & { content: RefundInitiatedContent }, - ); - return; - } - break; - - case EventType.RULE_CREATED: - if (this._handlers.onRuleCreated) { - await this._handlers.onRuleCreated( - event as WebhookEvent & { content: RuleCreatedContent }, - ); - return; - } - break; - - case EventType.RULE_DELETED: - if (this._handlers.onRuleDeleted) { - await this._handlers.onRuleDeleted( - event as WebhookEvent & { content: RuleDeletedContent }, - ); - return; - } - break; - - case EventType.RULE_UPDATED: - if (this._handlers.onRuleUpdated) { - await this._handlers.onRuleUpdated( - event as WebhookEvent & { content: RuleUpdatedContent }, - ); - return; - } - break; - - case EventType.SALES_ORDER_CREATED: - if (this._handlers.onSalesOrderCreated) { - await this._handlers.onSalesOrderCreated( - event as WebhookEvent & { content: SalesOrderCreatedContent }, - ); - return; - } - break; - - case EventType.SALES_ORDER_UPDATED: - if (this._handlers.onSalesOrderUpdated) { - await this._handlers.onSalesOrderUpdated( - event as WebhookEvent & { content: SalesOrderUpdatedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ACTIVATED: - if (this._handlers.onSubscriptionActivated) { - await this._handlers.onSubscriptionActivated( - event as WebhookEvent & { content: SubscriptionActivatedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ACTIVATED_WITH_BACKDATING: - if (this._handlers.onSubscriptionActivatedWithBackdating) { - await this._handlers.onSubscriptionActivatedWithBackdating( - event as WebhookEvent & { - content: SubscriptionActivatedWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_ADDED: - if (this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded) { - await this._handlers.onSubscriptionAdvanceInvoiceScheduleAdded( - event as WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleAddedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_REMOVED: - if (this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved) { - await this._handlers.onSubscriptionAdvanceInvoiceScheduleRemoved( - event as WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleRemovedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ADVANCE_INVOICE_SCHEDULE_UPDATED: - if (this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated) { - await this._handlers.onSubscriptionAdvanceInvoiceScheduleUpdated( - event as WebhookEvent & { - content: SubscriptionAdvanceInvoiceScheduleUpdatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_BUSINESS_ENTITY_CHANGED: - if (this._handlers.onSubscriptionBusinessEntityChanged) { - await this._handlers.onSubscriptionBusinessEntityChanged( - event as WebhookEvent & { - content: SubscriptionBusinessEntityChangedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CANCELED_WITH_BACKDATING: - if (this._handlers.onSubscriptionCanceledWithBackdating) { - await this._handlers.onSubscriptionCanceledWithBackdating( - event as WebhookEvent & { - content: SubscriptionCanceledWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CANCELLATION_REMINDER: - if (this._handlers.onSubscriptionCancellationReminder) { - await this._handlers.onSubscriptionCancellationReminder( - event as WebhookEvent & { - content: SubscriptionCancellationReminderContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CANCELLATION_SCHEDULED: - if (this._handlers.onSubscriptionCancellationScheduled) { - await this._handlers.onSubscriptionCancellationScheduled( - event as WebhookEvent & { - content: SubscriptionCancellationScheduledContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CANCELLED: - if (this._handlers.onSubscriptionCancelled) { - await this._handlers.onSubscriptionCancelled( - event as WebhookEvent & { content: SubscriptionCancelledContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CHANGED: - if (this._handlers.onSubscriptionChanged) { - await this._handlers.onSubscriptionChanged( - event as WebhookEvent & { content: SubscriptionChangedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CHANGED_WITH_BACKDATING: - if (this._handlers.onSubscriptionChangedWithBackdating) { - await this._handlers.onSubscriptionChangedWithBackdating( - event as WebhookEvent & { - content: SubscriptionChangedWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CHANGES_SCHEDULED: - if (this._handlers.onSubscriptionChangesScheduled) { - await this._handlers.onSubscriptionChangesScheduled( - event as WebhookEvent & { - content: SubscriptionChangesScheduledContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CREATED: - if (this._handlers.onSubscriptionCreated) { - await this._handlers.onSubscriptionCreated( - event as WebhookEvent & { content: SubscriptionCreatedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_CREATED_WITH_BACKDATING: - if (this._handlers.onSubscriptionCreatedWithBackdating) { - await this._handlers.onSubscriptionCreatedWithBackdating( - event as WebhookEvent & { - content: SubscriptionCreatedWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_DELETED: - if (this._handlers.onSubscriptionDeleted) { - await this._handlers.onSubscriptionDeleted( - event as WebhookEvent & { content: SubscriptionDeletedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ENTITLEMENTS_CREATED: - if (this._handlers.onSubscriptionEntitlementsCreated) { - await this._handlers.onSubscriptionEntitlementsCreated( - event as WebhookEvent & { - content: SubscriptionEntitlementsCreatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ENTITLEMENTS_UPDATED: - if (this._handlers.onSubscriptionEntitlementsUpdated) { - await this._handlers.onSubscriptionEntitlementsUpdated( - event as WebhookEvent & { - content: SubscriptionEntitlementsUpdatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_ITEMS_RENEWED: - if (this._handlers.onSubscriptionItemsRenewed) { - await this._handlers.onSubscriptionItemsRenewed( - event as WebhookEvent & { - content: SubscriptionItemsRenewedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_MOVED_IN: - if (this._handlers.onSubscriptionMovedIn) { - await this._handlers.onSubscriptionMovedIn( - event as WebhookEvent & { content: SubscriptionMovedInContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_MOVED_OUT: - if (this._handlers.onSubscriptionMovedOut) { - await this._handlers.onSubscriptionMovedOut( - event as WebhookEvent & { content: SubscriptionMovedOutContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_MOVEMENT_FAILED: - if (this._handlers.onSubscriptionMovementFailed) { - await this._handlers.onSubscriptionMovementFailed( - event as WebhookEvent & { - content: SubscriptionMovementFailedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_PAUSE_SCHEDULED: - if (this._handlers.onSubscriptionPauseScheduled) { - await this._handlers.onSubscriptionPauseScheduled( - event as WebhookEvent & { - content: SubscriptionPauseScheduledContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_PAUSED: - if (this._handlers.onSubscriptionPaused) { - await this._handlers.onSubscriptionPaused( - event as WebhookEvent & { content: SubscriptionPausedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RAMP_APPLIED: - if (this._handlers.onSubscriptionRampApplied) { - await this._handlers.onSubscriptionRampApplied( - event as WebhookEvent & { - content: SubscriptionRampAppliedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RAMP_CREATED: - if (this._handlers.onSubscriptionRampCreated) { - await this._handlers.onSubscriptionRampCreated( - event as WebhookEvent & { - content: SubscriptionRampCreatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RAMP_DELETED: - if (this._handlers.onSubscriptionRampDeleted) { - await this._handlers.onSubscriptionRampDeleted( - event as WebhookEvent & { - content: SubscriptionRampDeletedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RAMP_DRAFTED: - if (this._handlers.onSubscriptionRampDrafted) { - await this._handlers.onSubscriptionRampDrafted( - event as WebhookEvent & { - content: SubscriptionRampDraftedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RAMP_UPDATED: - if (this._handlers.onSubscriptionRampUpdated) { - await this._handlers.onSubscriptionRampUpdated( - event as WebhookEvent & { - content: SubscriptionRampUpdatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_REACTIVATED: - if (this._handlers.onSubscriptionReactivated) { - await this._handlers.onSubscriptionReactivated( - event as WebhookEvent & { - content: SubscriptionReactivatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_REACTIVATED_WITH_BACKDATING: - if (this._handlers.onSubscriptionReactivatedWithBackdating) { - await this._handlers.onSubscriptionReactivatedWithBackdating( - event as WebhookEvent & { - content: SubscriptionReactivatedWithBackdatingContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RENEWAL_REMINDER: - if (this._handlers.onSubscriptionRenewalReminder) { - await this._handlers.onSubscriptionRenewalReminder( - event as WebhookEvent & { - content: SubscriptionRenewalReminderContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RENEWED: - if (this._handlers.onSubscriptionRenewed) { - await this._handlers.onSubscriptionRenewed( - event as WebhookEvent & { content: SubscriptionRenewedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RESUMED: - if (this._handlers.onSubscriptionResumed) { - await this._handlers.onSubscriptionResumed( - event as WebhookEvent & { content: SubscriptionResumedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_RESUMPTION_SCHEDULED: - if (this._handlers.onSubscriptionResumptionScheduled) { - await this._handlers.onSubscriptionResumptionScheduled( - event as WebhookEvent & { - content: SubscriptionResumptionScheduledContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_SCHEDULED_CANCELLATION_REMOVED: - if (this._handlers.onSubscriptionScheduledCancellationRemoved) { - await this._handlers.onSubscriptionScheduledCancellationRemoved( - event as WebhookEvent & { - content: SubscriptionScheduledCancellationRemovedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_SCHEDULED_CHANGES_REMOVED: - if (this._handlers.onSubscriptionScheduledChangesRemoved) { - await this._handlers.onSubscriptionScheduledChangesRemoved( - event as WebhookEvent & { - content: SubscriptionScheduledChangesRemovedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_SCHEDULED_PAUSE_REMOVED: - if (this._handlers.onSubscriptionScheduledPauseRemoved) { - await this._handlers.onSubscriptionScheduledPauseRemoved( - event as WebhookEvent & { - content: SubscriptionScheduledPauseRemovedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_SCHEDULED_RESUMPTION_REMOVED: - if (this._handlers.onSubscriptionScheduledResumptionRemoved) { - await this._handlers.onSubscriptionScheduledResumptionRemoved( - event as WebhookEvent & { - content: SubscriptionScheduledResumptionRemovedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_SHIPPING_ADDRESS_UPDATED: - if (this._handlers.onSubscriptionShippingAddressUpdated) { - await this._handlers.onSubscriptionShippingAddressUpdated( - event as WebhookEvent & { - content: SubscriptionShippingAddressUpdatedContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_STARTED: - if (this._handlers.onSubscriptionStarted) { - await this._handlers.onSubscriptionStarted( - event as WebhookEvent & { content: SubscriptionStartedContent }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_TRIAL_END_REMINDER: - if (this._handlers.onSubscriptionTrialEndReminder) { - await this._handlers.onSubscriptionTrialEndReminder( - event as WebhookEvent & { - content: SubscriptionTrialEndReminderContent; - }, - ); - return; - } - break; - - case EventType.SUBSCRIPTION_TRIAL_EXTENDED: - if (this._handlers.onSubscriptionTrialExtended) { - await this._handlers.onSubscriptionTrialExtended( - event as WebhookEvent & { - content: SubscriptionTrialExtendedContent; - }, - ); - return; - } - break; - - case EventType.TAX_WITHHELD_DELETED: - if (this._handlers.onTaxWithheldDeleted) { - await this._handlers.onTaxWithheldDeleted( - event as WebhookEvent & { content: TaxWithheldDeletedContent }, - ); - return; - } - break; - - case EventType.TAX_WITHHELD_RECORDED: - if (this._handlers.onTaxWithheldRecorded) { - await this._handlers.onTaxWithheldRecorded( - event as WebhookEvent & { content: TaxWithheldRecordedContent }, - ); - return; - } - break; - - case EventType.TAX_WITHHELD_REFUNDED: - if (this._handlers.onTaxWithheldRefunded) { - await this._handlers.onTaxWithheldRefunded( - event as WebhookEvent & { content: TaxWithheldRefundedContent }, - ); - return; - } - break; - - case EventType.TOKEN_CONSUMED: - if (this._handlers.onTokenConsumed) { - await this._handlers.onTokenConsumed( - event as WebhookEvent & { content: TokenConsumedContent }, - ); - return; - } - break; - - case EventType.TOKEN_CREATED: - if (this._handlers.onTokenCreated) { - await this._handlers.onTokenCreated( - event as WebhookEvent & { content: TokenCreatedContent }, - ); - return; - } - break; - - case EventType.TOKEN_EXPIRED: - if (this._handlers.onTokenExpired) { - await this._handlers.onTokenExpired( - event as WebhookEvent & { content: TokenExpiredContent }, - ); - return; - } - break; - - case EventType.TRANSACTION_CREATED: - if (this._handlers.onTransactionCreated) { - await this._handlers.onTransactionCreated( - event as WebhookEvent & { content: TransactionCreatedContent }, - ); - return; - } - break; - - case EventType.TRANSACTION_DELETED: - if (this._handlers.onTransactionDeleted) { - await this._handlers.onTransactionDeleted( - event as WebhookEvent & { content: TransactionDeletedContent }, - ); - return; - } - break; - - case EventType.TRANSACTION_UPDATED: - if (this._handlers.onTransactionUpdated) { - await this._handlers.onTransactionUpdated( - event as WebhookEvent & { content: TransactionUpdatedContent }, - ); - return; - } - break; - - case EventType.UNBILLED_CHARGES_CREATED: - if (this._handlers.onUnbilledChargesCreated) { - await this._handlers.onUnbilledChargesCreated( - event as WebhookEvent & { - content: UnbilledChargesCreatedContent; - }, - ); - return; - } - break; - - case EventType.UNBILLED_CHARGES_DELETED: - if (this._handlers.onUnbilledChargesDeleted) { - await this._handlers.onUnbilledChargesDeleted( - event as WebhookEvent & { - content: UnbilledChargesDeletedContent; - }, - ); - return; - } - break; - - case EventType.UNBILLED_CHARGES_INVOICED: - if (this._handlers.onUnbilledChargesInvoiced) { - await this._handlers.onUnbilledChargesInvoiced( - event as WebhookEvent & { - content: UnbilledChargesInvoicedContent; - }, - ); - return; - } - break; - - case EventType.UNBILLED_CHARGES_VOIDED: - if (this._handlers.onUnbilledChargesVoided) { - await this._handlers.onUnbilledChargesVoided( - event as WebhookEvent & { content: UnbilledChargesVoidedContent }, - ); - return; - } - break; - - case EventType.USAGE_FILE_INGESTED: - if (this._handlers.onUsageFileIngested) { - await this._handlers.onUsageFileIngested( - event as WebhookEvent & { content: UsageFileIngestedContent }, - ); - return; - } - break; - - case EventType.VARIANT_CREATED: - if (this._handlers.onVariantCreated) { - await this._handlers.onVariantCreated( - event as WebhookEvent & { content: VariantCreatedContent }, - ); - return; - } - break; - - case EventType.VARIANT_DELETED: - if (this._handlers.onVariantDeleted) { - await this._handlers.onVariantDeleted( - event as WebhookEvent & { content: VariantDeletedContent }, - ); - return; - } - break; - - case EventType.VARIANT_UPDATED: - if (this._handlers.onVariantUpdated) { - await this._handlers.onVariantUpdated( - event as WebhookEvent & { content: VariantUpdatedContent }, - ); - return; - } - break; - - case EventType.VIRTUAL_BANK_ACCOUNT_ADDED: - if (this._handlers.onVirtualBankAccountAdded) { - await this._handlers.onVirtualBankAccountAdded( - event as WebhookEvent & { - content: VirtualBankAccountAddedContent; - }, - ); - return; - } - break; - - case EventType.VIRTUAL_BANK_ACCOUNT_DELETED: - if (this._handlers.onVirtualBankAccountDeleted) { - await this._handlers.onVirtualBankAccountDeleted( - event as WebhookEvent & { - content: VirtualBankAccountDeletedContent; - }, - ); - return; - } - break; - - case EventType.VIRTUAL_BANK_ACCOUNT_UPDATED: - if (this._handlers.onVirtualBankAccountUpdated) { - await this._handlers.onVirtualBankAccountUpdated( - event as WebhookEvent & { - content: VirtualBankAccountUpdatedContent; - }, - ); - return; - } - break; - - case EventType.VOUCHER_CREATE_FAILED: - if (this._handlers.onVoucherCreateFailed) { - await this._handlers.onVoucherCreateFailed( - event as WebhookEvent & { content: VoucherCreateFailedContent }, - ); - return; - } - break; - - case EventType.VOUCHER_CREATED: - if (this._handlers.onVoucherCreated) { - await this._handlers.onVoucherCreated( - event as WebhookEvent & { content: VoucherCreatedContent }, - ); - return; - } - break; - - case EventType.VOUCHER_EXPIRED: - if (this._handlers.onVoucherExpired) { - await this._handlers.onVoucherExpired( - event as WebhookEvent & { content: VoucherExpiredContent }, - ); - return; - } - break; - } - - if (this.onUnhandledEvent) { - await this.onUnhandledEvent(event); + if (this.listenerCount(eventType) > 0) { + this.emit(eventType, event); + } else if (this.listenerCount('unhandled_event') > 0) { + this.emit('unhandled_event', event); } } catch (err) { - if (this.onError) { - this.onError(err); - } else { - throw err; - } + this.emit('error', err); } } } + +export type { WebhookEvent } from './content.js'; diff --git a/test/webhook.test.ts b/test/webhook.test.ts index 936c57c..4da16e6 100644 --- a/test/webhook.test.ts +++ b/test/webhook.test.ts @@ -1,6 +1,5 @@ import { expect } from 'chai'; import { WebhookHandler } from '../src/resources/webhook/handler.js'; -import { EventType } from '../src/resources/webhook/event_types.js'; import { basicAuthValidator } from '../src/resources/webhook/auth.js'; describe('WebhookHandler', () => { @@ -17,14 +16,14 @@ describe('WebhookHandler', () => { it('should route to callback successfully', async () => { let called = false; const handler = new WebhookHandler(); - handler.onPendingInvoiceCreated = async (event) => { + handler.on('pending_invoice_created', async (event) => { called = true; expect(event.id).to.not.be.empty; - expect(event.event_type).to.equal(EventType.PENDING_INVOICE_CREATED); + expect(event.event_type).to.equal('pending_invoice_created'); expect(event.content).to.not.be.null; - }; + }); - await handler.handle(makeEventBody('pending_invoice_created')); + handler.handle(makeEventBody('pending_invoice_created')); expect(called).to.be.true; }); @@ -34,39 +33,39 @@ describe('WebhookHandler', () => { handler.requestValidator = () => { throw new Error('bad signature'); }; - handler.onError = (err) => { + handler.on('error', (err: unknown) => { onErrorCalled = true; - expect(err.message).to.equal('bad signature'); - }; + expect((err as Error).message).to.equal('bad signature'); + }); - await handler.handle(makeEventBody('pending_invoice_created'), {}); + handler.handle(makeEventBody('pending_invoice_created'), {}); expect(onErrorCalled).to.be.true; }); - it('should handle callback error', async () => { + it('should handle sync callback error', () => { let onErrorCalled = false; const handler = new WebhookHandler(); - handler.onPendingInvoiceCreated = async () => { + handler.on('pending_invoice_created', () => { throw new Error('user code failed'); - }; - handler.onError = (err) => { + }); + handler.on('error', (err: unknown) => { onErrorCalled = true; - expect(err.message).to.equal('user code failed'); - }; + expect((err as Error).message).to.equal('user code failed'); + }); - await handler.handle(makeEventBody('pending_invoice_created')); + handler.handle(makeEventBody('pending_invoice_created')); expect(onErrorCalled).to.be.true; }); it('should handle unknown event', async () => { let onUnhandledCalled = false; const handler = new WebhookHandler(); - handler.onUnhandledEvent = async (event) => { + handler.on('unhandled_event', async (event) => { onUnhandledCalled = true; expect(event.event_type).to.equal('non_existing_event'); - }; + }); - await handler.handle(makeEventBody('non_existing_event')); + handler.handle(makeEventBody('non_existing_event')); expect(onUnhandledCalled).to.be.true; }); @@ -75,19 +74,19 @@ describe('WebhookHandler', () => { let subscriptionCalled = false; const handler = new WebhookHandler(); - handler.onPendingInvoiceCreated = async () => { + handler.on('pending_invoice_created', async () => { pendingInvoiceCalled = true; - }; - handler.onSubscriptionCreated = async () => { + }); + handler.on('subscription_created', async () => { subscriptionCalled = true; - }; + }); - await handler.handle(makeEventBody('pending_invoice_created')); + handler.handle(makeEventBody('pending_invoice_created')); expect(pendingInvoiceCalled).to.be.true; expect(subscriptionCalled).to.be.false; pendingInvoiceCalled = false; - await handler.handle(makeEventBody('subscription_created')); + handler.handle(makeEventBody('subscription_created')); expect(pendingInvoiceCalled).to.be.false; expect(subscriptionCalled).to.be.true; }); @@ -95,11 +94,11 @@ describe('WebhookHandler', () => { it('should handle invalid JSON body', async () => { let onErrorCalled = false; const handler = new WebhookHandler(); - handler.onError = (err) => { + handler.on('error', () => { onErrorCalled = true; - }; + }); - await handler.handle('invalid json'); + handler.handle('invalid json'); expect(onErrorCalled).to.be.true; }); @@ -114,25 +113,117 @@ describe('WebhookHandler', () => { }; let onErrorCalled = false; - handler.onError = (err) => { + handler.on('error', (err: unknown) => { onErrorCalled = true; - expect(err.message).to.equal('missing required header'); - }; + expect((err as Error).message).to.equal('missing required header'); + }); // Fail case - await handler.handle(makeEventBody('pending_invoice_created'), {}); + handler.handle(makeEventBody('pending_invoice_created'), {}); expect(validatorCalled).to.be.true; expect(onErrorCalled).to.be.true; // Success case validatorCalled = false; onErrorCalled = false; - await handler.handle(makeEventBody('pending_invoice_created'), { + handler.handle(makeEventBody('pending_invoice_created'), { 'x-custom-header': 'expected-value', }); expect(validatorCalled).to.be.true; expect(onErrorCalled).to.be.false; }); + + it('should support multiple listeners for same event', async () => { + let listener1Called = false; + let listener2Called = false; + + const handler = new WebhookHandler(); + handler.on('customer_created', async () => { + listener1Called = true; + }); + handler.on('customer_created', async () => { + listener2Called = true; + }); + + handler.handle(makeEventBody('customer_created')); + expect(listener1Called).to.be.true; + expect(listener2Called).to.be.true; + }); + + it('should support once() for one-time listeners', async () => { + let callCount = 0; + + const handler = new WebhookHandler(); + handler.once('customer_created', async () => { + callCount++; + }); + + handler.handle(makeEventBody('customer_created')); + handler.handle(makeEventBody('customer_created')); + + expect(callCount).to.equal(1); + }); + + it('should support off() to remove listeners', async () => { + let callCount = 0; + + const handler = new WebhookHandler(); + const listener = async () => { + callCount++; + }; + + handler.on('customer_created', listener); + handler.handle(makeEventBody('customer_created')); + expect(callCount).to.equal(1); + + handler.off('customer_created', listener); + handler.handle(makeEventBody('customer_created')); + expect(callCount).to.equal(1); // Should not increment + }); + + it('should support removeAllListeners()', async () => { + let callCount = 0; + + const handler = new WebhookHandler(); + handler.on('customer_created', async () => { + callCount++; + }); + handler.on('customer_created', async () => { + callCount++; + }); + + handler.removeAllListeners('customer_created'); + handler.handle(makeEventBody('customer_created')); + expect(callCount).to.equal(0); + }); + + it('should correctly report listenerCount', () => { + const handler = new WebhookHandler(); + expect(handler.listenerCount('customer_created')).to.equal(0); + + handler.on('customer_created', async () => {}); + expect(handler.listenerCount('customer_created')).to.equal(1); + + handler.on('customer_created', async () => {}); + expect(handler.listenerCount('customer_created')).to.equal(2); + }); + + it('should support method chaining', async () => { + let customerCreatedCalled = false; + let subscriptionCreatedCalled = false; + + const handler = new WebhookHandler() + .on('customer_created', async () => { + customerCreatedCalled = true; + }) + .on('subscription_created', async () => { + subscriptionCreatedCalled = true; + }); + + handler.handle(makeEventBody('customer_created')); + expect(customerCreatedCalled).to.be.true; + expect(subscriptionCreatedCalled).to.be.false; + }); }); describe('BasicAuthValidator', () => { @@ -173,9 +264,9 @@ describe('BasicAuthValidator', () => { let callbackCalled = false; const handler = new WebhookHandler(); handler.requestValidator = validator; - handler.onPendingInvoiceCreated = async () => { + handler.on('pending_invoice_created', async () => { callbackCalled = true; - }; + }); const auth = 'Basic ' + Buffer.from('testuser:testpass').toString('base64'); const body = JSON.stringify({ @@ -183,7 +274,7 @@ describe('BasicAuthValidator', () => { content: {}, }); - await handler.handle(body, { authorization: auth }); + handler.handle(body, { authorization: auth }); expect(callbackCalled).to.be.true; }); }); diff --git a/types/index.d.ts b/types/index.d.ts index 4cb9f6c..e31cf7b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -250,13 +250,17 @@ declare module 'chargebee' { } // Webhook Handler + export type WebhookEventType = EventTypeEnum | 'unhandled_event' | 'error'; + export type WebhookEventListener = (event: WebhookEvent) => Promise | void; + export class WebhookHandler { - constructor(handlers?: Record Promise>); + on(eventName: WebhookEventType, listener: WebhookEventListener): this; + once(eventName: WebhookEventType, listener: WebhookEventListener): this; + off(eventName: WebhookEventType, listener: WebhookEventListener): this; handle( body: string | object, headers?: Record, - ): Promise; - onUnhandledEvent?: (event: WebhookEvent) => Promise; + ): void; onError?: (error: any) => void; requestValidator?: ( headers: Record, From 0c4a456031f9de035635b5208bf7e24045b1906d Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 2 Dec 2025 20:12:56 +0530 Subject: [PATCH 03/11] add generic for webhook hander, update readme --- README.md | 101 ++++++++++++++----------------- package-lock.json | 31 ++++++++-- package.json | 5 +- src/resources/webhook/handler.ts | 44 +++----------- tsconfig.cjs.json | 4 +- 5 files changed, 85 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index 2f5d566..1f50cbf 100644 --- a/README.md +++ b/README.md @@ -157,33 +157,25 @@ Use the webhook handlers to parse and route webhook payloads from Chargebee with ```typescript import express from 'express'; import { WebhookHandler, basicAuthValidator } from 'chargebee'; -import type { - SubscriptionCreatedContent, - PaymentSucceededContent, - WebhookEvent -} from 'chargebee'; const app = express(); app.use(express.json()); -const handler = new WebhookHandler({ - // Register only the events you care about - // Event callbacks are fully typed with proper content types - onSubscriptionCreated: async (event: WebhookEvent & { content: SubscriptionCreatedContent }) => { - console.log(`Subscription created: ${event.id}`); - // Full IntelliSense for subscription properties - const subscription = event.content.subscription; - console.log(`Customer: ${subscription.customer_id}`); - console.log(`Plan: ${subscription.plan_id}`); - }, - - onPaymentSucceeded: async (event: WebhookEvent & { content: PaymentSucceededContent }) => { - console.log(`Payment succeeded: ${event.id}`); - // Full IntelliSense for transaction and customer - const transaction = event.content.transaction; - const customer = event.content.customer; - console.log(`Amount: ${transaction.amount}, Customer: ${customer.email}`); - }, +const handler = new WebhookHandler(); + +// Register event listeners using .on() - events are fully typed +handler.on('subscription_created', async (event) => { + console.log(`Subscription created: ${event.id}`); + const subscription = event.content.subscription; + console.log(`Customer: ${subscription.customer_id}`); + console.log(`Plan: ${subscription.plan_id}`); +}); + +handler.on('payment_succeeded', async (event) => { + console.log(`Payment succeeded: ${event.id}`); + const transaction = event.content.transaction; + const customer = event.content.customer; + console.log(`Amount: ${transaction.amount}, Customer: ${customer.email}`); }); // Optional: Add request validator (e.g., Basic Auth) @@ -191,14 +183,9 @@ handler.requestValidator = basicAuthValidator((username, password) => { return username === 'admin' && password === 'secret'; }); -app.post('/chargebee/webhooks', async (req, res) => { - try { - await handler.handle(req.body, req.headers); - res.status(200).send('OK'); - } catch (err) { - console.error('Webhook error:', err); - res.status(500).send('Error processing webhook'); - } +app.post('/chargebee/webhooks', (req, res) => { + handler.handle(req.body, req.headers); + res.status(200).send('OK'); }); app.listen(8080); @@ -249,47 +236,47 @@ app.listen(8080); 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: -**Using `onUnhandledEvent` callback:** +**Using the `unhandled_event` listener:** ```typescript import { WebhookHandler } from 'chargebee'; -const handler = new WebhookHandler({ - onSubscriptionCreated: async (event) => { - // Handle subscription created - }, - - // Gracefully handle events without registered callbacks - onUnhandledEvent: async (event) => { - console.log(`Received unhandled event: ${event.event_type}`); - // Log for monitoring or store for later processing - }, +const handler = new WebhookHandler(); + +handler.on('subscription_created', async (event) => { + // Handle subscription created +}); + +// Gracefully handle events without registered listeners +handler.on('unhandled_event', async (event) => { + console.log(`Received unhandled event: ${event.event_type}`); + // Log for monitoring or store for later processing }); ``` -**Using `onError` for error handling:** +**Using the `error` listener for error handling:** -If no `onUnhandledEvent` callback is provided and an unhandled event is received, the SDK will invoke the `onError` callback (if configured): +If an error occurs during webhook processing (e.g., invalid JSON, validator failure), the SDK will emit an `error` event: ```typescript -const handler = new WebhookHandler({ - onSubscriptionCreated: async (event) => { - // Handle subscription created - }, - - // Catch any errors during webhook processing - onError: (err) => { - console.error('Webhook processing error:', err); - // Log to monitoring service, alert team, etc. - }, +const handler = new WebhookHandler(); + +handler.on('subscription_created', async (event) => { + // Handle subscription created +}); + +// Catch any errors during webhook processing +handler.on('error', (err) => { + console.error('Webhook processing error:', err); + // Log to monitoring service, alert team, etc. }); ``` **Best Practices:** -- Set `onUnhandledEvent` if you want to acknowledge unknown events (return 200 OK) and log them -- Use `onError` to catch and handle exceptions thrown during event processing -- Both callbacks help ensure your webhook endpoint remains stable even when new event types are introduced by Chargebee +- Use `unhandled_event` listener to acknowledge unknown events (return 200 OK) and log them +- Use `error` listener to catch and handle exceptions thrown during event processing +- Both listeners help ensure your webhook endpoint remains stable even when new event types are introduced by Chargebee ### Processing Webhooks - API Version Check diff --git a/package-lock.json b/package-lock.json index 16aeb08..e02a0f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,13 @@ "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.10", - "@types/node": "20.0.0", + "@types/node": "20.12.0", "chai": "^4.3.7", "mocha": "^10.2.0", "prettier": "^3.3.3", "ts-node": "^10.9.1", - "typescript": "^5.5.4" + "typescript": "^5.5.4", + "undici-types": "^7.16.0" }, "engines": { "node": ">=18.*" @@ -105,10 +106,21 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.0.0.tgz", - "integrity": "sha512-cD2uPTDnQQCVpmRefonO98/PPijuOnnEy5oytWJFPY1N9aJCz2wJ5kSGWO+zJoed2cY2JxQh6yBuUq4vIn61hw==", - "dev": true + "version": "20.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.0.tgz", + "integrity": "sha512-jVC7fWX1Did5TNn8mmGsE81mdyv+7a+nHNlUiNVys8G392CfNfhqAVRd+cuY0+OBU2vN6GzpiRX/MgJ9b3rtpQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/node/node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" }, "node_modules/acorn": { "version": "8.15.0", @@ -1147,6 +1159,13 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/package.json b/package.json index 25c45ba..e31310b 100644 --- a/package.json +++ b/package.json @@ -63,12 +63,13 @@ "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.10", - "@types/node": "20.0.0", + "@types/node": "20.12.0", "chai": "^4.3.7", "mocha": "^10.2.0", "prettier": "^3.3.3", "ts-node": "^10.9.1", - "typescript": "^5.5.4" + "typescript": "^5.5.4", + "undici-types": "^7.16.0" }, "prettier": { "semi": true, diff --git a/src/resources/webhook/handler.ts b/src/resources/webhook/handler.ts index 0d8499e..4646aac 100644 --- a/src/resources/webhook/handler.ts +++ b/src/resources/webhook/handler.ts @@ -3,48 +3,24 @@ import { WebhookEvent } from './content.js'; export type EventType = import('chargebee').EventTypeEnum; -export interface WebhookEventMap extends Record { - unhandled_event: WebhookEvent; - error: unknown; +export interface WebhookEventMap extends Record { + unhandled_event: [WebhookEvent]; + error: [Error]; } export type WebhookEventListener = ( - event: WebhookEventMap[K], + ...args: WebhookEventMap[K] ) => Promise | void; -export class WebhookHandler extends EventEmitter { +export class WebhookHandler extends EventEmitter { requestValidator?: ( headers: Record, ) => void; - on( - eventName: K, - listener: WebhookEventListener, - ): this { - return super.on(eventName, listener as (...args: unknown[]) => void); + constructor() { + super({ captureRejections: true }); } - - once( - eventName: K, - listener: WebhookEventListener, - ): this { - return super.once(eventName, listener as (...args: unknown[]) => void); - } - - off( - eventName: K, - listener: WebhookEventListener, - ): this { - return super.off(eventName, listener as (...args: unknown[]) => void); - } - - emit( - eventName: K, - event: WebhookEventMap[K], - ): boolean { - return super.emit(eventName, event); - } - + handle( body: string | object, headers?: Record, @@ -61,11 +37,11 @@ export class WebhookHandler extends EventEmitter { if (this.listenerCount(eventType) > 0) { this.emit(eventType, event); - } else if (this.listenerCount('unhandled_event') > 0) { + } else { this.emit('unhandled_event', event); } } catch (err) { - this.emit('error', err); + this.emit('error', err instanceof Error ? err : new Error(String(err))); } } } diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 59884f4..3c2768a 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -2,12 +2,14 @@ "compilerOptions": { "outDir": "./cjs", "module": "commonjs", + "moduleResolution": "node", "target": "es2017", "strict": true, "types": [ "node" ], - "esModuleInterop": false + "esModuleInterop": false, + "skipLibCheck": true }, "include": [ "./src/**/*" From 0e741dc1bc48516f649605eda80f70963c1ddd98 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Thu, 4 Dec 2025 16:59:29 +0530 Subject: [PATCH 04/11] webhook handler default instance --- README.md | 40 ++++++++- src/chargebee.cjs.ts | 2 + src/chargebee.esm.ts | 1 + src/resources/webhook/handler.ts | 15 ++++ test/webhook.test.ts | 135 ++++++++++++++++++++++++++++--- types/index.d.ts | 9 ++- 6 files changed, 190 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1f50cbf..9a64181 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,45 @@ const chargebeeSiteEU = new Chargebee({ Use the webhook handlers to parse and route webhook payloads from Chargebee with full TypeScript support. -#### High-level: Route events with callbacks using `WebhookHandler` +#### Quick Start: Using the default `webhook` instance + +The simplest way to handle webhooks is using the pre-configured `webhook` instance: + +```typescript +import express from 'express'; +import { webhook, type WebhookEvent } from 'chargebee'; + +const app = express(); +app.use(express.json()); + +webhook.on('subscription_created', async (event: WebhookEvent) => { + console.log(`Subscription created: ${event.id}`); + const subscription = event.content.subscription; + console.log(`Customer: ${subscription.customer_id}`); +}); + +webhook.on('error', (err: Error) => { + console.error('Webhook error:', err.message); +}); + +app.post('/chargebee/webhooks', (req, res) => { + webhook.handle(req.body, req.headers); + res.status(200).send('OK'); +}); + +app.listen(8080); +``` + +**Auto-configured Basic Auth:** The default `webhook` instance automatically configures Basic Auth validation if the following environment variables are set: + +- `CHARGEBEE_WEBHOOK_USERNAME` - The expected username +- `CHARGEBEE_WEBHOOK_PASSWORD` - The expected password + +When both are present, incoming webhook requests will be validated against these credentials. If not set, no authentication is applied. + +#### Creating custom `WebhookHandler` instances + +For more control or multiple webhook endpoints, create your own instances: ```typescript import express from 'express'; diff --git a/src/chargebee.cjs.ts b/src/chargebee.cjs.ts index 2f2f19b..c96f7cd 100644 --- a/src/chargebee.cjs.ts +++ b/src/chargebee.cjs.ts @@ -1,6 +1,7 @@ import { CreateChargebee } from './createChargebee.js'; import { FetchHttpClient } from './net/FetchClient.js'; import { WebhookHandler } from './resources/webhook/handler.js'; +import webhookInstance from './resources/webhook/handler.js'; import { basicAuthValidator } from './resources/webhook/auth.js'; const httpClient = new FetchHttpClient(); @@ -11,6 +12,7 @@ module.exports.default = Chargebee; // Export webhook modules module.exports.WebhookHandler = WebhookHandler; +module.exports.webhook = webhookInstance; module.exports.basicAuthValidator = basicAuthValidator; // Export webhook types diff --git a/src/chargebee.esm.ts b/src/chargebee.esm.ts index d1a08df..54a4315 100644 --- a/src/chargebee.esm.ts +++ b/src/chargebee.esm.ts @@ -8,6 +8,7 @@ export default Chargebee; // Export webhook modules export { WebhookHandler, EventType } from './resources/webhook/handler.js'; +export { default as webhook } from './resources/webhook/handler.js'; export { basicAuthValidator } from './resources/webhook/auth.js'; // Export webhook types diff --git a/src/resources/webhook/handler.ts b/src/resources/webhook/handler.ts index 4646aac..175d09a 100644 --- a/src/resources/webhook/handler.ts +++ b/src/resources/webhook/handler.ts @@ -1,5 +1,6 @@ import { EventEmitter } from 'node:events'; import { WebhookEvent } from './content.js'; +import { basicAuthValidator } from './auth.js'; export type EventType = import('chargebee').EventTypeEnum; @@ -46,4 +47,18 @@ export class WebhookHandler extends EventEmitter { } } +const webhook = new WebhookHandler(); + +// Auto-configure basic auth if env vars are present +const username = process.env.CHARGEBEE_WEBHOOK_USERNAME; +const password = process.env.CHARGEBEE_WEBHOOK_PASSWORD; + +if (username && password) { + webhook.requestValidator = basicAuthValidator( + (u, p) => u === username && p === password, + ); +} + +export default webhook; + export type { WebhookEvent } from './content.js'; diff --git a/test/webhook.test.ts b/test/webhook.test.ts index 4da16e6..1f363f1 100644 --- a/test/webhook.test.ts +++ b/test/webhook.test.ts @@ -2,17 +2,42 @@ import { expect } from 'chai'; import { WebhookHandler } from '../src/resources/webhook/handler.js'; import { basicAuthValidator } from '../src/resources/webhook/auth.js'; -describe('WebhookHandler', () => { - const makeEventBody = (eventType: string, content: string = '{}') => { - return JSON.stringify({ - id: 'evt_test_1', - occurred_at: Math.floor(Date.now() / 1000), - event_type: eventType, - api_version: 'v2', - content: JSON.parse(content), - }); - }; +// Helper to re-import the default webhook instance with fresh env vars +async function getDefaultWebhookWithEnv( + env: Record, +): Promise { + // Save original env + const originalEnv = { ...process.env }; + + // Clear module cache for handler + const modulePath = require.resolve('../src/resources/webhook/handler.js'); + delete require.cache[modulePath]; + + // Set new env vars + Object.assign(process.env, env); + + // Re-import + const { default: webhook } = await import( + '../src/resources/webhook/handler.js' + ); + + // Restore original env + process.env = originalEnv; + + return webhook; +} + +const makeEventBody = (eventType: string, content: string = '{}') => { + return JSON.stringify({ + id: 'evt_test_1', + occurred_at: Math.floor(Date.now() / 1000), + event_type: eventType, + api_version: 'v2', + content: JSON.parse(content), + }); +}; +describe('WebhookHandler', () => { it('should route to callback successfully', async () => { let called = false; const handler = new WebhookHandler(); @@ -278,3 +303,93 @@ describe('BasicAuthValidator', () => { expect(callbackCalled).to.be.true; }); }); + +describe('Default webhook instance', () => { + it('should auto-configure basic auth when env vars are set', async () => { + const webhook = await getDefaultWebhookWithEnv({ + CHARGEBEE_WEBHOOK_USERNAME: 'envuser', + CHARGEBEE_WEBHOOK_PASSWORD: 'envpass', + }); + + expect(webhook.requestValidator).to.not.be.undefined; + + // Valid credentials should pass + const validAuth = + 'Basic ' + Buffer.from('envuser:envpass').toString('base64'); + expect(() => + webhook.requestValidator!({ authorization: validAuth }), + ).to.not.throw(); + + // Invalid credentials should fail + const invalidAuth = + 'Basic ' + Buffer.from('wrong:wrong').toString('base64'); + expect(() => + webhook.requestValidator!({ authorization: invalidAuth }), + ).to.throw('Invalid credentials'); + }); + + it('should not configure auth when env vars are missing', async () => { + const webhook = await getDefaultWebhookWithEnv({ + CHARGEBEE_WEBHOOK_USERNAME: undefined, + CHARGEBEE_WEBHOOK_PASSWORD: undefined, + }); + + expect(webhook.requestValidator).to.be.undefined; + }); + + it('should not configure auth when only username is set', async () => { + const webhook = await getDefaultWebhookWithEnv({ + CHARGEBEE_WEBHOOK_USERNAME: 'envuser', + CHARGEBEE_WEBHOOK_PASSWORD: undefined, + }); + + expect(webhook.requestValidator).to.be.undefined; + }); + + it('should not configure auth when only password is set', async () => { + const webhook = await getDefaultWebhookWithEnv({ + CHARGEBEE_WEBHOOK_USERNAME: undefined, + CHARGEBEE_WEBHOOK_PASSWORD: 'envpass', + }); + + expect(webhook.requestValidator).to.be.undefined; + }); + + it('should work end-to-end with env-configured auth', async () => { + const webhook = await getDefaultWebhookWithEnv({ + CHARGEBEE_WEBHOOK_USERNAME: 'testuser', + CHARGEBEE_WEBHOOK_PASSWORD: 'testpass', + }); + + let callbackCalled = false; + let errorCalled = false; + + webhook.on('customer_created', async () => { + callbackCalled = true; + }); + webhook.on('error', () => { + errorCalled = true; + }); + + const validAuth = + 'Basic ' + Buffer.from('testuser:testpass').toString('base64'); + const body = JSON.stringify({ + id: 'evt_test', + event_type: 'customer_created', + content: {}, + }); + + // With valid auth, callback should be called + webhook.handle(body, { authorization: validAuth }); + expect(callbackCalled).to.be.true; + expect(errorCalled).to.be.false; + + // With invalid auth, error should be emitted + callbackCalled = false; + const invalidAuth = + 'Basic ' + Buffer.from('wrong:wrong').toString('base64'); + webhook.handle(body, { authorization: invalidAuth }); + expect(callbackCalled).to.be.false; + expect(errorCalled).to.be.true; + }); +}); diff --git a/types/index.d.ts b/types/index.d.ts index e31cf7b..0d384b6 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -250,13 +250,17 @@ declare module 'chargebee' { } // Webhook Handler - export type WebhookEventType = EventTypeEnum | 'unhandled_event' | 'error'; + export type WebhookEventType = EventTypeEnum | 'unhandled_event'; export type WebhookEventListener = (event: WebhookEvent) => Promise | void; + export type WebhookErrorListener = (error: Error) => Promise | void; export class WebhookHandler { on(eventName: WebhookEventType, listener: WebhookEventListener): this; + on(eventName: 'error', listener: WebhookErrorListener): this; once(eventName: WebhookEventType, listener: WebhookEventListener): this; + once(eventName: 'error', listener: WebhookErrorListener): this; off(eventName: WebhookEventType, listener: WebhookEventListener): this; + off(eventName: 'error', listener: WebhookErrorListener): this; handle( body: string | object, headers?: Record, @@ -272,6 +276,9 @@ declare module 'chargebee' { validateCredentials: (username: string, password: string) => boolean, ): (headers: Record) => void; + // Default webhook handler instance + export const webhook: WebhookHandler; + // Additional webhook content types not in WebhookEvent.d.ts // Note: These use lowercase property names to match the actual webhook JSON structure export type AddonCreatedContent = { From 67c330af0dcc6811d956ce13b75d506465bda939 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Wed, 10 Dec 2025 09:40:19 +0530 Subject: [PATCH 05/11] Webhook ContentType class name change --- types/index.d.ts | 57 ++-- types/resources/WebhookEvent.d.ts | 466 ++++++++++++++++-------------- 2 files changed, 289 insertions(+), 234 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 0d384b6..21fc622 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -250,16 +250,51 @@ declare module 'chargebee' { } // Webhook Handler - export type WebhookEventType = EventTypeEnum | 'unhandled_event'; - export type WebhookEventListener = (event: WebhookEvent) => Promise | void; + export type WebhookEventName = EventTypeEnum | 'unhandled_event'; + export type WebhookEventTypeValue = `${WebhookEventType}`; + /** @deprecated Use WebhookEventTypeValue instead */ + export type WebhookContentTypeValue = WebhookEventTypeValue; + + export type WebhookEventListener< + T extends WebhookEventType = WebhookEventType, + > = (event: WebhookEvent) => Promise | void; export type WebhookErrorListener = (error: Error) => Promise | void; + // Helper type to map string literal to enum member + type StringToWebhookEventType = { + [K in WebhookEventType]: `${K}` extends S ? K : never; + }[WebhookEventType]; + export class WebhookHandler { - on(eventName: WebhookEventType, listener: WebhookEventListener): this; + on( + eventName: T, + listener: WebhookEventListener, + ): this; + on( + eventName: S, + listener: WebhookEventListener>, + ): this; + on(eventName: 'unhandled_event', listener: WebhookEventListener): this; on(eventName: 'error', listener: WebhookErrorListener): this; - once(eventName: WebhookEventType, listener: WebhookEventListener): this; + once( + eventName: T, + listener: WebhookEventListener, + ): this; + once( + eventName: S, + listener: WebhookEventListener>, + ): this; + once(eventName: 'unhandled_event', listener: WebhookEventListener): this; once(eventName: 'error', listener: WebhookErrorListener): this; - off(eventName: WebhookEventType, listener: WebhookEventListener): this; + off( + eventName: T, + listener: WebhookEventListener, + ): this; + off( + eventName: S, + listener: WebhookEventListener>, + ): this; + off(eventName: 'unhandled_event', listener: WebhookEventListener): this; off(eventName: 'error', listener: WebhookErrorListener): this; handle( body: string | object, @@ -278,16 +313,4 @@ declare module 'chargebee' { // Default webhook handler instance export const webhook: WebhookHandler; - - // Additional webhook content types not in WebhookEvent.d.ts - // Note: These use lowercase property names to match the actual webhook JSON structure - export type AddonCreatedContent = { - addon: Addon; - }; - export type AddonUpdatedContent = { - addon: Addon; - }; - export type AddonDeletedContent = { - addon: Addon; - }; } diff --git a/types/resources/WebhookEvent.d.ts b/types/resources/WebhookEvent.d.ts index 0ebe1f9..9a53983 100644 --- a/types/resources/WebhookEvent.d.ts +++ b/types/resources/WebhookEvent.d.ts @@ -3,7 +3,7 @@ /// declare module 'chargebee' { - export enum WebhookContentType { + export enum WebhookEventType { SubscriptionPauseScheduled = 'subscription_pause_scheduled', CustomerBusinessEntityChanged = 'customer_business_entity_changed', SubscriptionAdvanceInvoiceScheduleAdded = 'subscription_advance_invoice_schedule_added', @@ -213,225 +213,239 @@ declare module 'chargebee' { BusinessEntityDeleted = 'business_entity_deleted', AuthorizationVoided = 'authorization_voided', SubscriptionRampDeleted = 'subscription_ramp_deleted', + PlanDeleted = 'plan_deleted', + AddonDeleted = 'addon_deleted', + AddonUpdated = 'addon_updated', + AddonCreated = 'addon_created', + PlanCreated = 'plan_created', + PlanUpdated = 'plan_updated', } + /** + * @deprecated Use WebhookEventType instead. + */ + export import WebhookContentType = WebhookEventType; export type WebhookContentMap = { - [WebhookContentType.SubscriptionPauseScheduled]: SubscriptionPauseScheduledContent; - [WebhookContentType.CustomerBusinessEntityChanged]: CustomerBusinessEntityChangedContent; - [WebhookContentType.SubscriptionAdvanceInvoiceScheduleAdded]: SubscriptionAdvanceInvoiceScheduleAddedContent; - [WebhookContentType.GiftExpired]: GiftExpiredContent; - [WebhookContentType.TaxWithheldDeleted]: TaxWithheldDeletedContent; - [WebhookContentType.UnbilledChargesDeleted]: UnbilledChargesDeletedContent; - [WebhookContentType.CouponUpdated]: CouponUpdatedContent; - [WebhookContentType.OmnichannelSubscriptionItemReactivated]: OmnichannelSubscriptionItemReactivatedContent; - [WebhookContentType.OmnichannelSubscriptionItemRenewed]: OmnichannelSubscriptionItemRenewedContent; - [WebhookContentType.UnbilledChargesCreated]: UnbilledChargesCreatedContent; - [WebhookContentType.SubscriptionResumed]: SubscriptionResumedContent; - [WebhookContentType.OmnichannelOneTimeOrderItemCancelled]: OmnichannelOneTimeOrderItemCancelledContent; - [WebhookContentType.SubscriptionCancelled]: SubscriptionCancelledContent; - [WebhookContentType.ItemEntitlementsRemoved]: ItemEntitlementsRemovedContent; - [WebhookContentType.BusinessEntityCreated]: BusinessEntityCreatedContent; - [WebhookContentType.CouponSetUpdated]: CouponSetUpdatedContent; - [WebhookContentType.DifferentialPriceUpdated]: DifferentialPriceUpdatedContent; - [WebhookContentType.OmnichannelSubscriptionItemPaused]: OmnichannelSubscriptionItemPausedContent; - [WebhookContentType.EntitlementOverridesRemoved]: EntitlementOverridesRemovedContent; - [WebhookContentType.SubscriptionActivatedWithBackdating]: SubscriptionActivatedWithBackdatingContent; - [WebhookContentType.SubscriptionTrialEndReminder]: SubscriptionTrialEndReminderContent; - [WebhookContentType.SubscriptionShippingAddressUpdated]: SubscriptionShippingAddressUpdatedContent; - [WebhookContentType.VoucherCreateFailed]: VoucherCreateFailedContent; - [WebhookContentType.GiftClaimed]: GiftClaimedContent; - [WebhookContentType.CustomerDeleted]: CustomerDeletedContent; - [WebhookContentType.RefundInitiated]: RefundInitiatedContent; - [WebhookContentType.InvoiceGeneratedWithBackdating]: InvoiceGeneratedWithBackdatingContent; - [WebhookContentType.OmnichannelTransactionCreated]: OmnichannelTransactionCreatedContent; - [WebhookContentType.AddUsagesReminder]: AddUsagesReminderContent; - [WebhookContentType.VoucherCreated]: VoucherCreatedContent; - [WebhookContentType.RuleUpdated]: RuleUpdatedContent; - [WebhookContentType.PaymentSchedulesCreated]: PaymentSchedulesCreatedContent; - [WebhookContentType.FeatureActivated]: FeatureActivatedContent; - [WebhookContentType.PaymentSourceLocallyDeleted]: PaymentSourceLocallyDeletedContent; - [WebhookContentType.InvoiceGenerated]: InvoiceGeneratedContent; - [WebhookContentType.VoucherExpired]: VoucherExpiredContent; - [WebhookContentType.AuthorizationSucceeded]: AuthorizationSucceededContent; - [WebhookContentType.GiftScheduled]: GiftScheduledContent; - [WebhookContentType.SubscriptionChangesScheduled]: SubscriptionChangesScheduledContent; - [WebhookContentType.SubscriptionChangedWithBackdating]: SubscriptionChangedWithBackdatingContent; - [WebhookContentType.OmnichannelSubscriptionItemChanged]: OmnichannelSubscriptionItemChangedContent; - [WebhookContentType.GiftUnclaimed]: GiftUnclaimedContent; - [WebhookContentType.VirtualBankAccountAdded]: VirtualBankAccountAddedContent; - [WebhookContentType.PaymentIntentCreated]: PaymentIntentCreatedContent; - [WebhookContentType.CreditNoteCreatedWithBackdating]: CreditNoteCreatedWithBackdatingContent; - [WebhookContentType.ContractTermTerminated]: ContractTermTerminatedContent; - [WebhookContentType.ItemFamilyUpdated]: ItemFamilyUpdatedContent; - [WebhookContentType.OrderCreated]: OrderCreatedContent; - [WebhookContentType.PriceVariantDeleted]: PriceVariantDeletedContent; - [WebhookContentType.SubscriptionMovementFailed]: SubscriptionMovementFailedContent; - [WebhookContentType.CustomerMovedIn]: CustomerMovedInContent; - [WebhookContentType.SubscriptionAdvanceInvoiceScheduleUpdated]: SubscriptionAdvanceInvoiceScheduleUpdatedContent; - [WebhookContentType.ItemDeleted]: ItemDeletedContent; - [WebhookContentType.SubscriptionRampDrafted]: SubscriptionRampDraftedContent; - [WebhookContentType.DunningUpdated]: DunningUpdatedContent; - [WebhookContentType.ItemEntitlementsUpdated]: ItemEntitlementsUpdatedContent; - [WebhookContentType.TokenConsumed]: TokenConsumedContent; - [WebhookContentType.HierarchyDeleted]: HierarchyDeletedContent; - [WebhookContentType.SubscriptionCancellationScheduled]: SubscriptionCancellationScheduledContent; - [WebhookContentType.SubscriptionRenewed]: SubscriptionRenewedContent; - [WebhookContentType.FeatureUpdated]: FeatureUpdatedContent; - [WebhookContentType.FeatureDeleted]: FeatureDeletedContent; - [WebhookContentType.ItemFamilyCreated]: ItemFamilyCreatedContent; - [WebhookContentType.OmnichannelSubscriptionItemScheduledChangeRemoved]: OmnichannelSubscriptionItemScheduledChangeRemovedContent; - [WebhookContentType.OmnichannelSubscriptionItemResumed]: OmnichannelSubscriptionItemResumedContent; - [WebhookContentType.PurchaseCreated]: PurchaseCreatedContent; - [WebhookContentType.EntitlementOverridesUpdated]: EntitlementOverridesUpdatedContent; - [WebhookContentType.ItemFamilyDeleted]: ItemFamilyDeletedContent; - [WebhookContentType.SubscriptionResumptionScheduled]: SubscriptionResumptionScheduledContent; - [WebhookContentType.FeatureReactivated]: FeatureReactivatedContent; - [WebhookContentType.CouponCodesDeleted]: CouponCodesDeletedContent; - [WebhookContentType.CardExpired]: CardExpiredContent; - [WebhookContentType.CreditNoteUpdated]: CreditNoteUpdatedContent; - [WebhookContentType.OmnichannelSubscriptionItemDowngraded]: OmnichannelSubscriptionItemDowngradedContent; - [WebhookContentType.PriceVariantUpdated]: PriceVariantUpdatedContent; - [WebhookContentType.PromotionalCreditsDeducted]: PromotionalCreditsDeductedContent; - [WebhookContentType.SubscriptionRampApplied]: SubscriptionRampAppliedContent; - [WebhookContentType.SubscriptionPaused]: SubscriptionPausedContent; - [WebhookContentType.OrderReadyToProcess]: OrderReadyToProcessContent; - [WebhookContentType.FeatureCreated]: FeatureCreatedContent; - [WebhookContentType.TransactionDeleted]: TransactionDeletedContent; - [WebhookContentType.CreditNoteCreated]: CreditNoteCreatedContent; - [WebhookContentType.OmnichannelSubscriptionItemResubscribed]: OmnichannelSubscriptionItemResubscribedContent; - [WebhookContentType.RecordPurchaseFailed]: RecordPurchaseFailedContent; - [WebhookContentType.ItemCreated]: ItemCreatedContent; - [WebhookContentType.TransactionUpdated]: TransactionUpdatedContent; - [WebhookContentType.MrrUpdated]: MrrUpdatedContent; - [WebhookContentType.UnbilledChargesInvoiced]: UnbilledChargesInvoicedContent; - [WebhookContentType.ItemPriceUpdated]: ItemPriceUpdatedContent; - [WebhookContentType.CouponCodesUpdated]: CouponCodesUpdatedContent; - [WebhookContentType.VirtualBankAccountUpdated]: VirtualBankAccountUpdatedContent; - [WebhookContentType.ContractTermCreated]: ContractTermCreatedContent; - [WebhookContentType.SubscriptionChanged]: SubscriptionChangedContent; - [WebhookContentType.PaymentFailed]: PaymentFailedContent; - [WebhookContentType.CreditNoteDeleted]: CreditNoteDeletedContent; - [WebhookContentType.TaxWithheldRefunded]: TaxWithheldRefundedContent; - [WebhookContentType.ContractTermCompleted]: ContractTermCompletedContent; - [WebhookContentType.PaymentSchedulesUpdated]: PaymentSchedulesUpdatedContent; - [WebhookContentType.OmnichannelSubscriptionItemExpired]: OmnichannelSubscriptionItemExpiredContent; - [WebhookContentType.CardUpdated]: CardUpdatedContent; - [WebhookContentType.CustomerCreated]: CustomerCreatedContent; - [WebhookContentType.SubscriptionRenewalReminder]: SubscriptionRenewalReminderContent; - [WebhookContentType.OrderDelivered]: OrderDeliveredContent; - [WebhookContentType.OmnichannelSubscriptionItemCancellationScheduled]: OmnichannelSubscriptionItemCancellationScheduledContent; - [WebhookContentType.OmnichannelSubscriptionItemGracePeriodExpired]: OmnichannelSubscriptionItemGracePeriodExpiredContent; - [WebhookContentType.CouponCodesAdded]: CouponCodesAddedContent; - [WebhookContentType.GiftCancelled]: GiftCancelledContent; - [WebhookContentType.OrderCancelled]: OrderCancelledContent; - [WebhookContentType.CouponDeleted]: CouponDeletedContent; - [WebhookContentType.SubscriptionScheduledChangesRemoved]: SubscriptionScheduledChangesRemovedContent; - [WebhookContentType.PendingInvoiceCreated]: PendingInvoiceCreatedContent; - [WebhookContentType.EntitlementOverridesAutoRemoved]: EntitlementOverridesAutoRemovedContent; - [WebhookContentType.OmnichannelSubscriptionItemUpgraded]: OmnichannelSubscriptionItemUpgradedContent; - [WebhookContentType.SubscriptionBusinessEntityChanged]: SubscriptionBusinessEntityChangedContent; - [WebhookContentType.OmnichannelOneTimeOrderCreated]: OmnichannelOneTimeOrderCreatedContent; - [WebhookContentType.PaymentSourceDeleted]: PaymentSourceDeletedContent; - [WebhookContentType.OmnichannelSubscriptionItemCancelled]: OmnichannelSubscriptionItemCancelledContent; - [WebhookContentType.QuoteDeleted]: QuoteDeletedContent; - [WebhookContentType.InvoiceUpdated]: InvoiceUpdatedContent; - [WebhookContentType.SubscriptionAdvanceInvoiceScheduleRemoved]: SubscriptionAdvanceInvoiceScheduleRemovedContent; - [WebhookContentType.CardDeleted]: CardDeletedContent; - [WebhookContentType.OrderReadyToShip]: OrderReadyToShipContent; - [WebhookContentType.SubscriptionMovedOut]: SubscriptionMovedOutContent; - [WebhookContentType.PaymentScheduleSchemeCreated]: PaymentScheduleSchemeCreatedContent; - [WebhookContentType.BusinessEntityUpdated]: BusinessEntityUpdatedContent; - [WebhookContentType.SubscriptionScheduledResumptionRemoved]: SubscriptionScheduledResumptionRemovedContent; - [WebhookContentType.PaymentInitiated]: PaymentInitiatedContent; - [WebhookContentType.FeatureArchived]: FeatureArchivedContent; - [WebhookContentType.SubscriptionReactivatedWithBackdating]: SubscriptionReactivatedWithBackdatingContent; - [WebhookContentType.OmnichannelSubscriptionImported]: OmnichannelSubscriptionImportedContent; - [WebhookContentType.TokenExpired]: TokenExpiredContent; - [WebhookContentType.CardAdded]: CardAddedContent; - [WebhookContentType.CouponCreated]: CouponCreatedContent; - [WebhookContentType.RuleDeleted]: RuleDeletedContent; - [WebhookContentType.ItemPriceEntitlementsUpdated]: ItemPriceEntitlementsUpdatedContent; - [WebhookContentType.ItemPriceDeleted]: ItemPriceDeletedContent; - [WebhookContentType.VirtualBankAccountDeleted]: VirtualBankAccountDeletedContent; - [WebhookContentType.PaymentScheduleSchemeDeleted]: PaymentScheduleSchemeDeletedContent; - [WebhookContentType.SubscriptionCreated]: SubscriptionCreatedContent; - [WebhookContentType.SubscriptionEntitlementsCreated]: SubscriptionEntitlementsCreatedContent; - [WebhookContentType.OrderReturned]: OrderReturnedContent; - [WebhookContentType.SubscriptionDeleted]: SubscriptionDeletedContent; - [WebhookContentType.PaymentSourceAdded]: PaymentSourceAddedContent; - [WebhookContentType.SubscriptionMovedIn]: SubscriptionMovedInContent; - [WebhookContentType.ItemPriceCreated]: ItemPriceCreatedContent; - [WebhookContentType.SubscriptionScheduledCancellationRemoved]: SubscriptionScheduledCancellationRemovedContent; - [WebhookContentType.PaymentRefunded]: PaymentRefundedContent; - [WebhookContentType.UsageFileIngested]: UsageFileIngestedContent; - [WebhookContentType.OmnichannelSubscriptionMovedIn]: OmnichannelSubscriptionMovedInContent; - [WebhookContentType.DifferentialPriceCreated]: DifferentialPriceCreatedContent; - [WebhookContentType.TransactionCreated]: TransactionCreatedContent; - [WebhookContentType.PaymentSucceeded]: PaymentSucceededContent; - [WebhookContentType.SubscriptionCanceledWithBackdating]: SubscriptionCanceledWithBackdatingContent; - [WebhookContentType.UnbilledChargesVoided]: UnbilledChargesVoidedContent; - [WebhookContentType.QuoteCreated]: QuoteCreatedContent; - [WebhookContentType.CouponSetDeleted]: CouponSetDeletedContent; - [WebhookContentType.AttachedItemCreated]: AttachedItemCreatedContent; - [WebhookContentType.SalesOrderCreated]: SalesOrderCreatedContent; - [WebhookContentType.CustomerChanged]: CustomerChangedContent; - [WebhookContentType.SubscriptionStarted]: SubscriptionStartedContent; - [WebhookContentType.SubscriptionActivated]: SubscriptionActivatedContent; - [WebhookContentType.PaymentSourceExpiring]: PaymentSourceExpiringContent; - [WebhookContentType.SubscriptionReactivated]: SubscriptionReactivatedContent; - [WebhookContentType.OrderUpdated]: OrderUpdatedContent; - [WebhookContentType.SubscriptionScheduledPauseRemoved]: SubscriptionScheduledPauseRemovedContent; - [WebhookContentType.SubscriptionCancellationReminder]: SubscriptionCancellationReminderContent; - [WebhookContentType.SubscriptionCreatedWithBackdating]: SubscriptionCreatedWithBackdatingContent; - [WebhookContentType.SubscriptionRampCreated]: SubscriptionRampCreatedContent; - [WebhookContentType.OrderDeleted]: OrderDeletedContent; - [WebhookContentType.OmnichannelSubscriptionItemPauseScheduled]: OmnichannelSubscriptionItemPauseScheduledContent; - [WebhookContentType.GiftUpdated]: GiftUpdatedContent; - [WebhookContentType.SubscriptionTrialExtended]: SubscriptionTrialExtendedContent; - [WebhookContentType.OmnichannelSubscriptionItemGracePeriodStarted]: OmnichannelSubscriptionItemGracePeriodStartedContent; - [WebhookContentType.CardExpiryReminder]: CardExpiryReminderContent; - [WebhookContentType.TokenCreated]: TokenCreatedContent; - [WebhookContentType.PromotionalCreditsAdded]: PromotionalCreditsAddedContent; - [WebhookContentType.SubscriptionRampUpdated]: SubscriptionRampUpdatedContent; - [WebhookContentType.CustomerEntitlementsUpdated]: CustomerEntitlementsUpdatedContent; - [WebhookContentType.PaymentSourceExpired]: PaymentSourceExpiredContent; - [WebhookContentType.CustomerMovedOut]: CustomerMovedOutContent; - [WebhookContentType.SubscriptionEntitlementsUpdated]: SubscriptionEntitlementsUpdatedContent; - [WebhookContentType.OmnichannelSubscriptionItemDunningExpired]: OmnichannelSubscriptionItemDunningExpiredContent; - [WebhookContentType.HierarchyCreated]: HierarchyCreatedContent; - [WebhookContentType.AttachedItemDeleted]: AttachedItemDeletedContent; - [WebhookContentType.OmnichannelSubscriptionItemScheduledCancellationRemoved]: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; - [WebhookContentType.ItemUpdated]: ItemUpdatedContent; - [WebhookContentType.CouponSetCreated]: CouponSetCreatedContent; - [WebhookContentType.PaymentIntentUpdated]: PaymentIntentUpdatedContent; - [WebhookContentType.OrderResent]: OrderResentContent; - [WebhookContentType.OmnichannelSubscriptionCreated]: OmnichannelSubscriptionCreatedContent; - [WebhookContentType.TaxWithheldRecorded]: TaxWithheldRecordedContent; - [WebhookContentType.PriceVariantCreated]: PriceVariantCreatedContent; - [WebhookContentType.DifferentialPriceDeleted]: DifferentialPriceDeletedContent; - [WebhookContentType.SubscriptionItemsRenewed]: SubscriptionItemsRenewedContent; - [WebhookContentType.RuleCreated]: RuleCreatedContent; - [WebhookContentType.ContractTermCancelled]: ContractTermCancelledContent; - [WebhookContentType.ContractTermRenewed]: ContractTermRenewedContent; - [WebhookContentType.InvoiceDeleted]: InvoiceDeletedContent; - [WebhookContentType.ItemPriceEntitlementsRemoved]: ItemPriceEntitlementsRemovedContent; - [WebhookContentType.SalesOrderUpdated]: SalesOrderUpdatedContent; - [WebhookContentType.OmnichannelSubscriptionItemDunningStarted]: OmnichannelSubscriptionItemDunningStartedContent; - [WebhookContentType.OmnichannelSubscriptionItemChangeScheduled]: OmnichannelSubscriptionItemChangeScheduledContent; - [WebhookContentType.PendingInvoiceUpdated]: PendingInvoiceUpdatedContent; - [WebhookContentType.QuoteUpdated]: QuoteUpdatedContent; - [WebhookContentType.AttachedItemUpdated]: AttachedItemUpdatedContent; - [WebhookContentType.PaymentSourceUpdated]: PaymentSourceUpdatedContent; - [WebhookContentType.BusinessEntityDeleted]: BusinessEntityDeletedContent; - [WebhookContentType.AuthorizationVoided]: AuthorizationVoidedContent; - [WebhookContentType.SubscriptionRampDeleted]: SubscriptionRampDeletedContent; - }; - - export type ContentFor = WebhookContentMap[T]; - - export interface WebhookEvent< - T extends WebhookContentType = WebhookContentType, - > { + [WebhookEventType.SubscriptionPauseScheduled]: SubscriptionPauseScheduledContent; + [WebhookEventType.CustomerBusinessEntityChanged]: CustomerBusinessEntityChangedContent; + [WebhookEventType.SubscriptionAdvanceInvoiceScheduleAdded]: SubscriptionAdvanceInvoiceScheduleAddedContent; + [WebhookEventType.GiftExpired]: GiftExpiredContent; + [WebhookEventType.TaxWithheldDeleted]: TaxWithheldDeletedContent; + [WebhookEventType.UnbilledChargesDeleted]: UnbilledChargesDeletedContent; + [WebhookEventType.CouponUpdated]: CouponUpdatedContent; + [WebhookEventType.OmnichannelSubscriptionItemReactivated]: OmnichannelSubscriptionItemReactivatedContent; + [WebhookEventType.OmnichannelSubscriptionItemRenewed]: OmnichannelSubscriptionItemRenewedContent; + [WebhookEventType.UnbilledChargesCreated]: UnbilledChargesCreatedContent; + [WebhookEventType.SubscriptionResumed]: SubscriptionResumedContent; + [WebhookEventType.OmnichannelOneTimeOrderItemCancelled]: OmnichannelOneTimeOrderItemCancelledContent; + [WebhookEventType.SubscriptionCancelled]: SubscriptionCancelledContent; + [WebhookEventType.ItemEntitlementsRemoved]: ItemEntitlementsRemovedContent; + [WebhookEventType.BusinessEntityCreated]: BusinessEntityCreatedContent; + [WebhookEventType.CouponSetUpdated]: CouponSetUpdatedContent; + [WebhookEventType.DifferentialPriceUpdated]: DifferentialPriceUpdatedContent; + [WebhookEventType.OmnichannelSubscriptionItemPaused]: OmnichannelSubscriptionItemPausedContent; + [WebhookEventType.EntitlementOverridesRemoved]: EntitlementOverridesRemovedContent; + [WebhookEventType.SubscriptionActivatedWithBackdating]: SubscriptionActivatedWithBackdatingContent; + [WebhookEventType.SubscriptionTrialEndReminder]: SubscriptionTrialEndReminderContent; + [WebhookEventType.SubscriptionShippingAddressUpdated]: SubscriptionShippingAddressUpdatedContent; + [WebhookEventType.VoucherCreateFailed]: VoucherCreateFailedContent; + [WebhookEventType.GiftClaimed]: GiftClaimedContent; + [WebhookEventType.CustomerDeleted]: CustomerDeletedContent; + [WebhookEventType.RefundInitiated]: RefundInitiatedContent; + [WebhookEventType.InvoiceGeneratedWithBackdating]: InvoiceGeneratedWithBackdatingContent; + [WebhookEventType.OmnichannelTransactionCreated]: OmnichannelTransactionCreatedContent; + [WebhookEventType.AddUsagesReminder]: AddUsagesReminderContent; + [WebhookEventType.VoucherCreated]: VoucherCreatedContent; + [WebhookEventType.RuleUpdated]: RuleUpdatedContent; + [WebhookEventType.PaymentSchedulesCreated]: PaymentSchedulesCreatedContent; + [WebhookEventType.FeatureActivated]: FeatureActivatedContent; + [WebhookEventType.PaymentSourceLocallyDeleted]: PaymentSourceLocallyDeletedContent; + [WebhookEventType.InvoiceGenerated]: InvoiceGeneratedContent; + [WebhookEventType.VoucherExpired]: VoucherExpiredContent; + [WebhookEventType.AuthorizationSucceeded]: AuthorizationSucceededContent; + [WebhookEventType.GiftScheduled]: GiftScheduledContent; + [WebhookEventType.SubscriptionChangesScheduled]: SubscriptionChangesScheduledContent; + [WebhookEventType.SubscriptionChangedWithBackdating]: SubscriptionChangedWithBackdatingContent; + [WebhookEventType.OmnichannelSubscriptionItemChanged]: OmnichannelSubscriptionItemChangedContent; + [WebhookEventType.GiftUnclaimed]: GiftUnclaimedContent; + [WebhookEventType.VirtualBankAccountAdded]: VirtualBankAccountAddedContent; + [WebhookEventType.PaymentIntentCreated]: PaymentIntentCreatedContent; + [WebhookEventType.CreditNoteCreatedWithBackdating]: CreditNoteCreatedWithBackdatingContent; + [WebhookEventType.ContractTermTerminated]: ContractTermTerminatedContent; + [WebhookEventType.ItemFamilyUpdated]: ItemFamilyUpdatedContent; + [WebhookEventType.OrderCreated]: OrderCreatedContent; + [WebhookEventType.PriceVariantDeleted]: PriceVariantDeletedContent; + [WebhookEventType.SubscriptionMovementFailed]: SubscriptionMovementFailedContent; + [WebhookEventType.CustomerMovedIn]: CustomerMovedInContent; + [WebhookEventType.SubscriptionAdvanceInvoiceScheduleUpdated]: SubscriptionAdvanceInvoiceScheduleUpdatedContent; + [WebhookEventType.ItemDeleted]: ItemDeletedContent; + [WebhookEventType.SubscriptionRampDrafted]: SubscriptionRampDraftedContent; + [WebhookEventType.DunningUpdated]: DunningUpdatedContent; + [WebhookEventType.ItemEntitlementsUpdated]: ItemEntitlementsUpdatedContent; + [WebhookEventType.TokenConsumed]: TokenConsumedContent; + [WebhookEventType.HierarchyDeleted]: HierarchyDeletedContent; + [WebhookEventType.SubscriptionCancellationScheduled]: SubscriptionCancellationScheduledContent; + [WebhookEventType.SubscriptionRenewed]: SubscriptionRenewedContent; + [WebhookEventType.FeatureUpdated]: FeatureUpdatedContent; + [WebhookEventType.FeatureDeleted]: FeatureDeletedContent; + [WebhookEventType.ItemFamilyCreated]: ItemFamilyCreatedContent; + [WebhookEventType.OmnichannelSubscriptionItemScheduledChangeRemoved]: OmnichannelSubscriptionItemScheduledChangeRemovedContent; + [WebhookEventType.OmnichannelSubscriptionItemResumed]: OmnichannelSubscriptionItemResumedContent; + [WebhookEventType.PurchaseCreated]: PurchaseCreatedContent; + [WebhookEventType.EntitlementOverridesUpdated]: EntitlementOverridesUpdatedContent; + [WebhookEventType.ItemFamilyDeleted]: ItemFamilyDeletedContent; + [WebhookEventType.SubscriptionResumptionScheduled]: SubscriptionResumptionScheduledContent; + [WebhookEventType.FeatureReactivated]: FeatureReactivatedContent; + [WebhookEventType.CouponCodesDeleted]: CouponCodesDeletedContent; + [WebhookEventType.CardExpired]: CardExpiredContent; + [WebhookEventType.CreditNoteUpdated]: CreditNoteUpdatedContent; + [WebhookEventType.OmnichannelSubscriptionItemDowngraded]: OmnichannelSubscriptionItemDowngradedContent; + [WebhookEventType.PriceVariantUpdated]: PriceVariantUpdatedContent; + [WebhookEventType.PromotionalCreditsDeducted]: PromotionalCreditsDeductedContent; + [WebhookEventType.SubscriptionRampApplied]: SubscriptionRampAppliedContent; + [WebhookEventType.SubscriptionPaused]: SubscriptionPausedContent; + [WebhookEventType.OrderReadyToProcess]: OrderReadyToProcessContent; + [WebhookEventType.FeatureCreated]: FeatureCreatedContent; + [WebhookEventType.TransactionDeleted]: TransactionDeletedContent; + [WebhookEventType.CreditNoteCreated]: CreditNoteCreatedContent; + [WebhookEventType.OmnichannelSubscriptionItemResubscribed]: OmnichannelSubscriptionItemResubscribedContent; + [WebhookEventType.RecordPurchaseFailed]: RecordPurchaseFailedContent; + [WebhookEventType.ItemCreated]: ItemCreatedContent; + [WebhookEventType.TransactionUpdated]: TransactionUpdatedContent; + [WebhookEventType.MrrUpdated]: MrrUpdatedContent; + [WebhookEventType.UnbilledChargesInvoiced]: UnbilledChargesInvoicedContent; + [WebhookEventType.ItemPriceUpdated]: ItemPriceUpdatedContent; + [WebhookEventType.CouponCodesUpdated]: CouponCodesUpdatedContent; + [WebhookEventType.VirtualBankAccountUpdated]: VirtualBankAccountUpdatedContent; + [WebhookEventType.ContractTermCreated]: ContractTermCreatedContent; + [WebhookEventType.SubscriptionChanged]: SubscriptionChangedContent; + [WebhookEventType.PaymentFailed]: PaymentFailedContent; + [WebhookEventType.CreditNoteDeleted]: CreditNoteDeletedContent; + [WebhookEventType.TaxWithheldRefunded]: TaxWithheldRefundedContent; + [WebhookEventType.ContractTermCompleted]: ContractTermCompletedContent; + [WebhookEventType.PaymentSchedulesUpdated]: PaymentSchedulesUpdatedContent; + [WebhookEventType.OmnichannelSubscriptionItemExpired]: OmnichannelSubscriptionItemExpiredContent; + [WebhookEventType.CardUpdated]: CardUpdatedContent; + [WebhookEventType.CustomerCreated]: CustomerCreatedContent; + [WebhookEventType.SubscriptionRenewalReminder]: SubscriptionRenewalReminderContent; + [WebhookEventType.OrderDelivered]: OrderDeliveredContent; + [WebhookEventType.OmnichannelSubscriptionItemCancellationScheduled]: OmnichannelSubscriptionItemCancellationScheduledContent; + [WebhookEventType.OmnichannelSubscriptionItemGracePeriodExpired]: OmnichannelSubscriptionItemGracePeriodExpiredContent; + [WebhookEventType.CouponCodesAdded]: CouponCodesAddedContent; + [WebhookEventType.GiftCancelled]: GiftCancelledContent; + [WebhookEventType.OrderCancelled]: OrderCancelledContent; + [WebhookEventType.CouponDeleted]: CouponDeletedContent; + [WebhookEventType.SubscriptionScheduledChangesRemoved]: SubscriptionScheduledChangesRemovedContent; + [WebhookEventType.PendingInvoiceCreated]: PendingInvoiceCreatedContent; + [WebhookEventType.EntitlementOverridesAutoRemoved]: EntitlementOverridesAutoRemovedContent; + [WebhookEventType.OmnichannelSubscriptionItemUpgraded]: OmnichannelSubscriptionItemUpgradedContent; + [WebhookEventType.SubscriptionBusinessEntityChanged]: SubscriptionBusinessEntityChangedContent; + [WebhookEventType.OmnichannelOneTimeOrderCreated]: OmnichannelOneTimeOrderCreatedContent; + [WebhookEventType.PaymentSourceDeleted]: PaymentSourceDeletedContent; + [WebhookEventType.OmnichannelSubscriptionItemCancelled]: OmnichannelSubscriptionItemCancelledContent; + [WebhookEventType.QuoteDeleted]: QuoteDeletedContent; + [WebhookEventType.InvoiceUpdated]: InvoiceUpdatedContent; + [WebhookEventType.SubscriptionAdvanceInvoiceScheduleRemoved]: SubscriptionAdvanceInvoiceScheduleRemovedContent; + [WebhookEventType.CardDeleted]: CardDeletedContent; + [WebhookEventType.OrderReadyToShip]: OrderReadyToShipContent; + [WebhookEventType.SubscriptionMovedOut]: SubscriptionMovedOutContent; + [WebhookEventType.PaymentScheduleSchemeCreated]: PaymentScheduleSchemeCreatedContent; + [WebhookEventType.BusinessEntityUpdated]: BusinessEntityUpdatedContent; + [WebhookEventType.SubscriptionScheduledResumptionRemoved]: SubscriptionScheduledResumptionRemovedContent; + [WebhookEventType.PaymentInitiated]: PaymentInitiatedContent; + [WebhookEventType.FeatureArchived]: FeatureArchivedContent; + [WebhookEventType.SubscriptionReactivatedWithBackdating]: SubscriptionReactivatedWithBackdatingContent; + [WebhookEventType.OmnichannelSubscriptionImported]: OmnichannelSubscriptionImportedContent; + [WebhookEventType.TokenExpired]: TokenExpiredContent; + [WebhookEventType.CardAdded]: CardAddedContent; + [WebhookEventType.CouponCreated]: CouponCreatedContent; + [WebhookEventType.RuleDeleted]: RuleDeletedContent; + [WebhookEventType.ItemPriceEntitlementsUpdated]: ItemPriceEntitlementsUpdatedContent; + [WebhookEventType.ItemPriceDeleted]: ItemPriceDeletedContent; + [WebhookEventType.VirtualBankAccountDeleted]: VirtualBankAccountDeletedContent; + [WebhookEventType.PaymentScheduleSchemeDeleted]: PaymentScheduleSchemeDeletedContent; + [WebhookEventType.SubscriptionCreated]: SubscriptionCreatedContent; + [WebhookEventType.SubscriptionEntitlementsCreated]: SubscriptionEntitlementsCreatedContent; + [WebhookEventType.OrderReturned]: OrderReturnedContent; + [WebhookEventType.SubscriptionDeleted]: SubscriptionDeletedContent; + [WebhookEventType.PaymentSourceAdded]: PaymentSourceAddedContent; + [WebhookEventType.SubscriptionMovedIn]: SubscriptionMovedInContent; + [WebhookEventType.ItemPriceCreated]: ItemPriceCreatedContent; + [WebhookEventType.SubscriptionScheduledCancellationRemoved]: SubscriptionScheduledCancellationRemovedContent; + [WebhookEventType.PaymentRefunded]: PaymentRefundedContent; + [WebhookEventType.UsageFileIngested]: UsageFileIngestedContent; + [WebhookEventType.OmnichannelSubscriptionMovedIn]: OmnichannelSubscriptionMovedInContent; + [WebhookEventType.DifferentialPriceCreated]: DifferentialPriceCreatedContent; + [WebhookEventType.TransactionCreated]: TransactionCreatedContent; + [WebhookEventType.PaymentSucceeded]: PaymentSucceededContent; + [WebhookEventType.SubscriptionCanceledWithBackdating]: SubscriptionCanceledWithBackdatingContent; + [WebhookEventType.UnbilledChargesVoided]: UnbilledChargesVoidedContent; + [WebhookEventType.QuoteCreated]: QuoteCreatedContent; + [WebhookEventType.CouponSetDeleted]: CouponSetDeletedContent; + [WebhookEventType.AttachedItemCreated]: AttachedItemCreatedContent; + [WebhookEventType.SalesOrderCreated]: SalesOrderCreatedContent; + [WebhookEventType.CustomerChanged]: CustomerChangedContent; + [WebhookEventType.SubscriptionStarted]: SubscriptionStartedContent; + [WebhookEventType.SubscriptionActivated]: SubscriptionActivatedContent; + [WebhookEventType.PaymentSourceExpiring]: PaymentSourceExpiringContent; + [WebhookEventType.SubscriptionReactivated]: SubscriptionReactivatedContent; + [WebhookEventType.OrderUpdated]: OrderUpdatedContent; + [WebhookEventType.SubscriptionScheduledPauseRemoved]: SubscriptionScheduledPauseRemovedContent; + [WebhookEventType.SubscriptionCancellationReminder]: SubscriptionCancellationReminderContent; + [WebhookEventType.SubscriptionCreatedWithBackdating]: SubscriptionCreatedWithBackdatingContent; + [WebhookEventType.SubscriptionRampCreated]: SubscriptionRampCreatedContent; + [WebhookEventType.OrderDeleted]: OrderDeletedContent; + [WebhookEventType.OmnichannelSubscriptionItemPauseScheduled]: OmnichannelSubscriptionItemPauseScheduledContent; + [WebhookEventType.GiftUpdated]: GiftUpdatedContent; + [WebhookEventType.SubscriptionTrialExtended]: SubscriptionTrialExtendedContent; + [WebhookEventType.OmnichannelSubscriptionItemGracePeriodStarted]: OmnichannelSubscriptionItemGracePeriodStartedContent; + [WebhookEventType.CardExpiryReminder]: CardExpiryReminderContent; + [WebhookEventType.TokenCreated]: TokenCreatedContent; + [WebhookEventType.PromotionalCreditsAdded]: PromotionalCreditsAddedContent; + [WebhookEventType.SubscriptionRampUpdated]: SubscriptionRampUpdatedContent; + [WebhookEventType.CustomerEntitlementsUpdated]: CustomerEntitlementsUpdatedContent; + [WebhookEventType.PaymentSourceExpired]: PaymentSourceExpiredContent; + [WebhookEventType.CustomerMovedOut]: CustomerMovedOutContent; + [WebhookEventType.SubscriptionEntitlementsUpdated]: SubscriptionEntitlementsUpdatedContent; + [WebhookEventType.OmnichannelSubscriptionItemDunningExpired]: OmnichannelSubscriptionItemDunningExpiredContent; + [WebhookEventType.HierarchyCreated]: HierarchyCreatedContent; + [WebhookEventType.AttachedItemDeleted]: AttachedItemDeletedContent; + [WebhookEventType.OmnichannelSubscriptionItemScheduledCancellationRemoved]: OmnichannelSubscriptionItemScheduledCancellationRemovedContent; + [WebhookEventType.ItemUpdated]: ItemUpdatedContent; + [WebhookEventType.CouponSetCreated]: CouponSetCreatedContent; + [WebhookEventType.PaymentIntentUpdated]: PaymentIntentUpdatedContent; + [WebhookEventType.OrderResent]: OrderResentContent; + [WebhookEventType.OmnichannelSubscriptionCreated]: OmnichannelSubscriptionCreatedContent; + [WebhookEventType.TaxWithheldRecorded]: TaxWithheldRecordedContent; + [WebhookEventType.PriceVariantCreated]: PriceVariantCreatedContent; + [WebhookEventType.DifferentialPriceDeleted]: DifferentialPriceDeletedContent; + [WebhookEventType.SubscriptionItemsRenewed]: SubscriptionItemsRenewedContent; + [WebhookEventType.RuleCreated]: RuleCreatedContent; + [WebhookEventType.ContractTermCancelled]: ContractTermCancelledContent; + [WebhookEventType.ContractTermRenewed]: ContractTermRenewedContent; + [WebhookEventType.InvoiceDeleted]: InvoiceDeletedContent; + [WebhookEventType.ItemPriceEntitlementsRemoved]: ItemPriceEntitlementsRemovedContent; + [WebhookEventType.SalesOrderUpdated]: SalesOrderUpdatedContent; + [WebhookEventType.OmnichannelSubscriptionItemDunningStarted]: OmnichannelSubscriptionItemDunningStartedContent; + [WebhookEventType.OmnichannelSubscriptionItemChangeScheduled]: OmnichannelSubscriptionItemChangeScheduledContent; + [WebhookEventType.PendingInvoiceUpdated]: PendingInvoiceUpdatedContent; + [WebhookEventType.QuoteUpdated]: QuoteUpdatedContent; + [WebhookEventType.AttachedItemUpdated]: AttachedItemUpdatedContent; + [WebhookEventType.PaymentSourceUpdated]: PaymentSourceUpdatedContent; + [WebhookEventType.BusinessEntityDeleted]: BusinessEntityDeletedContent; + [WebhookEventType.AuthorizationVoided]: AuthorizationVoidedContent; + [WebhookEventType.SubscriptionRampDeleted]: SubscriptionRampDeletedContent; + [WebhookEventType.PlanDeleted]: PlanDeletedContent; + [WebhookEventType.AddonDeleted]: AddonDeletedContent; + [WebhookEventType.AddonUpdated]: AddonUpdatedContent; + [WebhookEventType.AddonCreated]: AddonCreatedContent; + [WebhookEventType.PlanCreated]: PlanCreatedContent; + [WebhookEventType.PlanUpdated]: PlanUpdatedContent; + }; + + export type ContentFor = WebhookContentMap[T]; + + export interface WebhookEvent { content: ContentFor; id: string; occurred_at: number; @@ -1621,4 +1635,22 @@ declare module 'chargebee' { export type SubscriptionRampDeletedContent = { ramp: Ramp; }; + export type PlanDeletedContent = { + plan: Plan; + }; + export type AddonDeletedContent = { + addon: Addon; + }; + export type AddonUpdatedContent = { + addon: Addon; + }; + export type AddonCreatedContent = { + addon: Addon; + }; + export type PlanCreatedContent = { + plan: Plan; + }; + export type PlanUpdatedContent = { + plan: Plan; + }; } From 23124b23d565644fdf34f4c891b816fd5ac11c43 Mon Sep 17 00:00:00 2001 From: cb-alish Date: Wed, 10 Dec 2025 15:26:05 +0530 Subject: [PATCH 06/11] Changing the release to be beta, in release.yml file --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8be3996..cb29d7b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,6 @@ jobs: *) echo "ERROR: package.json version must be 3.x.x for v3 tags" && exit 1 ;; esac - name: Publish to NPM with dist-tag "latest" - run: npm run prepack && npm publish --tag latest --//registry.npmjs.org/:_authToken="$NPM_TOKEN" + run: npm run prepack && npm publish --tag beta --//registry.npmjs.org/:_authToken="$NPM_TOKEN" env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 9aac1ebeb9487a59b833660354850781e217b781 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Wed, 10 Dec 2025 16:37:38 +0530 Subject: [PATCH 07/11] Beta version update --- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0993d2..c9ca061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v3.17.0-beta.1 (2025-12-10) + +### Enhancements +* add webhook event handler to process chargebee-events. +* deprecated `WebhookContentType` class, added `WebhookEventType` class. + ### v3.16.0 (2025-12-01) * * * diff --git a/package-lock.json b/package-lock.json index 6b1a960..898487e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "chargebee", - "version": "3.16.0", + "version": "3.17.0-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "chargebee", - "version": "3.16.0", + "version": "3.17.0-beta.1", "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.10", diff --git a/package.json b/package.json index 4e9012c..32201f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chargebee", - "version": "3.16.0", + "version": "3.17.0-beta.1", "description": "A library for integrating with Chargebee.", "scripts": { "prepack": "npm install && npm run build", From a0be41f7674e5c5625acd248c515983da22d7fe6 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 16 Dec 2025 13:57:26 +0530 Subject: [PATCH 08/11] unhandled Event type and run-time enum --- src/chargebee.cjs.ts | 8 +- src/chargebee.esm.ts | 6 +- src/resources/webhook/eventType.ts | 460 +++++++++++++++++++++++++++++ src/resources/webhook/handler.ts | 5 +- types/resources/WebhookEvent.d.ts | 1 + 5 files changed, 477 insertions(+), 3 deletions(-) create mode 100644 src/resources/webhook/eventType.ts diff --git a/src/chargebee.cjs.ts b/src/chargebee.cjs.ts index c96f7cd..6153864 100644 --- a/src/chargebee.cjs.ts +++ b/src/chargebee.cjs.ts @@ -1,6 +1,10 @@ import { CreateChargebee } from './createChargebee.js'; import { FetchHttpClient } from './net/FetchClient.js'; -import { WebhookHandler } from './resources/webhook/handler.js'; +import { + WebhookHandler, + WebhookEventType, + WebhookContentType, +} from './resources/webhook/handler.js'; import webhookInstance from './resources/webhook/handler.js'; import { basicAuthValidator } from './resources/webhook/auth.js'; @@ -12,6 +16,8 @@ module.exports.default = Chargebee; // Export webhook modules module.exports.WebhookHandler = WebhookHandler; +module.exports.WebhookEventType = WebhookEventType; +module.exports.WebhookContentType = WebhookContentType; module.exports.webhook = webhookInstance; module.exports.basicAuthValidator = basicAuthValidator; diff --git a/src/chargebee.esm.ts b/src/chargebee.esm.ts index 54a4315..ccb13c6 100644 --- a/src/chargebee.esm.ts +++ b/src/chargebee.esm.ts @@ -7,7 +7,11 @@ const Chargebee = CreateChargebee(httpClient); export default Chargebee; // Export webhook modules -export { WebhookHandler, EventType } from './resources/webhook/handler.js'; +export { + WebhookHandler, + WebhookEventType, + WebhookContentType, +} from './resources/webhook/handler.js'; export { default as webhook } from './resources/webhook/handler.js'; export { basicAuthValidator } from './resources/webhook/auth.js'; diff --git a/src/resources/webhook/eventType.ts b/src/resources/webhook/eventType.ts new file mode 100644 index 0000000..15b879e --- /dev/null +++ b/src/resources/webhook/eventType.ts @@ -0,0 +1,460 @@ +/** + * Enum representing all possible webhook event types from Chargebee. + * This enum provides both compile-time type safety and runtime values. + */ +export enum WebhookEventType { + AddUsagesReminder = 'add_usages_reminder', + + AddonCreated = 'addon_created', + + AddonDeleted = 'addon_deleted', + + AddonUpdated = 'addon_updated', + + AttachedItemCreated = 'attached_item_created', + + AttachedItemDeleted = 'attached_item_deleted', + + AttachedItemUpdated = 'attached_item_updated', + + AuthorizationSucceeded = 'authorization_succeeded', + + AuthorizationVoided = 'authorization_voided', + + BusinessEntityCreated = 'business_entity_created', + + BusinessEntityDeleted = 'business_entity_deleted', + + BusinessEntityUpdated = 'business_entity_updated', + + CardAdded = 'card_added', + + CardDeleted = 'card_deleted', + + CardExpired = 'card_expired', + + CardExpiryReminder = 'card_expiry_reminder', + + CardUpdated = 'card_updated', + + ContractTermCancelled = 'contract_term_cancelled', + + ContractTermCompleted = 'contract_term_completed', + + ContractTermCreated = 'contract_term_created', + + ContractTermRenewed = 'contract_term_renewed', + + ContractTermTerminated = 'contract_term_terminated', + + CouponCodesAdded = 'coupon_codes_added', + + CouponCodesDeleted = 'coupon_codes_deleted', + + CouponCodesUpdated = 'coupon_codes_updated', + + CouponCreated = 'coupon_created', + + CouponDeleted = 'coupon_deleted', + + CouponSetCreated = 'coupon_set_created', + + CouponSetDeleted = 'coupon_set_deleted', + + CouponSetUpdated = 'coupon_set_updated', + + CouponUpdated = 'coupon_updated', + + CreditNoteCreated = 'credit_note_created', + + CreditNoteCreatedWithBackdating = 'credit_note_created_with_backdating', + + CreditNoteDeleted = 'credit_note_deleted', + + CreditNoteUpdated = 'credit_note_updated', + + CustomerBusinessEntityChanged = 'customer_business_entity_changed', + + CustomerChanged = 'customer_changed', + + CustomerCreated = 'customer_created', + + CustomerDeleted = 'customer_deleted', + + CustomerEntitlementsUpdated = 'customer_entitlements_updated', + + CustomerMovedIn = 'customer_moved_in', + + CustomerMovedOut = 'customer_moved_out', + + DifferentialPriceCreated = 'differential_price_created', + + DifferentialPriceDeleted = 'differential_price_deleted', + + DifferentialPriceUpdated = 'differential_price_updated', + + DunningUpdated = 'dunning_updated', + + EntitlementOverridesAutoRemoved = 'entitlement_overrides_auto_removed', + + EntitlementOverridesRemoved = 'entitlement_overrides_removed', + + EntitlementOverridesUpdated = 'entitlement_overrides_updated', + + FeatureActivated = 'feature_activated', + + FeatureArchived = 'feature_archived', + + FeatureCreated = 'feature_created', + + FeatureDeleted = 'feature_deleted', + + FeatureReactivated = 'feature_reactivated', + + FeatureUpdated = 'feature_updated', + + GiftCancelled = 'gift_cancelled', + + GiftClaimed = 'gift_claimed', + + GiftExpired = 'gift_expired', + + GiftScheduled = 'gift_scheduled', + + GiftUnclaimed = 'gift_unclaimed', + + GiftUpdated = 'gift_updated', + + HierarchyCreated = 'hierarchy_created', + + HierarchyDeleted = 'hierarchy_deleted', + + InvoiceDeleted = 'invoice_deleted', + + InvoiceGenerated = 'invoice_generated', + + InvoiceGeneratedWithBackdating = 'invoice_generated_with_backdating', + + InvoiceUpdated = 'invoice_updated', + + ItemCreated = 'item_created', + + ItemDeleted = 'item_deleted', + + ItemEntitlementsRemoved = 'item_entitlements_removed', + + ItemEntitlementsUpdated = 'item_entitlements_updated', + + ItemFamilyCreated = 'item_family_created', + + ItemFamilyDeleted = 'item_family_deleted', + + ItemFamilyUpdated = 'item_family_updated', + + ItemPriceCreated = 'item_price_created', + + ItemPriceDeleted = 'item_price_deleted', + + ItemPriceEntitlementsRemoved = 'item_price_entitlements_removed', + + ItemPriceEntitlementsUpdated = 'item_price_entitlements_updated', + + ItemPriceUpdated = 'item_price_updated', + + ItemUpdated = 'item_updated', + + MrrUpdated = 'mrr_updated', + + NetdPaymentDueReminder = 'netd_payment_due_reminder', + + OmnichannelOneTimeOrderCreated = 'omnichannel_one_time_order_created', + + OmnichannelOneTimeOrderItemCancelled = 'omnichannel_one_time_order_item_cancelled', + + OmnichannelSubscriptionCreated = 'omnichannel_subscription_created', + + OmnichannelSubscriptionImported = 'omnichannel_subscription_imported', + + OmnichannelSubscriptionItemCancellationScheduled = 'omnichannel_subscription_item_cancellation_scheduled', + + OmnichannelSubscriptionItemCancelled = 'omnichannel_subscription_item_cancelled', + + OmnichannelSubscriptionItemChangeScheduled = 'omnichannel_subscription_item_change_scheduled', + + OmnichannelSubscriptionItemChanged = 'omnichannel_subscription_item_changed', + + OmnichannelSubscriptionItemDowngradeScheduled = 'omnichannel_subscription_item_downgrade_scheduled', + + OmnichannelSubscriptionItemDowngraded = 'omnichannel_subscription_item_downgraded', + + OmnichannelSubscriptionItemDunningExpired = 'omnichannel_subscription_item_dunning_expired', + + OmnichannelSubscriptionItemDunningStarted = 'omnichannel_subscription_item_dunning_started', + + OmnichannelSubscriptionItemExpired = 'omnichannel_subscription_item_expired', + + OmnichannelSubscriptionItemGracePeriodExpired = 'omnichannel_subscription_item_grace_period_expired', + + OmnichannelSubscriptionItemGracePeriodStarted = 'omnichannel_subscription_item_grace_period_started', + + OmnichannelSubscriptionItemPauseScheduled = 'omnichannel_subscription_item_pause_scheduled', + + OmnichannelSubscriptionItemPaused = 'omnichannel_subscription_item_paused', + + OmnichannelSubscriptionItemReactivated = 'omnichannel_subscription_item_reactivated', + + OmnichannelSubscriptionItemRenewed = 'omnichannel_subscription_item_renewed', + + OmnichannelSubscriptionItemResubscribed = 'omnichannel_subscription_item_resubscribed', + + OmnichannelSubscriptionItemResumed = 'omnichannel_subscription_item_resumed', + + OmnichannelSubscriptionItemScheduledCancellationRemoved = 'omnichannel_subscription_item_scheduled_cancellation_removed', + + OmnichannelSubscriptionItemScheduledChangeRemoved = 'omnichannel_subscription_item_scheduled_change_removed', + + OmnichannelSubscriptionItemScheduledDowngradeRemoved = 'omnichannel_subscription_item_scheduled_downgrade_removed', + + OmnichannelSubscriptionItemUpgraded = 'omnichannel_subscription_item_upgraded', + + OmnichannelSubscriptionMovedIn = 'omnichannel_subscription_moved_in', + + OmnichannelTransactionCreated = 'omnichannel_transaction_created', + + OrderCancelled = 'order_cancelled', + + OrderCreated = 'order_created', + + OrderDeleted = 'order_deleted', + + OrderDelivered = 'order_delivered', + + OrderReadyToProcess = 'order_ready_to_process', + + OrderReadyToShip = 'order_ready_to_ship', + + OrderResent = 'order_resent', + + OrderReturned = 'order_returned', + + OrderUpdated = 'order_updated', + + PaymentFailed = 'payment_failed', + + PaymentInitiated = 'payment_initiated', + + PaymentIntentCreated = 'payment_intent_created', + + PaymentIntentUpdated = 'payment_intent_updated', + + PaymentRefunded = 'payment_refunded', + + PaymentScheduleSchemeCreated = 'payment_schedule_scheme_created', + + PaymentScheduleSchemeDeleted = 'payment_schedule_scheme_deleted', + + PaymentSchedulesCreated = 'payment_schedules_created', + + PaymentSchedulesUpdated = 'payment_schedules_updated', + + PaymentSourceAdded = 'payment_source_added', + + PaymentSourceDeleted = 'payment_source_deleted', + + PaymentSourceExpired = 'payment_source_expired', + + PaymentSourceExpiring = 'payment_source_expiring', + + PaymentSourceLocallyDeleted = 'payment_source_locally_deleted', + + PaymentSourceUpdated = 'payment_source_updated', + + PaymentSucceeded = 'payment_succeeded', + + PendingInvoiceCreated = 'pending_invoice_created', + + PendingInvoiceUpdated = 'pending_invoice_updated', + + PlanCreated = 'plan_created', + + PlanDeleted = 'plan_deleted', + + PlanUpdated = 'plan_updated', + + PriceVariantCreated = 'price_variant_created', + + PriceVariantDeleted = 'price_variant_deleted', + + PriceVariantUpdated = 'price_variant_updated', + + ProductCreated = 'product_created', + + ProductDeleted = 'product_deleted', + + ProductUpdated = 'product_updated', + + PromotionalCreditsAdded = 'promotional_credits_added', + + PromotionalCreditsDeducted = 'promotional_credits_deducted', + + PurchaseCreated = 'purchase_created', + + QuoteCreated = 'quote_created', + + QuoteDeleted = 'quote_deleted', + + QuoteUpdated = 'quote_updated', + + RecordPurchaseFailed = 'record_purchase_failed', + + RefundInitiated = 'refund_initiated', + + RuleCreated = 'rule_created', + + RuleDeleted = 'rule_deleted', + + RuleUpdated = 'rule_updated', + + SalesOrderCreated = 'sales_order_created', + + SalesOrderUpdated = 'sales_order_updated', + + SubscriptionActivated = 'subscription_activated', + + SubscriptionActivatedWithBackdating = 'subscription_activated_with_backdating', + + SubscriptionAdvanceInvoiceScheduleAdded = 'subscription_advance_invoice_schedule_added', + + SubscriptionAdvanceInvoiceScheduleRemoved = 'subscription_advance_invoice_schedule_removed', + + SubscriptionAdvanceInvoiceScheduleUpdated = 'subscription_advance_invoice_schedule_updated', + + SubscriptionBusinessEntityChanged = 'subscription_business_entity_changed', + + SubscriptionCanceledWithBackdating = 'subscription_canceled_with_backdating', + + SubscriptionCancellationReminder = 'subscription_cancellation_reminder', + + SubscriptionCancellationScheduled = 'subscription_cancellation_scheduled', + + SubscriptionCancelled = 'subscription_cancelled', + + SubscriptionChanged = 'subscription_changed', + + SubscriptionChangedWithBackdating = 'subscription_changed_with_backdating', + + SubscriptionChangesScheduled = 'subscription_changes_scheduled', + + SubscriptionCreated = 'subscription_created', + + SubscriptionCreatedWithBackdating = 'subscription_created_with_backdating', + + SubscriptionDeleted = 'subscription_deleted', + + SubscriptionEntitlementsCreated = 'subscription_entitlements_created', + + SubscriptionEntitlementsUpdated = 'subscription_entitlements_updated', + + SubscriptionItemsRenewed = 'subscription_items_renewed', + + SubscriptionMovedIn = 'subscription_moved_in', + + SubscriptionMovedOut = 'subscription_moved_out', + + SubscriptionMovementFailed = 'subscription_movement_failed', + + SubscriptionPauseScheduled = 'subscription_pause_scheduled', + + SubscriptionPaused = 'subscription_paused', + + SubscriptionRampApplied = 'subscription_ramp_applied', + + SubscriptionRampCreated = 'subscription_ramp_created', + + SubscriptionRampDeleted = 'subscription_ramp_deleted', + + SubscriptionRampDrafted = 'subscription_ramp_drafted', + + SubscriptionRampUpdated = 'subscription_ramp_updated', + + SubscriptionReactivated = 'subscription_reactivated', + + SubscriptionReactivatedWithBackdating = 'subscription_reactivated_with_backdating', + + SubscriptionRenewalReminder = 'subscription_renewal_reminder', + + SubscriptionRenewed = 'subscription_renewed', + + SubscriptionResumed = 'subscription_resumed', + + SubscriptionResumptionScheduled = 'subscription_resumption_scheduled', + + SubscriptionScheduledCancellationRemoved = 'subscription_scheduled_cancellation_removed', + + SubscriptionScheduledChangesRemoved = 'subscription_scheduled_changes_removed', + + SubscriptionScheduledPauseRemoved = 'subscription_scheduled_pause_removed', + + SubscriptionScheduledResumptionRemoved = 'subscription_scheduled_resumption_removed', + + SubscriptionShippingAddressUpdated = 'subscription_shipping_address_updated', + + SubscriptionStarted = 'subscription_started', + + SubscriptionTrialEndReminder = 'subscription_trial_end_reminder', + + SubscriptionTrialExtended = 'subscription_trial_extended', + + TaxWithheldDeleted = 'tax_withheld_deleted', + + TaxWithheldRecorded = 'tax_withheld_recorded', + + TaxWithheldRefunded = 'tax_withheld_refunded', + + TokenConsumed = 'token_consumed', + + TokenCreated = 'token_created', + + TokenExpired = 'token_expired', + + TransactionCreated = 'transaction_created', + + TransactionDeleted = 'transaction_deleted', + + TransactionUpdated = 'transaction_updated', + + UnbilledChargesCreated = 'unbilled_charges_created', + + UnbilledChargesDeleted = 'unbilled_charges_deleted', + + UnbilledChargesInvoiced = 'unbilled_charges_invoiced', + + UnbilledChargesVoided = 'unbilled_charges_voided', + + UsageFileIngested = 'usage_file_ingested', + + VariantCreated = 'variant_created', + + VariantDeleted = 'variant_deleted', + + VariantUpdated = 'variant_updated', + + VirtualBankAccountAdded = 'virtual_bank_account_added', + + VirtualBankAccountDeleted = 'virtual_bank_account_deleted', + + VirtualBankAccountUpdated = 'virtual_bank_account_updated', + + VoucherCreateFailed = 'voucher_create_failed', + + VoucherCreated = 'voucher_created', + + VoucherExpired = 'voucher_expired', + + UnhandledEvent = 'unhandled_event', +} + +/** + * @deprecated Use WebhookEventType instead. + */ +export const WebhookContentType = WebhookEventType; diff --git a/src/resources/webhook/handler.ts b/src/resources/webhook/handler.ts index 175d09a..7c1cf22 100644 --- a/src/resources/webhook/handler.ts +++ b/src/resources/webhook/handler.ts @@ -1,6 +1,9 @@ import { EventEmitter } from 'node:events'; import { WebhookEvent } from './content.js'; import { basicAuthValidator } from './auth.js'; +import { WebhookEventType, WebhookContentType } from './eventType.js'; + +export { WebhookEventType, WebhookContentType }; export type EventType = import('chargebee').EventTypeEnum; @@ -21,7 +24,7 @@ export class WebhookHandler extends EventEmitter { constructor() { super({ captureRejections: true }); } - + handle( body: string | object, headers?: Record, diff --git a/types/resources/WebhookEvent.d.ts b/types/resources/WebhookEvent.d.ts index 9a53983..ed95aa3 100644 --- a/types/resources/WebhookEvent.d.ts +++ b/types/resources/WebhookEvent.d.ts @@ -219,6 +219,7 @@ declare module 'chargebee' { AddonCreated = 'addon_created', PlanCreated = 'plan_created', PlanUpdated = 'plan_updated', + UnhandledEvent = 'unhandled_event', } /** * @deprecated Use WebhookEventType instead. From 08eea7741aee4351ba111848245b3967447c6908 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 16 Dec 2025 14:00:21 +0530 Subject: [PATCH 09/11] Version bumpup --- CHANGELOG.md | 10 ++++++++-- package-lock.json | 4 ++-- package.json | 2 +- src/environment.ts | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9ca061..0b1bb1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ +### v3.17.0-beta.2 (2025-12-16) + +### Enhancements +* Added `UnhandledEvent` to `WebhookEventType` enum for handling unknown event types. +* `WebhookEventType` and `WebhookContentType` are now exported from the main entry points. + ### v3.17.0-beta.1 (2025-12-10) ### Enhancements -* add webhook event handler to process chargebee-events. -* deprecated `WebhookContentType` class, added `WebhookEventType` class. +* Add webhook event handler to process chargebee-events. +* Deprecated `WebhookContentType` class, added `WebhookEventType` class. ### v3.16.0 (2025-12-01) * * * diff --git a/package-lock.json b/package-lock.json index 898487e..efdf82f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "chargebee", - "version": "3.17.0-beta.1", + "version": "3.17.0-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "chargebee", - "version": "3.17.0-beta.1", + "version": "3.17.0-beta.2", "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.10", diff --git a/package.json b/package.json index 32201f7..8f1f744 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chargebee", - "version": "3.17.0-beta.1", + "version": "3.17.0-beta.2", "description": "A library for integrating with Chargebee.", "scripts": { "prepack": "npm install && npm run build", diff --git a/src/environment.ts b/src/environment.ts index 13d582c..820ce60 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -9,7 +9,7 @@ export const Environment = { hostSuffix: '.chargebee.com', apiPath: '/api/v2', timeout: DEFAULT_TIME_OUT, - clientVersion: 'v3.16.0', + clientVersion: '3.17.0-beta.2', port: DEFAULT_PORT, timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT, exportWaitInMillis: DEFAULT_EXPORT_WAIT, From f7340bff53413cc4e87fe56cf8ceaa862a4ba8c7 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Wed, 17 Dec 2025 12:41:32 +0530 Subject: [PATCH 10/11] Unhandled event --- CHANGELOG.md | 2 +- src/resources/webhook/eventType.ts | 2 -- types/resources/WebhookEvent.d.ts | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b1bb1c..c858cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ### v3.17.0-beta.2 (2025-12-16) ### Enhancements -* Added `UnhandledEvent` to `WebhookEventType` enum for handling unknown event types. +* `WebhookEventType` is now a runtime enum that can be used for event type comparisons at runtime. * `WebhookEventType` and `WebhookContentType` are now exported from the main entry points. ### v3.17.0-beta.1 (2025-12-10) diff --git a/src/resources/webhook/eventType.ts b/src/resources/webhook/eventType.ts index 15b879e..72ddbe6 100644 --- a/src/resources/webhook/eventType.ts +++ b/src/resources/webhook/eventType.ts @@ -450,8 +450,6 @@ export enum WebhookEventType { VoucherCreated = 'voucher_created', VoucherExpired = 'voucher_expired', - - UnhandledEvent = 'unhandled_event', } /** diff --git a/types/resources/WebhookEvent.d.ts b/types/resources/WebhookEvent.d.ts index ed95aa3..9a53983 100644 --- a/types/resources/WebhookEvent.d.ts +++ b/types/resources/WebhookEvent.d.ts @@ -219,7 +219,6 @@ declare module 'chargebee' { AddonCreated = 'addon_created', PlanCreated = 'plan_created', PlanUpdated = 'plan_updated', - UnhandledEvent = 'unhandled_event', } /** * @deprecated Use WebhookEventType instead. From a31c02a28d66e9ef40aca69a4356ae26b1521f5f Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Wed, 24 Dec 2025 13:32:08 +0530 Subject: [PATCH 11/11] framework agnostic request, response type --- src/chargebee.cjs.ts | 8 ++- src/chargebee.esm.ts | 8 ++- src/resources/webhook/auth.ts | 52 ++++++++++++--- src/resources/webhook/handler.ts | 106 ++++++++++++++++++++++++++----- types/index.d.ts | 97 ++++++++++++++++++++++------ 5 files changed, 224 insertions(+), 47 deletions(-) diff --git a/src/chargebee.cjs.ts b/src/chargebee.cjs.ts index 6153864..01f1abf 100644 --- a/src/chargebee.cjs.ts +++ b/src/chargebee.cjs.ts @@ -22,4 +22,10 @@ module.exports.webhook = webhookInstance; module.exports.basicAuthValidator = basicAuthValidator; // Export webhook types -export type { WebhookEvent } from './resources/webhook/content.js'; +export type { + WebhookEvent, + WebhookContext, + WebhookHandlerOptions, + RequestValidator, +} from './resources/webhook/handler.js'; +export type { CredentialValidator } from './resources/webhook/auth.js'; diff --git a/src/chargebee.esm.ts b/src/chargebee.esm.ts index ccb13c6..803ca7c 100644 --- a/src/chargebee.esm.ts +++ b/src/chargebee.esm.ts @@ -16,4 +16,10 @@ export { default as webhook } from './resources/webhook/handler.js'; export { basicAuthValidator } from './resources/webhook/auth.js'; // Export webhook types -export type { WebhookEvent } from './resources/webhook/content.js'; +export type { + WebhookEvent, + WebhookContext, + WebhookHandlerOptions, + RequestValidator, +} from './resources/webhook/handler.js'; +export type { CredentialValidator } from './resources/webhook/auth.js'; diff --git a/src/resources/webhook/auth.ts b/src/resources/webhook/auth.ts index 23a207a..bf8e184 100644 --- a/src/resources/webhook/auth.ts +++ b/src/resources/webhook/auth.ts @@ -1,11 +1,41 @@ +/** + * Credential validator function type. + * Can be synchronous or asynchronous (e.g., for database lookups). + */ +export type CredentialValidator = ( + username: string, + password: string, +) => boolean | Promise; + +/** + * Creates a Basic Auth validator for webhook requests. + * Parses the Authorization header and validates credentials. + * + * @param validateCredentials - Function to validate username/password. + * Can be sync or async (e.g., for database lookups). + * @returns A request validator function for use with WebhookHandler + * + * @example + * // Simple sync validation + * const validator = basicAuthValidator((u, p) => u === 'admin' && p === 'secret'); + * + * @example + * // Async validation (e.g., database lookup) + * const validator = basicAuthValidator(async (u, p) => { + * const user = await db.findUser(u); + * return user && await bcrypt.compare(p, user.passwordHash); + * }); + */ export const basicAuthValidator = ( - validateCredentials: (username: string, password: string) => boolean, + validateCredentials: CredentialValidator, ) => { - return (headers: Record) => { + return async ( + headers: Record, + ): Promise => { const authHeader = headers['authorization'] || headers['Authorization']; if (!authHeader) { - throw new Error('Invalid authorization header'); + throw new Error('Missing authorization header'); } const authStr = Array.isArray(authHeader) ? authHeader[0] : authHeader; @@ -15,15 +45,21 @@ export const basicAuthValidator = ( const parts = authStr.split(' '); if (parts.length !== 2 || parts[0] !== 'Basic') { - throw new Error('Invalid authorization header'); + throw new Error('Invalid authorization header format'); } - const credentials = Buffer.from(parts[1], 'base64').toString().split(':'); - if (credentials.length !== 2) { - throw new Error('Invalid credentials'); + const decoded = Buffer.from(parts[1], 'base64').toString(); + const separatorIndex = decoded.indexOf(':'); + + if (separatorIndex === -1) { + throw new Error('Invalid credentials format'); } - if (!validateCredentials(credentials[0], credentials[1])) { + const username = decoded.substring(0, separatorIndex); + const password = decoded.substring(separatorIndex + 1); + + const isValid = await validateCredentials(username, password); + if (!isValid) { throw new Error('Invalid credentials'); } }; diff --git a/src/resources/webhook/handler.ts b/src/resources/webhook/handler.ts index 7c1cf22..33fc6cb 100644 --- a/src/resources/webhook/handler.ts +++ b/src/resources/webhook/handler.ts @@ -7,42 +7,112 @@ export { WebhookEventType, WebhookContentType }; export type EventType = import('chargebee').EventTypeEnum; -export interface WebhookEventMap extends Record { - unhandled_event: [WebhookEvent]; +/** + * Context object passed to webhook event listeners. + * Wraps the event data with optional framework-specific request/response objects. + */ +export interface WebhookContext { + /** The parsed webhook event from Chargebee */ + event: WebhookEvent; + /** Framework-specific request object (Express, Fastify, etc.) */ + request?: ReqT; + /** Framework-specific response object (Express, Fastify, etc.) */ + response?: ResT; +} + +export interface WebhookEventMap + extends Record]> { + unhandled_event: [WebhookContext]; error: [Error]; } -export type WebhookEventListener = ( - ...args: WebhookEventMap[K] -) => Promise | void; +export type WebhookEventListener< + ReqT, + ResT, + K extends keyof WebhookEventMap, +> = (...args: WebhookEventMap[K]) => Promise | void; + +/** + * Validator function type for authenticating webhook requests. + * Can be synchronous or asynchronous. + */ +export type RequestValidator = ( + headers: Record, +) => void | Promise; + +/** + * Configuration options for WebhookHandler. + */ +export interface WebhookHandlerOptions { + /** + * Optional validator function to authenticate incoming webhook requests. + * Typically used for Basic Auth validation. + * Can be sync or async - throw an error to reject the request. + */ + requestValidator?: RequestValidator; +} -export class WebhookHandler extends EventEmitter { - requestValidator?: ( - headers: Record, - ) => void; +export class WebhookHandler< + ReqT = unknown, + ResT = unknown, +> extends EventEmitter> { + private _requestValidator?: RequestValidator; - constructor() { + constructor(options?: WebhookHandlerOptions) { super({ captureRejections: true }); + this._requestValidator = options?.requestValidator; } - handle( + /** + * Gets the current request validator. + */ + get requestValidator(): RequestValidator | undefined { + return this._requestValidator; + } + + /** + * Sets a new request validator. + */ + set requestValidator(validator: RequestValidator | undefined) { + this._requestValidator = validator; + } + + /** + * Handles an incoming webhook request. + * Validates the request (if validator configured), parses the body, + * and emits the appropriate event. + * + * @param body - The raw request body (string) or pre-parsed object + * @param headers - Optional HTTP headers for validation + * @param request - Optional framework-specific request object + * @param response - Optional framework-specific response object + */ + async handle( body: string | object, headers?: Record, - ): void { + request?: ReqT, + response?: ResT, + ): Promise { try { - if (this.requestValidator && headers) { - this.requestValidator(headers); + if (this._requestValidator && headers) { + await this._requestValidator(headers); } const event: WebhookEvent = typeof body === 'string' ? JSON.parse(body) : (body as WebhookEvent); - const eventType = event.event_type as keyof WebhookEventMap; + const context: WebhookContext = { + event, + request, + response, + }; + + const eventType = event.event_type as keyof WebhookEventMap; if (this.listenerCount(eventType) > 0) { - this.emit(eventType, event); + this.emit(eventType, context); } else { - this.emit('unhandled_event', event); + this.emit('unhandled_event', context); } } catch (err) { this.emit('error', err instanceof Error ? err : new Error(String(err))); @@ -50,6 +120,7 @@ export class WebhookHandler extends EventEmitter { } } +// Default instance for simple use cases const webhook = new WebhookHandler(); // Auto-configure basic auth if env vars are present @@ -65,3 +136,4 @@ if (username && password) { export default webhook; export type { WebhookEvent } from './content.js'; +export { basicAuthValidator, type CredentialValidator } from './auth.js'; diff --git a/types/index.d.ts b/types/index.d.ts index 9368f27..13f03ca 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -6,7 +6,6 @@ /// /// /// -/// /// /// /// @@ -251,15 +250,52 @@ declare module 'chargebee' { webhookEndpoint: WebhookEndpoint.WebhookEndpointResource; } - // Webhook Handler + // Webhook Handler Types export type WebhookEventName = EventTypeEnum | 'unhandled_event'; export type WebhookEventTypeValue = `${WebhookEventType}`; /** @deprecated Use WebhookEventTypeValue instead */ export type WebhookContentTypeValue = WebhookEventTypeValue; + /** + * Context object passed to webhook event listeners. + * Wraps the event data with optional framework-specific request/response objects. + */ + export interface WebhookContext { + /** The parsed webhook event from Chargebee */ + event: WebhookEvent; + /** Framework-specific request object (Express, Fastify, etc.) */ + request?: ReqT; + /** Framework-specific response object (Express, Fastify, etc.) */ + response?: ResT; + } + + /** + * Validator function type for authenticating webhook requests. + * Can be synchronous or asynchronous. + */ + export type RequestValidator = ( + headers: Record, + ) => void | Promise; + + /** + * Configuration options for WebhookHandler. + */ + export interface WebhookHandlerOptions { + /** + * Optional validator function to authenticate incoming webhook requests. + * Typically used for Basic Auth validation. + * Can be sync or async - throw an error to reject the request. + */ + requestValidator?: RequestValidator; + } + export type WebhookEventListener< + ReqT = unknown, + ResT = unknown, T extends WebhookEventType = WebhookEventType, - > = (event: WebhookEvent) => Promise | void; + > = ( + context: WebhookContext & { event: WebhookEvent }, + ) => Promise | void; export type WebhookErrorListener = (error: Error) => Promise | void; // Helper type to map string literal to enum member @@ -267,51 +303,72 @@ declare module 'chargebee' { [K in WebhookEventType]: `${K}` extends S ? K : never; }[WebhookEventType]; - export class WebhookHandler { + export class WebhookHandler { + constructor(options?: WebhookHandlerOptions); on( eventName: T, - listener: WebhookEventListener, + listener: WebhookEventListener, ): this; on( eventName: S, - listener: WebhookEventListener>, + listener: WebhookEventListener>, + ): this; + on( + eventName: 'unhandled_event', + listener: WebhookEventListener, ): this; - on(eventName: 'unhandled_event', listener: WebhookEventListener): this; on(eventName: 'error', listener: WebhookErrorListener): this; once( eventName: T, - listener: WebhookEventListener, + listener: WebhookEventListener, ): this; once( eventName: S, - listener: WebhookEventListener>, + listener: WebhookEventListener>, + ): this; + once( + eventName: 'unhandled_event', + listener: WebhookEventListener, ): this; - once(eventName: 'unhandled_event', listener: WebhookEventListener): this; once(eventName: 'error', listener: WebhookErrorListener): this; off( eventName: T, - listener: WebhookEventListener, + listener: WebhookEventListener, ): this; off( eventName: S, - listener: WebhookEventListener>, + listener: WebhookEventListener>, + ): this; + off( + eventName: 'unhandled_event', + listener: WebhookEventListener, ): this; - off(eventName: 'unhandled_event', listener: WebhookEventListener): this; off(eventName: 'error', listener: WebhookErrorListener): this; handle( body: string | object, headers?: Record, - ): void; - onError?: (error: any) => void; - requestValidator?: ( - headers: Record, - ) => void; + request?: ReqT, + response?: ResT, + ): Promise; + requestValidator: RequestValidator | undefined; } // Webhook Auth + /** + * Credential validator function type. + * Can be synchronous or asynchronous (e.g., for database lookups). + */ + export type CredentialValidator = ( + username: string, + password: string, + ) => boolean | Promise; + + /** + * Creates a Basic Auth validator for webhook requests. + */ export function basicAuthValidator( - validateCredentials: (username: string, password: string) => boolean, - ): (headers: Record) => void; + validateCredentials: CredentialValidator, + ): (headers: Record) => Promise; // Default webhook handler instance export const webhook: WebhookHandler;