@dodopayments/astro 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/customerPortal/customerPortal.d.ts.map +1 -1
- package/dist/index.cjs +1505 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1505 -125
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4180,7 +4180,7 @@ const safeJSON = (text) => {
|
|
|
4180
4180
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4181
4181
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4182
4182
|
|
|
4183
|
-
const VERSION = '2.
|
|
4183
|
+
const VERSION = '2.23.2'; // x-release-please-version
|
|
4184
4184
|
|
|
4185
4185
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4186
4186
|
/**
|
|
@@ -4390,6 +4390,25 @@ const FallbackEncoder = ({ headers, body }) => {
|
|
|
4390
4390
|
};
|
|
4391
4391
|
};
|
|
4392
4392
|
|
|
4393
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4394
|
+
/**
|
|
4395
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
4396
|
+
*/
|
|
4397
|
+
function stringifyQuery(query) {
|
|
4398
|
+
return Object.entries(query)
|
|
4399
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
4400
|
+
.map(([key, value]) => {
|
|
4401
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
4402
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
4403
|
+
}
|
|
4404
|
+
if (value === null) {
|
|
4405
|
+
return `${encodeURIComponent(key)}=`;
|
|
4406
|
+
}
|
|
4407
|
+
throw new DodoPaymentsError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
4408
|
+
})
|
|
4409
|
+
.join('&');
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4393
4412
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4394
4413
|
const levelNumbers = {
|
|
4395
4414
|
off: 0,
|
|
@@ -4483,6 +4502,11 @@ async function defaultParseResponse(client, props) {
|
|
|
4483
4502
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
4484
4503
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
4485
4504
|
if (isJSON) {
|
|
4505
|
+
const contentLength = response.headers.get('content-length');
|
|
4506
|
+
if (contentLength === '0') {
|
|
4507
|
+
// if there is no content we can't do anything
|
|
4508
|
+
return undefined;
|
|
4509
|
+
}
|
|
4486
4510
|
const json = await response.json();
|
|
4487
4511
|
return json;
|
|
4488
4512
|
}
|
|
@@ -4903,6 +4927,16 @@ class Addons extends APIResource {
|
|
|
4903
4927
|
}
|
|
4904
4928
|
}
|
|
4905
4929
|
|
|
4930
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4931
|
+
let Balances$1 = class Balances extends APIResource {
|
|
4932
|
+
retrieveLedger(query = {}, options) {
|
|
4933
|
+
return this._client.getAPIList('/balances/ledger', (DefaultPageNumberPagination), {
|
|
4934
|
+
query,
|
|
4935
|
+
...options,
|
|
4936
|
+
});
|
|
4937
|
+
}
|
|
4938
|
+
};
|
|
4939
|
+
|
|
4906
4940
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4907
4941
|
class Brands extends APIResource {
|
|
4908
4942
|
create(body, options) {
|
|
@@ -4933,66 +4967,155 @@ class CheckoutSessions extends APIResource {
|
|
|
4933
4967
|
retrieve(id, options) {
|
|
4934
4968
|
return this._client.get(path `/checkouts/${id}`, options);
|
|
4935
4969
|
}
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4939
|
-
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
4940
|
-
create(customerID, params = {}, options) {
|
|
4941
|
-
const { send_email } = params ?? {};
|
|
4942
|
-
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
4943
|
-
query: { send_email },
|
|
4944
|
-
...options,
|
|
4945
|
-
});
|
|
4946
|
-
}
|
|
4947
|
-
};
|
|
4948
|
-
|
|
4949
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4950
|
-
class LedgerEntries extends APIResource {
|
|
4951
|
-
create(customerID, body, options) {
|
|
4952
|
-
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
4953
|
-
}
|
|
4954
|
-
list(customerID, query = {}, options) {
|
|
4955
|
-
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
4956
|
-
}
|
|
4957
|
-
}
|
|
4958
|
-
|
|
4959
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4960
|
-
class Wallets extends APIResource {
|
|
4961
|
-
constructor() {
|
|
4962
|
-
super(...arguments);
|
|
4963
|
-
this.ledgerEntries = new LedgerEntries(this._client);
|
|
4964
|
-
}
|
|
4965
|
-
list(customerID, options) {
|
|
4966
|
-
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
4970
|
+
preview(body, options) {
|
|
4971
|
+
return this._client.post('/checkouts/preview', { body, ...options });
|
|
4967
4972
|
}
|
|
4968
4973
|
}
|
|
4969
|
-
Wallets.LedgerEntries = LedgerEntries;
|
|
4970
4974
|
|
|
4971
4975
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4972
|
-
class
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4976
|
+
class Balances extends APIResource {
|
|
4977
|
+
/**
|
|
4978
|
+
* Returns the credit balance details for a specific customer and credit
|
|
4979
|
+
* entitlement.
|
|
4980
|
+
*
|
|
4981
|
+
* # Authentication
|
|
4982
|
+
*
|
|
4983
|
+
* Requires an API key with `Viewer` role or higher.
|
|
4984
|
+
*
|
|
4985
|
+
* # Path Parameters
|
|
4986
|
+
*
|
|
4987
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
4988
|
+
* - `customer_id` - The unique identifier of the customer
|
|
4989
|
+
*
|
|
4990
|
+
* # Responses
|
|
4991
|
+
*
|
|
4992
|
+
* - `200 OK` - Returns the customer's balance
|
|
4993
|
+
* - `404 Not Found` - Credit entitlement or customer balance not found
|
|
4994
|
+
* - `500 Internal Server Error` - Database or server error
|
|
4995
|
+
*/
|
|
4996
|
+
retrieve(customerID, params, options) {
|
|
4997
|
+
const { credit_entitlement_id } = params;
|
|
4998
|
+
return this._client.get(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}`, options);
|
|
4977
4999
|
}
|
|
4978
|
-
|
|
4979
|
-
|
|
5000
|
+
/**
|
|
5001
|
+
* Returns a paginated list of customer credit balances for the given credit
|
|
5002
|
+
* entitlement.
|
|
5003
|
+
*
|
|
5004
|
+
* # Authentication
|
|
5005
|
+
*
|
|
5006
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5007
|
+
*
|
|
5008
|
+
* # Path Parameters
|
|
5009
|
+
*
|
|
5010
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5011
|
+
*
|
|
5012
|
+
* # Query Parameters
|
|
5013
|
+
*
|
|
5014
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5015
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5016
|
+
* - `customer_id` - Optional filter by specific customer
|
|
5017
|
+
*
|
|
5018
|
+
* # Responses
|
|
5019
|
+
*
|
|
5020
|
+
* - `200 OK` - Returns list of customer balances
|
|
5021
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5022
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5023
|
+
*/
|
|
5024
|
+
list(creditEntitlementID, query = {}, options) {
|
|
5025
|
+
return this._client.getAPIList(path `/credit-entitlements/${creditEntitlementID}/balances`, (DefaultPageNumberPagination), { query, ...options });
|
|
4980
5026
|
}
|
|
4981
|
-
|
|
4982
|
-
|
|
5027
|
+
/**
|
|
5028
|
+
* For credit entries, a new grant is created. For debit entries, credits are
|
|
5029
|
+
* deducted from existing grants using FIFO (oldest first).
|
|
5030
|
+
*
|
|
5031
|
+
* # Authentication
|
|
5032
|
+
*
|
|
5033
|
+
* Requires an API key with `Editor` role.
|
|
5034
|
+
*
|
|
5035
|
+
* # Path Parameters
|
|
5036
|
+
*
|
|
5037
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5038
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5039
|
+
*
|
|
5040
|
+
* # Request Body
|
|
5041
|
+
*
|
|
5042
|
+
* - `entry_type` - "credit" or "debit"
|
|
5043
|
+
* - `amount` - Amount to credit or debit
|
|
5044
|
+
* - `reason` - Optional human-readable reason
|
|
5045
|
+
* - `expires_at` - Optional expiration for credited amount (only for credit type)
|
|
5046
|
+
* - `idempotency_key` - Optional key to prevent duplicate entries
|
|
5047
|
+
*
|
|
5048
|
+
* # Responses
|
|
5049
|
+
*
|
|
5050
|
+
* - `201 Created` - Ledger entry created successfully
|
|
5051
|
+
* - `400 Bad Request` - Invalid request (e.g., debit with insufficient balance)
|
|
5052
|
+
* - `404 Not Found` - Credit entitlement or customer not found
|
|
5053
|
+
* - `409 Conflict` - Idempotency key already exists
|
|
5054
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5055
|
+
*/
|
|
5056
|
+
createLedgerEntry(customerID, params, options) {
|
|
5057
|
+
const { credit_entitlement_id, ...body } = params;
|
|
5058
|
+
return this._client.post(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger-entries`, { body, ...options });
|
|
4983
5059
|
}
|
|
4984
|
-
|
|
4985
|
-
|
|
5060
|
+
/**
|
|
5061
|
+
* Returns a paginated list of credit grants with optional filtering by status.
|
|
5062
|
+
*
|
|
5063
|
+
* # Authentication
|
|
5064
|
+
*
|
|
5065
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5066
|
+
*
|
|
5067
|
+
* # Path Parameters
|
|
5068
|
+
*
|
|
5069
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5070
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5071
|
+
*
|
|
5072
|
+
* # Query Parameters
|
|
5073
|
+
*
|
|
5074
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5075
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5076
|
+
* - `status` - Filter by status: active, expired, depleted
|
|
5077
|
+
*
|
|
5078
|
+
* # Responses
|
|
5079
|
+
*
|
|
5080
|
+
* - `200 OK` - Returns list of grants
|
|
5081
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5082
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5083
|
+
*/
|
|
5084
|
+
listGrants(customerID, params, options) {
|
|
5085
|
+
const { credit_entitlement_id, ...query } = params;
|
|
5086
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/grants`, (DefaultPageNumberPagination), { query, ...options });
|
|
4986
5087
|
}
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
5088
|
+
/**
|
|
5089
|
+
* Returns a paginated list of credit transaction history with optional filtering.
|
|
5090
|
+
*
|
|
5091
|
+
* # Authentication
|
|
5092
|
+
*
|
|
5093
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5094
|
+
*
|
|
5095
|
+
* # Path Parameters
|
|
5096
|
+
*
|
|
5097
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
5098
|
+
* - `customer_id` - The unique identifier of the customer
|
|
5099
|
+
*
|
|
5100
|
+
* # Query Parameters
|
|
5101
|
+
*
|
|
5102
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5103
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5104
|
+
* - `transaction_type` - Filter by transaction type
|
|
5105
|
+
* - `start_date` - Filter entries from this date
|
|
5106
|
+
* - `end_date` - Filter entries until this date
|
|
5107
|
+
*
|
|
5108
|
+
* # Responses
|
|
5109
|
+
*
|
|
5110
|
+
* - `200 OK` - Returns list of ledger entries
|
|
5111
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
5112
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5113
|
+
*/
|
|
5114
|
+
listLedger(customerID, params, options) {
|
|
5115
|
+
const { credit_entitlement_id, ...query } = params;
|
|
5116
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger`, (DefaultPageNumberPagination), { query, ...options });
|
|
4992
5117
|
}
|
|
4993
5118
|
}
|
|
4994
|
-
Customers.CustomerPortal = CustomerPortal$1;
|
|
4995
|
-
Customers.Wallets = Wallets;
|
|
4996
5119
|
|
|
4997
5120
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4998
5121
|
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
@@ -5062,6 +5185,313 @@ const buildHeaders = (newHeaders) => {
|
|
|
5062
5185
|
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
5063
5186
|
};
|
|
5064
5187
|
|
|
5188
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5189
|
+
class CreditEntitlements extends APIResource {
|
|
5190
|
+
constructor() {
|
|
5191
|
+
super(...arguments);
|
|
5192
|
+
this.balances = new Balances(this._client);
|
|
5193
|
+
}
|
|
5194
|
+
/**
|
|
5195
|
+
* Credit entitlements define reusable credit templates that can be attached to
|
|
5196
|
+
* products. Each entitlement defines how credits behave in terms of expiration,
|
|
5197
|
+
* rollover, and overage.
|
|
5198
|
+
*
|
|
5199
|
+
* # Authentication
|
|
5200
|
+
*
|
|
5201
|
+
* Requires an API key with `Editor` role.
|
|
5202
|
+
*
|
|
5203
|
+
* # Request Body
|
|
5204
|
+
*
|
|
5205
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters,
|
|
5206
|
+
* required)
|
|
5207
|
+
* - `description` - Optional description (max 1000 characters)
|
|
5208
|
+
* - `precision` - Decimal precision for credit amounts (0-10 decimal places)
|
|
5209
|
+
* - `unit` - Unit of measurement for the credit (e.g., "API Calls", "Tokens",
|
|
5210
|
+
* "Credits")
|
|
5211
|
+
* - `expires_after_days` - Number of days after which credits expire (optional)
|
|
5212
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
5213
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100)
|
|
5214
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
5215
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year)
|
|
5216
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
5217
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
5218
|
+
* (requires price_per_unit)
|
|
5219
|
+
* - `overage_limit` - Maximum overage units allowed (optional)
|
|
5220
|
+
* - `currency` - Currency for pricing (required if price_per_unit is set)
|
|
5221
|
+
* - `price_per_unit` - Price per credit unit (decimal)
|
|
5222
|
+
*
|
|
5223
|
+
* # Responses
|
|
5224
|
+
*
|
|
5225
|
+
* - `201 Created` - Credit entitlement created successfully, returns the full
|
|
5226
|
+
* entitlement object
|
|
5227
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
5228
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5229
|
+
*
|
|
5230
|
+
* # Business Logic
|
|
5231
|
+
*
|
|
5232
|
+
* - A unique ID with prefix `cde_` is automatically generated for the entitlement
|
|
5233
|
+
* - Created and updated timestamps are automatically set
|
|
5234
|
+
* - Currency is required when price_per_unit is set
|
|
5235
|
+
* - price_per_unit is required when overage_enabled is true
|
|
5236
|
+
* - rollover_timeframe_count and rollover_timeframe_interval must both be set or
|
|
5237
|
+
* both be null
|
|
5238
|
+
*/
|
|
5239
|
+
create(body, options) {
|
|
5240
|
+
return this._client.post('/credit-entitlements', { body, ...options });
|
|
5241
|
+
}
|
|
5242
|
+
/**
|
|
5243
|
+
* Returns the full details of a single credit entitlement including all
|
|
5244
|
+
* configuration settings for expiration, rollover, and overage policies.
|
|
5245
|
+
*
|
|
5246
|
+
* # Authentication
|
|
5247
|
+
*
|
|
5248
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5249
|
+
*
|
|
5250
|
+
* # Path Parameters
|
|
5251
|
+
*
|
|
5252
|
+
* - `id` - The unique identifier of the credit entitlement (format: `cde_...`)
|
|
5253
|
+
*
|
|
5254
|
+
* # Responses
|
|
5255
|
+
*
|
|
5256
|
+
* - `200 OK` - Returns the full credit entitlement object
|
|
5257
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
5258
|
+
* authenticated business
|
|
5259
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5260
|
+
*
|
|
5261
|
+
* # Business Logic
|
|
5262
|
+
*
|
|
5263
|
+
* - Only non-deleted credit entitlements can be retrieved through this endpoint
|
|
5264
|
+
* - The entitlement must belong to the authenticated business (business_id check)
|
|
5265
|
+
* - Deleted entitlements return a 404 error and must be retrieved via the list
|
|
5266
|
+
* endpoint with `deleted=true`
|
|
5267
|
+
*/
|
|
5268
|
+
retrieve(id, options) {
|
|
5269
|
+
return this._client.get(path `/credit-entitlements/${id}`, options);
|
|
5270
|
+
}
|
|
5271
|
+
/**
|
|
5272
|
+
* Allows partial updates to a credit entitlement's configuration. Only the fields
|
|
5273
|
+
* provided in the request body will be updated; all other fields remain unchanged.
|
|
5274
|
+
* This endpoint supports nullable fields using the double option pattern.
|
|
5275
|
+
*
|
|
5276
|
+
* # Authentication
|
|
5277
|
+
*
|
|
5278
|
+
* Requires an API key with `Editor` role.
|
|
5279
|
+
*
|
|
5280
|
+
* # Path Parameters
|
|
5281
|
+
*
|
|
5282
|
+
* - `id` - The unique identifier of the credit entitlement to update (format:
|
|
5283
|
+
* `cde_...`)
|
|
5284
|
+
*
|
|
5285
|
+
* # Request Body (all fields optional)
|
|
5286
|
+
*
|
|
5287
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters)
|
|
5288
|
+
* - `description` - Optional description (max 1000 characters)
|
|
5289
|
+
* - `unit` - Unit of measurement for the credit (1-50 characters)
|
|
5290
|
+
*
|
|
5291
|
+
* Note: `precision` cannot be modified after creation as it would invalidate
|
|
5292
|
+
* existing grants.
|
|
5293
|
+
*
|
|
5294
|
+
* - `expires_after_days` - Number of days after which credits expire (use `null`
|
|
5295
|
+
* to remove expiration)
|
|
5296
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
5297
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100,
|
|
5298
|
+
* nullable)
|
|
5299
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
5300
|
+
* (nullable)
|
|
5301
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year,
|
|
5302
|
+
* nullable)
|
|
5303
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
5304
|
+
* (nullable)
|
|
5305
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
5306
|
+
* - `overage_limit` - Maximum overage units allowed (nullable)
|
|
5307
|
+
* - `currency` - Currency for pricing (nullable)
|
|
5308
|
+
* - `price_per_unit` - Price per credit unit (decimal, nullable)
|
|
5309
|
+
*
|
|
5310
|
+
* # Responses
|
|
5311
|
+
*
|
|
5312
|
+
* - `200 OK` - Credit entitlement updated successfully
|
|
5313
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
5314
|
+
* authenticated business
|
|
5315
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
5316
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5317
|
+
*
|
|
5318
|
+
* # Business Logic
|
|
5319
|
+
*
|
|
5320
|
+
* - Only non-deleted credit entitlements can be updated
|
|
5321
|
+
* - Fields set to `null` explicitly will clear the database value (using double
|
|
5322
|
+
* option pattern)
|
|
5323
|
+
* - The `updated_at` timestamp is automatically updated on successful modification
|
|
5324
|
+
* - Changes take effect immediately but do not retroactively affect existing
|
|
5325
|
+
* credit grants
|
|
5326
|
+
* - The merged state is validated: currency required with price, rollover
|
|
5327
|
+
* timeframe fields together, price required for overage
|
|
5328
|
+
*/
|
|
5329
|
+
update(id, body, options) {
|
|
5330
|
+
return this._client.patch(path `/credit-entitlements/${id}`, {
|
|
5331
|
+
body,
|
|
5332
|
+
...options,
|
|
5333
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5334
|
+
});
|
|
5335
|
+
}
|
|
5336
|
+
/**
|
|
5337
|
+
* Returns a paginated list of credit entitlements, allowing filtering of deleted
|
|
5338
|
+
* entitlements. By default, only non-deleted entitlements are returned.
|
|
5339
|
+
*
|
|
5340
|
+
* # Authentication
|
|
5341
|
+
*
|
|
5342
|
+
* Requires an API key with `Viewer` role or higher.
|
|
5343
|
+
*
|
|
5344
|
+
* # Query Parameters
|
|
5345
|
+
*
|
|
5346
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
5347
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
5348
|
+
* - `deleted` - Boolean flag to list deleted entitlements instead of active ones
|
|
5349
|
+
* (default: false)
|
|
5350
|
+
*
|
|
5351
|
+
* # Responses
|
|
5352
|
+
*
|
|
5353
|
+
* - `200 OK` - Returns a list of credit entitlements wrapped in a response object
|
|
5354
|
+
* - `422 Unprocessable Entity` - Invalid query parameters (e.g., page_size > 100)
|
|
5355
|
+
* - `500 Internal Server Error` - Database or server error
|
|
5356
|
+
*
|
|
5357
|
+
* # Business Logic
|
|
5358
|
+
*
|
|
5359
|
+
* - Results are ordered by creation date in descending order (newest first)
|
|
5360
|
+
* - Only entitlements belonging to the authenticated business are returned
|
|
5361
|
+
* - The `deleted` parameter controls visibility of soft-deleted entitlements
|
|
5362
|
+
* - Pagination uses offset-based pagination (offset = page_number \* page_size)
|
|
5363
|
+
*/
|
|
5364
|
+
list(query = {}, options) {
|
|
5365
|
+
return this._client.getAPIList('/credit-entitlements', (DefaultPageNumberPagination), {
|
|
5366
|
+
query,
|
|
5367
|
+
...options,
|
|
5368
|
+
});
|
|
5369
|
+
}
|
|
5370
|
+
delete(id, options) {
|
|
5371
|
+
return this._client.delete(path `/credit-entitlements/${id}`, {
|
|
5372
|
+
...options,
|
|
5373
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5374
|
+
});
|
|
5375
|
+
}
|
|
5376
|
+
/**
|
|
5377
|
+
* Undeletes a soft-deleted credit entitlement by clearing `deleted_at`, making it
|
|
5378
|
+
* available again through standard list and get endpoints.
|
|
5379
|
+
*
|
|
5380
|
+
* # Authentication
|
|
5381
|
+
*
|
|
5382
|
+
* Requires an API key with `Editor` role.
|
|
5383
|
+
*
|
|
5384
|
+
* # Path Parameters
|
|
5385
|
+
*
|
|
5386
|
+
* - `id` - The unique identifier of the credit entitlement to restore (format:
|
|
5387
|
+
* `cde_...`)
|
|
5388
|
+
*
|
|
5389
|
+
* # Responses
|
|
5390
|
+
*
|
|
5391
|
+
* - `200 OK` - Credit entitlement restored successfully
|
|
5392
|
+
* - `500 Internal Server Error` - Database error, entitlement not found, or
|
|
5393
|
+
* entitlement is not deleted
|
|
5394
|
+
*
|
|
5395
|
+
* # Business Logic
|
|
5396
|
+
*
|
|
5397
|
+
* - Only deleted credit entitlements can be restored
|
|
5398
|
+
* - The query filters for `deleted_at IS NOT NULL`, so non-deleted entitlements
|
|
5399
|
+
* will result in 0 rows affected
|
|
5400
|
+
* - If no rows are affected (entitlement doesn't exist, doesn't belong to
|
|
5401
|
+
* business, or is not deleted), returns 500
|
|
5402
|
+
* - The `updated_at` timestamp is automatically updated on successful restoration
|
|
5403
|
+
* - Once restored, the entitlement becomes immediately available in the standard
|
|
5404
|
+
* list and get endpoints
|
|
5405
|
+
* - All configuration settings are preserved during delete/restore operations
|
|
5406
|
+
*
|
|
5407
|
+
* # Error Handling
|
|
5408
|
+
*
|
|
5409
|
+
* This endpoint returns 500 Internal Server Error in several cases:
|
|
5410
|
+
*
|
|
5411
|
+
* - The credit entitlement does not exist
|
|
5412
|
+
* - The credit entitlement belongs to a different business
|
|
5413
|
+
* - The credit entitlement is not currently deleted (already active)
|
|
5414
|
+
*
|
|
5415
|
+
* Callers should verify the entitlement exists and is deleted before calling this
|
|
5416
|
+
* endpoint.
|
|
5417
|
+
*/
|
|
5418
|
+
undelete(id, options) {
|
|
5419
|
+
return this._client.post(path `/credit-entitlements/${id}/undelete`, {
|
|
5420
|
+
...options,
|
|
5421
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5422
|
+
});
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
CreditEntitlements.Balances = Balances;
|
|
5426
|
+
|
|
5427
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5428
|
+
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
5429
|
+
create(customerID, params = {}, options) {
|
|
5430
|
+
const { send_email } = params ?? {};
|
|
5431
|
+
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
5432
|
+
query: { send_email },
|
|
5433
|
+
...options,
|
|
5434
|
+
});
|
|
5435
|
+
}
|
|
5436
|
+
};
|
|
5437
|
+
|
|
5438
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5439
|
+
class LedgerEntries extends APIResource {
|
|
5440
|
+
create(customerID, body, options) {
|
|
5441
|
+
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
5442
|
+
}
|
|
5443
|
+
list(customerID, query = {}, options) {
|
|
5444
|
+
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
5445
|
+
}
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5448
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5449
|
+
class Wallets extends APIResource {
|
|
5450
|
+
constructor() {
|
|
5451
|
+
super(...arguments);
|
|
5452
|
+
this.ledgerEntries = new LedgerEntries(this._client);
|
|
5453
|
+
}
|
|
5454
|
+
list(customerID, options) {
|
|
5455
|
+
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
Wallets.LedgerEntries = LedgerEntries;
|
|
5459
|
+
|
|
5460
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5461
|
+
class Customers extends APIResource {
|
|
5462
|
+
constructor() {
|
|
5463
|
+
super(...arguments);
|
|
5464
|
+
this.customerPortal = new CustomerPortal$1(this._client);
|
|
5465
|
+
this.wallets = new Wallets(this._client);
|
|
5466
|
+
}
|
|
5467
|
+
create(body, options) {
|
|
5468
|
+
return this._client.post('/customers', { body, ...options });
|
|
5469
|
+
}
|
|
5470
|
+
retrieve(customerID, options) {
|
|
5471
|
+
return this._client.get(path `/customers/${customerID}`, options);
|
|
5472
|
+
}
|
|
5473
|
+
update(customerID, body, options) {
|
|
5474
|
+
return this._client.patch(path `/customers/${customerID}`, { body, ...options });
|
|
5475
|
+
}
|
|
5476
|
+
list(query = {}, options) {
|
|
5477
|
+
return this._client.getAPIList('/customers', (DefaultPageNumberPagination), {
|
|
5478
|
+
query,
|
|
5479
|
+
...options,
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
/**
|
|
5483
|
+
* List all credit entitlements for a customer with their current balances
|
|
5484
|
+
*/
|
|
5485
|
+
listCreditEntitlements(customerID, options) {
|
|
5486
|
+
return this._client.get(path `/customers/${customerID}/credit-entitlements`, options);
|
|
5487
|
+
}
|
|
5488
|
+
retrievePaymentMethods(customerID, options) {
|
|
5489
|
+
return this._client.get(path `/customers/${customerID}/payment-methods`, options);
|
|
5490
|
+
}
|
|
5491
|
+
}
|
|
5492
|
+
Customers.CustomerPortal = CustomerPortal$1;
|
|
5493
|
+
Customers.Wallets = Wallets;
|
|
5494
|
+
|
|
5065
5495
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5066
5496
|
class Discounts extends APIResource {
|
|
5067
5497
|
/**
|
|
@@ -5101,6 +5531,14 @@ class Discounts extends APIResource {
|
|
|
5101
5531
|
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5102
5532
|
});
|
|
5103
5533
|
}
|
|
5534
|
+
/**
|
|
5535
|
+
* Validate and fetch a discount by its code name (e.g., "SAVE20"). This allows
|
|
5536
|
+
* real-time validation directly against the API using the human-readable discount
|
|
5537
|
+
* code instead of requiring the internal discount_id.
|
|
5538
|
+
*/
|
|
5539
|
+
retrieveByCode(code, options) {
|
|
5540
|
+
return this._client.get(path `/discounts/code/${code}`, options);
|
|
5541
|
+
}
|
|
5104
5542
|
}
|
|
5105
5543
|
|
|
5106
5544
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -5299,6 +5737,9 @@ class Misc extends APIResource {
|
|
|
5299
5737
|
|
|
5300
5738
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5301
5739
|
class Payments extends APIResource {
|
|
5740
|
+
/**
|
|
5741
|
+
* @deprecated
|
|
5742
|
+
*/
|
|
5302
5743
|
create(body, options) {
|
|
5303
5744
|
return this._client.post('/payments', { body, ...options });
|
|
5304
5745
|
}
|
|
@@ -5334,11 +5775,29 @@ class Images extends APIResource {
|
|
|
5334
5775
|
}
|
|
5335
5776
|
}
|
|
5336
5777
|
|
|
5778
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5779
|
+
class ShortLinks extends APIResource {
|
|
5780
|
+
/**
|
|
5781
|
+
* Gives a Short Checkout URL with custom slug for a product. Uses a Static
|
|
5782
|
+
* Checkout URL under the hood.
|
|
5783
|
+
*/
|
|
5784
|
+
create(id, body, options) {
|
|
5785
|
+
return this._client.post(path `/products/${id}/short_links`, { body, ...options });
|
|
5786
|
+
}
|
|
5787
|
+
/**
|
|
5788
|
+
* Lists all short links created by the business.
|
|
5789
|
+
*/
|
|
5790
|
+
list(query = {}, options) {
|
|
5791
|
+
return this._client.getAPIList('/products/short_links', (DefaultPageNumberPagination), { query, ...options });
|
|
5792
|
+
}
|
|
5793
|
+
}
|
|
5794
|
+
|
|
5337
5795
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5338
5796
|
class Products extends APIResource {
|
|
5339
5797
|
constructor() {
|
|
5340
5798
|
super(...arguments);
|
|
5341
5799
|
this.images = new Images(this._client);
|
|
5800
|
+
this.shortLinks = new ShortLinks(this._client);
|
|
5342
5801
|
}
|
|
5343
5802
|
create(body, options) {
|
|
5344
5803
|
return this._client.post('/products', { body, ...options });
|
|
@@ -5376,6 +5835,7 @@ class Products extends APIResource {
|
|
|
5376
5835
|
}
|
|
5377
5836
|
}
|
|
5378
5837
|
Products.Images = Images;
|
|
5838
|
+
Products.ShortLinks = ShortLinks;
|
|
5379
5839
|
|
|
5380
5840
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5381
5841
|
class Refunds extends APIResource {
|
|
@@ -5395,6 +5855,9 @@ class Refunds extends APIResource {
|
|
|
5395
5855
|
|
|
5396
5856
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5397
5857
|
class Subscriptions extends APIResource {
|
|
5858
|
+
/**
|
|
5859
|
+
* @deprecated
|
|
5860
|
+
*/
|
|
5398
5861
|
create(body, options) {
|
|
5399
5862
|
return this._client.post('/subscriptions', { body, ...options });
|
|
5400
5863
|
}
|
|
@@ -5420,6 +5883,15 @@ class Subscriptions extends APIResource {
|
|
|
5420
5883
|
charge(subscriptionID, body, options) {
|
|
5421
5884
|
return this._client.post(path `/subscriptions/${subscriptionID}/charge`, { body, ...options });
|
|
5422
5885
|
}
|
|
5886
|
+
previewChangePlan(subscriptionID, body, options) {
|
|
5887
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/change-plan/preview`, {
|
|
5888
|
+
body,
|
|
5889
|
+
...options,
|
|
5890
|
+
});
|
|
5891
|
+
}
|
|
5892
|
+
retrieveCreditUsage(subscriptionID, options) {
|
|
5893
|
+
return this._client.get(path `/subscriptions/${subscriptionID}/credit-usage`, options);
|
|
5894
|
+
}
|
|
5423
5895
|
/**
|
|
5424
5896
|
* Get detailed usage history for a subscription that includes usage-based billing
|
|
5425
5897
|
* (metered components). This endpoint provides insights into customer usage
|
|
@@ -5467,6 +5939,12 @@ class Subscriptions extends APIResource {
|
|
|
5467
5939
|
retrieveUsageHistory(subscriptionID, query = {}, options) {
|
|
5468
5940
|
return this._client.getAPIList(path `/subscriptions/${subscriptionID}/usage-history`, (DefaultPageNumberPagination), { query, ...options });
|
|
5469
5941
|
}
|
|
5942
|
+
updatePaymentMethod(subscriptionID, body, options) {
|
|
5943
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/update-payment-method`, {
|
|
5944
|
+
body,
|
|
5945
|
+
...options,
|
|
5946
|
+
});
|
|
5947
|
+
}
|
|
5470
5948
|
}
|
|
5471
5949
|
|
|
5472
5950
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -6588,6 +7066,8 @@ class DodoPayments {
|
|
|
6588
7066
|
this.webhookEvents = new WebhookEvents(this);
|
|
6589
7067
|
this.usageEvents = new UsageEvents(this);
|
|
6590
7068
|
this.meters = new Meters(this);
|
|
7069
|
+
this.balances = new Balances$1(this);
|
|
7070
|
+
this.creditEntitlements = new CreditEntitlements(this);
|
|
6591
7071
|
if (bearerToken === undefined) {
|
|
6592
7072
|
throw new DodoPaymentsError("The DODO_PAYMENTS_API_KEY environment variable is missing or empty; either provide it, or instantiate the DodoPayments client with an bearerToken option, like new DodoPayments({ bearerToken: 'My Bearer Token' }).");
|
|
6593
7073
|
}
|
|
@@ -6652,18 +7132,7 @@ class DodoPayments {
|
|
|
6652
7132
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
6653
7133
|
*/
|
|
6654
7134
|
stringifyQuery(query) {
|
|
6655
|
-
return
|
|
6656
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
6657
|
-
.map(([key, value]) => {
|
|
6658
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
6659
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
6660
|
-
}
|
|
6661
|
-
if (value === null) {
|
|
6662
|
-
return `${encodeURIComponent(key)}=`;
|
|
6663
|
-
}
|
|
6664
|
-
throw new DodoPaymentsError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
6665
|
-
})
|
|
6666
|
-
.join('&');
|
|
7135
|
+
return stringifyQuery(query);
|
|
6667
7136
|
}
|
|
6668
7137
|
getUserAgent() {
|
|
6669
7138
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -6827,7 +7296,9 @@ class DodoPayments {
|
|
|
6827
7296
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
6828
7297
|
}
|
|
6829
7298
|
getAPIList(path, Page, opts) {
|
|
6830
|
-
return this.requestAPIList(Page,
|
|
7299
|
+
return this.requestAPIList(Page, opts && 'then' in opts ?
|
|
7300
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
7301
|
+
: { method: 'get', path, ...opts });
|
|
6831
7302
|
}
|
|
6832
7303
|
requestAPIList(Page, options) {
|
|
6833
7304
|
const request = this.makeRequest(options, null, undefined);
|
|
@@ -6835,9 +7306,10 @@ class DodoPayments {
|
|
|
6835
7306
|
}
|
|
6836
7307
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
6837
7308
|
const { signal, method, ...options } = init || {};
|
|
7309
|
+
const abort = this._makeAbort(controller);
|
|
6838
7310
|
if (signal)
|
|
6839
|
-
signal.addEventListener('abort',
|
|
6840
|
-
const timeout = setTimeout(
|
|
7311
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
7312
|
+
const timeout = setTimeout(abort, ms);
|
|
6841
7313
|
const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
|
|
6842
7314
|
(typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
|
|
6843
7315
|
const fetchOptions = {
|
|
@@ -6902,9 +7374,9 @@ class DodoPayments {
|
|
|
6902
7374
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
6903
7375
|
}
|
|
6904
7376
|
}
|
|
6905
|
-
// If the API asks us to wait a certain amount of time
|
|
6906
|
-
//
|
|
6907
|
-
if (
|
|
7377
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
7378
|
+
// says, but otherwise calculate a default
|
|
7379
|
+
if (timeoutMillis === undefined) {
|
|
6908
7380
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
6909
7381
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
6910
7382
|
}
|
|
@@ -6966,6 +7438,11 @@ class DodoPayments {
|
|
|
6966
7438
|
this.validateHeaders(headers);
|
|
6967
7439
|
return headers.values;
|
|
6968
7440
|
}
|
|
7441
|
+
_makeAbort(controller) {
|
|
7442
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
7443
|
+
// would capture all request options, and cause a memory leak.
|
|
7444
|
+
return () => controller.abort();
|
|
7445
|
+
}
|
|
6969
7446
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
6970
7447
|
if (!body) {
|
|
6971
7448
|
return { bodyHeaders: undefined, body: undefined };
|
|
@@ -6994,6 +7471,13 @@ class DodoPayments {
|
|
|
6994
7471
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
6995
7472
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
6996
7473
|
}
|
|
7474
|
+
else if (typeof body === 'object' &&
|
|
7475
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
7476
|
+
return {
|
|
7477
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
7478
|
+
body: this.stringifyQuery(body),
|
|
7479
|
+
};
|
|
7480
|
+
}
|
|
6997
7481
|
else {
|
|
6998
7482
|
return __classPrivateFieldGet(this, _DodoPayments_encoder, "f").call(this, { body, headers });
|
|
6999
7483
|
}
|
|
@@ -7038,6 +7522,8 @@ DodoPayments.Webhooks = Webhooks$1;
|
|
|
7038
7522
|
DodoPayments.WebhookEvents = WebhookEvents;
|
|
7039
7523
|
DodoPayments.UsageEvents = UsageEvents;
|
|
7040
7524
|
DodoPayments.Meters = Meters;
|
|
7525
|
+
DodoPayments.Balances = Balances$1;
|
|
7526
|
+
DodoPayments.CreditEntitlements = CreditEntitlements;
|
|
7041
7527
|
|
|
7042
7528
|
// src/checkout/checkout.ts
|
|
7043
7529
|
var checkoutQuerySchema = objectType({
|
|
@@ -7508,6 +7994,32 @@ var buildCheckoutUrl = async ({
|
|
|
7508
7994
|
}
|
|
7509
7995
|
};
|
|
7510
7996
|
|
|
7997
|
+
var __create = Object.create;
|
|
7998
|
+
var __defProp = Object.defineProperty;
|
|
7999
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8000
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8001
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8002
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8003
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
8004
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8005
|
+
};
|
|
8006
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8007
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8008
|
+
for (let key of __getOwnPropNames(from))
|
|
8009
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
8010
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
8011
|
+
}
|
|
8012
|
+
return to;
|
|
8013
|
+
};
|
|
8014
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
8015
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
8016
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
8017
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
8018
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
8019
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
8020
|
+
mod
|
|
8021
|
+
));
|
|
8022
|
+
|
|
7511
8023
|
const Checkout = (config) => {
|
|
7512
8024
|
const getHandler = async ({ request }) => {
|
|
7513
8025
|
const { searchParams } = new URL(request.url);
|
|
@@ -7600,12 +8112,11 @@ const CustomerPortal = ({ bearerToken, environment, }) => {
|
|
|
7600
8112
|
const getHandler = async ({ request }) => {
|
|
7601
8113
|
const { searchParams } = new URL(request.url);
|
|
7602
8114
|
const customerId = searchParams.get("customer_id");
|
|
7603
|
-
const
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
params.send_email = sendEmail;
|
|
8115
|
+
const sendEmailParam = searchParams.get("send_email");
|
|
8116
|
+
const params = {};
|
|
8117
|
+
if (sendEmailParam !== null) {
|
|
8118
|
+
// searchParams.get() already returns a single string or null
|
|
8119
|
+
params.send_email = sendEmailParam === "true";
|
|
7609
8120
|
}
|
|
7610
8121
|
if (!customerId) {
|
|
7611
8122
|
return new Response("Missing customerId in query parameters", {
|
|
@@ -7635,23 +8146,33 @@ var PaymentSchema = objectType({
|
|
|
7635
8146
|
payload_type: literalType("Payment"),
|
|
7636
8147
|
billing: objectType({
|
|
7637
8148
|
city: stringType().nullable(),
|
|
7638
|
-
country: stringType()
|
|
8149
|
+
country: stringType(),
|
|
7639
8150
|
state: stringType().nullable(),
|
|
7640
8151
|
street: stringType().nullable(),
|
|
7641
8152
|
zipcode: stringType().nullable()
|
|
7642
8153
|
}),
|
|
7643
8154
|
brand_id: stringType(),
|
|
7644
8155
|
business_id: stringType(),
|
|
8156
|
+
card_holder_name: stringType().nullable(),
|
|
7645
8157
|
card_issuing_country: stringType().nullable(),
|
|
7646
8158
|
card_last_four: stringType().nullable(),
|
|
7647
8159
|
card_network: stringType().nullable(),
|
|
7648
8160
|
card_type: stringType().nullable(),
|
|
8161
|
+
checkout_session_id: stringType().nullable(),
|
|
7649
8162
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7650
8163
|
currency: stringType(),
|
|
8164
|
+
custom_field_responses: arrayType(
|
|
8165
|
+
objectType({
|
|
8166
|
+
key: stringType(),
|
|
8167
|
+
value: stringType()
|
|
8168
|
+
})
|
|
8169
|
+
).nullable(),
|
|
7651
8170
|
customer: objectType({
|
|
7652
8171
|
customer_id: stringType(),
|
|
7653
8172
|
email: stringType(),
|
|
7654
|
-
|
|
8173
|
+
metadata: recordType(anyType()),
|
|
8174
|
+
name: stringType(),
|
|
8175
|
+
phone_number: stringType().nullable()
|
|
7655
8176
|
}),
|
|
7656
8177
|
digital_products_delivered: booleanType(),
|
|
7657
8178
|
discount_id: stringType().nullable(),
|
|
@@ -7662,27 +8183,25 @@ var PaymentSchema = objectType({
|
|
|
7662
8183
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7663
8184
|
currency: stringType(),
|
|
7664
8185
|
dispute_id: stringType(),
|
|
7665
|
-
dispute_stage: enumType([
|
|
7666
|
-
"pre_dispute",
|
|
7667
|
-
"dispute_opened",
|
|
7668
|
-
"dispute_won",
|
|
7669
|
-
"dispute_lost"
|
|
7670
|
-
]),
|
|
8186
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7671
8187
|
dispute_status: enumType([
|
|
7672
8188
|
"dispute_opened",
|
|
7673
|
-
"
|
|
7674
|
-
"dispute_lost",
|
|
8189
|
+
"dispute_expired",
|
|
7675
8190
|
"dispute_accepted",
|
|
7676
8191
|
"dispute_cancelled",
|
|
7677
|
-
"dispute_challenged"
|
|
8192
|
+
"dispute_challenged",
|
|
8193
|
+
"dispute_won",
|
|
8194
|
+
"dispute_lost"
|
|
7678
8195
|
]),
|
|
7679
8196
|
payment_id: stringType(),
|
|
7680
8197
|
remarks: stringType().nullable()
|
|
7681
8198
|
})
|
|
7682
|
-
).
|
|
8199
|
+
).default([]),
|
|
7683
8200
|
error_code: stringType().nullable(),
|
|
7684
8201
|
error_message: stringType().nullable(),
|
|
7685
|
-
|
|
8202
|
+
invoice_id: stringType().nullable(),
|
|
8203
|
+
invoice_url: stringType().nullable(),
|
|
8204
|
+
metadata: recordType(anyType()),
|
|
7686
8205
|
payment_id: stringType(),
|
|
7687
8206
|
payment_link: stringType().nullable(),
|
|
7688
8207
|
payment_method: stringType().nullable(),
|
|
@@ -7695,21 +8214,34 @@ var PaymentSchema = objectType({
|
|
|
7695
8214
|
).nullable(),
|
|
7696
8215
|
refunds: arrayType(
|
|
7697
8216
|
objectType({
|
|
7698
|
-
amount: numberType(),
|
|
8217
|
+
amount: numberType().nullable(),
|
|
7699
8218
|
business_id: stringType(),
|
|
7700
8219
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7701
|
-
currency: stringType(),
|
|
8220
|
+
currency: stringType().nullable(),
|
|
7702
8221
|
is_partial: booleanType(),
|
|
7703
8222
|
payment_id: stringType(),
|
|
7704
8223
|
reason: stringType().nullable(),
|
|
7705
8224
|
refund_id: stringType(),
|
|
7706
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8225
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7707
8226
|
})
|
|
7708
|
-
)
|
|
8227
|
+
),
|
|
8228
|
+
refund_status: enumType(["partial", "full"]).nullable(),
|
|
7709
8229
|
settlement_amount: numberType(),
|
|
7710
8230
|
settlement_currency: stringType(),
|
|
7711
8231
|
settlement_tax: numberType().nullable(),
|
|
7712
|
-
status: enumType([
|
|
8232
|
+
status: enumType([
|
|
8233
|
+
"succeeded",
|
|
8234
|
+
"failed",
|
|
8235
|
+
"cancelled",
|
|
8236
|
+
"processing",
|
|
8237
|
+
"requires_customer_action",
|
|
8238
|
+
"requires_merchant_action",
|
|
8239
|
+
"requires_payment_method",
|
|
8240
|
+
"requires_confirmation",
|
|
8241
|
+
"requires_capture",
|
|
8242
|
+
"partially_captured",
|
|
8243
|
+
"partially_captured_and_capturable"
|
|
8244
|
+
]).nullable(),
|
|
7713
8245
|
subscription_id: stringType().nullable(),
|
|
7714
8246
|
tax: numberType().nullable(),
|
|
7715
8247
|
total_amount: numberType(),
|
|
@@ -7722,10 +8254,10 @@ var SubscriptionSchema = objectType({
|
|
|
7722
8254
|
addon_id: stringType(),
|
|
7723
8255
|
quantity: numberType()
|
|
7724
8256
|
})
|
|
7725
|
-
)
|
|
8257
|
+
),
|
|
7726
8258
|
billing: objectType({
|
|
7727
8259
|
city: stringType().nullable(),
|
|
7728
|
-
country: stringType()
|
|
8260
|
+
country: stringType(),
|
|
7729
8261
|
state: stringType().nullable(),
|
|
7730
8262
|
street: stringType().nullable(),
|
|
7731
8263
|
zipcode: stringType().nullable()
|
|
@@ -7737,15 +8269,72 @@ var SubscriptionSchema = objectType({
|
|
|
7737
8269
|
customer: objectType({
|
|
7738
8270
|
customer_id: stringType(),
|
|
7739
8271
|
email: stringType(),
|
|
7740
|
-
|
|
8272
|
+
metadata: recordType(anyType()),
|
|
8273
|
+
name: stringType(),
|
|
8274
|
+
phone_number: stringType().nullable()
|
|
7741
8275
|
}),
|
|
8276
|
+
custom_field_responses: arrayType(
|
|
8277
|
+
objectType({
|
|
8278
|
+
key: stringType(),
|
|
8279
|
+
value: stringType()
|
|
8280
|
+
})
|
|
8281
|
+
).nullable(),
|
|
8282
|
+
discount_cycles_remaining: numberType().nullable(),
|
|
7742
8283
|
discount_id: stringType().nullable(),
|
|
7743
|
-
|
|
7744
|
-
|
|
8284
|
+
expires_at: stringType().transform((d) => new Date(d)).nullable(),
|
|
8285
|
+
credit_entitlement_cart: arrayType(
|
|
8286
|
+
objectType({
|
|
8287
|
+
credit_entitlement_id: stringType(),
|
|
8288
|
+
credit_entitlement_name: stringType(),
|
|
8289
|
+
credits_amount: stringType(),
|
|
8290
|
+
overage_balance: stringType(),
|
|
8291
|
+
overage_behavior: enumType([
|
|
8292
|
+
"forgive_at_reset",
|
|
8293
|
+
"invoice_at_billing",
|
|
8294
|
+
"carry_deficit",
|
|
8295
|
+
"carry_deficit_auto_repay"
|
|
8296
|
+
]),
|
|
8297
|
+
overage_enabled: booleanType(),
|
|
8298
|
+
product_id: stringType(),
|
|
8299
|
+
remaining_balance: stringType(),
|
|
8300
|
+
rollover_enabled: booleanType(),
|
|
8301
|
+
unit: stringType(),
|
|
8302
|
+
expires_after_days: numberType().nullable(),
|
|
8303
|
+
low_balance_threshold_percent: numberType().nullable(),
|
|
8304
|
+
max_rollover_count: numberType().nullable(),
|
|
8305
|
+
overage_limit: stringType().nullable(),
|
|
8306
|
+
rollover_percentage: numberType().nullable(),
|
|
8307
|
+
rollover_timeframe_count: numberType().nullable(),
|
|
8308
|
+
rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
|
|
8309
|
+
})
|
|
8310
|
+
),
|
|
8311
|
+
meter_credit_entitlement_cart: arrayType(
|
|
8312
|
+
objectType({
|
|
8313
|
+
credit_entitlement_id: stringType(),
|
|
8314
|
+
meter_id: stringType(),
|
|
8315
|
+
meter_name: stringType(),
|
|
8316
|
+
meter_units_per_credit: stringType(),
|
|
8317
|
+
product_id: stringType()
|
|
8318
|
+
})
|
|
8319
|
+
),
|
|
8320
|
+
meters: arrayType(
|
|
8321
|
+
objectType({
|
|
8322
|
+
currency: stringType(),
|
|
8323
|
+
description: stringType().nullable(),
|
|
8324
|
+
free_threshold: numberType(),
|
|
8325
|
+
measurement_unit: stringType(),
|
|
8326
|
+
meter_id: stringType(),
|
|
8327
|
+
name: stringType(),
|
|
8328
|
+
price_per_unit: stringType().nullable()
|
|
8329
|
+
})
|
|
8330
|
+
),
|
|
8331
|
+
metadata: recordType(anyType()),
|
|
8332
|
+
next_billing_date: stringType().transform((d) => new Date(d)),
|
|
7745
8333
|
on_demand: booleanType(),
|
|
7746
8334
|
payment_frequency_count: numberType(),
|
|
7747
8335
|
payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
7748
|
-
|
|
8336
|
+
payment_method_id: stringType().nullable(),
|
|
8337
|
+
previous_billing_date: stringType().transform((d) => new Date(d)),
|
|
7749
8338
|
product_id: stringType(),
|
|
7750
8339
|
quantity: numberType(),
|
|
7751
8340
|
recurring_pre_tax_amount: numberType(),
|
|
@@ -7753,7 +8342,6 @@ var SubscriptionSchema = objectType({
|
|
|
7753
8342
|
"pending",
|
|
7754
8343
|
"active",
|
|
7755
8344
|
"on_hold",
|
|
7756
|
-
"paused",
|
|
7757
8345
|
"cancelled",
|
|
7758
8346
|
"expired",
|
|
7759
8347
|
"failed"
|
|
@@ -7761,20 +8349,29 @@ var SubscriptionSchema = objectType({
|
|
|
7761
8349
|
subscription_id: stringType(),
|
|
7762
8350
|
subscription_period_count: numberType(),
|
|
7763
8351
|
subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
8352
|
+
tax_id: stringType().nullable(),
|
|
7764
8353
|
tax_inclusive: booleanType(),
|
|
7765
8354
|
trial_period_days: numberType()
|
|
7766
8355
|
});
|
|
7767
8356
|
var RefundSchema = objectType({
|
|
7768
8357
|
payload_type: literalType("Refund"),
|
|
7769
|
-
amount: numberType(),
|
|
8358
|
+
amount: numberType().nullable(),
|
|
7770
8359
|
business_id: stringType(),
|
|
7771
8360
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7772
|
-
|
|
8361
|
+
customer: objectType({
|
|
8362
|
+
customer_id: stringType(),
|
|
8363
|
+
email: stringType(),
|
|
8364
|
+
metadata: recordType(anyType()),
|
|
8365
|
+
name: stringType(),
|
|
8366
|
+
phone_number: stringType().nullable()
|
|
8367
|
+
}),
|
|
8368
|
+
currency: stringType().nullable(),
|
|
7773
8369
|
is_partial: booleanType(),
|
|
8370
|
+
metadata: recordType(anyType()),
|
|
7774
8371
|
payment_id: stringType(),
|
|
7775
8372
|
reason: stringType().nullable(),
|
|
7776
8373
|
refund_id: stringType(),
|
|
7777
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8374
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7778
8375
|
});
|
|
7779
8376
|
var DisputeSchema = objectType({
|
|
7780
8377
|
payload_type: literalType("Dispute"),
|
|
@@ -7782,27 +8379,31 @@ var DisputeSchema = objectType({
|
|
|
7782
8379
|
business_id: stringType(),
|
|
7783
8380
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7784
8381
|
currency: stringType(),
|
|
8382
|
+
customer: objectType({
|
|
8383
|
+
customer_id: stringType(),
|
|
8384
|
+
email: stringType(),
|
|
8385
|
+
metadata: recordType(anyType()),
|
|
8386
|
+
name: stringType(),
|
|
8387
|
+
phone_number: stringType().nullable()
|
|
8388
|
+
}),
|
|
7785
8389
|
dispute_id: stringType(),
|
|
7786
|
-
dispute_stage: enumType([
|
|
7787
|
-
"pre_dispute",
|
|
7788
|
-
"dispute_opened",
|
|
7789
|
-
"dispute_won",
|
|
7790
|
-
"dispute_lost"
|
|
7791
|
-
]),
|
|
8390
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7792
8391
|
dispute_status: enumType([
|
|
7793
8392
|
"dispute_opened",
|
|
7794
|
-
"
|
|
7795
|
-
"dispute_lost",
|
|
8393
|
+
"dispute_expired",
|
|
7796
8394
|
"dispute_accepted",
|
|
7797
8395
|
"dispute_cancelled",
|
|
7798
|
-
"dispute_challenged"
|
|
8396
|
+
"dispute_challenged",
|
|
8397
|
+
"dispute_won",
|
|
8398
|
+
"dispute_lost"
|
|
7799
8399
|
]),
|
|
7800
8400
|
payment_id: stringType(),
|
|
8401
|
+
reason: stringType().nullable(),
|
|
7801
8402
|
remarks: stringType().nullable()
|
|
7802
8403
|
});
|
|
7803
8404
|
var LicenseKeySchema = objectType({
|
|
7804
8405
|
payload_type: literalType("LicenseKey"),
|
|
7805
|
-
activations_limit: numberType(),
|
|
8406
|
+
activations_limit: numberType().nullable(),
|
|
7806
8407
|
business_id: stringType(),
|
|
7807
8408
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7808
8409
|
customer_id: stringType(),
|
|
@@ -7812,7 +8413,7 @@ var LicenseKeySchema = objectType({
|
|
|
7812
8413
|
key: stringType(),
|
|
7813
8414
|
payment_id: stringType(),
|
|
7814
8415
|
product_id: stringType(),
|
|
7815
|
-
status: enumType(["active", "
|
|
8416
|
+
status: enumType(["active", "expired", "disabled"]),
|
|
7816
8417
|
subscription_id: stringType().nullable()
|
|
7817
8418
|
});
|
|
7818
8419
|
var PaymentSucceededPayloadSchema = objectType({
|
|
@@ -7911,12 +8512,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
|
|
|
7911
8512
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7912
8513
|
data: SubscriptionSchema
|
|
7913
8514
|
});
|
|
7914
|
-
var SubscriptionPausedPayloadSchema = objectType({
|
|
7915
|
-
business_id: stringType(),
|
|
7916
|
-
type: literalType("subscription.paused"),
|
|
7917
|
-
timestamp: stringType().transform((d) => new Date(d)),
|
|
7918
|
-
data: SubscriptionSchema
|
|
7919
|
-
});
|
|
7920
8515
|
var SubscriptionPlanChangedPayloadSchema = objectType({
|
|
7921
8516
|
business_id: stringType(),
|
|
7922
8517
|
type: literalType("subscription.plan_changed"),
|
|
@@ -7953,6 +8548,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
|
|
|
7953
8548
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7954
8549
|
data: LicenseKeySchema
|
|
7955
8550
|
});
|
|
8551
|
+
var CreditLedgerEntrySchema = objectType({
|
|
8552
|
+
payload_type: literalType("CreditLedgerEntry"),
|
|
8553
|
+
id: stringType(),
|
|
8554
|
+
amount: stringType(),
|
|
8555
|
+
balance_after: stringType(),
|
|
8556
|
+
balance_before: stringType(),
|
|
8557
|
+
business_id: stringType(),
|
|
8558
|
+
created_at: stringType().transform((d) => new Date(d)),
|
|
8559
|
+
credit_entitlement_id: stringType(),
|
|
8560
|
+
customer_id: stringType(),
|
|
8561
|
+
is_credit: booleanType(),
|
|
8562
|
+
overage_after: stringType(),
|
|
8563
|
+
overage_before: stringType(),
|
|
8564
|
+
transaction_type: enumType([
|
|
8565
|
+
"credit_added",
|
|
8566
|
+
"credit_deducted",
|
|
8567
|
+
"credit_expired",
|
|
8568
|
+
"credit_rolled_over",
|
|
8569
|
+
"rollover_forfeited",
|
|
8570
|
+
"overage_charged",
|
|
8571
|
+
"auto_top_up",
|
|
8572
|
+
"manual_adjustment",
|
|
8573
|
+
"refund"
|
|
8574
|
+
]),
|
|
8575
|
+
description: stringType().nullable(),
|
|
8576
|
+
grant_id: stringType().nullable(),
|
|
8577
|
+
reference_id: stringType().nullable(),
|
|
8578
|
+
reference_type: stringType().nullable()
|
|
8579
|
+
});
|
|
8580
|
+
var CreditBalanceLowSchema = objectType({
|
|
8581
|
+
payload_type: literalType("CreditBalanceLow"),
|
|
8582
|
+
customer_id: stringType(),
|
|
8583
|
+
subscription_id: stringType(),
|
|
8584
|
+
credit_entitlement_id: stringType(),
|
|
8585
|
+
credit_entitlement_name: stringType(),
|
|
8586
|
+
available_balance: stringType(),
|
|
8587
|
+
subscription_credits_amount: stringType(),
|
|
8588
|
+
threshold_percent: numberType(),
|
|
8589
|
+
threshold_amount: stringType()
|
|
8590
|
+
});
|
|
8591
|
+
var CreditAddedPayloadSchema = objectType({
|
|
8592
|
+
business_id: stringType(),
|
|
8593
|
+
type: literalType("credit.added"),
|
|
8594
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8595
|
+
data: CreditLedgerEntrySchema
|
|
8596
|
+
});
|
|
8597
|
+
var CreditDeductedPayloadSchema = objectType({
|
|
8598
|
+
business_id: stringType(),
|
|
8599
|
+
type: literalType("credit.deducted"),
|
|
8600
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8601
|
+
data: CreditLedgerEntrySchema
|
|
8602
|
+
});
|
|
8603
|
+
var CreditExpiredPayloadSchema = objectType({
|
|
8604
|
+
business_id: stringType(),
|
|
8605
|
+
type: literalType("credit.expired"),
|
|
8606
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8607
|
+
data: CreditLedgerEntrySchema
|
|
8608
|
+
});
|
|
8609
|
+
var CreditRolledOverPayloadSchema = objectType({
|
|
8610
|
+
business_id: stringType(),
|
|
8611
|
+
type: literalType("credit.rolled_over"),
|
|
8612
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8613
|
+
data: CreditLedgerEntrySchema
|
|
8614
|
+
});
|
|
8615
|
+
var CreditRolloverForfeitedPayloadSchema = objectType({
|
|
8616
|
+
business_id: stringType(),
|
|
8617
|
+
type: literalType("credit.rollover_forfeited"),
|
|
8618
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8619
|
+
data: CreditLedgerEntrySchema
|
|
8620
|
+
});
|
|
8621
|
+
var CreditOverageChargedPayloadSchema = objectType({
|
|
8622
|
+
business_id: stringType(),
|
|
8623
|
+
type: literalType("credit.overage_charged"),
|
|
8624
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8625
|
+
data: CreditLedgerEntrySchema
|
|
8626
|
+
});
|
|
8627
|
+
var CreditManualAdjustmentPayloadSchema = objectType({
|
|
8628
|
+
business_id: stringType(),
|
|
8629
|
+
type: literalType("credit.manual_adjustment"),
|
|
8630
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8631
|
+
data: CreditLedgerEntrySchema
|
|
8632
|
+
});
|
|
8633
|
+
var CreditBalanceLowPayloadSchema = objectType({
|
|
8634
|
+
business_id: stringType(),
|
|
8635
|
+
type: literalType("credit.balance_low"),
|
|
8636
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8637
|
+
data: CreditBalanceLowSchema
|
|
8638
|
+
});
|
|
7956
8639
|
var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
7957
8640
|
PaymentSucceededPayloadSchema,
|
|
7958
8641
|
PaymentFailedPayloadSchema,
|
|
@@ -7970,15 +8653,691 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
7970
8653
|
SubscriptionActivePayloadSchema,
|
|
7971
8654
|
SubscriptionOnHoldPayloadSchema,
|
|
7972
8655
|
SubscriptionRenewedPayloadSchema,
|
|
7973
|
-
SubscriptionPausedPayloadSchema,
|
|
7974
8656
|
SubscriptionPlanChangedPayloadSchema,
|
|
7975
8657
|
SubscriptionCancelledPayloadSchema,
|
|
7976
8658
|
SubscriptionFailedPayloadSchema,
|
|
7977
8659
|
SubscriptionExpiredPayloadSchema,
|
|
7978
8660
|
SubscriptionUpdatedPayloadSchema,
|
|
7979
|
-
LicenseKeyCreatedPayloadSchema
|
|
8661
|
+
LicenseKeyCreatedPayloadSchema,
|
|
8662
|
+
CreditAddedPayloadSchema,
|
|
8663
|
+
CreditDeductedPayloadSchema,
|
|
8664
|
+
CreditExpiredPayloadSchema,
|
|
8665
|
+
CreditRolledOverPayloadSchema,
|
|
8666
|
+
CreditRolloverForfeitedPayloadSchema,
|
|
8667
|
+
CreditOverageChargedPayloadSchema,
|
|
8668
|
+
CreditManualAdjustmentPayloadSchema,
|
|
8669
|
+
CreditBalanceLowPayloadSchema
|
|
7980
8670
|
]);
|
|
7981
8671
|
|
|
8672
|
+
// ../../node_modules/@stablelib/base64/lib/base64.js
|
|
8673
|
+
var require_base64 = __commonJS({
|
|
8674
|
+
"../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
|
|
8675
|
+
var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
|
|
8676
|
+
var extendStatics = function(d, b) {
|
|
8677
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
8678
|
+
d2.__proto__ = b2;
|
|
8679
|
+
} || function(d2, b2) {
|
|
8680
|
+
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
8681
|
+
};
|
|
8682
|
+
return extendStatics(d, b);
|
|
8683
|
+
};
|
|
8684
|
+
return function(d, b) {
|
|
8685
|
+
extendStatics(d, b);
|
|
8686
|
+
function __() {
|
|
8687
|
+
this.constructor = d;
|
|
8688
|
+
}
|
|
8689
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8690
|
+
};
|
|
8691
|
+
}();
|
|
8692
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8693
|
+
var INVALID_BYTE = 256;
|
|
8694
|
+
var Coder = (
|
|
8695
|
+
/** @class */
|
|
8696
|
+
function() {
|
|
8697
|
+
function Coder2(_paddingCharacter) {
|
|
8698
|
+
if (_paddingCharacter === void 0) {
|
|
8699
|
+
_paddingCharacter = "=";
|
|
8700
|
+
}
|
|
8701
|
+
this._paddingCharacter = _paddingCharacter;
|
|
8702
|
+
}
|
|
8703
|
+
Coder2.prototype.encodedLength = function(length) {
|
|
8704
|
+
if (!this._paddingCharacter) {
|
|
8705
|
+
return (length * 8 + 5) / 6 | 0;
|
|
8706
|
+
}
|
|
8707
|
+
return (length + 2) / 3 * 4 | 0;
|
|
8708
|
+
};
|
|
8709
|
+
Coder2.prototype.encode = function(data) {
|
|
8710
|
+
var out = "";
|
|
8711
|
+
var i = 0;
|
|
8712
|
+
for (; i < data.length - 2; i += 3) {
|
|
8713
|
+
var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
|
|
8714
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
8715
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
8716
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
8717
|
+
out += this._encodeByte(c >>> 0 * 6 & 63);
|
|
8718
|
+
}
|
|
8719
|
+
var left = data.length - i;
|
|
8720
|
+
if (left > 0) {
|
|
8721
|
+
var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
|
|
8722
|
+
out += this._encodeByte(c >>> 3 * 6 & 63);
|
|
8723
|
+
out += this._encodeByte(c >>> 2 * 6 & 63);
|
|
8724
|
+
if (left === 2) {
|
|
8725
|
+
out += this._encodeByte(c >>> 1 * 6 & 63);
|
|
8726
|
+
} else {
|
|
8727
|
+
out += this._paddingCharacter || "";
|
|
8728
|
+
}
|
|
8729
|
+
out += this._paddingCharacter || "";
|
|
8730
|
+
}
|
|
8731
|
+
return out;
|
|
8732
|
+
};
|
|
8733
|
+
Coder2.prototype.maxDecodedLength = function(length) {
|
|
8734
|
+
if (!this._paddingCharacter) {
|
|
8735
|
+
return (length * 6 + 7) / 8 | 0;
|
|
8736
|
+
}
|
|
8737
|
+
return length / 4 * 3 | 0;
|
|
8738
|
+
};
|
|
8739
|
+
Coder2.prototype.decodedLength = function(s) {
|
|
8740
|
+
return this.maxDecodedLength(s.length - this._getPaddingLength(s));
|
|
8741
|
+
};
|
|
8742
|
+
Coder2.prototype.decode = function(s) {
|
|
8743
|
+
if (s.length === 0) {
|
|
8744
|
+
return new Uint8Array(0);
|
|
8745
|
+
}
|
|
8746
|
+
var paddingLength = this._getPaddingLength(s);
|
|
8747
|
+
var length = s.length - paddingLength;
|
|
8748
|
+
var out = new Uint8Array(this.maxDecodedLength(length));
|
|
8749
|
+
var op = 0;
|
|
8750
|
+
var i = 0;
|
|
8751
|
+
var haveBad = 0;
|
|
8752
|
+
var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
|
|
8753
|
+
for (; i < length - 4; i += 4) {
|
|
8754
|
+
v0 = this._decodeChar(s.charCodeAt(i + 0));
|
|
8755
|
+
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
8756
|
+
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
8757
|
+
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
8758
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
8759
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
8760
|
+
out[op++] = v2 << 6 | v3;
|
|
8761
|
+
haveBad |= v0 & INVALID_BYTE;
|
|
8762
|
+
haveBad |= v1 & INVALID_BYTE;
|
|
8763
|
+
haveBad |= v2 & INVALID_BYTE;
|
|
8764
|
+
haveBad |= v3 & INVALID_BYTE;
|
|
8765
|
+
}
|
|
8766
|
+
if (i < length - 1) {
|
|
8767
|
+
v0 = this._decodeChar(s.charCodeAt(i));
|
|
8768
|
+
v1 = this._decodeChar(s.charCodeAt(i + 1));
|
|
8769
|
+
out[op++] = v0 << 2 | v1 >>> 4;
|
|
8770
|
+
haveBad |= v0 & INVALID_BYTE;
|
|
8771
|
+
haveBad |= v1 & INVALID_BYTE;
|
|
8772
|
+
}
|
|
8773
|
+
if (i < length - 2) {
|
|
8774
|
+
v2 = this._decodeChar(s.charCodeAt(i + 2));
|
|
8775
|
+
out[op++] = v1 << 4 | v2 >>> 2;
|
|
8776
|
+
haveBad |= v2 & INVALID_BYTE;
|
|
8777
|
+
}
|
|
8778
|
+
if (i < length - 3) {
|
|
8779
|
+
v3 = this._decodeChar(s.charCodeAt(i + 3));
|
|
8780
|
+
out[op++] = v2 << 6 | v3;
|
|
8781
|
+
haveBad |= v3 & INVALID_BYTE;
|
|
8782
|
+
}
|
|
8783
|
+
if (haveBad !== 0) {
|
|
8784
|
+
throw new Error("Base64Coder: incorrect characters for decoding");
|
|
8785
|
+
}
|
|
8786
|
+
return out;
|
|
8787
|
+
};
|
|
8788
|
+
Coder2.prototype._encodeByte = function(b) {
|
|
8789
|
+
var result = b;
|
|
8790
|
+
result += 65;
|
|
8791
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
8792
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
8793
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
|
|
8794
|
+
result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
|
|
8795
|
+
return String.fromCharCode(result);
|
|
8796
|
+
};
|
|
8797
|
+
Coder2.prototype._decodeChar = function(c) {
|
|
8798
|
+
var result = INVALID_BYTE;
|
|
8799
|
+
result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
|
|
8800
|
+
result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
|
|
8801
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
8802
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
8803
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
8804
|
+
return result;
|
|
8805
|
+
};
|
|
8806
|
+
Coder2.prototype._getPaddingLength = function(s) {
|
|
8807
|
+
var paddingLength = 0;
|
|
8808
|
+
if (this._paddingCharacter) {
|
|
8809
|
+
for (var i = s.length - 1; i >= 0; i--) {
|
|
8810
|
+
if (s[i] !== this._paddingCharacter) {
|
|
8811
|
+
break;
|
|
8812
|
+
}
|
|
8813
|
+
paddingLength++;
|
|
8814
|
+
}
|
|
8815
|
+
if (s.length < 4 || paddingLength > 2) {
|
|
8816
|
+
throw new Error("Base64Coder: incorrect padding");
|
|
8817
|
+
}
|
|
8818
|
+
}
|
|
8819
|
+
return paddingLength;
|
|
8820
|
+
};
|
|
8821
|
+
return Coder2;
|
|
8822
|
+
}()
|
|
8823
|
+
);
|
|
8824
|
+
exports.Coder = Coder;
|
|
8825
|
+
var stdCoder = new Coder();
|
|
8826
|
+
function encode2(data) {
|
|
8827
|
+
return stdCoder.encode(data);
|
|
8828
|
+
}
|
|
8829
|
+
exports.encode = encode2;
|
|
8830
|
+
function decode2(s) {
|
|
8831
|
+
return stdCoder.decode(s);
|
|
8832
|
+
}
|
|
8833
|
+
exports.decode = decode2;
|
|
8834
|
+
var URLSafeCoder = (
|
|
8835
|
+
/** @class */
|
|
8836
|
+
function(_super) {
|
|
8837
|
+
__extends(URLSafeCoder2, _super);
|
|
8838
|
+
function URLSafeCoder2() {
|
|
8839
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
8840
|
+
}
|
|
8841
|
+
URLSafeCoder2.prototype._encodeByte = function(b) {
|
|
8842
|
+
var result = b;
|
|
8843
|
+
result += 65;
|
|
8844
|
+
result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
|
|
8845
|
+
result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
|
|
8846
|
+
result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
|
|
8847
|
+
result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
|
|
8848
|
+
return String.fromCharCode(result);
|
|
8849
|
+
};
|
|
8850
|
+
URLSafeCoder2.prototype._decodeChar = function(c) {
|
|
8851
|
+
var result = INVALID_BYTE;
|
|
8852
|
+
result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
|
|
8853
|
+
result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
|
|
8854
|
+
result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
|
|
8855
|
+
result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
|
|
8856
|
+
result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
|
|
8857
|
+
return result;
|
|
8858
|
+
};
|
|
8859
|
+
return URLSafeCoder2;
|
|
8860
|
+
}(Coder)
|
|
8861
|
+
);
|
|
8862
|
+
exports.URLSafeCoder = URLSafeCoder;
|
|
8863
|
+
var urlSafeCoder = new URLSafeCoder();
|
|
8864
|
+
function encodeURLSafe(data) {
|
|
8865
|
+
return urlSafeCoder.encode(data);
|
|
8866
|
+
}
|
|
8867
|
+
exports.encodeURLSafe = encodeURLSafe;
|
|
8868
|
+
function decodeURLSafe(s) {
|
|
8869
|
+
return urlSafeCoder.decode(s);
|
|
8870
|
+
}
|
|
8871
|
+
exports.decodeURLSafe = decodeURLSafe;
|
|
8872
|
+
exports.encodedLength = function(length) {
|
|
8873
|
+
return stdCoder.encodedLength(length);
|
|
8874
|
+
};
|
|
8875
|
+
exports.maxDecodedLength = function(length) {
|
|
8876
|
+
return stdCoder.maxDecodedLength(length);
|
|
8877
|
+
};
|
|
8878
|
+
exports.decodedLength = function(s) {
|
|
8879
|
+
return stdCoder.decodedLength(s);
|
|
8880
|
+
};
|
|
8881
|
+
}
|
|
8882
|
+
});
|
|
8883
|
+
|
|
8884
|
+
// ../../node_modules/fast-sha256/sha256.js
|
|
8885
|
+
var require_sha256 = __commonJS({
|
|
8886
|
+
"../../node_modules/fast-sha256/sha256.js"(exports, module) {
|
|
8887
|
+
(function(root, factory) {
|
|
8888
|
+
var exports2 = {};
|
|
8889
|
+
factory(exports2);
|
|
8890
|
+
var sha2562 = exports2["default"];
|
|
8891
|
+
for (var k in exports2) {
|
|
8892
|
+
sha2562[k] = exports2[k];
|
|
8893
|
+
}
|
|
8894
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
8895
|
+
module.exports = sha2562;
|
|
8896
|
+
} else if (typeof define === "function" && define.amd) {
|
|
8897
|
+
define(function() {
|
|
8898
|
+
return sha2562;
|
|
8899
|
+
});
|
|
8900
|
+
} else {
|
|
8901
|
+
root.sha256 = sha2562;
|
|
8902
|
+
}
|
|
8903
|
+
})(exports, function(exports2) {
|
|
8904
|
+
exports2.__esModule = true;
|
|
8905
|
+
exports2.digestLength = 32;
|
|
8906
|
+
exports2.blockSize = 64;
|
|
8907
|
+
var K = new Uint32Array([
|
|
8908
|
+
1116352408,
|
|
8909
|
+
1899447441,
|
|
8910
|
+
3049323471,
|
|
8911
|
+
3921009573,
|
|
8912
|
+
961987163,
|
|
8913
|
+
1508970993,
|
|
8914
|
+
2453635748,
|
|
8915
|
+
2870763221,
|
|
8916
|
+
3624381080,
|
|
8917
|
+
310598401,
|
|
8918
|
+
607225278,
|
|
8919
|
+
1426881987,
|
|
8920
|
+
1925078388,
|
|
8921
|
+
2162078206,
|
|
8922
|
+
2614888103,
|
|
8923
|
+
3248222580,
|
|
8924
|
+
3835390401,
|
|
8925
|
+
4022224774,
|
|
8926
|
+
264347078,
|
|
8927
|
+
604807628,
|
|
8928
|
+
770255983,
|
|
8929
|
+
1249150122,
|
|
8930
|
+
1555081692,
|
|
8931
|
+
1996064986,
|
|
8932
|
+
2554220882,
|
|
8933
|
+
2821834349,
|
|
8934
|
+
2952996808,
|
|
8935
|
+
3210313671,
|
|
8936
|
+
3336571891,
|
|
8937
|
+
3584528711,
|
|
8938
|
+
113926993,
|
|
8939
|
+
338241895,
|
|
8940
|
+
666307205,
|
|
8941
|
+
773529912,
|
|
8942
|
+
1294757372,
|
|
8943
|
+
1396182291,
|
|
8944
|
+
1695183700,
|
|
8945
|
+
1986661051,
|
|
8946
|
+
2177026350,
|
|
8947
|
+
2456956037,
|
|
8948
|
+
2730485921,
|
|
8949
|
+
2820302411,
|
|
8950
|
+
3259730800,
|
|
8951
|
+
3345764771,
|
|
8952
|
+
3516065817,
|
|
8953
|
+
3600352804,
|
|
8954
|
+
4094571909,
|
|
8955
|
+
275423344,
|
|
8956
|
+
430227734,
|
|
8957
|
+
506948616,
|
|
8958
|
+
659060556,
|
|
8959
|
+
883997877,
|
|
8960
|
+
958139571,
|
|
8961
|
+
1322822218,
|
|
8962
|
+
1537002063,
|
|
8963
|
+
1747873779,
|
|
8964
|
+
1955562222,
|
|
8965
|
+
2024104815,
|
|
8966
|
+
2227730452,
|
|
8967
|
+
2361852424,
|
|
8968
|
+
2428436474,
|
|
8969
|
+
2756734187,
|
|
8970
|
+
3204031479,
|
|
8971
|
+
3329325298
|
|
8972
|
+
]);
|
|
8973
|
+
function hashBlocks(w, v, p, pos, len) {
|
|
8974
|
+
var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
|
|
8975
|
+
while (len >= 64) {
|
|
8976
|
+
a = v[0];
|
|
8977
|
+
b = v[1];
|
|
8978
|
+
c = v[2];
|
|
8979
|
+
d = v[3];
|
|
8980
|
+
e = v[4];
|
|
8981
|
+
f = v[5];
|
|
8982
|
+
g = v[6];
|
|
8983
|
+
h = v[7];
|
|
8984
|
+
for (i = 0; i < 16; i++) {
|
|
8985
|
+
j = pos + i * 4;
|
|
8986
|
+
w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
|
|
8987
|
+
}
|
|
8988
|
+
for (i = 16; i < 64; i++) {
|
|
8989
|
+
u = w[i - 2];
|
|
8990
|
+
t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
|
|
8991
|
+
u = w[i - 15];
|
|
8992
|
+
t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
|
|
8993
|
+
w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
|
|
8994
|
+
}
|
|
8995
|
+
for (i = 0; i < 64; i++) {
|
|
8996
|
+
t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f ^ ~e & g) | 0) + (h + (K[i] + w[i] | 0) | 0) | 0;
|
|
8997
|
+
t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
8998
|
+
h = g;
|
|
8999
|
+
g = f;
|
|
9000
|
+
f = e;
|
|
9001
|
+
e = d + t1 | 0;
|
|
9002
|
+
d = c;
|
|
9003
|
+
c = b;
|
|
9004
|
+
b = a;
|
|
9005
|
+
a = t1 + t2 | 0;
|
|
9006
|
+
}
|
|
9007
|
+
v[0] += a;
|
|
9008
|
+
v[1] += b;
|
|
9009
|
+
v[2] += c;
|
|
9010
|
+
v[3] += d;
|
|
9011
|
+
v[4] += e;
|
|
9012
|
+
v[5] += f;
|
|
9013
|
+
v[6] += g;
|
|
9014
|
+
v[7] += h;
|
|
9015
|
+
pos += 64;
|
|
9016
|
+
len -= 64;
|
|
9017
|
+
}
|
|
9018
|
+
return pos;
|
|
9019
|
+
}
|
|
9020
|
+
var Hash = (
|
|
9021
|
+
/** @class */
|
|
9022
|
+
function() {
|
|
9023
|
+
function Hash2() {
|
|
9024
|
+
this.digestLength = exports2.digestLength;
|
|
9025
|
+
this.blockSize = exports2.blockSize;
|
|
9026
|
+
this.state = new Int32Array(8);
|
|
9027
|
+
this.temp = new Int32Array(64);
|
|
9028
|
+
this.buffer = new Uint8Array(128);
|
|
9029
|
+
this.bufferLength = 0;
|
|
9030
|
+
this.bytesHashed = 0;
|
|
9031
|
+
this.finished = false;
|
|
9032
|
+
this.reset();
|
|
9033
|
+
}
|
|
9034
|
+
Hash2.prototype.reset = function() {
|
|
9035
|
+
this.state[0] = 1779033703;
|
|
9036
|
+
this.state[1] = 3144134277;
|
|
9037
|
+
this.state[2] = 1013904242;
|
|
9038
|
+
this.state[3] = 2773480762;
|
|
9039
|
+
this.state[4] = 1359893119;
|
|
9040
|
+
this.state[5] = 2600822924;
|
|
9041
|
+
this.state[6] = 528734635;
|
|
9042
|
+
this.state[7] = 1541459225;
|
|
9043
|
+
this.bufferLength = 0;
|
|
9044
|
+
this.bytesHashed = 0;
|
|
9045
|
+
this.finished = false;
|
|
9046
|
+
return this;
|
|
9047
|
+
};
|
|
9048
|
+
Hash2.prototype.clean = function() {
|
|
9049
|
+
for (var i = 0; i < this.buffer.length; i++) {
|
|
9050
|
+
this.buffer[i] = 0;
|
|
9051
|
+
}
|
|
9052
|
+
for (var i = 0; i < this.temp.length; i++) {
|
|
9053
|
+
this.temp[i] = 0;
|
|
9054
|
+
}
|
|
9055
|
+
this.reset();
|
|
9056
|
+
};
|
|
9057
|
+
Hash2.prototype.update = function(data, dataLength) {
|
|
9058
|
+
if (dataLength === void 0) {
|
|
9059
|
+
dataLength = data.length;
|
|
9060
|
+
}
|
|
9061
|
+
if (this.finished) {
|
|
9062
|
+
throw new Error("SHA256: can't update because hash was finished.");
|
|
9063
|
+
}
|
|
9064
|
+
var dataPos = 0;
|
|
9065
|
+
this.bytesHashed += dataLength;
|
|
9066
|
+
if (this.bufferLength > 0) {
|
|
9067
|
+
while (this.bufferLength < 64 && dataLength > 0) {
|
|
9068
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
9069
|
+
dataLength--;
|
|
9070
|
+
}
|
|
9071
|
+
if (this.bufferLength === 64) {
|
|
9072
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, 64);
|
|
9073
|
+
this.bufferLength = 0;
|
|
9074
|
+
}
|
|
9075
|
+
}
|
|
9076
|
+
if (dataLength >= 64) {
|
|
9077
|
+
dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
|
|
9078
|
+
dataLength %= 64;
|
|
9079
|
+
}
|
|
9080
|
+
while (dataLength > 0) {
|
|
9081
|
+
this.buffer[this.bufferLength++] = data[dataPos++];
|
|
9082
|
+
dataLength--;
|
|
9083
|
+
}
|
|
9084
|
+
return this;
|
|
9085
|
+
};
|
|
9086
|
+
Hash2.prototype.finish = function(out) {
|
|
9087
|
+
if (!this.finished) {
|
|
9088
|
+
var bytesHashed = this.bytesHashed;
|
|
9089
|
+
var left = this.bufferLength;
|
|
9090
|
+
var bitLenHi = bytesHashed / 536870912 | 0;
|
|
9091
|
+
var bitLenLo = bytesHashed << 3;
|
|
9092
|
+
var padLength = bytesHashed % 64 < 56 ? 64 : 128;
|
|
9093
|
+
this.buffer[left] = 128;
|
|
9094
|
+
for (var i = left + 1; i < padLength - 8; i++) {
|
|
9095
|
+
this.buffer[i] = 0;
|
|
9096
|
+
}
|
|
9097
|
+
this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
|
|
9098
|
+
this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
|
|
9099
|
+
this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
|
|
9100
|
+
this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
|
|
9101
|
+
this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
|
|
9102
|
+
this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
|
|
9103
|
+
this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
|
|
9104
|
+
this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
|
|
9105
|
+
hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
|
|
9106
|
+
this.finished = true;
|
|
9107
|
+
}
|
|
9108
|
+
for (var i = 0; i < 8; i++) {
|
|
9109
|
+
out[i * 4 + 0] = this.state[i] >>> 24 & 255;
|
|
9110
|
+
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
|
|
9111
|
+
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
|
|
9112
|
+
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
|
|
9113
|
+
}
|
|
9114
|
+
return this;
|
|
9115
|
+
};
|
|
9116
|
+
Hash2.prototype.digest = function() {
|
|
9117
|
+
var out = new Uint8Array(this.digestLength);
|
|
9118
|
+
this.finish(out);
|
|
9119
|
+
return out;
|
|
9120
|
+
};
|
|
9121
|
+
Hash2.prototype._saveState = function(out) {
|
|
9122
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
9123
|
+
out[i] = this.state[i];
|
|
9124
|
+
}
|
|
9125
|
+
};
|
|
9126
|
+
Hash2.prototype._restoreState = function(from, bytesHashed) {
|
|
9127
|
+
for (var i = 0; i < this.state.length; i++) {
|
|
9128
|
+
this.state[i] = from[i];
|
|
9129
|
+
}
|
|
9130
|
+
this.bytesHashed = bytesHashed;
|
|
9131
|
+
this.finished = false;
|
|
9132
|
+
this.bufferLength = 0;
|
|
9133
|
+
};
|
|
9134
|
+
return Hash2;
|
|
9135
|
+
}()
|
|
9136
|
+
);
|
|
9137
|
+
exports2.Hash = Hash;
|
|
9138
|
+
var HMAC = (
|
|
9139
|
+
/** @class */
|
|
9140
|
+
function() {
|
|
9141
|
+
function HMAC2(key) {
|
|
9142
|
+
this.inner = new Hash();
|
|
9143
|
+
this.outer = new Hash();
|
|
9144
|
+
this.blockSize = this.inner.blockSize;
|
|
9145
|
+
this.digestLength = this.inner.digestLength;
|
|
9146
|
+
var pad = new Uint8Array(this.blockSize);
|
|
9147
|
+
if (key.length > this.blockSize) {
|
|
9148
|
+
new Hash().update(key).finish(pad).clean();
|
|
9149
|
+
} else {
|
|
9150
|
+
for (var i = 0; i < key.length; i++) {
|
|
9151
|
+
pad[i] = key[i];
|
|
9152
|
+
}
|
|
9153
|
+
}
|
|
9154
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9155
|
+
pad[i] ^= 54;
|
|
9156
|
+
}
|
|
9157
|
+
this.inner.update(pad);
|
|
9158
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9159
|
+
pad[i] ^= 54 ^ 92;
|
|
9160
|
+
}
|
|
9161
|
+
this.outer.update(pad);
|
|
9162
|
+
this.istate = new Uint32Array(8);
|
|
9163
|
+
this.ostate = new Uint32Array(8);
|
|
9164
|
+
this.inner._saveState(this.istate);
|
|
9165
|
+
this.outer._saveState(this.ostate);
|
|
9166
|
+
for (var i = 0; i < pad.length; i++) {
|
|
9167
|
+
pad[i] = 0;
|
|
9168
|
+
}
|
|
9169
|
+
}
|
|
9170
|
+
HMAC2.prototype.reset = function() {
|
|
9171
|
+
this.inner._restoreState(this.istate, this.inner.blockSize);
|
|
9172
|
+
this.outer._restoreState(this.ostate, this.outer.blockSize);
|
|
9173
|
+
return this;
|
|
9174
|
+
};
|
|
9175
|
+
HMAC2.prototype.clean = function() {
|
|
9176
|
+
for (var i = 0; i < this.istate.length; i++) {
|
|
9177
|
+
this.ostate[i] = this.istate[i] = 0;
|
|
9178
|
+
}
|
|
9179
|
+
this.inner.clean();
|
|
9180
|
+
this.outer.clean();
|
|
9181
|
+
};
|
|
9182
|
+
HMAC2.prototype.update = function(data) {
|
|
9183
|
+
this.inner.update(data);
|
|
9184
|
+
return this;
|
|
9185
|
+
};
|
|
9186
|
+
HMAC2.prototype.finish = function(out) {
|
|
9187
|
+
if (this.outer.finished) {
|
|
9188
|
+
this.outer.finish(out);
|
|
9189
|
+
} else {
|
|
9190
|
+
this.inner.finish(out);
|
|
9191
|
+
this.outer.update(out, this.digestLength).finish(out);
|
|
9192
|
+
}
|
|
9193
|
+
return this;
|
|
9194
|
+
};
|
|
9195
|
+
HMAC2.prototype.digest = function() {
|
|
9196
|
+
var out = new Uint8Array(this.digestLength);
|
|
9197
|
+
this.finish(out);
|
|
9198
|
+
return out;
|
|
9199
|
+
};
|
|
9200
|
+
return HMAC2;
|
|
9201
|
+
}()
|
|
9202
|
+
);
|
|
9203
|
+
exports2.HMAC = HMAC;
|
|
9204
|
+
function hash(data) {
|
|
9205
|
+
var h = new Hash().update(data);
|
|
9206
|
+
var digest = h.digest();
|
|
9207
|
+
h.clean();
|
|
9208
|
+
return digest;
|
|
9209
|
+
}
|
|
9210
|
+
exports2.hash = hash;
|
|
9211
|
+
exports2["default"] = hash;
|
|
9212
|
+
function hmac2(key, data) {
|
|
9213
|
+
var h = new HMAC(key).update(data);
|
|
9214
|
+
var digest = h.digest();
|
|
9215
|
+
h.clean();
|
|
9216
|
+
return digest;
|
|
9217
|
+
}
|
|
9218
|
+
exports2.hmac = hmac2;
|
|
9219
|
+
function fillBuffer(buffer, hmac3, info, counter) {
|
|
9220
|
+
var num = counter[0];
|
|
9221
|
+
if (num === 0) {
|
|
9222
|
+
throw new Error("hkdf: cannot expand more");
|
|
9223
|
+
}
|
|
9224
|
+
hmac3.reset();
|
|
9225
|
+
if (num > 1) {
|
|
9226
|
+
hmac3.update(buffer);
|
|
9227
|
+
}
|
|
9228
|
+
if (info) {
|
|
9229
|
+
hmac3.update(info);
|
|
9230
|
+
}
|
|
9231
|
+
hmac3.update(counter);
|
|
9232
|
+
hmac3.finish(buffer);
|
|
9233
|
+
counter[0]++;
|
|
9234
|
+
}
|
|
9235
|
+
var hkdfSalt = new Uint8Array(exports2.digestLength);
|
|
9236
|
+
function hkdf(key, salt, info, length) {
|
|
9237
|
+
if (salt === void 0) {
|
|
9238
|
+
salt = hkdfSalt;
|
|
9239
|
+
}
|
|
9240
|
+
if (length === void 0) {
|
|
9241
|
+
length = 32;
|
|
9242
|
+
}
|
|
9243
|
+
var counter = new Uint8Array([1]);
|
|
9244
|
+
var okm = hmac2(salt, key);
|
|
9245
|
+
var hmac_ = new HMAC(okm);
|
|
9246
|
+
var buffer = new Uint8Array(hmac_.digestLength);
|
|
9247
|
+
var bufpos = buffer.length;
|
|
9248
|
+
var out = new Uint8Array(length);
|
|
9249
|
+
for (var i = 0; i < length; i++) {
|
|
9250
|
+
if (bufpos === buffer.length) {
|
|
9251
|
+
fillBuffer(buffer, hmac_, info, counter);
|
|
9252
|
+
bufpos = 0;
|
|
9253
|
+
}
|
|
9254
|
+
out[i] = buffer[bufpos++];
|
|
9255
|
+
}
|
|
9256
|
+
hmac_.clean();
|
|
9257
|
+
buffer.fill(0);
|
|
9258
|
+
counter.fill(0);
|
|
9259
|
+
return out;
|
|
9260
|
+
}
|
|
9261
|
+
exports2.hkdf = hkdf;
|
|
9262
|
+
function pbkdf2(password, salt, iterations, dkLen) {
|
|
9263
|
+
var prf = new HMAC(password);
|
|
9264
|
+
var len = prf.digestLength;
|
|
9265
|
+
var ctr = new Uint8Array(4);
|
|
9266
|
+
var t = new Uint8Array(len);
|
|
9267
|
+
var u = new Uint8Array(len);
|
|
9268
|
+
var dk = new Uint8Array(dkLen);
|
|
9269
|
+
for (var i = 0; i * len < dkLen; i++) {
|
|
9270
|
+
var c = i + 1;
|
|
9271
|
+
ctr[0] = c >>> 24 & 255;
|
|
9272
|
+
ctr[1] = c >>> 16 & 255;
|
|
9273
|
+
ctr[2] = c >>> 8 & 255;
|
|
9274
|
+
ctr[3] = c >>> 0 & 255;
|
|
9275
|
+
prf.reset();
|
|
9276
|
+
prf.update(salt);
|
|
9277
|
+
prf.update(ctr);
|
|
9278
|
+
prf.finish(u);
|
|
9279
|
+
for (var j = 0; j < len; j++) {
|
|
9280
|
+
t[j] = u[j];
|
|
9281
|
+
}
|
|
9282
|
+
for (var j = 2; j <= iterations; j++) {
|
|
9283
|
+
prf.reset();
|
|
9284
|
+
prf.update(u).finish(u);
|
|
9285
|
+
for (var k = 0; k < len; k++) {
|
|
9286
|
+
t[k] ^= u[k];
|
|
9287
|
+
}
|
|
9288
|
+
}
|
|
9289
|
+
for (var j = 0; j < len && i * len + j < dkLen; j++) {
|
|
9290
|
+
dk[i * len + j] = t[j];
|
|
9291
|
+
}
|
|
9292
|
+
}
|
|
9293
|
+
for (var i = 0; i < len; i++) {
|
|
9294
|
+
t[i] = u[i] = 0;
|
|
9295
|
+
}
|
|
9296
|
+
for (var i = 0; i < 4; i++) {
|
|
9297
|
+
ctr[i] = 0;
|
|
9298
|
+
}
|
|
9299
|
+
prf.clean();
|
|
9300
|
+
return dk;
|
|
9301
|
+
}
|
|
9302
|
+
exports2.pbkdf2 = pbkdf2;
|
|
9303
|
+
});
|
|
9304
|
+
}
|
|
9305
|
+
});
|
|
9306
|
+
|
|
9307
|
+
// src/webhook/vendor/standardwebhook.ts
|
|
9308
|
+
__toESM(require_base64());
|
|
9309
|
+
__toESM(require_sha256());
|
|
9310
|
+
/**
|
|
9311
|
+
* The MIT License
|
|
9312
|
+
*
|
|
9313
|
+
* Copyright (c) 2023 Svix (https://www.svix.com)
|
|
9314
|
+
*
|
|
9315
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9316
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9317
|
+
* in the Software without restriction, including without limitation the rights
|
|
9318
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9319
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9320
|
+
* furnished to do so, subject to the following conditions:
|
|
9321
|
+
*
|
|
9322
|
+
* The above copyright notice and this permission notice shall be included in
|
|
9323
|
+
* all copies or substantial portions of the Software.
|
|
9324
|
+
*
|
|
9325
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
9326
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
9327
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
9328
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
9329
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
9330
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
9331
|
+
* THE SOFTWARE.
|
|
9332
|
+
*
|
|
9333
|
+
* @fileoverview Server-only webhook verification implementation.
|
|
9334
|
+
* @description Vendored from standardwebhooks package to avoid bundling issues.
|
|
9335
|
+
* Uses Node.js crypto module - DO NOT import in client/browser code.
|
|
9336
|
+
* @license MIT
|
|
9337
|
+
* @internal
|
|
9338
|
+
*/
|
|
9339
|
+
|
|
9340
|
+
// src/webhook/webhook.ts
|
|
7982
9341
|
async function handleWebhookPayload(payload, config, context) {
|
|
7983
9342
|
const callHandler = (handler, payload2) => {
|
|
7984
9343
|
if (!handler) return;
|
|
@@ -8035,9 +9394,6 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8035
9394
|
if (payload.type === "subscription.renewed") {
|
|
8036
9395
|
await callHandler(config.onSubscriptionRenewed, payload);
|
|
8037
9396
|
}
|
|
8038
|
-
if (payload.type === "subscription.paused") {
|
|
8039
|
-
await callHandler(config.onSubscriptionPaused, payload);
|
|
8040
|
-
}
|
|
8041
9397
|
if (payload.type === "subscription.plan_changed") {
|
|
8042
9398
|
await callHandler(config.onSubscriptionPlanChanged, payload);
|
|
8043
9399
|
}
|
|
@@ -8056,6 +9412,30 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8056
9412
|
if (payload.type === "license_key.created") {
|
|
8057
9413
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
8058
9414
|
}
|
|
9415
|
+
if (payload.type === "credit.added") {
|
|
9416
|
+
await callHandler(config.onCreditAdded, payload);
|
|
9417
|
+
}
|
|
9418
|
+
if (payload.type === "credit.deducted") {
|
|
9419
|
+
await callHandler(config.onCreditDeducted, payload);
|
|
9420
|
+
}
|
|
9421
|
+
if (payload.type === "credit.expired") {
|
|
9422
|
+
await callHandler(config.onCreditExpired, payload);
|
|
9423
|
+
}
|
|
9424
|
+
if (payload.type === "credit.rolled_over") {
|
|
9425
|
+
await callHandler(config.onCreditRolledOver, payload);
|
|
9426
|
+
}
|
|
9427
|
+
if (payload.type === "credit.rollover_forfeited") {
|
|
9428
|
+
await callHandler(config.onCreditRolloverForfeited, payload);
|
|
9429
|
+
}
|
|
9430
|
+
if (payload.type === "credit.overage_charged") {
|
|
9431
|
+
await callHandler(config.onCreditOverageCharged, payload);
|
|
9432
|
+
}
|
|
9433
|
+
if (payload.type === "credit.manual_adjustment") {
|
|
9434
|
+
await callHandler(config.onCreditManualAdjustment, payload);
|
|
9435
|
+
}
|
|
9436
|
+
if (payload.type === "credit.balance_low") {
|
|
9437
|
+
await callHandler(config.onCreditBalanceLow, payload);
|
|
9438
|
+
}
|
|
8059
9439
|
}
|
|
8060
9440
|
|
|
8061
9441
|
const Webhooks = ({ webhookKey, ...eventHandlers }) => {
|