@revenuecat/purchases-js 1.36.0 → 1.38.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
  */
@@ -696,6 +703,10 @@ export declare interface Package {
696
703
  * The {@link Product} assigned to this package.
697
704
  */
698
705
  readonly webBillingProduct: Product;
706
+ /**
707
+ * The web checkout URL for this package, if available.
708
+ */
709
+ readonly webCheckoutURL?: string | null;
699
710
  /**
700
711
  * The type of package.
701
712
  */
@@ -745,6 +756,26 @@ export declare enum PackageType {
745
756
  Weekly = "$rc_weekly"
746
757
  }
747
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
+
748
779
  /**
749
780
  * Represents the result of a purchase operation initiated from a paywall.
750
781
  * @public
@@ -856,8 +887,29 @@ export declare interface PresentPaywallParams {
856
887
  * If passed the checkout flow will not ask for it to the customer.
857
888
  */
858
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;
859
908
  /**
860
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.
861
913
  */
862
914
  readonly onNavigateToUrl?: (url: string) => void;
863
915
  /* Excluded from this release type: onCompleteWorkflowNavigate */
@@ -883,8 +935,13 @@ export declare interface PresentPaywallParams {
883
935
  /**
884
936
  * Callback called when an error that won't close the paywall occurs.
885
937
  * For example, a retryable error during the purchase process.
938
+ * @deprecated Use `listener.onPurchaseError` instead.
886
939
  */
887
940
  readonly onPurchaseError?: (error: Error) => void;
941
+ /**
942
+ * Optional listener for paywall purchase lifecycle events.
943
+ */
944
+ readonly listener?: PaywallListener;
888
945
  /**
889
946
  * The locale to use for the paywall and the checkout flow.
890
947
  */
@@ -895,7 +952,7 @@ export declare interface PresentPaywallParams {
895
952
  readonly hideBackButtons?: boolean;
896
953
  /**
897
954
  * Custom variables to pass to the paywall at runtime, overriding defaults set
898
- * in the RevenueCat dashboard.
955
+ * in the RevenueCat dashboard.f
899
956
  *
900
957
  * Variables must be defined in the dashboard first. Reference them in paywall
901
958
  * text using the `custom.` prefix (e.g. `{{ custom.player_name }}`).
@@ -1187,6 +1244,25 @@ export declare interface PurchaseParams {
1187
1244
  * Defaults to `false`.
1188
1245
  */
1189
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;
1190
1266
  /* Excluded from this release type: brandingAppearanceOverride */
1191
1267
  /* Excluded from this release type: labelsOverride */
1192
1268
  /* Excluded from this release type: termsAndConditionsUrl */
@@ -1315,6 +1391,7 @@ export declare class Purchases {
1315
1391
  */
1316
1392
  getCurrentOfferingForPlacement(placementIdentifier: string, params?: GetOfferingsParams): Promise<Offering | null>;
1317
1393
  private getAllOfferings;
1394
+ /* Excluded from this release type: _getProductWithDiscountCode */
1318
1395
  /**
1319
1396
  * Convenience method to check whether a user is entitled to a specific
1320
1397
  * entitlement. This will use {@link Purchases.getCustomerInfo} under the hood.
@@ -1812,6 +1889,10 @@ export declare class Purchases {
1812
1889
  * The product identifier.
1813
1890
  */
1814
1891
  readonly productIdentifier: string;
1892
+ /**
1893
+ * The base plan identifier of the subscription (For Google Play subs only).
1894
+ */
1895
+ readonly productPlanIdentifier: string | null;
1815
1896
  /**
1816
1897
  * Date when the last subscription period started.
1817
1898
  */