@umituz/react-native-subscription 2.41.12 → 2.41.13

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.41.12",
3
+ "version": "2.41.13",
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",
@@ -14,6 +14,7 @@ import {
14
14
  StatusBar,
15
15
  } from "react-native";
16
16
  import { useNavigation } from "@react-navigation/native";
17
+ import { usePremium } from "../../subscription/presentation/usePremium";
17
18
  import { AtomicText, AtomicIcon, AtomicSpinner } from "@umituz/react-native-design-system/atoms";
18
19
  import { useSafeAreaInsets } from "@umituz/react-native-design-system/safe-area";
19
20
  import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
@@ -32,6 +33,9 @@ import { hasItems } from "../../../shared/utils/arrayUtils";
32
33
  export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) => {
33
34
  const navigation = useNavigation();
34
35
 
36
+ // Get purchase functions from usePremium as fallback
37
+ const { purchasePackage: premiumPurchase, restorePurchase: premiumRestore } = usePremium();
38
+
35
39
  const {
36
40
  onClose,
37
41
  translations,
@@ -54,6 +58,21 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
54
58
  const tokens = useAppDesignTokens();
55
59
  const insets = useSafeAreaInsets();
56
60
 
61
+ // Use provided purchase functions or fall back to usePremium
62
+ const handlePurchasePackage = useCallback(async (pkg: any) => {
63
+ if (onPurchase) {
64
+ return await onPurchase(pkg);
65
+ }
66
+ return await premiumPurchase(pkg);
67
+ }, [onPurchase, premiumPurchase]);
68
+
69
+ const handleRestorePackages = useCallback(async () => {
70
+ if (onRestore) {
71
+ return await onRestore();
72
+ }
73
+ return await premiumRestore();
74
+ }, [onRestore, premiumRestore]);
75
+
57
76
  // Default close handler using navigation
58
77
  const handleClose = useCallback(() => {
59
78
  if (onClose) {
@@ -72,8 +91,8 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
72
91
  resetState
73
92
  } = usePaywallActions({
74
93
  packages,
75
- onPurchase,
76
- onRestore,
94
+ onPurchase: handlePurchasePackage,
95
+ onRestore: handleRestorePackages,
77
96
  source,
78
97
  onPurchaseSuccess,
79
98
  onPurchaseError,
@@ -86,7 +105,7 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
86
105
  return () => {
87
106
  resetState();
88
107
  };
89
- }, [resetState]);
108
+ }, [resetState, handlePurchasePackage, handleRestorePackages]);
90
109
 
91
110
  // Auto-select first package
92
111
  useEffect(() => {
@@ -87,6 +87,10 @@ export function usePaywallOrchestrator({
87
87
  heroImage,
88
88
  source: shouldShowPostOnboarding ? "onboarding" : "manual",
89
89
  packages,
90
+ onPurchase: purchasePackage,
91
+ onRestore: restorePurchase,
92
+ onPurchaseSuccess,
93
+ onAuthRequired,
90
94
  });
91
95
 
92
96
  if (shouldShowPostOnboarding) {
@@ -115,10 +119,14 @@ export function usePaywallOrchestrator({
115
119
  features,
116
120
  heroImage,
117
121
  packages,
122
+ purchasePackage,
123
+ restorePurchase,
118
124
  markPaywallShown,
119
125
  closePaywall,
120
126
  bestValueIdentifier,
121
127
  creditsLabel,
128
+ onPurchaseSuccess,
129
+ onAuthRequired,
122
130
  ]);
123
131
 
124
132
  const completeOnboarding = useSubscriptionFlowStore((state) => state.completeOnboarding);