@umituz/react-native-subscription 2.24.5 → 2.24.7
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.24.
|
|
3
|
+
"version": "2.24.7",
|
|
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",
|
|
@@ -30,12 +30,17 @@ export const usePaywallActions = ({
|
|
|
30
30
|
try {
|
|
31
31
|
if (__DEV__) console.log("[PaywallActions] Purchase started:", pkg.product.identifier);
|
|
32
32
|
const res = await authAwarePurchase(pkg, source);
|
|
33
|
+
if (__DEV__) console.log("[PaywallActions] Purchase result:", { res, productId: pkg.product.identifier });
|
|
33
34
|
if (res) {
|
|
35
|
+
if (__DEV__) console.log("[PaywallActions] Purchase successful, closing paywall");
|
|
34
36
|
onPurchaseSuccess?.();
|
|
35
37
|
onClose();
|
|
38
|
+
} else {
|
|
39
|
+
if (__DEV__) console.log("[PaywallActions] Purchase returned false, paywall stays open");
|
|
36
40
|
}
|
|
37
41
|
} catch (err: unknown) {
|
|
38
42
|
const message = err instanceof Error ? err.message : String(err);
|
|
43
|
+
if (__DEV__) console.log("[PaywallActions] Purchase error:", message);
|
|
39
44
|
onPurchaseError?.(message);
|
|
40
45
|
}
|
|
41
46
|
}, [authAwarePurchase, source, onClose, onPurchaseSuccess, onPurchaseError]);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Feedback Service
|
|
3
3
|
* Handles feedback submission to Firestore
|
|
4
|
+
* Feedback is stored under users/{userId}/feedback/{feedbackId}
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import { getFirestore } from "@umituz/react-native-firebase";
|
|
7
|
-
import { collection, addDoc } from "firebase/firestore";
|
|
8
|
+
import { collection, addDoc, doc } from "firebase/firestore";
|
|
8
9
|
|
|
9
10
|
export interface FeedbackData {
|
|
10
11
|
userId: string | null;
|
|
@@ -21,10 +22,9 @@ export interface FeedbackSubmitResult {
|
|
|
21
22
|
error?: Error;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
const FEEDBACK_COLLECTION = "feedback";
|
|
25
|
-
|
|
26
25
|
/**
|
|
27
26
|
* Submit feedback to Firestore
|
|
27
|
+
* Stores under users/{userId}/feedback
|
|
28
28
|
*/
|
|
29
29
|
export async function submitFeedback(
|
|
30
30
|
data: FeedbackData
|
|
@@ -38,6 +38,13 @@ export async function submitFeedback(
|
|
|
38
38
|
return { success: false, error: new Error("Firestore not available") };
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
if (!data.userId) {
|
|
42
|
+
if (__DEV__) {
|
|
43
|
+
console.warn("[FeedbackService] User ID is required for feedback");
|
|
44
|
+
}
|
|
45
|
+
return { success: false, error: new Error("User ID is required") };
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
try {
|
|
42
49
|
if (__DEV__) {
|
|
43
50
|
console.log("[FeedbackService] Submitting feedback:", {
|
|
@@ -48,8 +55,11 @@ export async function submitFeedback(
|
|
|
48
55
|
|
|
49
56
|
const now = new Date().toISOString();
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
// Store under users/{userId}/feedback
|
|
59
|
+
const userDocRef = doc(db, "users", data.userId);
|
|
60
|
+
const feedbackCollectionRef = collection(userDocRef, "feedback");
|
|
61
|
+
|
|
62
|
+
await addDoc(feedbackCollectionRef, {
|
|
53
63
|
userEmail: data.userEmail,
|
|
54
64
|
type: data.type,
|
|
55
65
|
title: data.title,
|
|
@@ -53,6 +53,13 @@ export const useAuthAwarePurchase = (
|
|
|
53
53
|
|
|
54
54
|
const handlePurchase = useCallback(
|
|
55
55
|
async (pkg: PurchasesPackage, source?: PurchaseSource): Promise<boolean> => {
|
|
56
|
+
if (__DEV__) {
|
|
57
|
+
console.log("[useAuthAwarePurchase] handlePurchase called:", {
|
|
58
|
+
productId: pkg.product.identifier,
|
|
59
|
+
hasAuthProvider: !!globalAuthProvider,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
if (!globalAuthProvider) {
|
|
57
64
|
if (__DEV__) {
|
|
58
65
|
console.error("[useAuthAwarePurchase] Auth provider not configured");
|
|
@@ -60,7 +67,12 @@ export const useAuthAwarePurchase = (
|
|
|
60
67
|
return false;
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
const isAuth = globalAuthProvider.isAuthenticated();
|
|
71
|
+
if (__DEV__) {
|
|
72
|
+
console.log("[useAuthAwarePurchase] Auth check:", { isAuthenticated: isAuth });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!isAuth) {
|
|
64
76
|
if (__DEV__) {
|
|
65
77
|
console.log("[useAuthAwarePurchase] Not authenticated, saving and showing auth");
|
|
66
78
|
}
|
|
@@ -70,7 +82,14 @@ export const useAuthAwarePurchase = (
|
|
|
70
82
|
return false;
|
|
71
83
|
}
|
|
72
84
|
|
|
73
|
-
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
console.log("[useAuthAwarePurchase] Calling purchasePackage");
|
|
87
|
+
}
|
|
88
|
+
const result = await purchasePackage(pkg);
|
|
89
|
+
if (__DEV__) {
|
|
90
|
+
console.log("[useAuthAwarePurchase] purchasePackage returned:", result);
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
74
93
|
},
|
|
75
94
|
[purchasePackage, params?.source]
|
|
76
95
|
);
|
|
@@ -85,8 +85,14 @@ export const usePremium = (userId?: string): UsePremiumResult => {
|
|
|
85
85
|
// Purchase handler with proper error handling
|
|
86
86
|
const handlePurchase = useCallback(
|
|
87
87
|
async (pkg: PurchasesPackage): Promise<boolean> => {
|
|
88
|
+
if (__DEV__) {
|
|
89
|
+
console.log("[usePremium] handlePurchase called:", pkg.product.identifier);
|
|
90
|
+
}
|
|
88
91
|
try {
|
|
89
92
|
const result = await purchaseMutation.mutateAsync(pkg);
|
|
93
|
+
if (__DEV__) {
|
|
94
|
+
console.log("[usePremium] Purchase result:", { success: result.success });
|
|
95
|
+
}
|
|
90
96
|
return result.success;
|
|
91
97
|
} catch (error) {
|
|
92
98
|
if (__DEV__) {
|