@umituz/react-native-subscription 2.14.62 → 2.14.64
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.14.
|
|
3
|
+
"version": "2.14.64",
|
|
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,7 +17,10 @@ export interface UseDeductCreditParams {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface UseDeductCreditResult {
|
|
20
|
+
/** Deduct a single credit */
|
|
20
21
|
deductCredit: (creditType: CreditType) => Promise<boolean>;
|
|
22
|
+
/** Deduct multiple credits (loops internally) */
|
|
23
|
+
deductCredits: (cost: number, creditType?: CreditType) => Promise<boolean>;
|
|
21
24
|
isDeducting: boolean;
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -96,8 +99,24 @@ export const useDeductCredit = ({
|
|
|
96
99
|
}
|
|
97
100
|
}, [mutation, onCreditsExhausted]);
|
|
98
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Deduct multiple credits at once
|
|
104
|
+
* Loops internally to deduct `cost` credits of the specified type
|
|
105
|
+
*/
|
|
106
|
+
const deductCredits = useCallback(
|
|
107
|
+
async (cost: number, creditType: CreditType = "image"): Promise<boolean> => {
|
|
108
|
+
for (let i = 0; i < cost; i++) {
|
|
109
|
+
const success = await deductCredit(creditType);
|
|
110
|
+
if (!success) return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
},
|
|
114
|
+
[deductCredit],
|
|
115
|
+
);
|
|
116
|
+
|
|
99
117
|
return {
|
|
100
118
|
deductCredit,
|
|
119
|
+
deductCredits,
|
|
101
120
|
isDeducting: mutation.isPending,
|
|
102
121
|
};
|
|
103
122
|
};
|