@freemius/sdk 0.0.5 → 0.1.0
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/README.md +1 -1
- package/dist/index.d.mts +153 -63
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +153 -63
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +212 -119
- package/dist/index.mjs +210 -120
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ your front-end to quickly render Checkout overlays, pricing tables, and a custom
|
|
|
56
56
|
## Installation
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npm install @freemius/sdk zod
|
|
59
|
+
npm install @freemius/sdk @freemius/checkout zod
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Requires Node.js 18+ (or an Edge runtime supporting Web Crypto + standard fetch APIs). See the
|
package/dist/index.d.mts
CHANGED
|
@@ -12935,6 +12935,7 @@ type PlanEntity = components['schemas']['Plan'];
|
|
|
12935
12935
|
type BillingEntity = components['schemas']['Billing'];
|
|
12936
12936
|
type BillingUpdatePayload = operations['users/update-or-create-billing']['requestBody']['content']['application/json'];
|
|
12937
12937
|
type EventEntity = components['schemas']['EventLog'];
|
|
12938
|
+
type EventFilterOptions = ApiEntitiesFilter<operations['events/list']['parameters']['query']>;
|
|
12938
12939
|
type InstallEntity = components['schemas']['Install'];
|
|
12939
12940
|
type BillingCycleApiEnum = components['schemas']['CommonEnums']['BillingCycle'];
|
|
12940
12941
|
type CurrencyApiEnum = components['schemas']['CommonEnums']['Currency'];
|
|
@@ -13195,9 +13196,9 @@ interface CheckoutRedirectData {
|
|
|
13195
13196
|
*/
|
|
13196
13197
|
pricing_id: string;
|
|
13197
13198
|
/**
|
|
13198
|
-
*
|
|
13199
|
+
* Indicates the type of action performed during checkout.
|
|
13199
13200
|
*/
|
|
13200
|
-
|
|
13201
|
+
action: 'payment_method_update' | 'license_update' | 'trial' | 'purchase';
|
|
13201
13202
|
/**
|
|
13202
13203
|
* ID of the Freemius license, if available.
|
|
13203
13204
|
*/
|
|
@@ -13211,12 +13212,17 @@ interface CheckoutRedirectData {
|
|
|
13211
13212
|
*/
|
|
13212
13213
|
quota: number | null;
|
|
13213
13214
|
/**
|
|
13214
|
-
* Indicates the
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13215
|
+
* Indicates if the trial is free or paid. Null if not a trial.
|
|
13216
|
+
*/
|
|
13217
|
+
trial: 'free' | 'paid' | null;
|
|
13218
|
+
/**
|
|
13219
|
+
* End date of the trial period, if applicable.
|
|
13220
|
+
*/
|
|
13221
|
+
trial_ends_at: Date | null;
|
|
13222
|
+
/**
|
|
13223
|
+
* Currency of the purchase (ISO code).
|
|
13218
13224
|
*/
|
|
13219
|
-
|
|
13225
|
+
currency: CURRENCY;
|
|
13220
13226
|
/**
|
|
13221
13227
|
* Total amount charged for the purchase.
|
|
13222
13228
|
*/
|
|
@@ -13225,18 +13231,6 @@ interface CheckoutRedirectData {
|
|
|
13225
13231
|
* Tax amount applied to the purchase.
|
|
13226
13232
|
*/
|
|
13227
13233
|
tax: number;
|
|
13228
|
-
/**
|
|
13229
|
-
* Indicates a subscription purchase.
|
|
13230
|
-
* If present, the following fields are required:
|
|
13231
|
-
* - type: 'subscription'
|
|
13232
|
-
* - subscription_id
|
|
13233
|
-
* - billing_cycle
|
|
13234
|
-
*
|
|
13235
|
-
* If not present, the purchase is a one-off and the following fields are required:
|
|
13236
|
-
* - type: 'one-off'
|
|
13237
|
-
* - payment_id
|
|
13238
|
-
*/
|
|
13239
|
-
type: 'subscription' | 'one-off';
|
|
13240
13234
|
/**
|
|
13241
13235
|
* ID of the Freemius subscription associated with the license (for subscriptions only).
|
|
13242
13236
|
*/
|
|
@@ -13249,6 +13243,20 @@ interface CheckoutRedirectData {
|
|
|
13249
13243
|
* ID of the payment for the one-off purchase (for one-off only).
|
|
13250
13244
|
*/
|
|
13251
13245
|
payment_id: string | null;
|
|
13246
|
+
/**
|
|
13247
|
+
* Indicates a subscription purchase.
|
|
13248
|
+
* If present, the following fields are required:
|
|
13249
|
+
* - type: 'subscription'
|
|
13250
|
+
* - subscription_id
|
|
13251
|
+
* - billing_cycle
|
|
13252
|
+
*
|
|
13253
|
+
* If not present, the purchase is a one-off and the following fields are required:
|
|
13254
|
+
* - type: 'one-off'
|
|
13255
|
+
* - payment_id
|
|
13256
|
+
*
|
|
13257
|
+
* If null, indicates this is a free trial purchase and the final type of purchase is not applicable.
|
|
13258
|
+
*/
|
|
13259
|
+
type: 'subscription' | 'one-off' | null;
|
|
13252
13260
|
}
|
|
13253
13261
|
type CheckoutBuilderUserOptions = {
|
|
13254
13262
|
email: string;
|
|
@@ -13301,6 +13309,12 @@ type CheckoutBuilderOptions = {
|
|
|
13301
13309
|
* If not provided, the checkout will not have a trial period.
|
|
13302
13310
|
*/
|
|
13303
13311
|
trial?: CheckoutOptions['trial'];
|
|
13312
|
+
/**
|
|
13313
|
+
* Optional license ID for license upgrade scenarios.
|
|
13314
|
+
*
|
|
13315
|
+
* When provided, the checkout will be configured for upgrading the specified license. Use this to generate upgrade links for existing users.
|
|
13316
|
+
*/
|
|
13317
|
+
licenseId?: string;
|
|
13304
13318
|
};
|
|
13305
13319
|
/**
|
|
13306
13320
|
* Interface for actions that can be processed during the checkout flow.
|
|
@@ -13332,6 +13346,20 @@ type PricingData = {
|
|
|
13332
13346
|
sellingUnit: SellingUnit;
|
|
13333
13347
|
};
|
|
13334
13348
|
//#endregion
|
|
13349
|
+
//#region src/contracts/webhook.d.ts
|
|
13350
|
+
type WebhookListenerResponse = {
|
|
13351
|
+
status: number;
|
|
13352
|
+
} & ({
|
|
13353
|
+
success: true;
|
|
13354
|
+
} | {
|
|
13355
|
+
success: false;
|
|
13356
|
+
error: string;
|
|
13357
|
+
});
|
|
13358
|
+
declare enum WebhookAuthenticationMethod {
|
|
13359
|
+
SignatureHeader = "SignatureHeader",
|
|
13360
|
+
Api = "Api",
|
|
13361
|
+
}
|
|
13362
|
+
//#endregion
|
|
13335
13363
|
//#region src/api/parser.d.ts
|
|
13336
13364
|
declare function idToNumber(id: FSId): number;
|
|
13337
13365
|
declare function idToString(id: FSId): string;
|
|
@@ -13343,6 +13371,26 @@ declare function parseDate(dateString?: string | null): Date | null;
|
|
|
13343
13371
|
declare function parseCurrency(currency?: CurrencyApiEnum): CURRENCY | null;
|
|
13344
13372
|
declare function parsePaymentMethod(gateway?: string | null): PaymentMethod | null;
|
|
13345
13373
|
//#endregion
|
|
13374
|
+
//#region src/errors/ActionError.d.ts
|
|
13375
|
+
declare class ActionError extends Error {
|
|
13376
|
+
readonly statusCode: number;
|
|
13377
|
+
readonly validationIssues?: unknown;
|
|
13378
|
+
constructor(message: string, statusCode?: number, validationIssues?: unknown);
|
|
13379
|
+
toResponse(): Response;
|
|
13380
|
+
static badRequest(message: string): ActionError;
|
|
13381
|
+
static unauthorized(message?: string): ActionError;
|
|
13382
|
+
static notFound(message?: string): ActionError;
|
|
13383
|
+
static validationFailed(message: string, validationIssues: unknown): ActionError;
|
|
13384
|
+
static internalError(message?: string): ActionError;
|
|
13385
|
+
}
|
|
13386
|
+
//#endregion
|
|
13387
|
+
//#region src/errors/WebhookError.d.ts
|
|
13388
|
+
declare class WebhookError extends Error {
|
|
13389
|
+
readonly statusCode: number;
|
|
13390
|
+
constructor(message: string, statusCode?: number);
|
|
13391
|
+
toResponse(): WebhookListenerResponse;
|
|
13392
|
+
}
|
|
13393
|
+
//#endregion
|
|
13346
13394
|
//#region src/api/client.d.ts
|
|
13347
13395
|
declare function createApiClient(baseUrl: string, bearerToken?: string): createClient.Client<paths, `${string}/${string}`>;
|
|
13348
13396
|
type FsApiClient = ReturnType<typeof createApiClient>;
|
|
@@ -13619,6 +13667,48 @@ declare class Payment extends ApiBase<PaymentEntity, PaymentFilterOptions> {
|
|
|
13619
13667
|
retrieveInvoice(paymentId: FSId): Promise<Blob | null>;
|
|
13620
13668
|
}
|
|
13621
13669
|
//#endregion
|
|
13670
|
+
//#region src/api/WebhookEvent.d.ts
|
|
13671
|
+
declare class WebhookEvent$1 extends ApiBase<EventEntity, EventFilterOptions> {
|
|
13672
|
+
retrieve(eventId: FSId): Promise<({
|
|
13673
|
+
state?: components["schemas"]["CommonEnums"]["EventLogState"];
|
|
13674
|
+
id?: components["schemas"]["CommonProperties"]["id"];
|
|
13675
|
+
created?: components["schemas"]["CommonProperties"]["created"];
|
|
13676
|
+
updated?: components["schemas"]["CommonProperties"]["updated"];
|
|
13677
|
+
type?: string;
|
|
13678
|
+
developer_id?: string;
|
|
13679
|
+
plugin_id?: components["schemas"]["CommonProperties"]["plugin_id_nullable"];
|
|
13680
|
+
user_id?: components["schemas"]["CommonProperties"]["user_id_nullable"];
|
|
13681
|
+
install_id?: components["schemas"]["CommonProperties"]["install_id_nullable"];
|
|
13682
|
+
data?: unknown;
|
|
13683
|
+
event_trigger?: "system" | "developer" | "plugin" | "user" | "install";
|
|
13684
|
+
process_time?: string | null;
|
|
13685
|
+
} & {
|
|
13686
|
+
objects?: {
|
|
13687
|
+
user?: components["schemas"]["UserPluginEnriched"] | null;
|
|
13688
|
+
install?: components["schemas"]["Install"] | null;
|
|
13689
|
+
payment?: components["schemas"]["Payment"] | null;
|
|
13690
|
+
subscription?: components["schemas"]["Subscription"] | null;
|
|
13691
|
+
license?: components["schemas"]["License"] | null;
|
|
13692
|
+
} & {
|
|
13693
|
+
[key: string]: unknown;
|
|
13694
|
+
};
|
|
13695
|
+
}) | null>;
|
|
13696
|
+
retrieveMany(filter?: EventFilterOptions, pagination?: PagingOptions): Promise<{
|
|
13697
|
+
state?: components["schemas"]["CommonEnums"]["EventLogState"];
|
|
13698
|
+
id?: components["schemas"]["CommonProperties"]["id"];
|
|
13699
|
+
created?: components["schemas"]["CommonProperties"]["created"];
|
|
13700
|
+
updated?: components["schemas"]["CommonProperties"]["updated"];
|
|
13701
|
+
type?: string;
|
|
13702
|
+
developer_id?: string;
|
|
13703
|
+
plugin_id?: components["schemas"]["CommonProperties"]["plugin_id_nullable"];
|
|
13704
|
+
user_id?: components["schemas"]["CommonProperties"]["user_id_nullable"];
|
|
13705
|
+
install_id?: components["schemas"]["CommonProperties"]["install_id_nullable"];
|
|
13706
|
+
data?: unknown;
|
|
13707
|
+
event_trigger?: "system" | "developer" | "plugin" | "user" | "install";
|
|
13708
|
+
process_time?: string | null;
|
|
13709
|
+
}[]>;
|
|
13710
|
+
}
|
|
13711
|
+
//#endregion
|
|
13622
13712
|
//#region src/services/ApiService.d.ts
|
|
13623
13713
|
/**
|
|
13624
13714
|
* @todo - Add a proper user-agent string with SDK version.
|
|
@@ -13633,6 +13723,7 @@ declare class ApiService {
|
|
|
13633
13723
|
readonly product: Product;
|
|
13634
13724
|
readonly subscription: Subscription;
|
|
13635
13725
|
readonly payment: Payment;
|
|
13726
|
+
readonly event: WebhookEvent$1;
|
|
13636
13727
|
readonly baseUrl: string;
|
|
13637
13728
|
constructor(productId: FSId, apiKey: string, secretKey: string, publicKey: string);
|
|
13638
13729
|
/**
|
|
@@ -13668,6 +13759,10 @@ type CheckoutSerialized = {
|
|
|
13668
13759
|
link: string;
|
|
13669
13760
|
baseUrl: string;
|
|
13670
13761
|
};
|
|
13762
|
+
type CheckoutLicenseAuthorization = {
|
|
13763
|
+
licenseId: FSId;
|
|
13764
|
+
authorization: string;
|
|
13765
|
+
};
|
|
13671
13766
|
/**
|
|
13672
13767
|
* A builder class for constructing checkout parameters. This class provides a fluent
|
|
13673
13768
|
* API to create Checkout parameters for a product with various configurations.
|
|
@@ -13679,43 +13774,37 @@ declare class Checkout {
|
|
|
13679
13774
|
private readonly productId;
|
|
13680
13775
|
private readonly publicKey;
|
|
13681
13776
|
private readonly secretKey;
|
|
13682
|
-
static createSandboxToken(productId: string, secretKey: string, publicKey: string): NonNullable<CheckoutPopupParams['sandbox']>;
|
|
13683
13777
|
private options;
|
|
13684
13778
|
constructor(productId: string, publicKey: string, secretKey: string);
|
|
13685
13779
|
/**
|
|
13686
13780
|
* Enables sandbox mode for testing purposes.
|
|
13687
13781
|
*
|
|
13688
|
-
* @returns A new builder instance with sandbox configuration
|
|
13689
13782
|
*/
|
|
13690
|
-
setSandbox(): Checkout;
|
|
13783
|
+
setSandbox(sandbox: NonNullable<CheckoutPopupParams['sandbox']>): Checkout;
|
|
13691
13784
|
/**
|
|
13692
13785
|
* Sets user information for the checkout session.
|
|
13693
13786
|
*
|
|
13694
13787
|
* @param user User object with email and optional name fields. The shape matches the session from `better-auth` or next-auth packages. Also handles `null` or `undefined` gracefully.
|
|
13695
13788
|
* @param readonly If true, the user information will be read-only in the checkout session.
|
|
13696
13789
|
*
|
|
13697
|
-
* @returns A new builder instance with user configuration
|
|
13698
13790
|
*/
|
|
13699
13791
|
setUser(user: CheckoutBuilderUserOptions, readonly?: boolean): Checkout;
|
|
13700
13792
|
/**
|
|
13701
13793
|
* Applies recommended UI settings for better user experience.
|
|
13702
13794
|
* This includes fullscreen mode, upsells, refund badge, and reviews display.
|
|
13703
13795
|
*
|
|
13704
|
-
* @returns A new builder instance with recommended UI settings
|
|
13705
13796
|
*/
|
|
13706
13797
|
setRecommendations(): Checkout;
|
|
13707
13798
|
/**
|
|
13708
13799
|
* Sets the plan ID for the checkout.
|
|
13709
13800
|
*
|
|
13710
13801
|
* @param planId The plan ID to purchase
|
|
13711
|
-
* @returns A new builder instance with plan ID set
|
|
13712
13802
|
*/
|
|
13713
13803
|
setPlan(planId: string | number): Checkout;
|
|
13714
13804
|
/**
|
|
13715
13805
|
* Sets the number of licenses to purchase.
|
|
13716
13806
|
*
|
|
13717
13807
|
* @param count Number of licenses
|
|
13718
|
-
* @returns A new builder instance with license count set
|
|
13719
13808
|
*/
|
|
13720
13809
|
setQuota(count: number): Checkout;
|
|
13721
13810
|
setPricing(pricingId: string | number): Checkout;
|
|
@@ -13725,7 +13814,6 @@ declare class Checkout {
|
|
|
13725
13814
|
*
|
|
13726
13815
|
* @param coupon The coupon code to apply
|
|
13727
13816
|
* @param hideUI Whether to hide the coupon input field from users
|
|
13728
|
-
* @returns A new builder instance with coupon configuration
|
|
13729
13817
|
*/
|
|
13730
13818
|
setCoupon(options: {
|
|
13731
13819
|
code: string;
|
|
@@ -13735,14 +13823,12 @@ declare class Checkout {
|
|
|
13735
13823
|
* Enables trial mode for the checkout.
|
|
13736
13824
|
*
|
|
13737
13825
|
* @param mode Trial type - true/false for plan default, or specific 'free'/'paid' mode
|
|
13738
|
-
* @returns A new builder instance with trial configuration
|
|
13739
13826
|
*/
|
|
13740
13827
|
setTrial(mode?: 'free' | 'paid' | boolean): Checkout;
|
|
13741
13828
|
/**
|
|
13742
13829
|
* Configures the visual layout and appearance of the checkout.
|
|
13743
13830
|
*
|
|
13744
13831
|
* @param options Appearance configuration options
|
|
13745
|
-
* @returns A new builder instance with appearance configuration
|
|
13746
13832
|
*/
|
|
13747
13833
|
setAppearance(options: {
|
|
13748
13834
|
layout?: 'vertical' | 'horizontal' | null;
|
|
@@ -13755,7 +13841,6 @@ declare class Checkout {
|
|
|
13755
13841
|
* Configures discount display settings.
|
|
13756
13842
|
*
|
|
13757
13843
|
* @param options Discount configuration options
|
|
13758
|
-
* @returns A new builder instance with discount configuration
|
|
13759
13844
|
*/
|
|
13760
13845
|
setDiscounts(options: {
|
|
13761
13846
|
annual?: boolean;
|
|
@@ -13768,21 +13853,18 @@ declare class Checkout {
|
|
|
13768
13853
|
*
|
|
13769
13854
|
* @param selector Type of billing cycle selector to show
|
|
13770
13855
|
* @param defaultCycle Default billing cycle to select
|
|
13771
|
-
* @returns A new builder instance with billing cycle configuration
|
|
13772
13856
|
*/
|
|
13773
13857
|
setBillingCycle(defaultCycle: 'monthly' | 'annual' | 'lifetime', selector?: 'list' | 'responsive_list' | 'dropdown'): Checkout;
|
|
13774
13858
|
/**
|
|
13775
13859
|
* Sets the language/locale for the checkout.
|
|
13776
13860
|
*
|
|
13777
13861
|
* @param locale Language setting - 'auto', 'auto-beta', or specific locale like 'en_US'
|
|
13778
|
-
* @returns A new builder instance with locale configuration
|
|
13779
13862
|
*/
|
|
13780
13863
|
setLanguage(locale?: 'auto' | 'auto-beta' | string): Checkout;
|
|
13781
13864
|
/**
|
|
13782
13865
|
* Configures review and badge display settings.
|
|
13783
13866
|
*
|
|
13784
13867
|
* @param options Review and badge configuration
|
|
13785
|
-
* @returns A new builder instance with reviews and badges configuration
|
|
13786
13868
|
*/
|
|
13787
13869
|
setSocialProofing(options: {
|
|
13788
13870
|
showReviews?: boolean;
|
|
@@ -13796,7 +13878,6 @@ declare class Checkout {
|
|
|
13796
13878
|
* @param currency Primary currency or 'auto' for automatic detection
|
|
13797
13879
|
* @param defaultCurrency Default currency when using 'auto'
|
|
13798
13880
|
* @param showInlineSelector Whether to show inline currency selector
|
|
13799
|
-
* @returns A new builder instance with currency configuration
|
|
13800
13881
|
*/
|
|
13801
13882
|
setCurrency(currency: 'usd' | 'eur' | 'gbp' | 'auto', defaultCurrency?: 'usd' | 'eur' | 'gbp', showInlineSelector?: boolean): Checkout;
|
|
13802
13883
|
/**
|
|
@@ -13804,42 +13885,42 @@ declare class Checkout {
|
|
|
13804
13885
|
*
|
|
13805
13886
|
* @param cancelUrl URL for back button when in page mode
|
|
13806
13887
|
* @param cancelIcon Custom cancel icon URL
|
|
13807
|
-
* @returns A new builder instance with navigation configuration
|
|
13808
13888
|
*/
|
|
13809
13889
|
setCancelButton(cancelUrl?: string, cancelIcon?: string): Checkout;
|
|
13810
13890
|
/**
|
|
13811
13891
|
* Associates purchases with an affiliate account.
|
|
13812
13892
|
*
|
|
13813
13893
|
* @param userId Affiliate user ID
|
|
13814
|
-
* @returns A new builder instance with affiliate configuration
|
|
13815
13894
|
*/
|
|
13816
13895
|
setAffiliate(userId: number): Checkout;
|
|
13817
13896
|
/**
|
|
13818
13897
|
* Sets a custom image/icon for the checkout.
|
|
13819
13898
|
*
|
|
13820
13899
|
* @param imageUrl Secure HTTPS URL to the image
|
|
13821
|
-
* @returns A new builder instance with custom image
|
|
13822
13900
|
*/
|
|
13823
13901
|
setImage(imageUrl: string): Checkout;
|
|
13824
13902
|
/**
|
|
13825
|
-
* Configures the checkout for license renewal.
|
|
13903
|
+
* Configures the checkout for license renewal or upgrade by the license key.
|
|
13904
|
+
*
|
|
13905
|
+
* @note - This is less secure since it exposes the license key to the client. Use only in authenticated contexts.
|
|
13826
13906
|
*
|
|
13827
13907
|
* @param licenseKey The license key to renew
|
|
13828
|
-
* @returns A new builder instance configured for renewal
|
|
13829
13908
|
*/
|
|
13830
|
-
|
|
13909
|
+
setLicenseUpgradeByKey(licenseKey: string): Checkout;
|
|
13831
13910
|
/**
|
|
13832
|
-
*
|
|
13911
|
+
* Configures the checkout for license upgrade using an authorization token.
|
|
13833
13912
|
*
|
|
13834
|
-
* @
|
|
13913
|
+
* @param params The license upgrade authorization parameters
|
|
13914
|
+
*/
|
|
13915
|
+
setLicenseUpgradeByAuth(params: CheckoutLicenseAuthorization): Checkout;
|
|
13916
|
+
/**
|
|
13917
|
+
* Builds and returns the final checkout options to be used with the `@freemius/checkout` package.
|
|
13835
13918
|
*
|
|
13836
13919
|
* @returns The constructed CheckoutOptions object
|
|
13837
13920
|
*/
|
|
13838
13921
|
getOptions(): CheckoutOptions;
|
|
13839
13922
|
/**
|
|
13840
13923
|
* Generates a checkout link based on the current builder state.
|
|
13841
|
-
*
|
|
13842
|
-
* @note - This is async by purpose so that we can allow for future enhancements that might require async operations.
|
|
13843
13924
|
*/
|
|
13844
13925
|
getLink(): string;
|
|
13845
13926
|
serialize(): CheckoutSerialized;
|
|
@@ -13949,14 +14030,16 @@ declare class CheckoutRedirectInfo implements CheckoutRedirectData {
|
|
|
13949
14030
|
plan_id: string;
|
|
13950
14031
|
email: string;
|
|
13951
14032
|
pricing_id: string;
|
|
13952
|
-
|
|
14033
|
+
action: 'payment_method_update' | 'license_update' | 'trial' | 'purchase';
|
|
13953
14034
|
license_id: string;
|
|
13954
14035
|
expiration: Date | null;
|
|
13955
14036
|
quota: number | null;
|
|
13956
|
-
|
|
14037
|
+
trial: 'free' | 'paid' | null;
|
|
14038
|
+
trial_ends_at: Date | null;
|
|
14039
|
+
currency: CURRENCY;
|
|
13957
14040
|
amount: number;
|
|
13958
14041
|
tax: number;
|
|
13959
|
-
type: 'subscription' | 'one-off';
|
|
14042
|
+
type: 'subscription' | 'one-off' | null;
|
|
13960
14043
|
subscription_id: string | null;
|
|
13961
14044
|
billing_cycle: BILLING_CYCLE | null;
|
|
13962
14045
|
payment_id: string | null;
|
|
@@ -14047,13 +14130,14 @@ declare class CheckoutRequestProcessor implements RequestProcessor<CheckoutReque
|
|
|
14047
14130
|
//#endregion
|
|
14048
14131
|
//#region src/services/CheckoutService.d.ts
|
|
14049
14132
|
declare class CheckoutService {
|
|
14133
|
+
private readonly api;
|
|
14050
14134
|
private readonly productId;
|
|
14051
14135
|
private readonly publicKey;
|
|
14052
14136
|
private readonly secretKey;
|
|
14053
14137
|
private readonly purchase;
|
|
14054
14138
|
private readonly pricing;
|
|
14055
14139
|
readonly request: CheckoutRequestProcessor;
|
|
14056
|
-
constructor(productId: FSId, publicKey: string, secretKey: string, purchase: PurchaseService, pricing: PricingService);
|
|
14140
|
+
constructor(api: ApiService, productId: FSId, publicKey: string, secretKey: string, purchase: PurchaseService, pricing: PricingService);
|
|
14057
14141
|
/**
|
|
14058
14142
|
* Use this to build a Checkout for your product.
|
|
14059
14143
|
* You can build a Checkout link or options for the popup.
|
|
@@ -14093,11 +14177,14 @@ declare class CheckoutService {
|
|
|
14093
14177
|
* This shouldn't be used in production, but is useful for testing purposes.
|
|
14094
14178
|
*
|
|
14095
14179
|
* @note This is intentionally set as `async` because we would use the API in the future to generate more fine grained sandbox params (for example for a specific email address only).
|
|
14096
|
-
*
|
|
14097
|
-
* @todo - This has a duplication with the `inSandbox` method in the builder. Consider refactoring to avoid this duplication.
|
|
14098
|
-
* Also think about whether we should make the builder's `inSandbox` method async as well.
|
|
14099
14180
|
*/
|
|
14100
14181
|
getSandboxParams(): Promise<NonNullable<CheckoutPopupParams['sandbox']>>;
|
|
14182
|
+
/**
|
|
14183
|
+
* Retrieves the license upgrade authorization for a given license ID.
|
|
14184
|
+
*
|
|
14185
|
+
* This is used to authorize a license upgrade during the checkout process. Useful when creating upgrade links for existing users.
|
|
14186
|
+
*/
|
|
14187
|
+
getLicenseUpgradeAuth(licenseId: FSId): Promise<CheckoutLicenseAuthorization>;
|
|
14101
14188
|
/**
|
|
14102
14189
|
* Processes a redirect URL and returns the checkout redirect information if valid.
|
|
14103
14190
|
*
|
|
@@ -14600,19 +14687,13 @@ interface NormalizedRequest {
|
|
|
14600
14687
|
headers: Record<string, string | string[] | undefined> | Headers;
|
|
14601
14688
|
rawBody: string | Buffer;
|
|
14602
14689
|
}
|
|
14603
|
-
type WebhookListenerResponse = {
|
|
14604
|
-
status: number;
|
|
14605
|
-
} & ({
|
|
14606
|
-
success: true;
|
|
14607
|
-
} | {
|
|
14608
|
-
success: false;
|
|
14609
|
-
error: string;
|
|
14610
|
-
});
|
|
14611
14690
|
declare class WebhookListener {
|
|
14691
|
+
private readonly api;
|
|
14612
14692
|
private readonly secretKey;
|
|
14613
14693
|
private readonly onError;
|
|
14694
|
+
private readonly authenticationMethod;
|
|
14614
14695
|
private eventHandlers;
|
|
14615
|
-
constructor(secretKey: string, onError?: (error: unknown) => void);
|
|
14696
|
+
constructor(api: ApiService, secretKey: string, onError?: (error: unknown) => Promise<void>, authenticationMethod?: WebhookAuthenticationMethod);
|
|
14616
14697
|
on<T extends WebhookEventType>(type: T, handler: WebhookEventHandler<T>): this;
|
|
14617
14698
|
on<T extends WebhookEventType>(types: T[], handler: WebhookEventHandler<T>): this;
|
|
14618
14699
|
off<T extends WebhookEventType>(type: T, handler: WebhookEventHandler<T>): this;
|
|
@@ -14634,14 +14715,23 @@ declare class WebhookListener {
|
|
|
14634
14715
|
* Returns an object you can map to your framework's response easily.
|
|
14635
14716
|
*/
|
|
14636
14717
|
process(input: NormalizedRequest): Promise<WebhookListenerResponse>;
|
|
14718
|
+
private authenticateAndGetEventFromInput;
|
|
14719
|
+
private authenticateAndGetEventFromApi;
|
|
14720
|
+
private parseEventFromInput;
|
|
14721
|
+
private processEvent;
|
|
14637
14722
|
private getHeader;
|
|
14638
14723
|
}
|
|
14639
14724
|
//#endregion
|
|
14640
14725
|
//#region src/services/WebhookService.d.ts
|
|
14726
|
+
type WebhookListenerConfig = {
|
|
14727
|
+
onError?: (error: unknown) => Promise<void>;
|
|
14728
|
+
authenticationMethod?: WebhookAuthenticationMethod;
|
|
14729
|
+
};
|
|
14641
14730
|
declare class WebhookService {
|
|
14731
|
+
private readonly api;
|
|
14642
14732
|
private readonly secretKey;
|
|
14643
|
-
constructor(secretKey: string);
|
|
14644
|
-
createListener(
|
|
14733
|
+
constructor(api: ApiService, secretKey: string);
|
|
14734
|
+
createListener(config?: WebhookListenerConfig): WebhookListener;
|
|
14645
14735
|
createRequestProcessor(listener: WebhookListener): (request: Request) => Promise<Response>;
|
|
14646
14736
|
/**
|
|
14647
14737
|
* WHATWG Fetch API adapter for modern JavaScript environments.
|
|
@@ -14755,5 +14845,5 @@ declare class Freemius {
|
|
|
14755
14845
|
constructor(config: FreemiusConfig);
|
|
14756
14846
|
}
|
|
14757
14847
|
//#endregion
|
|
14758
|
-
export { ApiAuthParams, ApiEntitiesFilter, type ApiService, type ApplyRenewalCouponRequest, BILLING_CYCLE, BillingCycleApiEnum, BillingEntity, type BillingRequest, BillingUpdatePayload, CURRENCY, type Checkout, CheckoutAction, type CheckoutRequestConfig as CheckoutActionConfig, CheckoutBuilderOptions, CheckoutBuilderUserOptions, CheckoutRedirectData, type CheckoutRedirectInfo, type CheckoutSerialized, type CheckoutService, CouponEntityEnriched, CurrencyApiEnum, type CustomerPortalDataWithEmailOption, type CustomerPortalDataWithUserOption, type CustomerPortalService, EventEntity, FSId, Freemius, FreemiusConfig, InstallEntity, LicenseEntity, LicenseFilterOptions, PagingOptions, PaymentEntity, PaymentFilterOptions, PaymentMethod, PlanEntity, PortalAction, PortalBilling, PortalData, PortalPayment, PortalPlans, type PortalRequestConfig, PortalSubscription, PortalSubscriptions, PricingData, PricingEntity, type PricingService, PricingTableData, ProductEntity, PurchaseData, PurchaseEntitlementData, PurchaseEntitlementType, type PurchaseInfo, type PurchaseService, RequestProcessor, SellingUnit, SubscriptionCancellationReasonType, type SubscriptionCancellationRequest, SubscriptionCancellationResult, SubscriptionDiscountEntity, SubscriptionEntity, SubscriptionFilterOptions, SubscriptionRenewalCouponResult, UserBillingEntity, UserEntity, UserFilterOptions, UserLicenseFilterOptions, UserPaymentFilterOptions, UserPluginEntity, UserRetriever, UserSubscriptionEntity, UserSubscriptionFilterOptions, UserSubscriptionWithDiscounts, type WebhookEvent, type WebhookEventDataMap, type WebhookEventHandler, type WebhookEventType, type WebhookService, idToNumber, idToString, isIdsEqual, parseBillingCycle, parseCurrency, parseDate, parseDateTime, parseNumber, parsePaymentMethod };
|
|
14848
|
+
export { ActionError, ApiAuthParams, ApiEntitiesFilter, type ApiService, type ApplyRenewalCouponRequest, BILLING_CYCLE, BillingCycleApiEnum, BillingEntity, type BillingRequest, BillingUpdatePayload, CURRENCY, type Checkout, CheckoutAction, type CheckoutRequestConfig as CheckoutActionConfig, CheckoutBuilderOptions, CheckoutBuilderUserOptions, CheckoutRedirectData, type CheckoutRedirectInfo, type CheckoutSerialized, type CheckoutService, CouponEntityEnriched, CurrencyApiEnum, type CustomerPortalDataWithEmailOption, type CustomerPortalDataWithUserOption, type CustomerPortalService, EventEntity, EventFilterOptions, FSId, Freemius, FreemiusConfig, InstallEntity, LicenseEntity, LicenseFilterOptions, PagingOptions, PaymentEntity, PaymentFilterOptions, PaymentMethod, PlanEntity, PortalAction, PortalBilling, PortalData, PortalPayment, PortalPlans, type PortalRequestConfig, PortalSubscription, PortalSubscriptions, PricingData, PricingEntity, type PricingService, PricingTableData, ProductEntity, PurchaseData, PurchaseEntitlementData, PurchaseEntitlementType, type PurchaseInfo, type PurchaseService, RequestProcessor, SellingUnit, SubscriptionCancellationReasonType, type SubscriptionCancellationRequest, SubscriptionCancellationResult, SubscriptionDiscountEntity, SubscriptionEntity, SubscriptionFilterOptions, SubscriptionRenewalCouponResult, UserBillingEntity, UserEntity, UserFilterOptions, UserLicenseFilterOptions, UserPaymentFilterOptions, UserPluginEntity, UserRetriever, UserSubscriptionEntity, UserSubscriptionFilterOptions, UserSubscriptionWithDiscounts, WebhookAuthenticationMethod, WebhookError, type WebhookEvent, type WebhookEventDataMap, type WebhookEventHandler, type WebhookEventType, WebhookListenerResponse, type WebhookService, idToNumber, idToString, isIdsEqual, parseBillingCycle, parseCurrency, parseDate, parseDateTime, parseNumber, parsePaymentMethod };
|
|
14759
14849
|
//# sourceMappingURL=index.d.mts.map
|