@revenuecat/purchases-js 1.35.1 → 1.37.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 CHANGED
@@ -63,6 +63,47 @@ pnpm link "@revenuecat/purchases-js"
63
63
 
64
64
  > **Note:** Any changes you make to the library will be automatically reflected in your testing project after running `pnpm run build:dev` or `pnpm run build`.
65
65
 
66
+ ### Using a local `@revenuecat/purchases-ui-js`
67
+
68
+ When you need to iterate on both `purchases-js` and `purchases-ui-js` together, you can point this repo at a sibling checkout using a `pnpm-workspace.yaml` override (instead of manually editing `package.json`).
69
+
70
+ 1. Place the two repos side by side, for example:
71
+
72
+ ```
73
+ Developer/
74
+ purchases-js/
75
+ purchases-ui-js/
76
+ ```
77
+
78
+ 2. In `purchases-js`, create or edit `pnpm-workspace.yaml` and add:
79
+
80
+ ```yaml
81
+ overrides:
82
+ "@revenuecat/purchases-ui-js": "link:../purchases-ui-js"
83
+ ```
84
+
85
+ Use the **scoped** package name (`@revenuecat/purchases-ui-js`). A key like `purchases-ui-js` will not apply the override.
86
+
87
+ 3. Reinstall dependencies from the `purchases-js` root:
88
+
89
+ ```bash
90
+ pnpm install
91
+ ```
92
+
93
+ 4. Verify the override resolved:
94
+
95
+ ```bash
96
+ pnpm why @revenuecat/purchases-ui-js
97
+ ```
98
+
99
+ You should see `link:../purchases-ui-js`.
100
+
101
+ 5. Build the UI package when you change it (from `purchases-ui-js`), then rebuild or run dev builds in `purchases-js` as needed.
102
+
103
+ #### Reverting
104
+
105
+ Remove the override from `pnpm-workspace.yaml` and run `pnpm install` again to return to the published `@revenuecat/purchases-ui-js` version.
106
+
66
107
  ## Running Storybook
67
108
 
68
109
  ```bash
@@ -4,6 +4,7 @@ import { CustomVariableValue } from '@revenuecat/purchases-ui-js';
4
4
  import { PaywallData } from '@revenuecat/purchases-ui-js';
5
5
  import { UIConfig } from '@revenuecat/purchases-ui-js';
6
6
  import { WalletButtonRender } from '@revenuecat/purchases-ui-js';
7
+ import { WalletButtonTheme } from '@revenuecat/purchases-ui-js';
7
8
 
8
9
  declare enum BackendErrorCode {
9
10
  BackendInvalidPlatform = 7000,
@@ -477,6 +478,8 @@ declare enum LocalizationKeys {
477
478
  PaywallVariablesTotalPriceAndPerMonth = "paywall_variables.total_price_and_per_month",
478
479
  PricingDropdownShowDetails = "pricing_dropdown.show_details",
479
480
  PricingDropdownHideDetails = "pricing_dropdown.hide_details",
481
+ PricingDropdownAddPromoCode = "pricing_dropdown.add_promo_code",
482
+ DiscountInputLabel = "discount_input.label",
480
483
  PricingTotalExcludingTax = "pricing_table.total_excluding_tax",
481
484
  PricingTableTrialEnds = "pricing_table.trial_ends",
482
485
  PricingTableTotalDueToday = "pricing_table.total_due_today",
@@ -593,6 +596,10 @@ export declare interface Offering {
593
596
  readonly metadata: {
594
597
  [key: string]: unknown;
595
598
  } | null;
599
+ /**
600
+ * The default web checkout URL for this offering, if available.
601
+ */
602
+ readonly webCheckoutURL?: string | null;
596
603
  /**
597
604
  * A map of all the packages available for purchase keyed by package ID.
598
605
  */
@@ -631,6 +638,10 @@ export declare interface Offering {
631
638
  * Weekly package type configured in the RevenueCat dashboard, if available.
632
639
  */
633
640
  readonly weekly: Package | null;
641
+ /**
642
+ * Whether this offering has an attached paywall configured in the RevenueCat dashboard.
643
+ */
644
+ readonly hasPaywall: boolean;
634
645
  /* Excluded from this release type: paywallComponents */
635
646
  /* Excluded from this release type: uiConfig */
636
647
  }
@@ -692,6 +703,10 @@ export declare interface Package {
692
703
  * The {@link Product} assigned to this package.
693
704
  */
694
705
  readonly webBillingProduct: Product;
706
+ /**
707
+ * The web checkout URL for this package, if available.
708
+ */
709
+ readonly webCheckoutURL?: string | null;
695
710
  /**
696
711
  * The type of package.
697
712
  */
@@ -741,6 +756,26 @@ export declare enum PackageType {
741
756
  Weekly = "$rc_weekly"
742
757
  }
743
758
 
759
+ /**
760
+ * Listener for paywall purchase lifecycle events.
761
+ * @public
762
+ */
763
+ export declare interface PaywallListener {
764
+ /**
765
+ * Called when a purchase flow is about to start for the given package.
766
+ */
767
+ onPurchaseStarted?: (rcPackage: Package) => void;
768
+ /**
769
+ * Callback called when an error that won't close the paywall occurs.
770
+ * For example, a retryable error during the purchase process.
771
+ */
772
+ onPurchaseError?: (error: Error) => void;
773
+ /**
774
+ * Called when the user cancels the purchase flow.
775
+ */
776
+ onPurchaseCancelled?: () => void;
777
+ }
778
+
744
779
  /**
745
780
  * Represents the result of a purchase operation initiated from a paywall.
746
781
  * @public
@@ -852,8 +887,29 @@ export declare interface PresentPaywallParams {
852
887
  * If passed the checkout flow will not ask for it to the customer.
853
888
  */
854
889
  readonly customerEmail?: string;
890
+ /**
891
+ * @experimental
892
+ * If set to true, the Web Billing checkout shown from the paywall
893
+ * will display a discount input code field.
894
+ */
895
+ readonly showDiscountCodeField?: boolean;
896
+ /**
897
+ * @experimental
898
+ * Initial discount code to apply to the checkout when one already exists
899
+ * outside of the paywall UI, for example in the hosting page's URL.
900
+ */
901
+ readonly discountCode?: string;
902
+ /**
903
+ * @experimental
904
+ * Called when the applied discount code changes in the checkout shown from
905
+ * the paywall. This can be used to sync host state such as URL parameters.
906
+ */
907
+ readonly onDiscountCodeChanged?: (discountCode: string | null) => void;
855
908
  /**
856
909
  * Callback to be called when the paywall tries to navigate to an external URL.
910
+ *
911
+ * Markdown text links keep their native browser navigation. Use this callback
912
+ * for side effects or to customize how button-driven URL actions are handled.
857
913
  */
858
914
  readonly onNavigateToUrl?: (url: string) => void;
859
915
  /* Excluded from this release type: onCompleteWorkflowNavigate */
@@ -879,8 +935,13 @@ export declare interface PresentPaywallParams {
879
935
  /**
880
936
  * Callback called when an error that won't close the paywall occurs.
881
937
  * For example, a retryable error during the purchase process.
938
+ * @deprecated Use `listener.onPurchaseError` instead.
882
939
  */
883
940
  readonly onPurchaseError?: (error: Error) => void;
941
+ /**
942
+ * Optional listener for paywall purchase lifecycle events.
943
+ */
944
+ readonly listener?: PaywallListener;
884
945
  /**
885
946
  * The locale to use for the paywall and the checkout flow.
886
947
  */
@@ -891,7 +952,7 @@ export declare interface PresentPaywallParams {
891
952
  readonly hideBackButtons?: boolean;
892
953
  /**
893
954
  * Custom variables to pass to the paywall at runtime, overriding defaults set
894
- * in the RevenueCat dashboard.
955
+ * in the RevenueCat dashboard.f
895
956
  *
896
957
  * Variables must be defined in the dashboard first. Reference them in paywall
897
958
  * text using the `custom.` prefix (e.g. `{{ custom.player_name }}`).
@@ -1183,6 +1244,25 @@ export declare interface PurchaseParams {
1183
1244
  * Defaults to `false`.
1184
1245
  */
1185
1246
  skipSuccessPage?: boolean;
1247
+ /**
1248
+ * @experimental
1249
+ * If set to true, the Web Billing checkout will show a discount input code field.
1250
+ */
1251
+ showDiscountCodeField?: boolean;
1252
+ /**
1253
+ * @experimental
1254
+ * Initial discount code to display as applied in the Web Billing checkout.
1255
+ * This is useful when the code originated outside of the checkout UI,
1256
+ * for example from a URL parameter.
1257
+ */
1258
+ discountCode?: string;
1259
+ /**
1260
+ * @experimental
1261
+ * Called when the applied discount code changes in the Web Billing checkout.
1262
+ * This can be used by host applications to keep external state, such as the URL,
1263
+ * in sync with the checkout.
1264
+ */
1265
+ onDiscountCodeChanged?: (discountCode: string | null) => void;
1186
1266
  /* Excluded from this release type: brandingAppearanceOverride */
1187
1267
  /* Excluded from this release type: labelsOverride */
1188
1268
  /* Excluded from this release type: termsAndConditionsUrl */
@@ -1311,6 +1391,7 @@ export declare class Purchases {
1311
1391
  */
1312
1392
  getCurrentOfferingForPlacement(placementIdentifier: string, params?: GetOfferingsParams): Promise<Offering | null>;
1313
1393
  private getAllOfferings;
1394
+ /* Excluded from this release type: _getProductWithDiscountCode */
1314
1395
  /**
1315
1396
  * Convenience method to check whether a user is entitled to a specific
1316
1397
  * entitlement. This will use {@link Purchases.getCustomerInfo} under the hood.
@@ -1808,6 +1889,10 @@ export declare class Purchases {
1808
1889
  * The product identifier.
1809
1890
  */
1810
1891
  readonly productIdentifier: string;
1892
+ /**
1893
+ * The base plan identifier of the subscription (For Google Play subs only).
1894
+ */
1895
+ readonly productPlanIdentifier: string | null;
1811
1896
  /**
1812
1897
  * Date when the last subscription period started.
1813
1898
  */