@umituz/react-native-subscription 2.26.20 → 2.27.0
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 +1 -1
- package/src/domains/paywall/components/PaywallContainer.tsx +1 -2
- package/src/domains/paywall/components/PaywallContainer.types.ts +0 -4
- package/src/domains/paywall/hooks/usePaywallActions.ts +1 -7
- package/src/presentation/hooks/usePremium.ts +3 -9
- package/src/revenuecat/presentation/hooks/usePurchasePackage.ts +8 -1
- package/src/revenuecat/presentation/hooks/useRestorePurchase.ts +8 -1
- package/src/revenuecat/presentation/hooks/useSubscriptionPackages.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
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",
|
|
@@ -16,7 +16,6 @@ import type { PaywallContainerProps } from "./PaywallContainer.types";
|
|
|
16
16
|
|
|
17
17
|
export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
|
|
18
18
|
const {
|
|
19
|
-
userId,
|
|
20
19
|
translations,
|
|
21
20
|
mode = "subscription",
|
|
22
21
|
legalUrls,
|
|
@@ -41,7 +40,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
|
|
|
41
40
|
|
|
42
41
|
const purchaseSource = source ?? currentSource ?? "settings";
|
|
43
42
|
|
|
44
|
-
const { data: allPackages = [], isLoading } = useSubscriptionPackages(
|
|
43
|
+
const { data: allPackages = [], isLoading } = useSubscriptionPackages();
|
|
45
44
|
const { eligibilityMap, checkEligibility } = useRevenueCatTrialEligibility();
|
|
46
45
|
const { handlePurchase, handleRestore } = usePaywallActions({
|
|
47
46
|
source: purchaseSource,
|
|
@@ -24,10 +24,6 @@ export interface TrialConfig {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface PaywallContainerProps {
|
|
27
|
-
/** User ID for subscription management */
|
|
28
|
-
readonly userId: string | null;
|
|
29
|
-
/** Whether user is anonymous (requires auth before purchase) */
|
|
30
|
-
readonly isAnonymous?: boolean;
|
|
31
27
|
/** Paywall translations - no defaults, must be provided */
|
|
32
28
|
readonly translations: PaywallTranslations;
|
|
33
29
|
/** Paywall mode - subscription, credits, or hybrid */
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
3
|
-
import {
|
|
4
|
-
useAuthStore,
|
|
5
|
-
selectUserId,
|
|
6
|
-
} from "@umituz/react-native-auth";
|
|
7
3
|
import { useRestorePurchase } from "../../../revenuecat/presentation/hooks/useRestorePurchase";
|
|
8
4
|
import { useAuthAwarePurchase } from "../../../presentation/hooks/useAuthAwarePurchase";
|
|
9
5
|
import type { PurchaseSource } from "../../../domain/entities/Credits";
|
|
@@ -25,10 +21,8 @@ export const usePaywallActions = ({
|
|
|
25
21
|
onAuthRequired: _onAuthRequired,
|
|
26
22
|
onClose,
|
|
27
23
|
}: UsePaywallActionsProps) => {
|
|
28
|
-
const userId = useAuthStore(selectUserId);
|
|
29
|
-
|
|
30
24
|
const { handlePurchase: authAwarePurchase } = useAuthAwarePurchase({ source });
|
|
31
|
-
const { mutateAsync: restorePurchases } = useRestorePurchase(
|
|
25
|
+
const { mutateAsync: restorePurchases } = useRestorePurchase();
|
|
32
26
|
|
|
33
27
|
const handlePurchase = useCallback(async (pkg: PurchasesPackage) => {
|
|
34
28
|
try {
|
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
import { useCallback } from 'react';
|
|
9
9
|
import type { PurchasesPackage } from 'react-native-purchases';
|
|
10
|
-
import {
|
|
11
|
-
useAuthStore,
|
|
12
|
-
selectUserId,
|
|
13
|
-
} from "@umituz/react-native-auth";
|
|
14
10
|
import type { UserCredits } from '../../domain/entities/Credits';
|
|
15
11
|
import { useCredits } from './useCredits';
|
|
16
12
|
import { useSubscriptionStatus } from './useSubscriptionStatus';
|
|
@@ -37,15 +33,13 @@ export interface UsePremiumResult {
|
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
export const usePremium = (): UsePremiumResult => {
|
|
40
|
-
const userId = useAuthStore(selectUserId);
|
|
41
|
-
|
|
42
36
|
const { isPremium: subscriptionActive, isLoading: statusLoading } = useSubscriptionStatus();
|
|
43
37
|
const { credits, isLoading: creditsLoading } = useCredits();
|
|
44
38
|
|
|
45
|
-
const { data: packages = [], isLoading: packagesLoading } = useSubscriptionPackages(
|
|
39
|
+
const { data: packages = [], isLoading: packagesLoading } = useSubscriptionPackages();
|
|
46
40
|
|
|
47
|
-
const purchaseMutation = usePurchasePackage(
|
|
48
|
-
const restoreMutation = useRestorePurchase(
|
|
41
|
+
const purchaseMutation = usePurchasePackage();
|
|
42
|
+
const restoreMutation = useRestorePurchase();
|
|
49
43
|
|
|
50
44
|
const { showPaywall, setShowPaywall, closePaywall, openPaywall } = usePaywallVisibility();
|
|
51
45
|
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* Purchase Package Hook
|
|
3
3
|
* TanStack mutation for purchasing subscription packages
|
|
4
4
|
* Credits are initialized by CustomerInfoListener (not here to avoid duplicates)
|
|
5
|
+
* Auth info automatically read from @umituz/react-native-auth
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import { useMutation, useQueryClient } from "@umituz/react-native-design-system";
|
|
8
9
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
9
10
|
import { useAlert } from "@umituz/react-native-design-system";
|
|
11
|
+
import {
|
|
12
|
+
useAuthStore,
|
|
13
|
+
selectUserId,
|
|
14
|
+
} from "@umituz/react-native-auth";
|
|
10
15
|
import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
|
|
11
16
|
import { SUBSCRIPTION_QUERY_KEYS } from "./subscriptionQueryKeys";
|
|
12
17
|
import { creditsQueryKeys } from "../../../presentation/hooks/useCredits";
|
|
@@ -23,8 +28,10 @@ export interface PurchaseMutationResult {
|
|
|
23
28
|
/**
|
|
24
29
|
* Purchase a subscription package
|
|
25
30
|
* Credits are initialized by CustomerInfoListener when entitlement becomes active
|
|
31
|
+
* Auth info automatically read from auth store
|
|
26
32
|
*/
|
|
27
|
-
export const usePurchasePackage = (
|
|
33
|
+
export const usePurchasePackage = () => {
|
|
34
|
+
const userId = useAuthStore(selectUserId);
|
|
28
35
|
const queryClient = useQueryClient();
|
|
29
36
|
const { showSuccess, showError } = useAlert();
|
|
30
37
|
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
* Restore Purchase Hook
|
|
3
3
|
* TanStack mutation for restoring previous purchases
|
|
4
4
|
* Credits are initialized by CustomerInfoListener (not here to avoid duplicates)
|
|
5
|
+
* Auth info automatically read from @umituz/react-native-auth
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import { useMutation, useQueryClient } from "@umituz/react-native-design-system";
|
|
9
|
+
import {
|
|
10
|
+
useAuthStore,
|
|
11
|
+
selectUserId,
|
|
12
|
+
} from "@umituz/react-native-auth";
|
|
8
13
|
import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
|
|
9
14
|
import { SUBSCRIPTION_QUERY_KEYS } from "./subscriptionQueryKeys";
|
|
10
15
|
import { creditsQueryKeys } from "../../../presentation/hooks/useCredits";
|
|
@@ -17,8 +22,10 @@ interface RestoreResult {
|
|
|
17
22
|
/**
|
|
18
23
|
* Restore previous purchases
|
|
19
24
|
* Credits are initialized by CustomerInfoListener when entitlement becomes active
|
|
25
|
+
* Auth info automatically read from auth store
|
|
20
26
|
*/
|
|
21
|
-
export const useRestorePurchase = (
|
|
27
|
+
export const useRestorePurchase = () => {
|
|
28
|
+
const userId = useAuthStore(selectUserId);
|
|
22
29
|
const queryClient = useQueryClient();
|
|
23
30
|
|
|
24
31
|
return useMutation({
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Subscription Packages Hook
|
|
3
3
|
* TanStack query for fetching available packages
|
|
4
|
+
* Auth info automatically read from @umituz/react-native-auth
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import { useQuery } from "@umituz/react-native-design-system";
|
|
8
|
+
import {
|
|
9
|
+
useAuthStore,
|
|
10
|
+
selectUserId,
|
|
11
|
+
} from "@umituz/react-native-auth";
|
|
7
12
|
import { SubscriptionManager } from '../../infrastructure/managers/SubscriptionManager';
|
|
8
13
|
import {
|
|
9
14
|
SUBSCRIPTION_QUERY_KEYS,
|
|
@@ -14,8 +19,10 @@ import {
|
|
|
14
19
|
/**
|
|
15
20
|
* Fetch available subscription packages
|
|
16
21
|
* Works for both authenticated and anonymous users
|
|
22
|
+
* Auth info automatically read from auth store
|
|
17
23
|
*/
|
|
18
|
-
export const useSubscriptionPackages = (
|
|
24
|
+
export const useSubscriptionPackages = () => {
|
|
25
|
+
const userId = useAuthStore(selectUserId);
|
|
19
26
|
const isConfigured = SubscriptionManager.isConfigured();
|
|
20
27
|
|
|
21
28
|
return useQuery({
|