@umituz/react-native-subscription 2.20.2 → 2.20.4
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.20.
|
|
3
|
+
"version": "2.20.4",
|
|
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",
|
|
@@ -95,6 +95,7 @@ export async function initializeCreditsTransaction(
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// Create purchase metadata for history (only if productId and source exists and packageType detected)
|
|
98
|
+
// NOTE: Cannot use serverTimestamp() in arrays, using Date.now() instead
|
|
98
99
|
const purchaseMetadata: PurchaseMetadata | undefined =
|
|
99
100
|
productId && metadata?.source && packageType && packageType !== "unknown" ? {
|
|
100
101
|
productId,
|
|
@@ -104,7 +105,7 @@ export async function initializeCreditsTransaction(
|
|
|
104
105
|
type: purchaseType,
|
|
105
106
|
platform,
|
|
106
107
|
appVersion,
|
|
107
|
-
timestamp: now as any,
|
|
108
|
+
timestamp: Date.now() as any, // Use Date.now() instead of serverTimestamp() for arrays
|
|
108
109
|
} : undefined;
|
|
109
110
|
|
|
110
111
|
// Update purchase history (keep last 10, only if metadata exists)
|
|
@@ -49,7 +49,7 @@ export interface UseAuthAwarePurchaseResult {
|
|
|
49
49
|
export const useAuthAwarePurchase = (
|
|
50
50
|
params?: UseAuthAwarePurchaseParams
|
|
51
51
|
): UseAuthAwarePurchaseResult => {
|
|
52
|
-
const { purchasePackage, restorePurchase
|
|
52
|
+
const { purchasePackage, restorePurchase } = usePremium(params?.userId);
|
|
53
53
|
|
|
54
54
|
const handlePurchase = useCallback(
|
|
55
55
|
async (pkg: PurchasesPackage, source?: PurchaseSource): Promise<boolean> => {
|
|
@@ -66,14 +66,13 @@ export const useAuthAwarePurchase = (
|
|
|
66
66
|
}
|
|
67
67
|
savedPackage = pkg;
|
|
68
68
|
savedSource = source || params?.source || "settings";
|
|
69
|
-
closePaywall();
|
|
70
69
|
globalAuthProvider.showAuthModal();
|
|
71
70
|
return false;
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
return purchasePackage(pkg);
|
|
75
74
|
},
|
|
76
|
-
[purchasePackage,
|
|
75
|
+
[purchasePackage, params?.source]
|
|
77
76
|
);
|
|
78
77
|
|
|
79
78
|
const handleRestore = useCallback(async (): Promise<boolean> => {
|
|
@@ -88,13 +87,12 @@ export const useAuthAwarePurchase = (
|
|
|
88
87
|
if (__DEV__) {
|
|
89
88
|
console.log("[useAuthAwarePurchase] Not authenticated for restore");
|
|
90
89
|
}
|
|
91
|
-
closePaywall();
|
|
92
90
|
globalAuthProvider.showAuthModal();
|
|
93
91
|
return false;
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
return restorePurchase();
|
|
97
|
-
}, [restorePurchase
|
|
95
|
+
}, [restorePurchase]);
|
|
98
96
|
|
|
99
97
|
const executeSavedPurchase = useCallback(async (): Promise<boolean> => {
|
|
100
98
|
const saved = getSavedPurchase();
|