@umituz/react-native-subscription 2.23.0 → 2.23.2
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.23.
|
|
3
|
+
"version": "2.23.2",
|
|
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",
|
|
@@ -17,6 +17,8 @@ export interface UseDeductCreditParams {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface UseDeductCreditResult {
|
|
20
|
+
/** Check if user has enough credits (server-side validation) */
|
|
21
|
+
checkCredits: (cost?: number) => Promise<boolean>;
|
|
20
22
|
deductCredit: (cost?: number) => Promise<boolean>;
|
|
21
23
|
deductCredits: (cost: number) => Promise<boolean>;
|
|
22
24
|
isDeducting: boolean;
|
|
@@ -73,5 +75,10 @@ export const useDeductCredit = ({
|
|
|
73
75
|
return await deductCredit(cost);
|
|
74
76
|
}, [deductCredit]);
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
const checkCredits = useCallback(async (cost: number = 1): Promise<boolean> => {
|
|
79
|
+
if (!userId) return false;
|
|
80
|
+
return repository.hasCredits(userId, cost);
|
|
81
|
+
}, [userId, repository]);
|
|
82
|
+
|
|
83
|
+
return { checkCredits, deductCredit, deductCredits, isDeducting: mutation.isPending };
|
|
77
84
|
};
|