@dodopayments/nextjs 0.3.4 → 0.3.5
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/index.cjs +805 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +805 -119
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9825,7 +9825,7 @@ const safeJSON = (text) => {
|
|
|
9825
9825
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
9826
9826
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9827
9827
|
|
|
9828
|
-
const VERSION = '2.
|
|
9828
|
+
const VERSION = '2.23.2'; // x-release-please-version
|
|
9829
9829
|
|
|
9830
9830
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
9831
9831
|
/**
|
|
@@ -10035,6 +10035,25 @@ const FallbackEncoder = ({ headers, body }) => {
|
|
|
10035
10035
|
};
|
|
10036
10036
|
};
|
|
10037
10037
|
|
|
10038
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10039
|
+
/**
|
|
10040
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
10041
|
+
*/
|
|
10042
|
+
function stringifyQuery(query) {
|
|
10043
|
+
return Object.entries(query)
|
|
10044
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
10045
|
+
.map(([key, value]) => {
|
|
10046
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
10047
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
10048
|
+
}
|
|
10049
|
+
if (value === null) {
|
|
10050
|
+
return `${encodeURIComponent(key)}=`;
|
|
10051
|
+
}
|
|
10052
|
+
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.`);
|
|
10053
|
+
})
|
|
10054
|
+
.join('&');
|
|
10055
|
+
}
|
|
10056
|
+
|
|
10038
10057
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10039
10058
|
const levelNumbers = {
|
|
10040
10059
|
off: 0,
|
|
@@ -10128,6 +10147,11 @@ async function defaultParseResponse(client, props) {
|
|
|
10128
10147
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
10129
10148
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
10130
10149
|
if (isJSON) {
|
|
10150
|
+
const contentLength = response.headers.get('content-length');
|
|
10151
|
+
if (contentLength === '0') {
|
|
10152
|
+
// if there is no content we can't do anything
|
|
10153
|
+
return undefined;
|
|
10154
|
+
}
|
|
10131
10155
|
const json = await response.json();
|
|
10132
10156
|
return json;
|
|
10133
10157
|
}
|
|
@@ -10548,6 +10572,16 @@ class Addons extends APIResource {
|
|
|
10548
10572
|
}
|
|
10549
10573
|
}
|
|
10550
10574
|
|
|
10575
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10576
|
+
let Balances$1 = class Balances extends APIResource {
|
|
10577
|
+
retrieveLedger(query = {}, options) {
|
|
10578
|
+
return this._client.getAPIList('/balances/ledger', (DefaultPageNumberPagination), {
|
|
10579
|
+
query,
|
|
10580
|
+
...options,
|
|
10581
|
+
});
|
|
10582
|
+
}
|
|
10583
|
+
};
|
|
10584
|
+
|
|
10551
10585
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10552
10586
|
class Brands extends APIResource {
|
|
10553
10587
|
create(body, options) {
|
|
@@ -10578,66 +10612,155 @@ class CheckoutSessions extends APIResource {
|
|
|
10578
10612
|
retrieve(id, options) {
|
|
10579
10613
|
return this._client.get(path `/checkouts/${id}`, options);
|
|
10580
10614
|
}
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10584
|
-
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
10585
|
-
create(customerID, params = {}, options) {
|
|
10586
|
-
const { send_email } = params ?? {};
|
|
10587
|
-
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
10588
|
-
query: { send_email },
|
|
10589
|
-
...options,
|
|
10590
|
-
});
|
|
10591
|
-
}
|
|
10592
|
-
};
|
|
10593
|
-
|
|
10594
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10595
|
-
class LedgerEntries extends APIResource {
|
|
10596
|
-
create(customerID, body, options) {
|
|
10597
|
-
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
10598
|
-
}
|
|
10599
|
-
list(customerID, query = {}, options) {
|
|
10600
|
-
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
10615
|
+
preview(body, options) {
|
|
10616
|
+
return this._client.post('/checkouts/preview', { body, ...options });
|
|
10601
10617
|
}
|
|
10602
10618
|
}
|
|
10603
10619
|
|
|
10604
10620
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10605
|
-
class
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10621
|
+
class Balances extends APIResource {
|
|
10622
|
+
/**
|
|
10623
|
+
* Returns the credit balance details for a specific customer and credit
|
|
10624
|
+
* entitlement.
|
|
10625
|
+
*
|
|
10626
|
+
* # Authentication
|
|
10627
|
+
*
|
|
10628
|
+
* Requires an API key with `Viewer` role or higher.
|
|
10629
|
+
*
|
|
10630
|
+
* # Path Parameters
|
|
10631
|
+
*
|
|
10632
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
10633
|
+
* - `customer_id` - The unique identifier of the customer
|
|
10634
|
+
*
|
|
10635
|
+
* # Responses
|
|
10636
|
+
*
|
|
10637
|
+
* - `200 OK` - Returns the customer's balance
|
|
10638
|
+
* - `404 Not Found` - Credit entitlement or customer balance not found
|
|
10639
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10640
|
+
*/
|
|
10641
|
+
retrieve(customerID, params, options) {
|
|
10642
|
+
const { credit_entitlement_id } = params;
|
|
10643
|
+
return this._client.get(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}`, options);
|
|
10622
10644
|
}
|
|
10623
|
-
|
|
10624
|
-
|
|
10645
|
+
/**
|
|
10646
|
+
* Returns a paginated list of customer credit balances for the given credit
|
|
10647
|
+
* entitlement.
|
|
10648
|
+
*
|
|
10649
|
+
* # Authentication
|
|
10650
|
+
*
|
|
10651
|
+
* Requires an API key with `Viewer` role or higher.
|
|
10652
|
+
*
|
|
10653
|
+
* # Path Parameters
|
|
10654
|
+
*
|
|
10655
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
10656
|
+
*
|
|
10657
|
+
* # Query Parameters
|
|
10658
|
+
*
|
|
10659
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
10660
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
10661
|
+
* - `customer_id` - Optional filter by specific customer
|
|
10662
|
+
*
|
|
10663
|
+
* # Responses
|
|
10664
|
+
*
|
|
10665
|
+
* - `200 OK` - Returns list of customer balances
|
|
10666
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
10667
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10668
|
+
*/
|
|
10669
|
+
list(creditEntitlementID, query = {}, options) {
|
|
10670
|
+
return this._client.getAPIList(path `/credit-entitlements/${creditEntitlementID}/balances`, (DefaultPageNumberPagination), { query, ...options });
|
|
10625
10671
|
}
|
|
10626
|
-
|
|
10627
|
-
|
|
10672
|
+
/**
|
|
10673
|
+
* For credit entries, a new grant is created. For debit entries, credits are
|
|
10674
|
+
* deducted from existing grants using FIFO (oldest first).
|
|
10675
|
+
*
|
|
10676
|
+
* # Authentication
|
|
10677
|
+
*
|
|
10678
|
+
* Requires an API key with `Editor` role.
|
|
10679
|
+
*
|
|
10680
|
+
* # Path Parameters
|
|
10681
|
+
*
|
|
10682
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
10683
|
+
* - `customer_id` - The unique identifier of the customer
|
|
10684
|
+
*
|
|
10685
|
+
* # Request Body
|
|
10686
|
+
*
|
|
10687
|
+
* - `entry_type` - "credit" or "debit"
|
|
10688
|
+
* - `amount` - Amount to credit or debit
|
|
10689
|
+
* - `reason` - Optional human-readable reason
|
|
10690
|
+
* - `expires_at` - Optional expiration for credited amount (only for credit type)
|
|
10691
|
+
* - `idempotency_key` - Optional key to prevent duplicate entries
|
|
10692
|
+
*
|
|
10693
|
+
* # Responses
|
|
10694
|
+
*
|
|
10695
|
+
* - `201 Created` - Ledger entry created successfully
|
|
10696
|
+
* - `400 Bad Request` - Invalid request (e.g., debit with insufficient balance)
|
|
10697
|
+
* - `404 Not Found` - Credit entitlement or customer not found
|
|
10698
|
+
* - `409 Conflict` - Idempotency key already exists
|
|
10699
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10700
|
+
*/
|
|
10701
|
+
createLedgerEntry(customerID, params, options) {
|
|
10702
|
+
const { credit_entitlement_id, ...body } = params;
|
|
10703
|
+
return this._client.post(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger-entries`, { body, ...options });
|
|
10628
10704
|
}
|
|
10629
|
-
|
|
10630
|
-
|
|
10705
|
+
/**
|
|
10706
|
+
* Returns a paginated list of credit grants with optional filtering by status.
|
|
10707
|
+
*
|
|
10708
|
+
* # Authentication
|
|
10709
|
+
*
|
|
10710
|
+
* Requires an API key with `Viewer` role or higher.
|
|
10711
|
+
*
|
|
10712
|
+
* # Path Parameters
|
|
10713
|
+
*
|
|
10714
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
10715
|
+
* - `customer_id` - The unique identifier of the customer
|
|
10716
|
+
*
|
|
10717
|
+
* # Query Parameters
|
|
10718
|
+
*
|
|
10719
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
10720
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
10721
|
+
* - `status` - Filter by status: active, expired, depleted
|
|
10722
|
+
*
|
|
10723
|
+
* # Responses
|
|
10724
|
+
*
|
|
10725
|
+
* - `200 OK` - Returns list of grants
|
|
10726
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
10727
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10728
|
+
*/
|
|
10729
|
+
listGrants(customerID, params, options) {
|
|
10730
|
+
const { credit_entitlement_id, ...query } = params;
|
|
10731
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/grants`, (DefaultPageNumberPagination), { query, ...options });
|
|
10631
10732
|
}
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10733
|
+
/**
|
|
10734
|
+
* Returns a paginated list of credit transaction history with optional filtering.
|
|
10735
|
+
*
|
|
10736
|
+
* # Authentication
|
|
10737
|
+
*
|
|
10738
|
+
* Requires an API key with `Viewer` role or higher.
|
|
10739
|
+
*
|
|
10740
|
+
* # Path Parameters
|
|
10741
|
+
*
|
|
10742
|
+
* - `credit_entitlement_id` - The unique identifier of the credit entitlement
|
|
10743
|
+
* - `customer_id` - The unique identifier of the customer
|
|
10744
|
+
*
|
|
10745
|
+
* # Query Parameters
|
|
10746
|
+
*
|
|
10747
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
10748
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
10749
|
+
* - `transaction_type` - Filter by transaction type
|
|
10750
|
+
* - `start_date` - Filter entries from this date
|
|
10751
|
+
* - `end_date` - Filter entries until this date
|
|
10752
|
+
*
|
|
10753
|
+
* # Responses
|
|
10754
|
+
*
|
|
10755
|
+
* - `200 OK` - Returns list of ledger entries
|
|
10756
|
+
* - `404 Not Found` - Credit entitlement not found
|
|
10757
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10758
|
+
*/
|
|
10759
|
+
listLedger(customerID, params, options) {
|
|
10760
|
+
const { credit_entitlement_id, ...query } = params;
|
|
10761
|
+
return this._client.getAPIList(path `/credit-entitlements/${credit_entitlement_id}/balances/${customerID}/ledger`, (DefaultPageNumberPagination), { query, ...options });
|
|
10637
10762
|
}
|
|
10638
10763
|
}
|
|
10639
|
-
Customers.CustomerPortal = CustomerPortal$1;
|
|
10640
|
-
Customers.Wallets = Wallets;
|
|
10641
10764
|
|
|
10642
10765
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10643
10766
|
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
@@ -10707,6 +10830,313 @@ const buildHeaders = (newHeaders) => {
|
|
|
10707
10830
|
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
10708
10831
|
};
|
|
10709
10832
|
|
|
10833
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10834
|
+
class CreditEntitlements extends APIResource {
|
|
10835
|
+
constructor() {
|
|
10836
|
+
super(...arguments);
|
|
10837
|
+
this.balances = new Balances(this._client);
|
|
10838
|
+
}
|
|
10839
|
+
/**
|
|
10840
|
+
* Credit entitlements define reusable credit templates that can be attached to
|
|
10841
|
+
* products. Each entitlement defines how credits behave in terms of expiration,
|
|
10842
|
+
* rollover, and overage.
|
|
10843
|
+
*
|
|
10844
|
+
* # Authentication
|
|
10845
|
+
*
|
|
10846
|
+
* Requires an API key with `Editor` role.
|
|
10847
|
+
*
|
|
10848
|
+
* # Request Body
|
|
10849
|
+
*
|
|
10850
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters,
|
|
10851
|
+
* required)
|
|
10852
|
+
* - `description` - Optional description (max 1000 characters)
|
|
10853
|
+
* - `precision` - Decimal precision for credit amounts (0-10 decimal places)
|
|
10854
|
+
* - `unit` - Unit of measurement for the credit (e.g., "API Calls", "Tokens",
|
|
10855
|
+
* "Credits")
|
|
10856
|
+
* - `expires_after_days` - Number of days after which credits expire (optional)
|
|
10857
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
10858
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100)
|
|
10859
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
10860
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year)
|
|
10861
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
10862
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
10863
|
+
* (requires price_per_unit)
|
|
10864
|
+
* - `overage_limit` - Maximum overage units allowed (optional)
|
|
10865
|
+
* - `currency` - Currency for pricing (required if price_per_unit is set)
|
|
10866
|
+
* - `price_per_unit` - Price per credit unit (decimal)
|
|
10867
|
+
*
|
|
10868
|
+
* # Responses
|
|
10869
|
+
*
|
|
10870
|
+
* - `201 Created` - Credit entitlement created successfully, returns the full
|
|
10871
|
+
* entitlement object
|
|
10872
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
10873
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10874
|
+
*
|
|
10875
|
+
* # Business Logic
|
|
10876
|
+
*
|
|
10877
|
+
* - A unique ID with prefix `cde_` is automatically generated for the entitlement
|
|
10878
|
+
* - Created and updated timestamps are automatically set
|
|
10879
|
+
* - Currency is required when price_per_unit is set
|
|
10880
|
+
* - price_per_unit is required when overage_enabled is true
|
|
10881
|
+
* - rollover_timeframe_count and rollover_timeframe_interval must both be set or
|
|
10882
|
+
* both be null
|
|
10883
|
+
*/
|
|
10884
|
+
create(body, options) {
|
|
10885
|
+
return this._client.post('/credit-entitlements', { body, ...options });
|
|
10886
|
+
}
|
|
10887
|
+
/**
|
|
10888
|
+
* Returns the full details of a single credit entitlement including all
|
|
10889
|
+
* configuration settings for expiration, rollover, and overage policies.
|
|
10890
|
+
*
|
|
10891
|
+
* # Authentication
|
|
10892
|
+
*
|
|
10893
|
+
* Requires an API key with `Viewer` role or higher.
|
|
10894
|
+
*
|
|
10895
|
+
* # Path Parameters
|
|
10896
|
+
*
|
|
10897
|
+
* - `id` - The unique identifier of the credit entitlement (format: `cde_...`)
|
|
10898
|
+
*
|
|
10899
|
+
* # Responses
|
|
10900
|
+
*
|
|
10901
|
+
* - `200 OK` - Returns the full credit entitlement object
|
|
10902
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
10903
|
+
* authenticated business
|
|
10904
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10905
|
+
*
|
|
10906
|
+
* # Business Logic
|
|
10907
|
+
*
|
|
10908
|
+
* - Only non-deleted credit entitlements can be retrieved through this endpoint
|
|
10909
|
+
* - The entitlement must belong to the authenticated business (business_id check)
|
|
10910
|
+
* - Deleted entitlements return a 404 error and must be retrieved via the list
|
|
10911
|
+
* endpoint with `deleted=true`
|
|
10912
|
+
*/
|
|
10913
|
+
retrieve(id, options) {
|
|
10914
|
+
return this._client.get(path `/credit-entitlements/${id}`, options);
|
|
10915
|
+
}
|
|
10916
|
+
/**
|
|
10917
|
+
* Allows partial updates to a credit entitlement's configuration. Only the fields
|
|
10918
|
+
* provided in the request body will be updated; all other fields remain unchanged.
|
|
10919
|
+
* This endpoint supports nullable fields using the double option pattern.
|
|
10920
|
+
*
|
|
10921
|
+
* # Authentication
|
|
10922
|
+
*
|
|
10923
|
+
* Requires an API key with `Editor` role.
|
|
10924
|
+
*
|
|
10925
|
+
* # Path Parameters
|
|
10926
|
+
*
|
|
10927
|
+
* - `id` - The unique identifier of the credit entitlement to update (format:
|
|
10928
|
+
* `cde_...`)
|
|
10929
|
+
*
|
|
10930
|
+
* # Request Body (all fields optional)
|
|
10931
|
+
*
|
|
10932
|
+
* - `name` - Human-readable name of the credit entitlement (1-255 characters)
|
|
10933
|
+
* - `description` - Optional description (max 1000 characters)
|
|
10934
|
+
* - `unit` - Unit of measurement for the credit (1-50 characters)
|
|
10935
|
+
*
|
|
10936
|
+
* Note: `precision` cannot be modified after creation as it would invalidate
|
|
10937
|
+
* existing grants.
|
|
10938
|
+
*
|
|
10939
|
+
* - `expires_after_days` - Number of days after which credits expire (use `null`
|
|
10940
|
+
* to remove expiration)
|
|
10941
|
+
* - `rollover_enabled` - Whether unused credits can rollover to the next period
|
|
10942
|
+
* - `rollover_percentage` - Percentage of unused credits that rollover (0-100,
|
|
10943
|
+
* nullable)
|
|
10944
|
+
* - `rollover_timeframe_count` - Count of timeframe periods for rollover limit
|
|
10945
|
+
* (nullable)
|
|
10946
|
+
* - `rollover_timeframe_interval` - Interval type (day, week, month, year,
|
|
10947
|
+
* nullable)
|
|
10948
|
+
* - `max_rollover_count` - Maximum number of times credits can be rolled over
|
|
10949
|
+
* (nullable)
|
|
10950
|
+
* - `overage_enabled` - Whether overage charges apply when credits run out
|
|
10951
|
+
* - `overage_limit` - Maximum overage units allowed (nullable)
|
|
10952
|
+
* - `currency` - Currency for pricing (nullable)
|
|
10953
|
+
* - `price_per_unit` - Price per credit unit (decimal, nullable)
|
|
10954
|
+
*
|
|
10955
|
+
* # Responses
|
|
10956
|
+
*
|
|
10957
|
+
* - `200 OK` - Credit entitlement updated successfully
|
|
10958
|
+
* - `404 Not Found` - Credit entitlement does not exist or does not belong to the
|
|
10959
|
+
* authenticated business
|
|
10960
|
+
* - `422 Unprocessable Entity` - Invalid request parameters or validation failure
|
|
10961
|
+
* - `500 Internal Server Error` - Database or server error
|
|
10962
|
+
*
|
|
10963
|
+
* # Business Logic
|
|
10964
|
+
*
|
|
10965
|
+
* - Only non-deleted credit entitlements can be updated
|
|
10966
|
+
* - Fields set to `null` explicitly will clear the database value (using double
|
|
10967
|
+
* option pattern)
|
|
10968
|
+
* - The `updated_at` timestamp is automatically updated on successful modification
|
|
10969
|
+
* - Changes take effect immediately but do not retroactively affect existing
|
|
10970
|
+
* credit grants
|
|
10971
|
+
* - The merged state is validated: currency required with price, rollover
|
|
10972
|
+
* timeframe fields together, price required for overage
|
|
10973
|
+
*/
|
|
10974
|
+
update(id, body, options) {
|
|
10975
|
+
return this._client.patch(path `/credit-entitlements/${id}`, {
|
|
10976
|
+
body,
|
|
10977
|
+
...options,
|
|
10978
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
10979
|
+
});
|
|
10980
|
+
}
|
|
10981
|
+
/**
|
|
10982
|
+
* Returns a paginated list of credit entitlements, allowing filtering of deleted
|
|
10983
|
+
* entitlements. By default, only non-deleted entitlements are returned.
|
|
10984
|
+
*
|
|
10985
|
+
* # Authentication
|
|
10986
|
+
*
|
|
10987
|
+
* Requires an API key with `Viewer` role or higher.
|
|
10988
|
+
*
|
|
10989
|
+
* # Query Parameters
|
|
10990
|
+
*
|
|
10991
|
+
* - `page_size` - Number of items per page (default: 10, max: 100)
|
|
10992
|
+
* - `page_number` - Zero-based page number (default: 0)
|
|
10993
|
+
* - `deleted` - Boolean flag to list deleted entitlements instead of active ones
|
|
10994
|
+
* (default: false)
|
|
10995
|
+
*
|
|
10996
|
+
* # Responses
|
|
10997
|
+
*
|
|
10998
|
+
* - `200 OK` - Returns a list of credit entitlements wrapped in a response object
|
|
10999
|
+
* - `422 Unprocessable Entity` - Invalid query parameters (e.g., page_size > 100)
|
|
11000
|
+
* - `500 Internal Server Error` - Database or server error
|
|
11001
|
+
*
|
|
11002
|
+
* # Business Logic
|
|
11003
|
+
*
|
|
11004
|
+
* - Results are ordered by creation date in descending order (newest first)
|
|
11005
|
+
* - Only entitlements belonging to the authenticated business are returned
|
|
11006
|
+
* - The `deleted` parameter controls visibility of soft-deleted entitlements
|
|
11007
|
+
* - Pagination uses offset-based pagination (offset = page_number \* page_size)
|
|
11008
|
+
*/
|
|
11009
|
+
list(query = {}, options) {
|
|
11010
|
+
return this._client.getAPIList('/credit-entitlements', (DefaultPageNumberPagination), {
|
|
11011
|
+
query,
|
|
11012
|
+
...options,
|
|
11013
|
+
});
|
|
11014
|
+
}
|
|
11015
|
+
delete(id, options) {
|
|
11016
|
+
return this._client.delete(path `/credit-entitlements/${id}`, {
|
|
11017
|
+
...options,
|
|
11018
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
11019
|
+
});
|
|
11020
|
+
}
|
|
11021
|
+
/**
|
|
11022
|
+
* Undeletes a soft-deleted credit entitlement by clearing `deleted_at`, making it
|
|
11023
|
+
* available again through standard list and get endpoints.
|
|
11024
|
+
*
|
|
11025
|
+
* # Authentication
|
|
11026
|
+
*
|
|
11027
|
+
* Requires an API key with `Editor` role.
|
|
11028
|
+
*
|
|
11029
|
+
* # Path Parameters
|
|
11030
|
+
*
|
|
11031
|
+
* - `id` - The unique identifier of the credit entitlement to restore (format:
|
|
11032
|
+
* `cde_...`)
|
|
11033
|
+
*
|
|
11034
|
+
* # Responses
|
|
11035
|
+
*
|
|
11036
|
+
* - `200 OK` - Credit entitlement restored successfully
|
|
11037
|
+
* - `500 Internal Server Error` - Database error, entitlement not found, or
|
|
11038
|
+
* entitlement is not deleted
|
|
11039
|
+
*
|
|
11040
|
+
* # Business Logic
|
|
11041
|
+
*
|
|
11042
|
+
* - Only deleted credit entitlements can be restored
|
|
11043
|
+
* - The query filters for `deleted_at IS NOT NULL`, so non-deleted entitlements
|
|
11044
|
+
* will result in 0 rows affected
|
|
11045
|
+
* - If no rows are affected (entitlement doesn't exist, doesn't belong to
|
|
11046
|
+
* business, or is not deleted), returns 500
|
|
11047
|
+
* - The `updated_at` timestamp is automatically updated on successful restoration
|
|
11048
|
+
* - Once restored, the entitlement becomes immediately available in the standard
|
|
11049
|
+
* list and get endpoints
|
|
11050
|
+
* - All configuration settings are preserved during delete/restore operations
|
|
11051
|
+
*
|
|
11052
|
+
* # Error Handling
|
|
11053
|
+
*
|
|
11054
|
+
* This endpoint returns 500 Internal Server Error in several cases:
|
|
11055
|
+
*
|
|
11056
|
+
* - The credit entitlement does not exist
|
|
11057
|
+
* - The credit entitlement belongs to a different business
|
|
11058
|
+
* - The credit entitlement is not currently deleted (already active)
|
|
11059
|
+
*
|
|
11060
|
+
* Callers should verify the entitlement exists and is deleted before calling this
|
|
11061
|
+
* endpoint.
|
|
11062
|
+
*/
|
|
11063
|
+
undelete(id, options) {
|
|
11064
|
+
return this._client.post(path `/credit-entitlements/${id}/undelete`, {
|
|
11065
|
+
...options,
|
|
11066
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
11067
|
+
});
|
|
11068
|
+
}
|
|
11069
|
+
}
|
|
11070
|
+
CreditEntitlements.Balances = Balances;
|
|
11071
|
+
|
|
11072
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11073
|
+
let CustomerPortal$1 = class CustomerPortal extends APIResource {
|
|
11074
|
+
create(customerID, params = {}, options) {
|
|
11075
|
+
const { send_email } = params ?? {};
|
|
11076
|
+
return this._client.post(path `/customers/${customerID}/customer-portal/session`, {
|
|
11077
|
+
query: { send_email },
|
|
11078
|
+
...options,
|
|
11079
|
+
});
|
|
11080
|
+
}
|
|
11081
|
+
};
|
|
11082
|
+
|
|
11083
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11084
|
+
class LedgerEntries extends APIResource {
|
|
11085
|
+
create(customerID, body, options) {
|
|
11086
|
+
return this._client.post(path `/customers/${customerID}/wallets/ledger-entries`, { body, ...options });
|
|
11087
|
+
}
|
|
11088
|
+
list(customerID, query = {}, options) {
|
|
11089
|
+
return this._client.getAPIList(path `/customers/${customerID}/wallets/ledger-entries`, (DefaultPageNumberPagination), { query, ...options });
|
|
11090
|
+
}
|
|
11091
|
+
}
|
|
11092
|
+
|
|
11093
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11094
|
+
class Wallets extends APIResource {
|
|
11095
|
+
constructor() {
|
|
11096
|
+
super(...arguments);
|
|
11097
|
+
this.ledgerEntries = new LedgerEntries(this._client);
|
|
11098
|
+
}
|
|
11099
|
+
list(customerID, options) {
|
|
11100
|
+
return this._client.get(path `/customers/${customerID}/wallets`, options);
|
|
11101
|
+
}
|
|
11102
|
+
}
|
|
11103
|
+
Wallets.LedgerEntries = LedgerEntries;
|
|
11104
|
+
|
|
11105
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11106
|
+
class Customers extends APIResource {
|
|
11107
|
+
constructor() {
|
|
11108
|
+
super(...arguments);
|
|
11109
|
+
this.customerPortal = new CustomerPortal$1(this._client);
|
|
11110
|
+
this.wallets = new Wallets(this._client);
|
|
11111
|
+
}
|
|
11112
|
+
create(body, options) {
|
|
11113
|
+
return this._client.post('/customers', { body, ...options });
|
|
11114
|
+
}
|
|
11115
|
+
retrieve(customerID, options) {
|
|
11116
|
+
return this._client.get(path `/customers/${customerID}`, options);
|
|
11117
|
+
}
|
|
11118
|
+
update(customerID, body, options) {
|
|
11119
|
+
return this._client.patch(path `/customers/${customerID}`, { body, ...options });
|
|
11120
|
+
}
|
|
11121
|
+
list(query = {}, options) {
|
|
11122
|
+
return this._client.getAPIList('/customers', (DefaultPageNumberPagination), {
|
|
11123
|
+
query,
|
|
11124
|
+
...options,
|
|
11125
|
+
});
|
|
11126
|
+
}
|
|
11127
|
+
/**
|
|
11128
|
+
* List all credit entitlements for a customer with their current balances
|
|
11129
|
+
*/
|
|
11130
|
+
listCreditEntitlements(customerID, options) {
|
|
11131
|
+
return this._client.get(path `/customers/${customerID}/credit-entitlements`, options);
|
|
11132
|
+
}
|
|
11133
|
+
retrievePaymentMethods(customerID, options) {
|
|
11134
|
+
return this._client.get(path `/customers/${customerID}/payment-methods`, options);
|
|
11135
|
+
}
|
|
11136
|
+
}
|
|
11137
|
+
Customers.CustomerPortal = CustomerPortal$1;
|
|
11138
|
+
Customers.Wallets = Wallets;
|
|
11139
|
+
|
|
10710
11140
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10711
11141
|
class Discounts extends APIResource {
|
|
10712
11142
|
/**
|
|
@@ -10746,6 +11176,14 @@ class Discounts extends APIResource {
|
|
|
10746
11176
|
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
10747
11177
|
});
|
|
10748
11178
|
}
|
|
11179
|
+
/**
|
|
11180
|
+
* Validate and fetch a discount by its code name (e.g., "SAVE20"). This allows
|
|
11181
|
+
* real-time validation directly against the API using the human-readable discount
|
|
11182
|
+
* code instead of requiring the internal discount_id.
|
|
11183
|
+
*/
|
|
11184
|
+
retrieveByCode(code, options) {
|
|
11185
|
+
return this._client.get(path `/discounts/code/${code}`, options);
|
|
11186
|
+
}
|
|
10749
11187
|
}
|
|
10750
11188
|
|
|
10751
11189
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -10944,6 +11382,9 @@ class Misc extends APIResource {
|
|
|
10944
11382
|
|
|
10945
11383
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10946
11384
|
class Payments extends APIResource {
|
|
11385
|
+
/**
|
|
11386
|
+
* @deprecated
|
|
11387
|
+
*/
|
|
10947
11388
|
create(body, options) {
|
|
10948
11389
|
return this._client.post('/payments', { body, ...options });
|
|
10949
11390
|
}
|
|
@@ -10979,11 +11420,29 @@ class Images extends APIResource {
|
|
|
10979
11420
|
}
|
|
10980
11421
|
}
|
|
10981
11422
|
|
|
11423
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11424
|
+
class ShortLinks extends APIResource {
|
|
11425
|
+
/**
|
|
11426
|
+
* Gives a Short Checkout URL with custom slug for a product. Uses a Static
|
|
11427
|
+
* Checkout URL under the hood.
|
|
11428
|
+
*/
|
|
11429
|
+
create(id, body, options) {
|
|
11430
|
+
return this._client.post(path `/products/${id}/short_links`, { body, ...options });
|
|
11431
|
+
}
|
|
11432
|
+
/**
|
|
11433
|
+
* Lists all short links created by the business.
|
|
11434
|
+
*/
|
|
11435
|
+
list(query = {}, options) {
|
|
11436
|
+
return this._client.getAPIList('/products/short_links', (DefaultPageNumberPagination), { query, ...options });
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
|
|
10982
11440
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
10983
11441
|
class Products extends APIResource {
|
|
10984
11442
|
constructor() {
|
|
10985
11443
|
super(...arguments);
|
|
10986
11444
|
this.images = new Images(this._client);
|
|
11445
|
+
this.shortLinks = new ShortLinks(this._client);
|
|
10987
11446
|
}
|
|
10988
11447
|
create(body, options) {
|
|
10989
11448
|
return this._client.post('/products', { body, ...options });
|
|
@@ -11021,6 +11480,7 @@ class Products extends APIResource {
|
|
|
11021
11480
|
}
|
|
11022
11481
|
}
|
|
11023
11482
|
Products.Images = Images;
|
|
11483
|
+
Products.ShortLinks = ShortLinks;
|
|
11024
11484
|
|
|
11025
11485
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11026
11486
|
class Refunds extends APIResource {
|
|
@@ -11040,6 +11500,9 @@ class Refunds extends APIResource {
|
|
|
11040
11500
|
|
|
11041
11501
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11042
11502
|
class Subscriptions extends APIResource {
|
|
11503
|
+
/**
|
|
11504
|
+
* @deprecated
|
|
11505
|
+
*/
|
|
11043
11506
|
create(body, options) {
|
|
11044
11507
|
return this._client.post('/subscriptions', { body, ...options });
|
|
11045
11508
|
}
|
|
@@ -11065,6 +11528,15 @@ class Subscriptions extends APIResource {
|
|
|
11065
11528
|
charge(subscriptionID, body, options) {
|
|
11066
11529
|
return this._client.post(path `/subscriptions/${subscriptionID}/charge`, { body, ...options });
|
|
11067
11530
|
}
|
|
11531
|
+
previewChangePlan(subscriptionID, body, options) {
|
|
11532
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/change-plan/preview`, {
|
|
11533
|
+
body,
|
|
11534
|
+
...options,
|
|
11535
|
+
});
|
|
11536
|
+
}
|
|
11537
|
+
retrieveCreditUsage(subscriptionID, options) {
|
|
11538
|
+
return this._client.get(path `/subscriptions/${subscriptionID}/credit-usage`, options);
|
|
11539
|
+
}
|
|
11068
11540
|
/**
|
|
11069
11541
|
* Get detailed usage history for a subscription that includes usage-based billing
|
|
11070
11542
|
* (metered components). This endpoint provides insights into customer usage
|
|
@@ -11112,6 +11584,12 @@ class Subscriptions extends APIResource {
|
|
|
11112
11584
|
retrieveUsageHistory(subscriptionID, query = {}, options) {
|
|
11113
11585
|
return this._client.getAPIList(path `/subscriptions/${subscriptionID}/usage-history`, (DefaultPageNumberPagination), { query, ...options });
|
|
11114
11586
|
}
|
|
11587
|
+
updatePaymentMethod(subscriptionID, body, options) {
|
|
11588
|
+
return this._client.post(path `/subscriptions/${subscriptionID}/update-payment-method`, {
|
|
11589
|
+
body,
|
|
11590
|
+
...options,
|
|
11591
|
+
});
|
|
11592
|
+
}
|
|
11115
11593
|
}
|
|
11116
11594
|
|
|
11117
11595
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
@@ -12231,6 +12709,8 @@ class DodoPayments {
|
|
|
12231
12709
|
this.webhookEvents = new WebhookEvents(this);
|
|
12232
12710
|
this.usageEvents = new UsageEvents(this);
|
|
12233
12711
|
this.meters = new Meters(this);
|
|
12712
|
+
this.balances = new Balances$1(this);
|
|
12713
|
+
this.creditEntitlements = new CreditEntitlements(this);
|
|
12234
12714
|
if (bearerToken === undefined) {
|
|
12235
12715
|
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' }).");
|
|
12236
12716
|
}
|
|
@@ -12295,18 +12775,7 @@ class DodoPayments {
|
|
|
12295
12775
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
12296
12776
|
*/
|
|
12297
12777
|
stringifyQuery(query) {
|
|
12298
|
-
return
|
|
12299
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
12300
|
-
.map(([key, value]) => {
|
|
12301
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
12302
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
12303
|
-
}
|
|
12304
|
-
if (value === null) {
|
|
12305
|
-
return `${encodeURIComponent(key)}=`;
|
|
12306
|
-
}
|
|
12307
|
-
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.`);
|
|
12308
|
-
})
|
|
12309
|
-
.join('&');
|
|
12778
|
+
return stringifyQuery(query);
|
|
12310
12779
|
}
|
|
12311
12780
|
getUserAgent() {
|
|
12312
12781
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -12470,7 +12939,9 @@ class DodoPayments {
|
|
|
12470
12939
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
12471
12940
|
}
|
|
12472
12941
|
getAPIList(path, Page, opts) {
|
|
12473
|
-
return this.requestAPIList(Page,
|
|
12942
|
+
return this.requestAPIList(Page, opts && 'then' in opts ?
|
|
12943
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
12944
|
+
: { method: 'get', path, ...opts });
|
|
12474
12945
|
}
|
|
12475
12946
|
requestAPIList(Page, options) {
|
|
12476
12947
|
const request = this.makeRequest(options, null, undefined);
|
|
@@ -12478,9 +12949,10 @@ class DodoPayments {
|
|
|
12478
12949
|
}
|
|
12479
12950
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
12480
12951
|
const { signal, method, ...options } = init || {};
|
|
12952
|
+
const abort = this._makeAbort(controller);
|
|
12481
12953
|
if (signal)
|
|
12482
|
-
signal.addEventListener('abort',
|
|
12483
|
-
const timeout = setTimeout(
|
|
12954
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
12955
|
+
const timeout = setTimeout(abort, ms);
|
|
12484
12956
|
const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
|
|
12485
12957
|
(typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
|
|
12486
12958
|
const fetchOptions = {
|
|
@@ -12545,9 +13017,9 @@ class DodoPayments {
|
|
|
12545
13017
|
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
12546
13018
|
}
|
|
12547
13019
|
}
|
|
12548
|
-
// If the API asks us to wait a certain amount of time
|
|
12549
|
-
//
|
|
12550
|
-
if (
|
|
13020
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
13021
|
+
// says, but otherwise calculate a default
|
|
13022
|
+
if (timeoutMillis === undefined) {
|
|
12551
13023
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
12552
13024
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
12553
13025
|
}
|
|
@@ -12609,6 +13081,11 @@ class DodoPayments {
|
|
|
12609
13081
|
this.validateHeaders(headers);
|
|
12610
13082
|
return headers.values;
|
|
12611
13083
|
}
|
|
13084
|
+
_makeAbort(controller) {
|
|
13085
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
13086
|
+
// would capture all request options, and cause a memory leak.
|
|
13087
|
+
return () => controller.abort();
|
|
13088
|
+
}
|
|
12612
13089
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
12613
13090
|
if (!body) {
|
|
12614
13091
|
return { bodyHeaders: undefined, body: undefined };
|
|
@@ -12637,6 +13114,13 @@ class DodoPayments {
|
|
|
12637
13114
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
12638
13115
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
12639
13116
|
}
|
|
13117
|
+
else if (typeof body === 'object' &&
|
|
13118
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
13119
|
+
return {
|
|
13120
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
13121
|
+
body: this.stringifyQuery(body),
|
|
13122
|
+
};
|
|
13123
|
+
}
|
|
12640
13124
|
else {
|
|
12641
13125
|
return __classPrivateFieldGet(this, _DodoPayments_encoder, "f").call(this, { body, headers });
|
|
12642
13126
|
}
|
|
@@ -12681,6 +13165,8 @@ DodoPayments.Webhooks = Webhooks$1;
|
|
|
12681
13165
|
DodoPayments.WebhookEvents = WebhookEvents;
|
|
12682
13166
|
DodoPayments.UsageEvents = UsageEvents;
|
|
12683
13167
|
DodoPayments.Meters = Meters;
|
|
13168
|
+
DodoPayments.Balances = Balances$1;
|
|
13169
|
+
DodoPayments.CreditEntitlements = CreditEntitlements;
|
|
12684
13170
|
|
|
12685
13171
|
// src/checkout/checkout.ts
|
|
12686
13172
|
var checkoutQuerySchema = objectType({
|
|
@@ -13270,23 +13756,33 @@ var PaymentSchema = objectType({
|
|
|
13270
13756
|
payload_type: literalType("Payment"),
|
|
13271
13757
|
billing: objectType({
|
|
13272
13758
|
city: stringType().nullable(),
|
|
13273
|
-
country: stringType()
|
|
13759
|
+
country: stringType(),
|
|
13274
13760
|
state: stringType().nullable(),
|
|
13275
13761
|
street: stringType().nullable(),
|
|
13276
13762
|
zipcode: stringType().nullable()
|
|
13277
13763
|
}),
|
|
13278
13764
|
brand_id: stringType(),
|
|
13279
13765
|
business_id: stringType(),
|
|
13766
|
+
card_holder_name: stringType().nullable(),
|
|
13280
13767
|
card_issuing_country: stringType().nullable(),
|
|
13281
13768
|
card_last_four: stringType().nullable(),
|
|
13282
13769
|
card_network: stringType().nullable(),
|
|
13283
13770
|
card_type: stringType().nullable(),
|
|
13771
|
+
checkout_session_id: stringType().nullable(),
|
|
13284
13772
|
created_at: stringType().transform((d) => new Date(d)),
|
|
13285
13773
|
currency: stringType(),
|
|
13774
|
+
custom_field_responses: arrayType(
|
|
13775
|
+
objectType({
|
|
13776
|
+
key: stringType(),
|
|
13777
|
+
value: stringType()
|
|
13778
|
+
})
|
|
13779
|
+
).nullable(),
|
|
13286
13780
|
customer: objectType({
|
|
13287
13781
|
customer_id: stringType(),
|
|
13288
13782
|
email: stringType(),
|
|
13289
|
-
|
|
13783
|
+
metadata: recordType(anyType()),
|
|
13784
|
+
name: stringType(),
|
|
13785
|
+
phone_number: stringType().nullable()
|
|
13290
13786
|
}),
|
|
13291
13787
|
digital_products_delivered: booleanType(),
|
|
13292
13788
|
discount_id: stringType().nullable(),
|
|
@@ -13297,27 +13793,25 @@ var PaymentSchema = objectType({
|
|
|
13297
13793
|
created_at: stringType().transform((d) => new Date(d)),
|
|
13298
13794
|
currency: stringType(),
|
|
13299
13795
|
dispute_id: stringType(),
|
|
13300
|
-
dispute_stage: enumType([
|
|
13301
|
-
"pre_dispute",
|
|
13302
|
-
"dispute_opened",
|
|
13303
|
-
"dispute_won",
|
|
13304
|
-
"dispute_lost"
|
|
13305
|
-
]),
|
|
13796
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
13306
13797
|
dispute_status: enumType([
|
|
13307
13798
|
"dispute_opened",
|
|
13308
|
-
"
|
|
13309
|
-
"dispute_lost",
|
|
13799
|
+
"dispute_expired",
|
|
13310
13800
|
"dispute_accepted",
|
|
13311
13801
|
"dispute_cancelled",
|
|
13312
|
-
"dispute_challenged"
|
|
13802
|
+
"dispute_challenged",
|
|
13803
|
+
"dispute_won",
|
|
13804
|
+
"dispute_lost"
|
|
13313
13805
|
]),
|
|
13314
13806
|
payment_id: stringType(),
|
|
13315
13807
|
remarks: stringType().nullable()
|
|
13316
13808
|
})
|
|
13317
|
-
).
|
|
13809
|
+
).default([]),
|
|
13318
13810
|
error_code: stringType().nullable(),
|
|
13319
13811
|
error_message: stringType().nullable(),
|
|
13320
|
-
|
|
13812
|
+
invoice_id: stringType().nullable(),
|
|
13813
|
+
invoice_url: stringType().nullable(),
|
|
13814
|
+
metadata: recordType(anyType()),
|
|
13321
13815
|
payment_id: stringType(),
|
|
13322
13816
|
payment_link: stringType().nullable(),
|
|
13323
13817
|
payment_method: stringType().nullable(),
|
|
@@ -13330,21 +13824,34 @@ var PaymentSchema = objectType({
|
|
|
13330
13824
|
).nullable(),
|
|
13331
13825
|
refunds: arrayType(
|
|
13332
13826
|
objectType({
|
|
13333
|
-
amount: numberType(),
|
|
13827
|
+
amount: numberType().nullable(),
|
|
13334
13828
|
business_id: stringType(),
|
|
13335
13829
|
created_at: stringType().transform((d) => new Date(d)),
|
|
13336
|
-
currency: stringType(),
|
|
13830
|
+
currency: stringType().nullable(),
|
|
13337
13831
|
is_partial: booleanType(),
|
|
13338
13832
|
payment_id: stringType(),
|
|
13339
13833
|
reason: stringType().nullable(),
|
|
13340
13834
|
refund_id: stringType(),
|
|
13341
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
13835
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
13342
13836
|
})
|
|
13343
|
-
)
|
|
13837
|
+
),
|
|
13838
|
+
refund_status: enumType(["partial", "full"]).nullable(),
|
|
13344
13839
|
settlement_amount: numberType(),
|
|
13345
13840
|
settlement_currency: stringType(),
|
|
13346
13841
|
settlement_tax: numberType().nullable(),
|
|
13347
|
-
status: enumType([
|
|
13842
|
+
status: enumType([
|
|
13843
|
+
"succeeded",
|
|
13844
|
+
"failed",
|
|
13845
|
+
"cancelled",
|
|
13846
|
+
"processing",
|
|
13847
|
+
"requires_customer_action",
|
|
13848
|
+
"requires_merchant_action",
|
|
13849
|
+
"requires_payment_method",
|
|
13850
|
+
"requires_confirmation",
|
|
13851
|
+
"requires_capture",
|
|
13852
|
+
"partially_captured",
|
|
13853
|
+
"partially_captured_and_capturable"
|
|
13854
|
+
]).nullable(),
|
|
13348
13855
|
subscription_id: stringType().nullable(),
|
|
13349
13856
|
tax: numberType().nullable(),
|
|
13350
13857
|
total_amount: numberType(),
|
|
@@ -13357,10 +13864,10 @@ var SubscriptionSchema = objectType({
|
|
|
13357
13864
|
addon_id: stringType(),
|
|
13358
13865
|
quantity: numberType()
|
|
13359
13866
|
})
|
|
13360
|
-
)
|
|
13867
|
+
),
|
|
13361
13868
|
billing: objectType({
|
|
13362
13869
|
city: stringType().nullable(),
|
|
13363
|
-
country: stringType()
|
|
13870
|
+
country: stringType(),
|
|
13364
13871
|
state: stringType().nullable(),
|
|
13365
13872
|
street: stringType().nullable(),
|
|
13366
13873
|
zipcode: stringType().nullable()
|
|
@@ -13372,15 +13879,72 @@ var SubscriptionSchema = objectType({
|
|
|
13372
13879
|
customer: objectType({
|
|
13373
13880
|
customer_id: stringType(),
|
|
13374
13881
|
email: stringType(),
|
|
13375
|
-
|
|
13882
|
+
metadata: recordType(anyType()),
|
|
13883
|
+
name: stringType(),
|
|
13884
|
+
phone_number: stringType().nullable()
|
|
13376
13885
|
}),
|
|
13886
|
+
custom_field_responses: arrayType(
|
|
13887
|
+
objectType({
|
|
13888
|
+
key: stringType(),
|
|
13889
|
+
value: stringType()
|
|
13890
|
+
})
|
|
13891
|
+
).nullable(),
|
|
13892
|
+
discount_cycles_remaining: numberType().nullable(),
|
|
13377
13893
|
discount_id: stringType().nullable(),
|
|
13378
|
-
|
|
13379
|
-
|
|
13894
|
+
expires_at: stringType().transform((d) => new Date(d)).nullable(),
|
|
13895
|
+
credit_entitlement_cart: arrayType(
|
|
13896
|
+
objectType({
|
|
13897
|
+
credit_entitlement_id: stringType(),
|
|
13898
|
+
credit_entitlement_name: stringType(),
|
|
13899
|
+
credits_amount: stringType(),
|
|
13900
|
+
overage_balance: stringType(),
|
|
13901
|
+
overage_behavior: enumType([
|
|
13902
|
+
"forgive_at_reset",
|
|
13903
|
+
"invoice_at_billing",
|
|
13904
|
+
"carry_deficit",
|
|
13905
|
+
"carry_deficit_auto_repay"
|
|
13906
|
+
]),
|
|
13907
|
+
overage_enabled: booleanType(),
|
|
13908
|
+
product_id: stringType(),
|
|
13909
|
+
remaining_balance: stringType(),
|
|
13910
|
+
rollover_enabled: booleanType(),
|
|
13911
|
+
unit: stringType(),
|
|
13912
|
+
expires_after_days: numberType().nullable(),
|
|
13913
|
+
low_balance_threshold_percent: numberType().nullable(),
|
|
13914
|
+
max_rollover_count: numberType().nullable(),
|
|
13915
|
+
overage_limit: stringType().nullable(),
|
|
13916
|
+
rollover_percentage: numberType().nullable(),
|
|
13917
|
+
rollover_timeframe_count: numberType().nullable(),
|
|
13918
|
+
rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
|
|
13919
|
+
})
|
|
13920
|
+
),
|
|
13921
|
+
meter_credit_entitlement_cart: arrayType(
|
|
13922
|
+
objectType({
|
|
13923
|
+
credit_entitlement_id: stringType(),
|
|
13924
|
+
meter_id: stringType(),
|
|
13925
|
+
meter_name: stringType(),
|
|
13926
|
+
meter_units_per_credit: stringType(),
|
|
13927
|
+
product_id: stringType()
|
|
13928
|
+
})
|
|
13929
|
+
),
|
|
13930
|
+
meters: arrayType(
|
|
13931
|
+
objectType({
|
|
13932
|
+
currency: stringType(),
|
|
13933
|
+
description: stringType().nullable(),
|
|
13934
|
+
free_threshold: numberType(),
|
|
13935
|
+
measurement_unit: stringType(),
|
|
13936
|
+
meter_id: stringType(),
|
|
13937
|
+
name: stringType(),
|
|
13938
|
+
price_per_unit: stringType().nullable()
|
|
13939
|
+
})
|
|
13940
|
+
),
|
|
13941
|
+
metadata: recordType(anyType()),
|
|
13942
|
+
next_billing_date: stringType().transform((d) => new Date(d)),
|
|
13380
13943
|
on_demand: booleanType(),
|
|
13381
13944
|
payment_frequency_count: numberType(),
|
|
13382
13945
|
payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
13383
|
-
|
|
13946
|
+
payment_method_id: stringType().nullable(),
|
|
13947
|
+
previous_billing_date: stringType().transform((d) => new Date(d)),
|
|
13384
13948
|
product_id: stringType(),
|
|
13385
13949
|
quantity: numberType(),
|
|
13386
13950
|
recurring_pre_tax_amount: numberType(),
|
|
@@ -13388,7 +13952,6 @@ var SubscriptionSchema = objectType({
|
|
|
13388
13952
|
"pending",
|
|
13389
13953
|
"active",
|
|
13390
13954
|
"on_hold",
|
|
13391
|
-
"paused",
|
|
13392
13955
|
"cancelled",
|
|
13393
13956
|
"expired",
|
|
13394
13957
|
"failed"
|
|
@@ -13396,20 +13959,29 @@ var SubscriptionSchema = objectType({
|
|
|
13396
13959
|
subscription_id: stringType(),
|
|
13397
13960
|
subscription_period_count: numberType(),
|
|
13398
13961
|
subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
|
|
13962
|
+
tax_id: stringType().nullable(),
|
|
13399
13963
|
tax_inclusive: booleanType(),
|
|
13400
13964
|
trial_period_days: numberType()
|
|
13401
13965
|
});
|
|
13402
13966
|
var RefundSchema = objectType({
|
|
13403
13967
|
payload_type: literalType("Refund"),
|
|
13404
|
-
amount: numberType(),
|
|
13968
|
+
amount: numberType().nullable(),
|
|
13405
13969
|
business_id: stringType(),
|
|
13406
13970
|
created_at: stringType().transform((d) => new Date(d)),
|
|
13407
|
-
|
|
13971
|
+
customer: objectType({
|
|
13972
|
+
customer_id: stringType(),
|
|
13973
|
+
email: stringType(),
|
|
13974
|
+
metadata: recordType(anyType()),
|
|
13975
|
+
name: stringType(),
|
|
13976
|
+
phone_number: stringType().nullable()
|
|
13977
|
+
}),
|
|
13978
|
+
currency: stringType().nullable(),
|
|
13408
13979
|
is_partial: booleanType(),
|
|
13980
|
+
metadata: recordType(anyType()),
|
|
13409
13981
|
payment_id: stringType(),
|
|
13410
13982
|
reason: stringType().nullable(),
|
|
13411
13983
|
refund_id: stringType(),
|
|
13412
|
-
status: enumType(["succeeded", "failed", "pending"])
|
|
13984
|
+
status: enumType(["succeeded", "failed", "pending", "review"])
|
|
13413
13985
|
});
|
|
13414
13986
|
var DisputeSchema = objectType({
|
|
13415
13987
|
payload_type: literalType("Dispute"),
|
|
@@ -13417,27 +13989,31 @@ var DisputeSchema = objectType({
|
|
|
13417
13989
|
business_id: stringType(),
|
|
13418
13990
|
created_at: stringType().transform((d) => new Date(d)),
|
|
13419
13991
|
currency: stringType(),
|
|
13992
|
+
customer: objectType({
|
|
13993
|
+
customer_id: stringType(),
|
|
13994
|
+
email: stringType(),
|
|
13995
|
+
metadata: recordType(anyType()),
|
|
13996
|
+
name: stringType(),
|
|
13997
|
+
phone_number: stringType().nullable()
|
|
13998
|
+
}),
|
|
13420
13999
|
dispute_id: stringType(),
|
|
13421
|
-
dispute_stage: enumType([
|
|
13422
|
-
"pre_dispute",
|
|
13423
|
-
"dispute_opened",
|
|
13424
|
-
"dispute_won",
|
|
13425
|
-
"dispute_lost"
|
|
13426
|
-
]),
|
|
14000
|
+
dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
|
|
13427
14001
|
dispute_status: enumType([
|
|
13428
14002
|
"dispute_opened",
|
|
13429
|
-
"
|
|
13430
|
-
"dispute_lost",
|
|
14003
|
+
"dispute_expired",
|
|
13431
14004
|
"dispute_accepted",
|
|
13432
14005
|
"dispute_cancelled",
|
|
13433
|
-
"dispute_challenged"
|
|
14006
|
+
"dispute_challenged",
|
|
14007
|
+
"dispute_won",
|
|
14008
|
+
"dispute_lost"
|
|
13434
14009
|
]),
|
|
13435
14010
|
payment_id: stringType(),
|
|
14011
|
+
reason: stringType().nullable(),
|
|
13436
14012
|
remarks: stringType().nullable()
|
|
13437
14013
|
});
|
|
13438
14014
|
var LicenseKeySchema = objectType({
|
|
13439
14015
|
payload_type: literalType("LicenseKey"),
|
|
13440
|
-
activations_limit: numberType(),
|
|
14016
|
+
activations_limit: numberType().nullable(),
|
|
13441
14017
|
business_id: stringType(),
|
|
13442
14018
|
created_at: stringType().transform((d) => new Date(d)),
|
|
13443
14019
|
customer_id: stringType(),
|
|
@@ -13447,7 +14023,7 @@ var LicenseKeySchema = objectType({
|
|
|
13447
14023
|
key: stringType(),
|
|
13448
14024
|
payment_id: stringType(),
|
|
13449
14025
|
product_id: stringType(),
|
|
13450
|
-
status: enumType(["active", "
|
|
14026
|
+
status: enumType(["active", "expired", "disabled"]),
|
|
13451
14027
|
subscription_id: stringType().nullable()
|
|
13452
14028
|
});
|
|
13453
14029
|
var PaymentSucceededPayloadSchema = objectType({
|
|
@@ -13546,12 +14122,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
|
|
|
13546
14122
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
13547
14123
|
data: SubscriptionSchema
|
|
13548
14124
|
});
|
|
13549
|
-
var SubscriptionPausedPayloadSchema = objectType({
|
|
13550
|
-
business_id: stringType(),
|
|
13551
|
-
type: literalType("subscription.paused"),
|
|
13552
|
-
timestamp: stringType().transform((d) => new Date(d)),
|
|
13553
|
-
data: SubscriptionSchema
|
|
13554
|
-
});
|
|
13555
14125
|
var SubscriptionPlanChangedPayloadSchema = objectType({
|
|
13556
14126
|
business_id: stringType(),
|
|
13557
14127
|
type: literalType("subscription.plan_changed"),
|
|
@@ -13588,6 +14158,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
|
|
|
13588
14158
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
13589
14159
|
data: LicenseKeySchema
|
|
13590
14160
|
});
|
|
14161
|
+
var CreditLedgerEntrySchema = objectType({
|
|
14162
|
+
payload_type: literalType("CreditLedgerEntry"),
|
|
14163
|
+
id: stringType(),
|
|
14164
|
+
amount: stringType(),
|
|
14165
|
+
balance_after: stringType(),
|
|
14166
|
+
balance_before: stringType(),
|
|
14167
|
+
business_id: stringType(),
|
|
14168
|
+
created_at: stringType().transform((d) => new Date(d)),
|
|
14169
|
+
credit_entitlement_id: stringType(),
|
|
14170
|
+
customer_id: stringType(),
|
|
14171
|
+
is_credit: booleanType(),
|
|
14172
|
+
overage_after: stringType(),
|
|
14173
|
+
overage_before: stringType(),
|
|
14174
|
+
transaction_type: enumType([
|
|
14175
|
+
"credit_added",
|
|
14176
|
+
"credit_deducted",
|
|
14177
|
+
"credit_expired",
|
|
14178
|
+
"credit_rolled_over",
|
|
14179
|
+
"rollover_forfeited",
|
|
14180
|
+
"overage_charged",
|
|
14181
|
+
"auto_top_up",
|
|
14182
|
+
"manual_adjustment",
|
|
14183
|
+
"refund"
|
|
14184
|
+
]),
|
|
14185
|
+
description: stringType().nullable(),
|
|
14186
|
+
grant_id: stringType().nullable(),
|
|
14187
|
+
reference_id: stringType().nullable(),
|
|
14188
|
+
reference_type: stringType().nullable()
|
|
14189
|
+
});
|
|
14190
|
+
var CreditBalanceLowSchema = objectType({
|
|
14191
|
+
payload_type: literalType("CreditBalanceLow"),
|
|
14192
|
+
customer_id: stringType(),
|
|
14193
|
+
subscription_id: stringType(),
|
|
14194
|
+
credit_entitlement_id: stringType(),
|
|
14195
|
+
credit_entitlement_name: stringType(),
|
|
14196
|
+
available_balance: stringType(),
|
|
14197
|
+
subscription_credits_amount: stringType(),
|
|
14198
|
+
threshold_percent: numberType(),
|
|
14199
|
+
threshold_amount: stringType()
|
|
14200
|
+
});
|
|
14201
|
+
var CreditAddedPayloadSchema = objectType({
|
|
14202
|
+
business_id: stringType(),
|
|
14203
|
+
type: literalType("credit.added"),
|
|
14204
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14205
|
+
data: CreditLedgerEntrySchema
|
|
14206
|
+
});
|
|
14207
|
+
var CreditDeductedPayloadSchema = objectType({
|
|
14208
|
+
business_id: stringType(),
|
|
14209
|
+
type: literalType("credit.deducted"),
|
|
14210
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14211
|
+
data: CreditLedgerEntrySchema
|
|
14212
|
+
});
|
|
14213
|
+
var CreditExpiredPayloadSchema = objectType({
|
|
14214
|
+
business_id: stringType(),
|
|
14215
|
+
type: literalType("credit.expired"),
|
|
14216
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14217
|
+
data: CreditLedgerEntrySchema
|
|
14218
|
+
});
|
|
14219
|
+
var CreditRolledOverPayloadSchema = objectType({
|
|
14220
|
+
business_id: stringType(),
|
|
14221
|
+
type: literalType("credit.rolled_over"),
|
|
14222
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14223
|
+
data: CreditLedgerEntrySchema
|
|
14224
|
+
});
|
|
14225
|
+
var CreditRolloverForfeitedPayloadSchema = objectType({
|
|
14226
|
+
business_id: stringType(),
|
|
14227
|
+
type: literalType("credit.rollover_forfeited"),
|
|
14228
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14229
|
+
data: CreditLedgerEntrySchema
|
|
14230
|
+
});
|
|
14231
|
+
var CreditOverageChargedPayloadSchema = objectType({
|
|
14232
|
+
business_id: stringType(),
|
|
14233
|
+
type: literalType("credit.overage_charged"),
|
|
14234
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14235
|
+
data: CreditLedgerEntrySchema
|
|
14236
|
+
});
|
|
14237
|
+
var CreditManualAdjustmentPayloadSchema = objectType({
|
|
14238
|
+
business_id: stringType(),
|
|
14239
|
+
type: literalType("credit.manual_adjustment"),
|
|
14240
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14241
|
+
data: CreditLedgerEntrySchema
|
|
14242
|
+
});
|
|
14243
|
+
var CreditBalanceLowPayloadSchema = objectType({
|
|
14244
|
+
business_id: stringType(),
|
|
14245
|
+
type: literalType("credit.balance_low"),
|
|
14246
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
14247
|
+
data: CreditBalanceLowSchema
|
|
14248
|
+
});
|
|
13591
14249
|
var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
13592
14250
|
PaymentSucceededPayloadSchema,
|
|
13593
14251
|
PaymentFailedPayloadSchema,
|
|
@@ -13605,13 +14263,20 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
13605
14263
|
SubscriptionActivePayloadSchema,
|
|
13606
14264
|
SubscriptionOnHoldPayloadSchema,
|
|
13607
14265
|
SubscriptionRenewedPayloadSchema,
|
|
13608
|
-
SubscriptionPausedPayloadSchema,
|
|
13609
14266
|
SubscriptionPlanChangedPayloadSchema,
|
|
13610
14267
|
SubscriptionCancelledPayloadSchema,
|
|
13611
14268
|
SubscriptionFailedPayloadSchema,
|
|
13612
14269
|
SubscriptionExpiredPayloadSchema,
|
|
13613
14270
|
SubscriptionUpdatedPayloadSchema,
|
|
13614
|
-
LicenseKeyCreatedPayloadSchema
|
|
14271
|
+
LicenseKeyCreatedPayloadSchema,
|
|
14272
|
+
CreditAddedPayloadSchema,
|
|
14273
|
+
CreditDeductedPayloadSchema,
|
|
14274
|
+
CreditExpiredPayloadSchema,
|
|
14275
|
+
CreditRolledOverPayloadSchema,
|
|
14276
|
+
CreditRolloverForfeitedPayloadSchema,
|
|
14277
|
+
CreditOverageChargedPayloadSchema,
|
|
14278
|
+
CreditManualAdjustmentPayloadSchema,
|
|
14279
|
+
CreditBalanceLowPayloadSchema
|
|
13615
14280
|
]);
|
|
13616
14281
|
|
|
13617
14282
|
// ../../node_modules/@stablelib/base64/lib/base64.js
|
|
@@ -14339,9 +15004,6 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
14339
15004
|
if (payload.type === "subscription.renewed") {
|
|
14340
15005
|
await callHandler(config.onSubscriptionRenewed, payload);
|
|
14341
15006
|
}
|
|
14342
|
-
if (payload.type === "subscription.paused") {
|
|
14343
|
-
await callHandler(config.onSubscriptionPaused, payload);
|
|
14344
|
-
}
|
|
14345
15007
|
if (payload.type === "subscription.plan_changed") {
|
|
14346
15008
|
await callHandler(config.onSubscriptionPlanChanged, payload);
|
|
14347
15009
|
}
|
|
@@ -14360,6 +15022,30 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
14360
15022
|
if (payload.type === "license_key.created") {
|
|
14361
15023
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
14362
15024
|
}
|
|
15025
|
+
if (payload.type === "credit.added") {
|
|
15026
|
+
await callHandler(config.onCreditAdded, payload);
|
|
15027
|
+
}
|
|
15028
|
+
if (payload.type === "credit.deducted") {
|
|
15029
|
+
await callHandler(config.onCreditDeducted, payload);
|
|
15030
|
+
}
|
|
15031
|
+
if (payload.type === "credit.expired") {
|
|
15032
|
+
await callHandler(config.onCreditExpired, payload);
|
|
15033
|
+
}
|
|
15034
|
+
if (payload.type === "credit.rolled_over") {
|
|
15035
|
+
await callHandler(config.onCreditRolledOver, payload);
|
|
15036
|
+
}
|
|
15037
|
+
if (payload.type === "credit.rollover_forfeited") {
|
|
15038
|
+
await callHandler(config.onCreditRolloverForfeited, payload);
|
|
15039
|
+
}
|
|
15040
|
+
if (payload.type === "credit.overage_charged") {
|
|
15041
|
+
await callHandler(config.onCreditOverageCharged, payload);
|
|
15042
|
+
}
|
|
15043
|
+
if (payload.type === "credit.manual_adjustment") {
|
|
15044
|
+
await callHandler(config.onCreditManualAdjustment, payload);
|
|
15045
|
+
}
|
|
15046
|
+
if (payload.type === "credit.balance_low") {
|
|
15047
|
+
await callHandler(config.onCreditBalanceLow, payload);
|
|
15048
|
+
}
|
|
14363
15049
|
}
|
|
14364
15050
|
|
|
14365
15051
|
const Webhooks = ({ webhookKey, ...eventHandlers }) => {
|