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