@umituz/react-native-subscription 2.26.5 → 2.26.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.26.
|
|
3
|
+
"version": "2.26.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",
|
|
@@ -11,6 +11,8 @@ import { creditsQueryKeys } from "./useCredits";
|
|
|
11
11
|
|
|
12
12
|
import { timezoneService } from "@umituz/react-native-design-system";
|
|
13
13
|
|
|
14
|
+
declare const __DEV__: boolean;
|
|
15
|
+
|
|
14
16
|
export interface UseDeductCreditParams {
|
|
15
17
|
userId: string | undefined;
|
|
16
18
|
onCreditsExhausted?: () => void;
|
|
@@ -61,14 +63,28 @@ export const useDeductCredit = ({
|
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
const deductCredit = useCallback(async (cost: number = 1): Promise<boolean> => {
|
|
66
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
67
|
+
console.log("[useDeductCredit] Attempting to deduct:", cost);
|
|
68
|
+
}
|
|
64
69
|
try {
|
|
65
70
|
const res = await mutation.mutateAsync(cost);
|
|
66
71
|
if (!res.success) {
|
|
72
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
73
|
+
console.log("[useDeductCredit] Deduction failed:", res.error?.code, res.error?.message);
|
|
74
|
+
}
|
|
67
75
|
if (res.error?.code === "CREDITS_EXHAUSTED") onCreditsExhausted?.();
|
|
68
76
|
return false;
|
|
69
77
|
}
|
|
78
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
79
|
+
console.log("[useDeductCredit] Deduction successful, remaining:", res.remainingCredits);
|
|
80
|
+
}
|
|
70
81
|
return true;
|
|
71
|
-
} catch {
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
84
|
+
console.log("[useDeductCredit] Deduction error:", err);
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
72
88
|
}, [mutation, onCreditsExhausted]);
|
|
73
89
|
|
|
74
90
|
const deductCredits = useCallback(async (cost: number): Promise<boolean> => {
|