@umituz/react-native-subscription 2.11.1 → 2.11.3
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.11.
|
|
3
|
+
"version": "2.11.3",
|
|
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",
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"README.md",
|
|
70
70
|
"LICENSE"
|
|
71
71
|
]
|
|
72
|
-
}
|
|
72
|
+
}
|
|
@@ -89,7 +89,10 @@ export const SubscriptionPackageList: React.FC<SubscriptionPackageListProps> = R
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Get credit amount for this package if provided
|
|
92
|
-
|
|
92
|
+
// check both product identifier (e.g., com.app.weekly) and package identifier (e.g., $rc_weekly)
|
|
93
|
+
const creditAmount =
|
|
94
|
+
creditAmounts?.[pkg.product.identifier] ??
|
|
95
|
+
creditAmounts?.[pkg.identifier];
|
|
93
96
|
|
|
94
97
|
return (
|
|
95
98
|
<SubscriptionPlanCard
|
|
@@ -66,43 +66,15 @@ export function useFeatureGate(
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
// User is premium if they have credits
|
|
69
|
+
// NOTE: This assumes credits system = premium subscription
|
|
70
|
+
// If your app uses CustomerInfo for premium status, use useCustomerInfo() instead
|
|
69
71
|
const isPremium = credits !== null;
|
|
70
72
|
|
|
71
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
72
|
-
// eslint-disable-next-line no-console
|
|
73
|
-
console.log("[useFeatureGate] Hook state", {
|
|
74
|
-
userId,
|
|
75
|
-
isAuthenticated,
|
|
76
|
-
isPremium,
|
|
77
|
-
hasCredits: credits !== null,
|
|
78
|
-
isLoading,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
73
|
const requireFeature = useCallback(
|
|
83
74
|
(action: () => void | Promise<void>) => {
|
|
84
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
85
|
-
// eslint-disable-next-line no-console
|
|
86
|
-
console.log("[useFeatureGate] requireFeature() called", {
|
|
87
|
-
isAuthenticated,
|
|
88
|
-
isPremium,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
75
|
// Step 1: Check authentication
|
|
93
76
|
if (!isAuthenticated) {
|
|
94
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
95
|
-
// eslint-disable-next-line no-console
|
|
96
|
-
console.log("[useFeatureGate] NOT authenticated → showing auth modal");
|
|
97
|
-
}
|
|
98
|
-
// After auth, re-check premium before executing
|
|
99
77
|
onShowAuthModal(() => {
|
|
100
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
101
|
-
// eslint-disable-next-line no-console
|
|
102
|
-
console.log(
|
|
103
|
-
"[useFeatureGate] Auth successful. Component will re-render to check premium status."
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
78
|
// We NO LONGER call action() blindly here.
|
|
107
79
|
// The component will re-render with the new auth state,
|
|
108
80
|
// and the user should be allowed to try the action again.
|
|
@@ -113,19 +85,11 @@ export function useFeatureGate(
|
|
|
113
85
|
|
|
114
86
|
// Step 2: Check premium (has credits from TanStack Query)
|
|
115
87
|
if (!isPremium) {
|
|
116
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
117
|
-
// eslint-disable-next-line no-console
|
|
118
|
-
console.log("[useFeatureGate] NOT premium → showing paywall");
|
|
119
|
-
}
|
|
120
88
|
onShowPaywall();
|
|
121
89
|
return;
|
|
122
90
|
}
|
|
123
91
|
|
|
124
92
|
// Step 3: User is authenticated and premium - execute action
|
|
125
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
126
|
-
// eslint-disable-next-line no-console
|
|
127
|
-
console.log("[useFeatureGate] PREMIUM user → executing action");
|
|
128
|
-
}
|
|
129
93
|
action();
|
|
130
94
|
},
|
|
131
95
|
[isAuthenticated, isPremium, onShowAuthModal, onShowPaywall]
|
|
@@ -57,6 +57,9 @@ export const usePremiumWithConfig = (
|
|
|
57
57
|
const { showPaywall, setShowPaywall, closePaywall, openPaywall } =
|
|
58
58
|
usePaywallVisibility();
|
|
59
59
|
|
|
60
|
+
// User is premium if they have credits
|
|
61
|
+
// NOTE: This assumes credits system = premium subscription
|
|
62
|
+
// If your app uses CustomerInfo for premium status, use useCustomerInfo() instead
|
|
60
63
|
const isPremium = credits !== null;
|
|
61
64
|
|
|
62
65
|
const handlePurchase = useCallback(
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { useState, useCallback } from 'react';
|
|
7
7
|
import { getSubscriptionService } from '../../infrastructure/services/SubscriptionService';
|
|
8
8
|
import type { SubscriptionStatus } from '../../domain/entities/SubscriptionStatus';
|
|
9
|
+
import { isSubscriptionValid } from '../../domain/entities/SubscriptionStatus';
|
|
9
10
|
|
|
10
11
|
export interface UseSubscriptionResult {
|
|
11
12
|
/** Current subscription status */
|
|
@@ -160,7 +161,7 @@ export function useSubscription(): UseSubscriptionResult {
|
|
|
160
161
|
}
|
|
161
162
|
}, []);
|
|
162
163
|
|
|
163
|
-
const isPremium =
|
|
164
|
+
const isPremium = isSubscriptionValid(status);
|
|
164
165
|
|
|
165
166
|
return {
|
|
166
167
|
status,
|