@umituz/react-native-subscription 2.37.85 → 2.37.86

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.37.85",
3
+ "version": "2.37.86",
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",
@@ -21,6 +21,14 @@ export async function handlePurchase(
21
21
  const consumableIds = deps.config.consumableProductIdentifiers || [];
22
22
  const isConsumable = isConsumableProduct(pkg, consumableIds);
23
23
 
24
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
25
+ console.log("[PurchaseHandler] handlePurchase:", {
26
+ productId: pkg.product.identifier,
27
+ userId,
28
+ isConsumable,
29
+ });
30
+ }
31
+
24
32
  try {
25
33
  const result = await executePurchase(deps.config, userId, pkg, isConsumable);
26
34
  return result;
@@ -86,13 +86,44 @@ async function executeSubscriptionPurchase(
86
86
  };
87
87
  }
88
88
 
89
+ /** Default timeout for purchase operations (2 minutes) */
90
+ const PURCHASE_TIMEOUT_MS = 120_000;
91
+
92
+ function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {
93
+ return new Promise<T>((resolve, reject) => {
94
+ const timer = setTimeout(() => {
95
+ reject(new Error(`[PurchaseExecutor] ${label} timed out after ${ms / 1000}s`));
96
+ }, ms);
97
+
98
+ promise
99
+ .then((result) => { clearTimeout(timer); resolve(result); })
100
+ .catch((error) => { clearTimeout(timer); reject(error); });
101
+ });
102
+ }
103
+
89
104
  export async function executePurchase(
90
105
  config: RevenueCatConfig,
91
106
  userId: string,
92
107
  pkg: PurchasesPackage,
93
108
  isConsumable: boolean
94
109
  ): Promise<PurchaseResult> {
95
- const { customerInfo } = await Purchases.purchasePackage(pkg);
110
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
111
+ console.log("[PurchaseExecutor] Starting Purchases.purchasePackage:", {
112
+ productId: pkg.product.identifier,
113
+ userId,
114
+ isConsumable,
115
+ });
116
+ }
117
+
118
+ const { customerInfo } = await withTimeout(
119
+ Purchases.purchasePackage(pkg),
120
+ PURCHASE_TIMEOUT_MS,
121
+ `Purchases.purchasePackage(${pkg.product.identifier})`
122
+ );
123
+
124
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
125
+ console.log("[PurchaseExecutor] Purchases.purchasePackage completed successfully");
126
+ }
96
127
 
97
128
  const productId = pkg.product.identifier;
98
129
  const packageType = pkg.packageType ?? null;