@umituz/react-native-subscription 2.14.65 → 2.14.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.14.65",
3
+ "version": "2.14.66",
4
4
  "description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -19,6 +19,7 @@ declare const __DEV__: boolean;
19
19
 
20
20
  export const PaywallContainer: React.FC<PaywallContainerProps> = ({
21
21
  userId,
22
+ isAnonymous = false,
22
23
  translations,
23
24
  mode = "subscription",
24
25
  legalUrls,
@@ -30,6 +31,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = ({
30
31
  packageFilterConfig,
31
32
  onPurchaseSuccess,
32
33
  onPurchaseError,
34
+ onAuthRequired,
33
35
  }) => {
34
36
  const { showPaywall, closePaywall } = usePaywallVisibility();
35
37
  const { data: allPackages = [], isLoading, isFetching, status, error } = useSubscriptionPackages(userId ?? undefined);
@@ -44,6 +46,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = ({
44
46
  if (__DEV__ && showPaywall) {
45
47
  console.log("[PaywallContainer] Paywall opened:", {
46
48
  userId,
49
+ isAnonymous,
47
50
  mode,
48
51
  isConfigured: SubscriptionManager.isConfigured(),
49
52
  isInitialized: SubscriptionManager.isInitialized(),
@@ -55,10 +58,20 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = ({
55
58
  error: error?.message ?? null,
56
59
  });
57
60
  }
58
- }, [showPaywall, userId, mode, allPackages.length, filteredPackages.length, isLoading, isFetching, status, error]);
61
+ }, [showPaywall, userId, isAnonymous, mode, allPackages.length, filteredPackages.length, isLoading, isFetching, status, error]);
59
62
 
60
63
  const handlePurchase = useCallback(
61
64
  async (pkg: PurchasesPackage) => {
65
+ // Auth gating: require authentication for anonymous users
66
+ if (isAnonymous) {
67
+ if (__DEV__) {
68
+ console.log("[PaywallContainer] Anonymous user, requiring auth before purchase");
69
+ }
70
+ closePaywall();
71
+ onAuthRequired?.();
72
+ return;
73
+ }
74
+
62
75
  try {
63
76
  if (__DEV__) {
64
77
  console.log("[PaywallContainer] Purchase started:", pkg.identifier);
@@ -79,7 +92,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = ({
79
92
  onPurchaseError?.(message);
80
93
  }
81
94
  },
82
- [purchasePackage, closePaywall, onPurchaseSuccess, onPurchaseError]
95
+ [isAnonymous, purchasePackage, closePaywall, onPurchaseSuccess, onPurchaseError, onAuthRequired]
83
96
  );
84
97
 
85
98
  const handleRestore = useCallback(async () => {
@@ -10,6 +10,8 @@ import type { PackageFilterConfig } from "../../../utils/packageFilter";
10
10
  export interface PaywallContainerProps {
11
11
  /** User ID for subscription management */
12
12
  readonly userId: string | null;
13
+ /** Whether user is anonymous (requires auth before purchase) */
14
+ readonly isAnonymous?: boolean;
13
15
  /** Paywall translations - no defaults, must be provided */
14
16
  readonly translations: PaywallTranslations;
15
17
  /** Paywall mode - subscription, credits, or hybrid */
@@ -32,4 +34,7 @@ export interface PaywallContainerProps {
32
34
  readonly onPurchaseSuccess?: () => void;
33
35
  /** Callback when purchase fails */
34
36
  readonly onPurchaseError?: (error: string) => void;
37
+ /** Callback when auth is required (for anonymous users) */
38
+ readonly onAuthRequired?: () => void;
35
39
  }
40
+