@umituz/react-native-subscription 2.43.19 → 2.43.20

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.43.19",
3
+ "version": "2.43.20",
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",
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from "react";
1
+ import React, { useState, useEffect, useCallback } from "react";
2
2
  import type { NavigationProp } from "@react-navigation/native";
3
3
  import type { ImageSourcePropType } from "react-native";
4
4
  import { SplashScreen, useSplashFlow } from "@umituz/react-native-design-system/molecules";
@@ -99,9 +99,26 @@ const ManagedSubscriptionFlowInner = React.memo<ManagedSubscriptionFlowProps>(({
99
99
  // Hooks for paywall (called at component level, not inside conditional render)
100
100
  const { isPremium, isSyncing, credits } = usePremiumStatus();
101
101
  const { packages } = usePremiumPackages();
102
- const { purchasePackage, restorePurchase } = usePremiumActions();
102
+ const { purchasePackage: originalPurchasePackage, restorePurchase } = usePremiumActions();
103
103
  const { closePostOnboardingPaywall } = useSubscriptionFlowStore();
104
104
 
105
+ // Track if purchase was successful to avoid showing feedback
106
+ const [purchaseSuccessful, setPurchaseSuccessful] = useState(false);
107
+
108
+ // Wrap purchasePackage to track success
109
+ const purchasePackage = useCallback(async (pkgId: string) => {
110
+ const result = await originalPurchasePackage(pkgId);
111
+ if (result?.success) {
112
+ setPurchaseSuccessful(true);
113
+ }
114
+ return result;
115
+ }, [originalPurchasePackage]);
116
+
117
+ // Wrap onClose to pass purchase status
118
+ const handleClose = useCallback(() => {
119
+ closePostOnboardingPaywall({ purchased: purchaseSuccessful });
120
+ }, [closePostOnboardingPaywall, purchaseSuccessful]);
121
+
105
122
  const [isNavReady, setIsNavReady] = useState(false);
106
123
 
107
124
  // Mark navigation tree as ready after splash and localization
@@ -208,7 +225,7 @@ const ManagedSubscriptionFlowInner = React.memo<ManagedSubscriptionFlowProps>(({
208
225
  isSyncing={isSyncing}
209
226
  onPurchase={purchasePackage}
210
227
  onRestore={restorePurchase}
211
- onClose={closePostOnboardingPaywall}
228
+ onClose={handleClose}
212
229
  />
213
230
  );
214
231
  }
@@ -36,7 +36,7 @@ export interface SubscriptionFlowState {
36
36
 
37
37
  export interface SubscriptionFlowActions {
38
38
  completeOnboarding: () => Promise<void>;
39
- closePostOnboardingPaywall: () => Promise<void>;
39
+ closePostOnboardingPaywall: (params?: { purchased: boolean }) => Promise<void>;
40
40
  closeFeedback: () => void;
41
41
  setAuthModalOpen: (open: boolean) => void;
42
42
  markPaywallShown: () => Promise<void>;
@@ -79,14 +79,18 @@ export const useSubscriptionFlowStore = createStore<SubscriptionFlowState, Subsc
79
79
  });
80
80
  subscriptionEventBus.emit(FLOW_EVENTS.ONBOARDING_COMPLETED, { timestamp: Date.now() });
81
81
  },
82
- closePostOnboardingPaywall: async () => {
82
+ closePostOnboardingPaywall: async (params?: { purchased: boolean }) => {
83
+ const purchased = params?.purchased ?? false;
83
84
  set({
84
85
  showPostOnboardingPaywall: false,
85
86
  paywallShown: true,
86
87
  status: SubscriptionFlowStatus.READY,
87
- showFeedback: true, // Show feedback screen when paywall is closed
88
+ showFeedback: !purchased, // Only show feedback if NOT purchased
89
+ });
90
+ subscriptionEventBus.emit(FLOW_EVENTS.PAYWALL_CLOSED, {
91
+ timestamp: Date.now(),
92
+ purchased
88
93
  });
89
- subscriptionEventBus.emit(FLOW_EVENTS.PAYWALL_CLOSED, { timestamp: Date.now() });
90
94
  },
91
95
  closeFeedback: () => set({ showFeedback: false }),
92
96
  setAuthModalOpen: (open: boolean) => set({ isAuthModalOpen: open }),