@umituz/react-native-subscription 2.31.21 → 2.31.23

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.31.21",
3
+ "version": "2.31.23",
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",
@@ -75,7 +75,6 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
75
75
  onClose={handleClose}
76
76
  translations={translations}
77
77
  packages={packages}
78
- isLoading={isLoading}
79
78
  legalUrls={legalUrls}
80
79
  features={features ? [...features] : undefined}
81
80
  heroImage={heroImage}
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect } from "react";
2
2
  import { View, TouchableOpacity, Linking } from "react-native";
3
- import { BaseModal, useAppDesignTokens, AtomicText, AtomicIcon, AtomicSpinner, useSafeAreaInsets } from "@umituz/react-native-design-system";
3
+ import { BaseModal, useAppDesignTokens, AtomicText, AtomicIcon, useSafeAreaInsets } from "@umituz/react-native-design-system";
4
4
  import { ScreenLayout } from "../../../shared/presentation";
5
5
  import { Image } from "expo-image";
6
6
  import { PlanCard } from "./PlanCard";
@@ -11,7 +11,7 @@ import { usePaywallActions } from "../hooks/usePaywallActions";
11
11
  import { PaywallModalProps } from "./PaywallModal.types";
12
12
 
13
13
  export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
14
- const { visible, onClose, translations, packages = [], features = [], isLoading = false, legalUrls = {}, bestValueIdentifier, creditAmounts, creditsLabel, heroImage, onPurchase, onRestore, trialEligibility = {}, trialSubtitleText } = props;
14
+ const { visible, onClose, translations, packages = [], features = [], legalUrls = {}, bestValueIdentifier, creditAmounts, creditsLabel, heroImage, onPurchase, onRestore, trialEligibility = {}, trialSubtitleText } = props;
15
15
  const tokens = useAppDesignTokens();
16
16
  const insets = useSafeAreaInsets();
17
17
  const { selectedPlanId, setSelectedPlanId, isProcessing, handlePurchase, handleRestore, resetState } = usePaywallActions({ packages, onPurchase, onRestore });
@@ -42,19 +42,15 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
42
42
  {translations.subtitle && <AtomicText type="bodyMedium" style={[styles.subtitle, { color: tokens.colors.textSecondary }]}>{translations.subtitle}</AtomicText>}
43
43
  </View>
44
44
  <PaywallFeatures features={features} />
45
- {isLoading ? (
46
- <View style={styles.loading}><AtomicSpinner size="lg" color="primary" text={translations.loadingText} /></View>
47
- ) : (
48
- <View style={styles.plans}>
49
- {packages.map((pkg) => {
50
- const pid = pkg.product.identifier;
51
- const hasTrial = trialEligibility[pid]?.eligible ?? false;
52
- return (
53
- <PlanCard key={pid} pkg={pkg} isSelected={selectedPlanId === pid} onSelect={() => setSelectedPlanId(pid)} badge={pid === bestValueIdentifier ? translations.bestValueBadgeText : undefined} creditAmount={creditAmounts?.[pid]} creditsLabel={creditsLabel} hasFreeTrial={hasTrial} trialSubtitleText={hasTrial ? trialSubtitleText : undefined} />
54
- );
55
- })}
56
- </View>
57
- )}
45
+ <View style={styles.plans}>
46
+ {packages.map((pkg) => {
47
+ const pid = pkg.product.identifier;
48
+ const hasTrial = trialEligibility[pid]?.eligible ?? false;
49
+ return (
50
+ <PlanCard key={pid} pkg={pkg} isSelected={selectedPlanId === pid} onSelect={() => setSelectedPlanId(pid)} badge={pid === bestValueIdentifier ? translations.bestValueBadgeText : undefined} creditAmount={creditAmounts?.[pid]} creditsLabel={creditsLabel} hasFreeTrial={hasTrial} trialSubtitleText={hasTrial ? trialSubtitleText : undefined} />
51
+ );
52
+ })}
53
+ </View>
58
54
  <TouchableOpacity onPress={handlePurchase} disabled={!selectedPlanId || isProcessing} style={[styles.cta, { backgroundColor: tokens.colors.primary }, (!selectedPlanId || isProcessing) && styles.ctaDisabled]} activeOpacity={0.8}>
59
55
  <AtomicText type="titleLarge" style={[styles.ctaText, { color: tokens.colors.onPrimary }]}>{isProcessing ? translations.processingText : translations.purchaseButtonText}</AtomicText>
60
56
  </TouchableOpacity>
@@ -13,7 +13,6 @@ export interface PaywallModalProps {
13
13
  translations: PaywallTranslations;
14
14
  packages?: PurchasesPackage[];
15
15
  features?: SubscriptionFeature[];
16
- isLoading?: boolean;
17
16
  legalUrls?: PaywallLegalUrls;
18
17
  bestValueIdentifier?: string;
19
18
  creditAmounts?: Record<string, number>;
@@ -34,7 +34,7 @@ class SubscriptionManagerImpl {
34
34
  async initialize(userId?: string): Promise<boolean> {
35
35
  this.ensureConfigured();
36
36
 
37
- const actualUserId = userId ?? (await this.managerConfig.getAnonymousUserId());
37
+ const actualUserId = userId ?? (await this.managerConfig.getAnonymousUserId()) ?? '';
38
38
  const { shouldInit, existingPromise } = this.state.initCache.tryAcquireInitialization(actualUserId);
39
39
 
40
40
  if (!shouldInit && existingPromise) {
@@ -49,7 +49,7 @@ class SubscriptionManagerImpl {
49
49
  private async performInitialization(userId: string): Promise<boolean> {
50
50
  this.ensureConfigured();
51
51
  const { service, success } = await performServiceInitialization(this.managerConfig.config, userId);
52
- this.serviceInstance = service;
52
+ this.serviceInstance = service ?? null;
53
53
  this.ensurePackageHandlerInitialized();
54
54
  return success;
55
55
  }
@@ -95,7 +95,7 @@ class SubscriptionManagerImpl {
95
95
 
96
96
  getEntitlementId(): string {
97
97
  this.ensureConfigured();
98
- return this.managerConfig.config.entitlementIdentifier;
98
+ return this.managerConfig.config.entitlementIdentifier ?? '';
99
99
  }
100
100
  }
101
101
 
@@ -76,7 +76,9 @@ export async function handlePurchase(
76
76
  const restoreResult = await handleRestore(deps, userId);
77
77
  if (restoreResult.success && restoreResult.isPremium) {
78
78
  // Restore succeeded, notify and return success
79
- await notifyPurchaseCompleted(deps.config, userId, pkg.product.identifier, restoreResult.customerInfo, getSavedPurchase()?.source);
79
+ if (restoreResult.customerInfo) {
80
+ await notifyPurchaseCompleted(deps.config, userId, pkg.product.identifier, restoreResult.customerInfo, getSavedPurchase()?.source);
81
+ }
80
82
  clearSavedPurchase();
81
83
  return {
82
84
  success: true,
@@ -13,16 +13,6 @@ export class TrialEligibilityService {
13
13
  const { hasUsedTrial, trialInProgress, userIds = [] } = record;
14
14
 
15
15
  if (userId && userIds.includes(userId)) {
16
- // Detect corrupted state: user in list but flags say trial not used
17
- if (!hasUsedTrial && !trialInProgress) {
18
- console.warn('[TrialEligibilityService] Corrupted trial state detected', {
19
- userId,
20
- deviceId,
21
- hasUsedTrial,
22
- trialInProgress,
23
- userIdsCount: userIds.length
24
- });
25
- }
26
16
  return { eligible: false, reason: "user_already_used", deviceId };
27
17
  }
28
18