@dodopayments/remix 0.2.5 → 0.2.6
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/customer-portal.d.ts.map +1 -1
- package/dist/index.cjs +810 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +810 -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 });
|
|
4970
|
+
preview(body, options) {
|
|
4971
|
+
return this._client.post('/checkouts/preview', { body, ...options });
|
|
4956
4972
|
}
|
|
4957
4973
|
}
|
|
4958
4974
|
|
|
4959
4975
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
4960
|
-
class
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
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({
|
|
@@ -7629,23 +8115,33 @@ var PaymentSchema = objectType({
|
|
|
7629
8115
|
payload_type: literalType("Payment"),
|
|
7630
8116
|
billing: objectType({
|
|
7631
8117
|
city: stringType().nullable(),
|
|
7632
|
-
country: stringType()
|
|
8118
|
+
country: stringType(),
|
|
7633
8119
|
state: stringType().nullable(),
|
|
7634
8120
|
street: stringType().nullable(),
|
|
7635
8121
|
zipcode: stringType().nullable()
|
|
7636
8122
|
}),
|
|
7637
8123
|
brand_id: stringType(),
|
|
7638
8124
|
business_id: stringType(),
|
|
8125
|
+
card_holder_name: stringType().nullable(),
|
|
7639
8126
|
card_issuing_country: stringType().nullable(),
|
|
7640
8127
|
card_last_four: stringType().nullable(),
|
|
7641
8128
|
card_network: stringType().nullable(),
|
|
7642
8129
|
card_type: stringType().nullable(),
|
|
8130
|
+
checkout_session_id: stringType().nullable(),
|
|
7643
8131
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7644
8132
|
currency: stringType(),
|
|
8133
|
+
custom_field_responses: arrayType(
|
|
8134
|
+
objectType({
|
|
8135
|
+
key: stringType(),
|
|
8136
|
+
value: stringType()
|
|
8137
|
+
})
|
|
8138
|
+
).nullable(),
|
|
7645
8139
|
customer: objectType({
|
|
7646
8140
|
customer_id: stringType(),
|
|
7647
8141
|
email: stringType(),
|
|
7648
|
-
|
|
8142
|
+
metadata: recordType(anyType()),
|
|
8143
|
+
name: stringType(),
|
|
8144
|
+
phone_number: stringType().nullable()
|
|
7649
8145
|
}),
|
|
7650
8146
|
digital_products_delivered: booleanType(),
|
|
7651
8147
|
discount_id: stringType().nullable(),
|
|
@@ -7656,27 +8152,25 @@ var PaymentSchema = objectType({
|
|
|
7656
8152
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7657
8153
|
currency: stringType(),
|
|
7658
8154
|
dispute_id: stringType(),
|
|
7659
|
-
dispute_stage: enumType([
|
|
7660
|
-
"pre_dispute",
|
|
7661
|
-
"dispute_opened",
|
|
7662
|
-
"dispute_won",
|
|
7663
|
-
"dispute_lost"
|
|
7664
|
-
]),
|
|
8155
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7665
8156
|
dispute_status: enumType([
|
|
7666
8157
|
"dispute_opened",
|
|
7667
|
-
"
|
|
7668
|
-
"dispute_lost",
|
|
8158
|
+
"dispute_expired",
|
|
7669
8159
|
"dispute_accepted",
|
|
7670
8160
|
"dispute_cancelled",
|
|
7671
|
-
"dispute_challenged"
|
|
8161
|
+
"dispute_challenged",
|
|
8162
|
+
"dispute_won",
|
|
8163
|
+
"dispute_lost"
|
|
7672
8164
|
]),
|
|
7673
8165
|
payment_id: stringType(),
|
|
7674
8166
|
remarks: stringType().nullable()
|
|
7675
8167
|
})
|
|
7676
|
-
).
|
|
8168
|
+
).default([]),
|
|
7677
8169
|
error_code: stringType().nullable(),
|
|
7678
8170
|
error_message: stringType().nullable(),
|
|
7679
|
-
|
|
8171
|
+
invoice_id: stringType().nullable(),
|
|
8172
|
+
invoice_url: stringType().nullable(),
|
|
8173
|
+
metadata: recordType(anyType()),
|
|
7680
8174
|
payment_id: stringType(),
|
|
7681
8175
|
payment_link: stringType().nullable(),
|
|
7682
8176
|
payment_method: stringType().nullable(),
|
|
@@ -7689,21 +8183,34 @@ var PaymentSchema = objectType({
|
|
|
7689
8183
|
).nullable(),
|
|
7690
8184
|
refunds: arrayType(
|
|
7691
8185
|
objectType({
|
|
7692
|
-
amount: numberType(),
|
|
8186
|
+
amount: numberType().nullable(),
|
|
7693
8187
|
business_id: stringType(),
|
|
7694
8188
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7695
|
-
currency: stringType(),
|
|
8189
|
+
currency: stringType().nullable(),
|
|
7696
8190
|
is_partial: booleanType(),
|
|
7697
8191
|
payment_id: stringType(),
|
|
7698
8192
|
reason: stringType().nullable(),
|
|
7699
8193
|
refund_id: stringType(),
|
|
7700
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8194
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7701
8195
|
})
|
|
7702
|
-
)
|
|
8196
|
+
),
|
|
8197
|
+
refund_status: enumType(["partial", "full"]).nullable(),
|
|
7703
8198
|
settlement_amount: numberType(),
|
|
7704
8199
|
settlement_currency: stringType(),
|
|
7705
8200
|
settlement_tax: numberType().nullable(),
|
|
7706
|
-
status: enumType([
|
|
8201
|
+
status: enumType([
|
|
8202
|
+
"succeeded",
|
|
8203
|
+
"failed",
|
|
8204
|
+
"cancelled",
|
|
8205
|
+
"processing",
|
|
8206
|
+
"requires_customer_action",
|
|
8207
|
+
"requires_merchant_action",
|
|
8208
|
+
"requires_payment_method",
|
|
8209
|
+
"requires_confirmation",
|
|
8210
|
+
"requires_capture",
|
|
8211
|
+
"partially_captured",
|
|
8212
|
+
"partially_captured_and_capturable"
|
|
8213
|
+
]).nullable(),
|
|
7707
8214
|
subscription_id: stringType().nullable(),
|
|
7708
8215
|
tax: numberType().nullable(),
|
|
7709
8216
|
total_amount: numberType(),
|
|
@@ -7716,10 +8223,10 @@ var SubscriptionSchema = objectType({
|
|
|
7716
8223
|
addon_id: stringType(),
|
|
7717
8224
|
quantity: numberType()
|
|
7718
8225
|
})
|
|
7719
|
-
)
|
|
8226
|
+
),
|
|
7720
8227
|
billing: objectType({
|
|
7721
8228
|
city: stringType().nullable(),
|
|
7722
|
-
country: stringType()
|
|
8229
|
+
country: stringType(),
|
|
7723
8230
|
state: stringType().nullable(),
|
|
7724
8231
|
street: stringType().nullable(),
|
|
7725
8232
|
zipcode: stringType().nullable()
|
|
@@ -7731,15 +8238,72 @@ var SubscriptionSchema = objectType({
|
|
|
7731
8238
|
customer: objectType({
|
|
7732
8239
|
customer_id: stringType(),
|
|
7733
8240
|
email: stringType(),
|
|
7734
|
-
|
|
8241
|
+
metadata: recordType(anyType()),
|
|
8242
|
+
name: stringType(),
|
|
8243
|
+
phone_number: stringType().nullable()
|
|
7735
8244
|
}),
|
|
8245
|
+
custom_field_responses: arrayType(
|
|
8246
|
+
objectType({
|
|
8247
|
+
key: stringType(),
|
|
8248
|
+
value: stringType()
|
|
8249
|
+
})
|
|
8250
|
+
).nullable(),
|
|
8251
|
+
discount_cycles_remaining: numberType().nullable(),
|
|
7736
8252
|
discount_id: stringType().nullable(),
|
|
7737
|
-
|
|
7738
|
-
|
|
8253
|
+
expires_at: stringType().transform((d) => new Date(d)).nullable(),
|
|
8254
|
+
credit_entitlement_cart: arrayType(
|
|
8255
|
+
objectType({
|
|
8256
|
+
credit_entitlement_id: stringType(),
|
|
8257
|
+
credit_entitlement_name: stringType(),
|
|
8258
|
+
credits_amount: stringType(),
|
|
8259
|
+
overage_balance: stringType(),
|
|
8260
|
+
overage_behavior: enumType([
|
|
8261
|
+
"forgive_at_reset",
|
|
8262
|
+
"invoice_at_billing",
|
|
8263
|
+
"carry_deficit",
|
|
8264
|
+
"carry_deficit_auto_repay"
|
|
8265
|
+
]),
|
|
8266
|
+
overage_enabled: booleanType(),
|
|
8267
|
+
product_id: stringType(),
|
|
8268
|
+
remaining_balance: stringType(),
|
|
8269
|
+
rollover_enabled: booleanType(),
|
|
8270
|
+
unit: stringType(),
|
|
8271
|
+
expires_after_days: numberType().nullable(),
|
|
8272
|
+
low_balance_threshold_percent: numberType().nullable(),
|
|
8273
|
+
max_rollover_count: numberType().nullable(),
|
|
8274
|
+
overage_limit: stringType().nullable(),
|
|
8275
|
+
rollover_percentage: numberType().nullable(),
|
|
8276
|
+
rollover_timeframe_count: numberType().nullable(),
|
|
8277
|
+
rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
|
|
8278
|
+
})
|
|
8279
|
+
),
|
|
8280
|
+
meter_credit_entitlement_cart: arrayType(
|
|
8281
|
+
objectType({
|
|
8282
|
+
credit_entitlement_id: stringType(),
|
|
8283
|
+
meter_id: stringType(),
|
|
8284
|
+
meter_name: stringType(),
|
|
8285
|
+
meter_units_per_credit: stringType(),
|
|
8286
|
+
product_id: stringType()
|
|
8287
|
+
})
|
|
8288
|
+
),
|
|
8289
|
+
meters: arrayType(
|
|
8290
|
+
objectType({
|
|
8291
|
+
currency: stringType(),
|
|
8292
|
+
description: stringType().nullable(),
|
|
8293
|
+
free_threshold: numberType(),
|
|
8294
|
+
measurement_unit: stringType(),
|
|
8295
|
+
meter_id: stringType(),
|
|
8296
|
+
name: stringType(),
|
|
8297
|
+
price_per_unit: stringType().nullable()
|
|
8298
|
+
})
|
|
8299
|
+
),
|
|
8300
|
+
metadata: recordType(anyType()),
|
|
8301
|
+
next_billing_date: stringType().transform((d) => new Date(d)),
|
|
7739
8302
|
on_demand: booleanType(),
|
|
7740
8303
|
payment_frequency_count: numberType(),
|
|
7741
8304
|
payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
7742
|
-
|
|
8305
|
+
payment_method_id: stringType().nullable(),
|
|
8306
|
+
previous_billing_date: stringType().transform((d) => new Date(d)),
|
|
7743
8307
|
product_id: stringType(),
|
|
7744
8308
|
quantity: numberType(),
|
|
7745
8309
|
recurring_pre_tax_amount: numberType(),
|
|
@@ -7747,7 +8311,6 @@ var SubscriptionSchema = objectType({
|
|
|
7747
8311
|
"pending",
|
|
7748
8312
|
"active",
|
|
7749
8313
|
"on_hold",
|
|
7750
|
-
"paused",
|
|
7751
8314
|
"cancelled",
|
|
7752
8315
|
"expired",
|
|
7753
8316
|
"failed"
|
|
@@ -7755,20 +8318,29 @@ var SubscriptionSchema = objectType({
|
|
|
7755
8318
|
subscription_id: stringType(),
|
|
7756
8319
|
subscription_period_count: numberType(),
|
|
7757
8320
|
subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
8321
|
+
tax_id: stringType().nullable(),
|
|
7758
8322
|
tax_inclusive: booleanType(),
|
|
7759
8323
|
trial_period_days: numberType()
|
|
7760
8324
|
});
|
|
7761
8325
|
var RefundSchema = objectType({
|
|
7762
8326
|
payload_type: literalType("Refund"),
|
|
7763
|
-
amount: numberType(),
|
|
8327
|
+
amount: numberType().nullable(),
|
|
7764
8328
|
business_id: stringType(),
|
|
7765
8329
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7766
|
-
|
|
8330
|
+
customer: objectType({
|
|
8331
|
+
customer_id: stringType(),
|
|
8332
|
+
email: stringType(),
|
|
8333
|
+
metadata: recordType(anyType()),
|
|
8334
|
+
name: stringType(),
|
|
8335
|
+
phone_number: stringType().nullable()
|
|
8336
|
+
}),
|
|
8337
|
+
currency: stringType().nullable(),
|
|
7767
8338
|
is_partial: booleanType(),
|
|
8339
|
+
metadata: recordType(anyType()),
|
|
7768
8340
|
payment_id: stringType(),
|
|
7769
8341
|
reason: stringType().nullable(),
|
|
7770
8342
|
refund_id: stringType(),
|
|
7771
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
8343
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
7772
8344
|
});
|
|
7773
8345
|
var DisputeSchema = objectType({
|
|
7774
8346
|
payload_type: literalType("Dispute"),
|
|
@@ -7776,27 +8348,31 @@ var DisputeSchema = objectType({
|
|
|
7776
8348
|
business_id: stringType(),
|
|
7777
8349
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7778
8350
|
currency: stringType(),
|
|
8351
|
+
customer: objectType({
|
|
8352
|
+
customer_id: stringType(),
|
|
8353
|
+
email: stringType(),
|
|
8354
|
+
metadata: recordType(anyType()),
|
|
8355
|
+
name: stringType(),
|
|
8356
|
+
phone_number: stringType().nullable()
|
|
8357
|
+
}),
|
|
7779
8358
|
dispute_id: stringType(),
|
|
7780
|
-
dispute_stage: enumType([
|
|
7781
|
-
"pre_dispute",
|
|
7782
|
-
"dispute_opened",
|
|
7783
|
-
"dispute_won",
|
|
7784
|
-
"dispute_lost"
|
|
7785
|
-
]),
|
|
8359
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
7786
8360
|
dispute_status: enumType([
|
|
7787
8361
|
"dispute_opened",
|
|
7788
|
-
"
|
|
7789
|
-
"dispute_lost",
|
|
8362
|
+
"dispute_expired",
|
|
7790
8363
|
"dispute_accepted",
|
|
7791
8364
|
"dispute_cancelled",
|
|
7792
|
-
"dispute_challenged"
|
|
8365
|
+
"dispute_challenged",
|
|
8366
|
+
"dispute_won",
|
|
8367
|
+
"dispute_lost"
|
|
7793
8368
|
]),
|
|
7794
8369
|
payment_id: stringType(),
|
|
8370
|
+
reason: stringType().nullable(),
|
|
7795
8371
|
remarks: stringType().nullable()
|
|
7796
8372
|
});
|
|
7797
8373
|
var LicenseKeySchema = objectType({
|
|
7798
8374
|
payload_type: literalType("LicenseKey"),
|
|
7799
|
-
activations_limit: numberType(),
|
|
8375
|
+
activations_limit: numberType().nullable(),
|
|
7800
8376
|
business_id: stringType(),
|
|
7801
8377
|
created_at: stringType().transform((d) => new Date(d)),
|
|
7802
8378
|
customer_id: stringType(),
|
|
@@ -7806,7 +8382,7 @@ var LicenseKeySchema = objectType({
|
|
|
7806
8382
|
key: stringType(),
|
|
7807
8383
|
payment_id: stringType(),
|
|
7808
8384
|
product_id: stringType(),
|
|
7809
|
-
status: enumType(["active", "
|
|
8385
|
+
status: enumType(["active", "expired", "disabled"]),
|
|
7810
8386
|
subscription_id: stringType().nullable()
|
|
7811
8387
|
});
|
|
7812
8388
|
var PaymentSucceededPayloadSchema = objectType({
|
|
@@ -7905,12 +8481,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
|
|
|
7905
8481
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7906
8482
|
data: SubscriptionSchema
|
|
7907
8483
|
});
|
|
7908
|
-
var SubscriptionPausedPayloadSchema = objectType({
|
|
7909
|
-
business_id: stringType(),
|
|
7910
|
-
type: literalType("subscription.paused"),
|
|
7911
|
-
timestamp: stringType().transform((d) => new Date(d)),
|
|
7912
|
-
data: SubscriptionSchema
|
|
7913
|
-
});
|
|
7914
8484
|
var SubscriptionPlanChangedPayloadSchema = objectType({
|
|
7915
8485
|
business_id: stringType(),
|
|
7916
8486
|
type: literalType("subscription.plan_changed"),
|
|
@@ -7947,6 +8517,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
|
|
|
7947
8517
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
7948
8518
|
data: LicenseKeySchema
|
|
7949
8519
|
});
|
|
8520
|
+
var CreditLedgerEntrySchema = objectType({
|
|
8521
|
+
payload_type: literalType("CreditLedgerEntry"),
|
|
8522
|
+
id: stringType(),
|
|
8523
|
+
amount: stringType(),
|
|
8524
|
+
balance_after: stringType(),
|
|
8525
|
+
balance_before: stringType(),
|
|
8526
|
+
business_id: stringType(),
|
|
8527
|
+
created_at: stringType().transform((d) => new Date(d)),
|
|
8528
|
+
credit_entitlement_id: stringType(),
|
|
8529
|
+
customer_id: stringType(),
|
|
8530
|
+
is_credit: booleanType(),
|
|
8531
|
+
overage_after: stringType(),
|
|
8532
|
+
overage_before: stringType(),
|
|
8533
|
+
transaction_type: enumType([
|
|
8534
|
+
"credit_added",
|
|
8535
|
+
"credit_deducted",
|
|
8536
|
+
"credit_expired",
|
|
8537
|
+
"credit_rolled_over",
|
|
8538
|
+
"rollover_forfeited",
|
|
8539
|
+
"overage_charged",
|
|
8540
|
+
"auto_top_up",
|
|
8541
|
+
"manual_adjustment",
|
|
8542
|
+
"refund"
|
|
8543
|
+
]),
|
|
8544
|
+
description: stringType().nullable(),
|
|
8545
|
+
grant_id: stringType().nullable(),
|
|
8546
|
+
reference_id: stringType().nullable(),
|
|
8547
|
+
reference_type: stringType().nullable()
|
|
8548
|
+
});
|
|
8549
|
+
var CreditBalanceLowSchema = objectType({
|
|
8550
|
+
payload_type: literalType("CreditBalanceLow"),
|
|
8551
|
+
customer_id: stringType(),
|
|
8552
|
+
subscription_id: stringType(),
|
|
8553
|
+
credit_entitlement_id: stringType(),
|
|
8554
|
+
credit_entitlement_name: stringType(),
|
|
8555
|
+
available_balance: stringType(),
|
|
8556
|
+
subscription_credits_amount: stringType(),
|
|
8557
|
+
threshold_percent: numberType(),
|
|
8558
|
+
threshold_amount: stringType()
|
|
8559
|
+
});
|
|
8560
|
+
var CreditAddedPayloadSchema = objectType({
|
|
8561
|
+
business_id: stringType(),
|
|
8562
|
+
type: literalType("credit.added"),
|
|
8563
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8564
|
+
data: CreditLedgerEntrySchema
|
|
8565
|
+
});
|
|
8566
|
+
var CreditDeductedPayloadSchema = objectType({
|
|
8567
|
+
business_id: stringType(),
|
|
8568
|
+
type: literalType("credit.deducted"),
|
|
8569
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8570
|
+
data: CreditLedgerEntrySchema
|
|
8571
|
+
});
|
|
8572
|
+
var CreditExpiredPayloadSchema = objectType({
|
|
8573
|
+
business_id: stringType(),
|
|
8574
|
+
type: literalType("credit.expired"),
|
|
8575
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8576
|
+
data: CreditLedgerEntrySchema
|
|
8577
|
+
});
|
|
8578
|
+
var CreditRolledOverPayloadSchema = objectType({
|
|
8579
|
+
business_id: stringType(),
|
|
8580
|
+
type: literalType("credit.rolled_over"),
|
|
8581
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8582
|
+
data: CreditLedgerEntrySchema
|
|
8583
|
+
});
|
|
8584
|
+
var CreditRolloverForfeitedPayloadSchema = objectType({
|
|
8585
|
+
business_id: stringType(),
|
|
8586
|
+
type: literalType("credit.rollover_forfeited"),
|
|
8587
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8588
|
+
data: CreditLedgerEntrySchema
|
|
8589
|
+
});
|
|
8590
|
+
var CreditOverageChargedPayloadSchema = objectType({
|
|
8591
|
+
business_id: stringType(),
|
|
8592
|
+
type: literalType("credit.overage_charged"),
|
|
8593
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8594
|
+
data: CreditLedgerEntrySchema
|
|
8595
|
+
});
|
|
8596
|
+
var CreditManualAdjustmentPayloadSchema = objectType({
|
|
8597
|
+
business_id: stringType(),
|
|
8598
|
+
type: literalType("credit.manual_adjustment"),
|
|
8599
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8600
|
+
data: CreditLedgerEntrySchema
|
|
8601
|
+
});
|
|
8602
|
+
var CreditBalanceLowPayloadSchema = objectType({
|
|
8603
|
+
business_id: stringType(),
|
|
8604
|
+
type: literalType("credit.balance_low"),
|
|
8605
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
8606
|
+
data: CreditBalanceLowSchema
|
|
8607
|
+
});
|
|
7950
8608
|
var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
7951
8609
|
PaymentSucceededPayloadSchema,
|
|
7952
8610
|
PaymentFailedPayloadSchema,
|
|
@@ -7964,13 +8622,20 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
7964
8622
|
SubscriptionActivePayloadSchema,
|
|
7965
8623
|
SubscriptionOnHoldPayloadSchema,
|
|
7966
8624
|
SubscriptionRenewedPayloadSchema,
|
|
7967
|
-
SubscriptionPausedPayloadSchema,
|
|
7968
8625
|
SubscriptionPlanChangedPayloadSchema,
|
|
7969
8626
|
SubscriptionCancelledPayloadSchema,
|
|
7970
8627
|
SubscriptionFailedPayloadSchema,
|
|
7971
8628
|
SubscriptionExpiredPayloadSchema,
|
|
7972
8629
|
SubscriptionUpdatedPayloadSchema,
|
|
7973
|
-
LicenseKeyCreatedPayloadSchema
|
|
8630
|
+
LicenseKeyCreatedPayloadSchema,
|
|
8631
|
+
CreditAddedPayloadSchema,
|
|
8632
|
+
CreditDeductedPayloadSchema,
|
|
8633
|
+
CreditExpiredPayloadSchema,
|
|
8634
|
+
CreditRolledOverPayloadSchema,
|
|
8635
|
+
CreditRolloverForfeitedPayloadSchema,
|
|
8636
|
+
CreditOverageChargedPayloadSchema,
|
|
8637
|
+
CreditManualAdjustmentPayloadSchema,
|
|
8638
|
+
CreditBalanceLowPayloadSchema
|
|
7974
8639
|
]);
|
|
7975
8640
|
|
|
7976
8641
|
// ../../node_modules/@stablelib/base64/lib/base64.js
|
|
@@ -8698,9 +9363,6 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8698
9363
|
if (payload.type === "subscription.renewed") {
|
|
8699
9364
|
await callHandler(config.onSubscriptionRenewed, payload);
|
|
8700
9365
|
}
|
|
8701
|
-
if (payload.type === "subscription.paused") {
|
|
8702
|
-
await callHandler(config.onSubscriptionPaused, payload);
|
|
8703
|
-
}
|
|
8704
9366
|
if (payload.type === "subscription.plan_changed") {
|
|
8705
9367
|
await callHandler(config.onSubscriptionPlanChanged, payload);
|
|
8706
9368
|
}
|
|
@@ -8719,6 +9381,30 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
8719
9381
|
if (payload.type === "license_key.created") {
|
|
8720
9382
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
8721
9383
|
}
|
|
9384
|
+
if (payload.type === "credit.added") {
|
|
9385
|
+
await callHandler(config.onCreditAdded, payload);
|
|
9386
|
+
}
|
|
9387
|
+
if (payload.type === "credit.deducted") {
|
|
9388
|
+
await callHandler(config.onCreditDeducted, payload);
|
|
9389
|
+
}
|
|
9390
|
+
if (payload.type === "credit.expired") {
|
|
9391
|
+
await callHandler(config.onCreditExpired, payload);
|
|
9392
|
+
}
|
|
9393
|
+
if (payload.type === "credit.rolled_over") {
|
|
9394
|
+
await callHandler(config.onCreditRolledOver, payload);
|
|
9395
|
+
}
|
|
9396
|
+
if (payload.type === "credit.rollover_forfeited") {
|
|
9397
|
+
await callHandler(config.onCreditRolloverForfeited, payload);
|
|
9398
|
+
}
|
|
9399
|
+
if (payload.type === "credit.overage_charged") {
|
|
9400
|
+
await callHandler(config.onCreditOverageCharged, payload);
|
|
9401
|
+
}
|
|
9402
|
+
if (payload.type === "credit.manual_adjustment") {
|
|
9403
|
+
await callHandler(config.onCreditManualAdjustment, payload);
|
|
9404
|
+
}
|
|
9405
|
+
if (payload.type === "credit.balance_low") {
|
|
9406
|
+
await callHandler(config.onCreditBalanceLow, payload);
|
|
9407
|
+
}
|
|
8722
9408
|
}
|
|
8723
9409
|
|
|
8724
9410
|
const Webhooks = ({ webhookKey, ...eventHandlers }) => {
|
|
@@ -8768,12 +9454,11 @@ const CustomerPortal = ({ bearerToken, environment, }) => {
|
|
|
8768
9454
|
return async function (request) {
|
|
8769
9455
|
const { searchParams } = new URL(request.url);
|
|
8770
9456
|
const customerId = searchParams.get("customer_id");
|
|
8771
|
-
const
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
params.send_email = sendEmail;
|
|
9457
|
+
const sendEmailParam = searchParams.get("send_email");
|
|
9458
|
+
const params = {};
|
|
9459
|
+
if (sendEmailParam !== null) {
|
|
9460
|
+
// searchParams.get() already returns a single string or null
|
|
9461
|
+
params.send_email = sendEmailParam === "true";
|
|
8777
9462
|
}
|
|
8778
9463
|
if (!customerId) {
|
|
8779
9464
|
return new Response("Missing customerId in query parameters", {
|