@umituz/react-native-subscription 2.33.7 → 2.33.8

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.33.7",
3
+ "version": "2.33.8",
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",
@@ -19,6 +19,8 @@ import { subscriptionStatusQueryKeys } from "../../presentation/useSubscriptionS
19
19
  import { creditsQueryKeys } from "../../../credits/presentation/creditsQueryKeys";
20
20
  import { getErrorMessage } from "../../../revenuecat/core/errors";
21
21
 
22
+ declare const __DEV__: boolean;
23
+
22
24
  /** Purchase mutation result - simplified for presentation layer */
23
25
  export interface PurchaseMutationResult {
24
26
  success: boolean;
@@ -39,21 +41,51 @@ export const usePurchasePackage = () => {
39
41
 
40
42
  return useMutation({
41
43
  mutationFn: async (pkg: PurchasesPackage): Promise<PurchaseMutationResult> => {
44
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
45
+ console.log("[Purchase] ========================================");
46
+ console.log("[Purchase] mutationFn called:", {
47
+ productId: pkg.product.identifier,
48
+ userId,
49
+ isAnonymous,
50
+ });
51
+ }
52
+
42
53
  if (!userId) {
54
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
55
+ console.log("[Purchase] ERROR: User not authenticated");
56
+ }
43
57
  throw new Error("User not authenticated");
44
58
  }
45
59
 
46
60
  if (isAnonymous) {
61
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
62
+ console.log("[Purchase] ERROR: Anonymous users cannot purchase");
63
+ }
47
64
  throw new Error("Anonymous users cannot purchase subscriptions");
48
65
  }
49
66
 
50
67
  const productId = pkg.product.identifier;
68
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
69
+ console.log("[Purchase] Calling SubscriptionManager.purchasePackage()");
70
+ }
71
+
51
72
  const success = await SubscriptionManager.purchasePackage(pkg);
52
73
 
74
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
75
+ console.log("[Purchase] Purchase completed:", { success, productId });
76
+ }
77
+
53
78
  return { success, productId };
54
79
  },
55
80
  onSuccess: (result) => {
81
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
82
+ console.log("[Purchase] onSuccess called:", result);
83
+ }
84
+
56
85
  if (result.success) {
86
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
87
+ console.log("[Purchase] ✅ Purchase successful! Invalidating queries...");
88
+ }
57
89
  showSuccess("Purchase Successful", "Your subscription is now active!");
58
90
  queryClient.invalidateQueries({
59
91
  queryKey: SUBSCRIPTION_QUERY_KEYS.packages,
@@ -65,17 +97,34 @@ export const usePurchasePackage = () => {
65
97
  queryClient.invalidateQueries({
66
98
  queryKey: creditsQueryKeys.user(userId),
67
99
  });
100
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
101
+ console.log("[Purchase] Queries invalidated - credits should reload now");
102
+ }
68
103
  }
69
104
  } else {
105
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
106
+ console.log("[Purchase] ❌ Purchase failed");
107
+ }
70
108
  showError("Purchase Failed", "Unable to complete purchase. Please try again.");
71
109
  }
72
110
  },
73
111
  onError: (error) => {
112
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
113
+ console.log("[Purchase] onError called:", error);
114
+ }
115
+
74
116
  // Use map-based lookup - O(1) complexity
75
117
  const errorInfo = getErrorMessage(error);
76
118
 
119
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
120
+ console.log("[Purchase] Error info:", errorInfo);
121
+ }
122
+
77
123
  // Don't show alert for user cancellation
78
124
  if (!errorInfo.shouldShowAlert) {
125
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
126
+ console.log("[Purchase] User cancelled - not showing alert");
127
+ }
79
128
  return;
80
129
  }
81
130