@revenuecat/purchases-js 1.19.0 → 1.20.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.
@@ -1,3 +1,44 @@
1
+ import { PaywallData } from '@revenuecat/purchases-ui-js';
2
+ import { UIConfig } from '@revenuecat/purchases-ui-js';
3
+
4
+ declare enum BackendErrorCode {
5
+ BackendInvalidPlatform = 7000,
6
+ BackendInvalidEmail = 7012,
7
+ BackendStoreProblem = 7101,
8
+ BackendCannotTransferPurchase = 7102,
9
+ BackendInvalidReceiptToken = 7103,
10
+ BackendInvalidAppStoreSharedSecret = 7104,
11
+ BackendInvalidPaymentModeOrIntroPriceNotProvided = 7105,
12
+ BackendProductIdForGoogleReceiptNotProvided = 7106,
13
+ BackendInvalidPlayStoreCredentials = 7107,
14
+ BackendInternalServerError = 7110,
15
+ BackendEmptyAppUserId = 7220,
16
+ BackendInvalidAuthToken = 7224,
17
+ BackendInvalidAPIKey = 7225,
18
+ BackendBadRequest = 7226,
19
+ BackendPlayStoreQuotaExceeded = 7229,
20
+ BackendPlayStoreInvalidPackageName = 7230,
21
+ BackendPlayStoreGenericError = 7231,
22
+ BackendUserIneligibleForPromoOffer = 7232,
23
+ BackendInvalidAppleSubscriptionKey = 7234,
24
+ BackendSubscriberNotFound = 7259,
25
+ BackendInvalidSubscriberAttributes = 7263,
26
+ BackendInvalidSubscriberAttributesBody = 7264,
27
+ BackendProductIDsMalformed = 7662,
28
+ BackendAlreadySubscribedError = 7772,
29
+ BackendPaymentGatewayGenericError = 7773,
30
+ BackendOfferNotFound = 7814,
31
+ BackendNoMXRecordsFound = 7834,
32
+ BackendInvalidOperationSession = 7877,
33
+ BackendPurchaseCannotBeCompleted = 7878,
34
+ BackendEmailIsRequired = 7879,
35
+ BackendGatewaySetupErrorStripeTaxNotActive = 7898,
36
+ BackendGatewaySetupErrorInvalidTaxOriginAddress = 7899,
37
+ BackendGatewaySetupErrorMissingRequiredPermission = 7900,
38
+ BackendGatewaySetupErrorSandboxModeOnly = 7901,
39
+ BackendInvalidPaddleAPIKey = 7967
40
+ }
41
+
1
42
  /**
2
43
  * @public
3
44
  * `BrandingAppearance` defines the appearance settings
@@ -77,6 +118,27 @@ export declare interface CustomerInfo {
77
118
  };
78
119
  }
79
120
 
121
+ /**
122
+ * Custom translations to be used in the purchase flow.
123
+ * This class allows you to override the default translations used in the purchase flow.
124
+ * The main level keys are the locale codes and the values are objects with the same keys as the default translations.
125
+ * @public
126
+ * @example
127
+ * This example will override the default translation for the email step title in the English locale.
128
+ * ```typescript
129
+ * const customTranslations = {
130
+ * en: {
131
+ * "email_entry_page.email_step_title": "Billing email",
132
+ * }
133
+ * }
134
+ * ```
135
+ */
136
+ declare type CustomTranslations = {
137
+ [langKey: string]: {
138
+ [translationKey in LocalizationKeys]?: string;
139
+ };
140
+ };
141
+
80
142
  /**
81
143
  * This object gives you access to all the information about the status
82
144
  * of a user's entitlements.
@@ -209,6 +271,16 @@ export declare enum ErrorCode {
209
271
  TestStoreSimulatedPurchaseError = 42
210
272
  }
211
273
 
274
+ declare interface EventProperties {
275
+ [key: string]: EventPropertyValue;
276
+ }
277
+
278
+ declare type EventPropertySingleValue = string | number | boolean;
279
+
280
+ declare type EventPropertyValue = null | EventPropertySingleValue | Array<EventPropertyValue>;
281
+
282
+ /* Excluded from this release type: ExpressPurchaseButtonUpdater */
283
+
212
284
  /**
213
285
  * Flags used to enable or disable certain features in the sdk.
214
286
  * @public
@@ -224,6 +296,8 @@ export declare interface FlagsConfig {
224
296
  * @defaultValue true
225
297
  */
226
298
  collectAnalyticsEvents?: boolean;
299
+ /* Excluded from this release type: rcSource */
300
+ /* Excluded from this release type: forceEnableWalletMethods */
227
301
  }
228
302
 
229
303
  /**
@@ -276,6 +350,108 @@ export declare interface IdentifyResult {
276
350
  readonly wasCreated: boolean;
277
351
  }
278
352
 
353
+ declare enum LocalizationKeys {
354
+ PeriodsWeek = "periods.week",
355
+ PeriodsMonth = "periods.month",
356
+ PeriodsYear = "periods.year",
357
+ PeriodsDay = "periods.day",
358
+ PeriodsWeekShort = "periods.weekShort",
359
+ PeriodsMonthShort = "periods.monthShort",
360
+ PeriodsYearShort = "periods.yearShort",
361
+ PeriodsDayShort = "periods.dayShort",
362
+ PeriodsLifetime = "periods.lifetime",
363
+ PeriodsWeekPlural = "periods.weekPlural",
364
+ PeriodsMonthPlural = "periods.monthPlural",
365
+ PeriodsYearPlural = "periods.yearPlural",
366
+ PeriodsDayPlural = "periods.dayPlural",
367
+ PeriodsWeekFrequency = "periods.weekFrequency",
368
+ PeriodsMonthFrequency = "periods.monthFrequency",
369
+ PeriodsYearFrequency = "periods.yearFrequency",
370
+ PeriodsDayFrequency = "periods.dayFrequency",
371
+ PeriodsPerWeekFrequency = "periods.perWeekFrequency",
372
+ PeriodsPerMonthFrequency = "periods.perMonthFrequency",
373
+ PeriodsPerYearFrequency = "periods.perYearFrequency",
374
+ PeriodsPerDayFrequency = "periods.perDayFrequency",
375
+ PeriodsUnknownFrequency = "periods.unknownFrequency",
376
+ PeriodsWeekFrequencyPlural = "periods.weekFrequencyPlural",
377
+ PeriodsMonthFrequencyPlural = "periods.monthFrequencyPlural",
378
+ PeriodsYearFrequencyPlural = "periods.yearFrequencyPlural",
379
+ PeriodsDayFrequencyPlural = "periods.dayFrequencyPlural",
380
+ ProductInfoProductTitle = "product_info.product_title",
381
+ ProductInfoProductDescription = "product_info.product_description",
382
+ ProductInfoProductPrice = "product_info.product_price",
383
+ ProductInfoFreeTrialDuration = "product_info.free_trial_duration",
384
+ ProductInfoPriceAfterFreeTrial = "product_info.price_after_free_trial",
385
+ ProductInfoIntroPricePhaseAfterTrial = "product_info.intro_price_phase_after_trial",
386
+ ProductInfoIntroPricePhasePaidOnce = "product_info.intro_price_phase_paid_once",
387
+ ProductInfoIntroPricePhase = "product_info.intro_price_phase",
388
+ ProductInfoPriceAfterIntroPrice = "product_info.price_after_intro_price",
389
+ ProductInfoAfterTrial = "product_info.after_trial",
390
+ ProductInfoAfter = "product_info.after",
391
+ ProductInfoPriceTotalDueToday = "product_info.total_due_today",
392
+ ProductInfoSubscribeTo = "product_info.subscribe_to",
393
+ ProductInfoRenewalFrequency = "product_info.renewal_frequency",
394
+ ProductInfoContinuesUntilCancelled = "product_info.continues_until_cancelled",
395
+ ProductInfoCancelAnytime = "product_info.cancel_anytime",
396
+ PaymentEntryPagePaymentStepTitle = "payment_entry_page.payment_step_title",
397
+ PaymentEntryPageTrialSubscriptionTermsInfo = "payment_entry_page.trial_subscription_terms_info",
398
+ PaymentEntryPageSubscriptionTermsInfo = "payment_entry_page.subscription_terms_info",
399
+ PaymentEntryPageOtpTermsInfo = "payment_entry_page.otp_terms_info",
400
+ PaymentEntryPageTermsLinkLabel = "payment_entry_page.terms_link_label",
401
+ PaymentEntryPageSubscriptionInfo = "payment_entry_page.subscription_info",
402
+ PaymentEntryPageButtonPay = "payment_entry_page.button_pay",
403
+ PaymentEntryPageButtonStartTrial = "payment_entry_page.button_start_trial",
404
+ PaymentEntryPageButtonWithPrice = "payment_entry_page.button_with_price",
405
+ PaymentEntryPageButtonPaymentMethod = "payment_entry_page.button_payment_method",
406
+ PaymentEntryPageExpressCheckoutDivider = "payment_entry_page.express_checkout_divider",
407
+ SuccessPagePurchaseSuccessful = "success_page.purchase_successful",
408
+ SuccessPageButtonClose = "success_page.button_close",
409
+ LoadingPageProcessingPayment = "loading_page.processing_payment",
410
+ LoadingPageKeepPageOpen = "loading_page.keep_page_open",
411
+ ErrorPageCloseButtonTitle = "error_page.close_button_title",
412
+ ErrorPageIfErrorPersists = "error_page.if_error_persists",
413
+ ErrorPageTroubleAccessing = "error_page.trouble_accessing",
414
+ ErrorPageErrorTitleAlreadySubscribed = "error_page.error_title_already_subscribed",
415
+ ErrorPageErrorTitleAlreadyPurchased = "error_page.error_title_already_purchased",
416
+ ErrorPageErrorTitleOtherErrors = "error_page.error_title_other_errors",
417
+ ErrorPageErrorTitleStripeTaxNotActive = "error_page.error_title_stripe_tax_not_active",
418
+ ErrorPageErrorTitleStripeInvalidTaxOriginAddress = "error_page.error_title_stripe_invalid_tax_origin_address",
419
+ ErrorPageErrorTitleStripeMissingRequiredPermission = "error_page.error_title_stripe_missing_required_permission",
420
+ ErrorPageErrorMessageAlreadySubscribed = "error_page.error_message_already_subscribed",
421
+ ErrorPageErrorMessageAlreadyPurchased = "error_page.error_message_already_purchased",
422
+ ErrorPageErrorMessageMissingEmailError = "error_page.error_message_missing_email_error",
423
+ ErrorPageErrorMessageInvalidEmailError = "error_page.error_message_invalid_email_error",
424
+ ErrorPageErrorMessageNetworkError = "error_page.error_message_network_error",
425
+ ErrorPageErrorMessageErrorChargingPayment = "error_page.error_message_error_charging_payment",
426
+ ErrorPageErrorMessageErrorSettingUpPurchase = "error_page.error_message_error_setting_up_purchase",
427
+ ErrorPageErrorMessageUnknownError = "error_page.error_message_unknown_error",
428
+ ErrorPageErrorMessageInvalidTaxLocation = "error_page.error_message_invalid_tax_location",
429
+ ErrorPageErrorMessageStripeTaxNotActive = "error_page.error_message_stripe_tax_not_active",
430
+ ErrorPageErrorMessageStripeInvalidTaxOriginAddress = "error_page.error_message_stripe_invalid_tax_origin_address",
431
+ ErrorPageErrorMessageStripeMissingRequiredPermission = "error_page.error_message_stripe_missing_required_permission",
432
+ ErrorPageErrorMessageOnlyInSandbox = "error_page.error_only_in_sandbox",
433
+ ErrorButtonTryAgain = "error_page.button_try_again",
434
+ ErrorButtonClose = "error_page.button_close",
435
+ PaywallVariablesPricePerPeriod = "paywall_variables.price_per_period",
436
+ PaywallVariablesSubRelativeDiscount = "paywall_variables.sub_relative_discount",
437
+ PaywallVariablesTotalPriceAndPerMonth = "paywall_variables.total_price_and_per_month",
438
+ PricingDropdownShowDetails = "pricing_dropdown.show_details",
439
+ PricingDropdownHideDetails = "pricing_dropdown.hide_details",
440
+ PricingTotalExcludingTax = "pricing_table.total_excluding_tax",
441
+ PricingTableTrialEnds = "pricing_table.trial_ends",
442
+ PricingTableTotalDueToday = "pricing_table.total_due_today",
443
+ PricingTableTax = "pricing_table.tax",
444
+ PricingTableEnterBillingAddressToCalculate = "pricing_table.enter_billing_address_to_calculate",
445
+ PricingTableEnterStateOrPostalCodeToCalculate = "pricing_table.enter_state_or_postal_code_to_calculate",
446
+ PricingTableEnterPostalCodeToCalculate = "pricing_table.enter_postal_code_to_calculate",
447
+ NavbarHeaderDetails = "navbar_header.details",
448
+ NavbarBackButton = "navbar_header.back_button",
449
+ PriceUpdateTitle = "price_update.title",
450
+ PriceUpdateBaseMessage = "price_update.base_message",
451
+ PriceUpdateTrialMessage = "price_update.trial_message",
452
+ ApplePayFreeTrial = "apple_pay.free_trial"
453
+ }
454
+
279
455
  /**
280
456
  * Custom log handler function type. Allows you to handle SDK log messages
281
457
  * with your own logging system.
@@ -412,6 +588,8 @@ export declare interface Offering {
412
588
  * Weekly package type configured in the RevenueCat dashboard, if available.
413
589
  */
414
590
  readonly weekly: Package | null;
591
+ /* Excluded from this release type: paywallComponents */
592
+ /* Excluded from this release type: uiConfig */
415
593
  }
416
594
 
417
595
  /**
@@ -593,6 +771,8 @@ export declare interface PresentedOfferingContext {
593
771
  readonly placementIdentifier: string | null;
594
772
  }
595
773
 
774
+ /* Excluded from this release type: PresentExpressPurchaseButtonParams */
775
+
596
776
  /**
597
777
  * Parameters for the {@link Purchases.presentPaywall} method.
598
778
  * @public
@@ -634,6 +814,7 @@ export declare interface PresentPaywallParams {
634
814
  * The locale to use for the paywall and the checkout flow.
635
815
  */
636
816
  readonly selectedLocale?: string;
817
+ /* Excluded from this release type: useExpressPurchaseButtons */
637
818
  }
638
819
 
639
820
  /**
@@ -817,6 +998,31 @@ export declare enum ProductType {
817
998
  NonConsumable = "non_consumable"
818
999
  }
819
1000
 
1001
+ declare class PurchaseFlowError extends Error {
1002
+ readonly errorCode: PurchaseFlowErrorCode;
1003
+ readonly underlyingErrorMessage?: string | null | undefined;
1004
+ readonly purchasesErrorCode?: ErrorCode | undefined;
1005
+ readonly extra?: PurchasesErrorExtra | undefined;
1006
+ readonly displayPurchaseFlowErrorCode?: boolean | undefined;
1007
+ constructor(errorCode: PurchaseFlowErrorCode, message?: string, underlyingErrorMessage?: string | null | undefined, purchasesErrorCode?: ErrorCode | undefined, extra?: PurchasesErrorExtra | undefined, displayPurchaseFlowErrorCode?: boolean | undefined);
1008
+ getErrorCode(): number;
1009
+ static fromPurchasesError(e: PurchasesError, defaultFlowErrorCode: PurchaseFlowErrorCode, displayPurchaseFlowErrorCode?: boolean): PurchaseFlowError;
1010
+ static fromBackendErrorCode(backendErrorCode: BackendErrorCode | undefined): PurchaseFlowErrorCode | null;
1011
+ }
1012
+
1013
+ declare enum PurchaseFlowErrorCode {
1014
+ ErrorSettingUpPurchase = 0,
1015
+ ErrorChargingPayment = 1,
1016
+ UnknownError = 2,
1017
+ NetworkError = 3,
1018
+ MissingEmailError = 4,
1019
+ AlreadyPurchasedError = 5,
1020
+ StripeTaxNotActive = 6,
1021
+ StripeInvalidTaxOriginAddress = 7,
1022
+ StripeMissingRequiredPermission = 8,
1023
+ InvalidPaddleAPIKeyError = 9
1024
+ }
1025
+
820
1026
  /**
821
1027
  * Metadata that can be passed to the backend when making a purchase.
822
1028
  * They will propagate to the payment gateway (i.e. Stripe) and to RevenueCat.
@@ -860,6 +1066,7 @@ export declare interface PurchaseParams {
860
1066
  * The email of the user. If undefined, RevenueCat will ask the customer for their email.
861
1067
  */
862
1068
  customerEmail?: string;
1069
+ /* Excluded from this release type: workflowPurchaseContext */
863
1070
  /**
864
1071
  * The locale to use for the purchase flow. If not specified, English will be used
865
1072
  */
@@ -881,6 +1088,9 @@ export declare interface PurchaseParams {
881
1088
  * Defaults to `false`.
882
1089
  */
883
1090
  skipSuccessPage?: boolean;
1091
+ /* Excluded from this release type: brandingAppearanceOverride */
1092
+ /* Excluded from this release type: labelsOverride */
1093
+ /* Excluded from this release type: termsAndConditionsUrl */
884
1094
  }
885
1095
 
886
1096
  /**
@@ -913,6 +1123,18 @@ export declare interface PurchaseResult {
913
1123
  * @public
914
1124
  */
915
1125
  export declare class Purchases {
1126
+ /* Excluded from this release type: _API_KEY */
1127
+ /* Excluded from this release type: _appUserId */
1128
+ /* Excluded from this release type: _brandingInfo */
1129
+ /* Excluded from this release type: _loadingResourcesPromise */
1130
+ /* Excluded from this release type: _flags */
1131
+ /* Excluded from this release type: _context */
1132
+ /* Excluded from this release type: backend */
1133
+ /* Excluded from this release type: purchaseOperationHelper */
1134
+ /* Excluded from this release type: eventsTracker */
1135
+ /* Excluded from this release type: _platformInfo */
1136
+ /* Excluded from this release type: inMemoryCache */
1137
+ /* Excluded from this release type: instance */
916
1138
  /**
917
1139
  * Set the log level. Logs of the given level and below will be printed
918
1140
  * in the console.
@@ -931,6 +1153,7 @@ export declare class Purchases {
931
1153
  * @experimental
932
1154
  * */
933
1155
  static setPlatformInfo(platformInfo: PlatformInfo): void;
1156
+ /* Excluded from this release type: getPlatformInfo */
934
1157
  /**
935
1158
  * Get the singleton instance of Purchases. It's preferred to use the instance
936
1159
  * obtained from the `configure` method when possible.
@@ -968,6 +1191,9 @@ export declare class Purchases {
968
1191
  * up the first call to {@link Purchases.purchase}.
969
1192
  */
970
1193
  preload(): Promise<void>;
1194
+ /* Excluded from this release type: fetchAndCacheBrandingInfo */
1195
+ /* Excluded from this release type: hasLoadedResources */
1196
+ /* Excluded from this release type: __constructor */
971
1197
  /**
972
1198
  * Renders an RC Paywall and allows the user to purchase from it using Web Billing.
973
1199
  * @param paywallParams - The parameters object to customise the paywall render. Check {@link PresentPaywallParams}
@@ -1010,6 +1236,7 @@ export declare class Purchases {
1010
1236
  * @throws {@link PurchasesError} if there is an error while performing the purchase. If the {@link PurchasesError.errorCode} is {@link ErrorCode.UserCancelledError}, the user cancelled the purchase.
1011
1237
  */
1012
1238
  purchasePackage(rcPackage: Package, customerEmail?: string, htmlTarget?: HTMLElement): Promise<PurchaseResult>;
1239
+ /* Excluded from this release type: presentExpressPurchaseButton */
1013
1240
  /**
1014
1241
  * Method to perform a purchase for a given package. You can obtain the
1015
1242
  * package from {@link Purchases.getOfferings}. This method will present the purchase
@@ -1030,6 +1257,9 @@ export declare class Purchases {
1030
1257
  private createCheckoutOnCloseHandler;
1031
1258
  private createCheckoutOnFinishedHandler;
1032
1259
  private createCheckoutOnErrorHandler;
1260
+ /* Excluded from this release type: _isConfiguredWithSimulatedStore */
1261
+ /* Excluded from this release type: _shouldForceEnableWalletMethods */
1262
+ /* Excluded from this release type: _postSimulatedStoreReceipt */
1033
1263
  /**
1034
1264
  * Gets latest available {@link CustomerInfo}.
1035
1265
  * @returns The latest {@link CustomerInfo}.
@@ -1071,6 +1301,7 @@ export declare class Purchases {
1071
1301
  */
1072
1302
  identifyUser(appUserId: string): Promise<IdentifyResult>;
1073
1303
  private replaceUserId;
1304
+ /* Excluded from this release type: logMissingProductIds */
1074
1305
  /**
1075
1306
  * @returns Whether the SDK is using a sandbox API Key.
1076
1307
  */
@@ -1106,6 +1337,8 @@ export declare class Purchases {
1106
1337
  * Closes the Purchases instance. You should never have to do this normally.
1107
1338
  */
1108
1339
  close(): void;
1340
+ /* Excluded from this release type: _getCustomerInfoForUserId */
1341
+ /* Excluded from this release type: _getVirtualCurrenciesForUserId */
1109
1342
  /**
1110
1343
  * Generates an anonymous app user ID that follows RevenueCat's format.
1111
1344
  * This can be used when you don't have a user identifier system in place.
@@ -1115,6 +1348,7 @@ export declare class Purchases {
1115
1348
  * @public
1116
1349
  */
1117
1350
  static generateRevenueCatAnonymousAppUserId(): string;
1351
+ /* Excluded from this release type: _trackEvent */
1118
1352
  }
1119
1353
 
1120
1354
  /**
@@ -1158,8 +1392,11 @@ export declare class Purchases {
1158
1392
  * Advanced functionality configuration {@link FlagsConfig}.
1159
1393
  */
1160
1394
  flags?: FlagsConfig;
1395
+ /* Excluded from this release type: context */
1161
1396
  }
1162
1397
 
1398
+ /* Excluded from this release type: PurchasesContext */
1399
+
1163
1400
  /**
1164
1401
  * Error class for Purchases SDK. You should handle these errors and react
1165
1402
  * accordingly in your app.
@@ -1180,6 +1417,8 @@ export declare class Purchases {
1180
1417
  * Contains extra information that is available in certain types of errors.
1181
1418
  */
1182
1419
  readonly extra?: PurchasesErrorExtra | undefined;
1420
+ /* Excluded from this release type: getForBackendError */
1421
+ /* Excluded from this release type: getForPurchasesFlowError */
1183
1422
  constructor(
1184
1423
  /**
1185
1424
  * Error code for the error. This is useful to appropriately react to
@@ -1424,6 +1663,8 @@ export declare class Purchases {
1424
1663
  TenjinId = "$tenjinId"
1425
1664
  }
1426
1665
 
1666
+ declare type SDKEventContextSource = "sdk" | "wpl" | string;
1667
+
1427
1668
  /**
1428
1669
  * The store where the user originally subscribed.
1429
1670
  * @public
@@ -1565,6 +1806,12 @@ export declare class Purchases {
1565
1806
  readonly revision: number;
1566
1807
  }
1567
1808
 
1809
+ declare interface TrackEventProps {
1810
+ eventName: string;
1811
+ source: SDKEventContextSource;
1812
+ properties?: EventProperties;
1813
+ }
1814
+
1568
1815
  /**
1569
1816
  * Error indicating that the SDK was accessed before it was initialized.
1570
1817
  * @public
@@ -1612,4 +1859,8 @@ export declare class Purchases {
1612
1859
  readonly serverDescription: string | null;
1613
1860
  }
1614
1861
 
1862
+ /* Excluded from this release type: WorkflowContext */
1863
+
1864
+ /* Excluded from this release type: WorkflowPurchaseContext */
1865
+
1615
1866
  export { }