@umituz/react-native-subscription 2.13.18 → 2.13.19
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.13.
|
|
3
|
+
"version": "2.13.19",
|
|
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",
|
|
@@ -36,6 +36,10 @@ export interface UsePaywallOperationsResult {
|
|
|
36
36
|
handleInAppPurchase: (pkg: PurchasesPackage) => Promise<boolean>;
|
|
37
37
|
/** Handle in-app restore (with auto-close logic) */
|
|
38
38
|
handleInAppRestore: () => Promise<boolean>;
|
|
39
|
+
/** Complete pending purchase after authentication */
|
|
40
|
+
completePendingPurchase: () => Promise<boolean>;
|
|
41
|
+
/** Clear pending package without purchasing */
|
|
42
|
+
clearPendingPackage: () => void;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
export function usePaywallOperations({
|
|
@@ -155,11 +159,46 @@ export function usePaywallOperations({
|
|
|
155
159
|
[executeRestore, closePaywall]
|
|
156
160
|
);
|
|
157
161
|
|
|
162
|
+
const completePendingPurchase = useCallback(async (): Promise<boolean> => {
|
|
163
|
+
if (!pendingPackage) {
|
|
164
|
+
if (__DEV__) {
|
|
165
|
+
console.log("[usePaywallOperations] No pending package to complete");
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (__DEV__) {
|
|
171
|
+
console.log("[usePaywallOperations] Completing pending purchase:", pendingPackage.identifier);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const pkg = pendingPackage;
|
|
175
|
+
setPendingPackage(null);
|
|
176
|
+
|
|
177
|
+
const success = await purchasePackage(pkg);
|
|
178
|
+
|
|
179
|
+
if (success) {
|
|
180
|
+
if (onPurchaseSuccess) onPurchaseSuccess();
|
|
181
|
+
} else {
|
|
182
|
+
Alert.alert(
|
|
183
|
+
t("premium.purchaseError"),
|
|
184
|
+
t("premium.purchaseErrorMessage")
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return success;
|
|
189
|
+
}, [pendingPackage, purchasePackage, onPurchaseSuccess, t]);
|
|
190
|
+
|
|
191
|
+
const clearPendingPackage = useCallback(() => {
|
|
192
|
+
setPendingPackage(null);
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
158
195
|
return {
|
|
159
196
|
pendingPackage,
|
|
160
197
|
handlePurchase,
|
|
161
198
|
handleRestore,
|
|
162
199
|
handleInAppPurchase,
|
|
163
200
|
handleInAppRestore,
|
|
201
|
+
completePendingPurchase,
|
|
202
|
+
clearPendingPackage,
|
|
164
203
|
};
|
|
165
204
|
}
|