@umituz/react-native-subscription 2.27.153 → 2.28.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.27.153",
3
+ "version": "2.28.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",
@@ -5,6 +5,16 @@ import { toDate } from "../../../../shared/utils/dateConverter";
5
5
  export interface PremiumStatus {
6
6
  isPremium: boolean;
7
7
  expirationDate: Date | null;
8
+ willRenew: boolean;
9
+ productIdentifier: string | null;
10
+ originalPurchaseDate: Date | null;
11
+ latestPurchaseDate: Date | null;
12
+ billingIssuesDetected: boolean;
13
+ isSandbox: boolean;
14
+ periodType: string | null;
15
+ store: string | null;
16
+ gracePeriodExpiresDate: Date | null;
17
+ unsubscribeDetectedAt: Date | null;
8
18
  }
9
19
 
10
20
  export class PurchaseStatusResolver {
@@ -12,15 +22,40 @@ export class PurchaseStatusResolver {
12
22
  const entitlement = getPremiumEntitlement(customerInfo, entitlementId);
13
23
 
14
24
  if (entitlement) {
25
+ // Get the active subscription from customerInfo
26
+ const activeSubscriptions = customerInfo.activeSubscriptions || [];
27
+ const productId = entitlement.productIdentifier;
28
+ const subscription = productId ? customerInfo.allPurchasedProductIdentifiers.includes(productId) : null;
29
+
15
30
  return {
16
31
  isPremium: true,
17
32
  expirationDate: toDate(entitlement.expirationDate),
33
+ willRenew: entitlement.willRenew || false,
34
+ productIdentifier: entitlement.productIdentifier || null,
35
+ originalPurchaseDate: toDate(entitlement.originalPurchaseDate) || null,
36
+ latestPurchaseDate: toDate(entitlement.latestPurchaseDate) || null,
37
+ billingIssuesDetected: entitlement.billingIssueDetectedAt !== null && entitlement.billingIssueDetectedAt !== undefined,
38
+ isSandbox: entitlement.isSandbox || false,
39
+ periodType: entitlement.periodType || null,
40
+ store: entitlement.store || null,
41
+ gracePeriodExpiresDate: toDate(entitlement.gracePeriodExpiresDate) || null,
42
+ unsubscribeDetectedAt: toDate(entitlement.unsubscribeDetectedAt) || null,
18
43
  };
19
44
  }
20
45
 
21
46
  return {
22
47
  isPremium: false,
23
48
  expirationDate: null,
49
+ willRenew: false,
50
+ productIdentifier: null,
51
+ originalPurchaseDate: null,
52
+ latestPurchaseDate: null,
53
+ billingIssuesDetected: false,
54
+ isSandbox: false,
55
+ periodType: null,
56
+ store: null,
57
+ gracePeriodExpiresDate: null,
58
+ unsubscribeDetectedAt: null,
24
59
  };
25
60
  }
26
61
  }
@@ -25,15 +25,30 @@ export const useSubscriptionStatus = (): SubscriptionStatusResult => {
25
25
  subscriptionStatusQueryKeys.user
26
26
  ),
27
27
  queryFn: async () => {
28
+ const defaultStatus = {
29
+ isPremium: false,
30
+ expirationDate: null,
31
+ willRenew: false,
32
+ productIdentifier: null,
33
+ originalPurchaseDate: null,
34
+ latestPurchaseDate: null,
35
+ billingIssuesDetected: false,
36
+ isSandbox: false,
37
+ periodType: null,
38
+ store: null,
39
+ gracePeriodExpiresDate: null,
40
+ unsubscribeDetectedAt: null,
41
+ };
42
+
28
43
  if (!isAuthenticated(userId)) {
29
- return { isPremium: false, expirationDate: null };
44
+ return defaultStatus;
30
45
  }
31
46
 
32
47
  try {
33
48
  const result = await SubscriptionManager.checkPremiumStatus();
34
- return result ?? { isPremium: false, expirationDate: null };
49
+ return result ?? defaultStatus;
35
50
  } catch {
36
- return { isPremium: false, expirationDate: null };
51
+ return defaultStatus;
37
52
  }
38
53
  },
39
54
  enabled: queryEnabled,
@@ -61,6 +76,16 @@ export const useSubscriptionStatus = (): SubscriptionStatusResult => {
61
76
  return {
62
77
  isPremium: data?.isPremium ?? false,
63
78
  expirationDate: data?.expirationDate ?? null,
79
+ willRenew: data?.willRenew ?? false,
80
+ productIdentifier: data?.productIdentifier ?? null,
81
+ originalPurchaseDate: data?.originalPurchaseDate ?? null,
82
+ latestPurchaseDate: data?.latestPurchaseDate ?? null,
83
+ billingIssuesDetected: data?.billingIssuesDetected ?? false,
84
+ isSandbox: data?.isSandbox ?? false,
85
+ periodType: data?.periodType ?? null,
86
+ store: data?.store ?? null,
87
+ gracePeriodExpiresDate: data?.gracePeriodExpiresDate ?? null,
88
+ unsubscribeDetectedAt: data?.unsubscribeDetectedAt ?? null,
64
89
  isLoading,
65
90
  error: error as Error | null,
66
91
  refetch,
@@ -1,6 +1,16 @@
1
1
  export interface SubscriptionStatusResult {
2
2
  isPremium: boolean;
3
3
  expirationDate: Date | null;
4
+ willRenew: boolean;
5
+ productIdentifier: string | null;
6
+ originalPurchaseDate: Date | null;
7
+ latestPurchaseDate: Date | null;
8
+ billingIssuesDetected: boolean;
9
+ isSandbox: boolean;
10
+ periodType: string | null;
11
+ store: string | null;
12
+ gracePeriodExpiresDate: Date | null;
13
+ unsubscribeDetectedAt: Date | null;
4
14
  isLoading: boolean;
5
15
  error: Error | null;
6
16
  refetch: () => void;