@umituz/react-native-subscription 2.27.154 → 2.28.1
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.
|
|
3
|
+
"version": "2.28.1",
|
|
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
|
}
|
|
@@ -26,14 +26,14 @@ export const useSubscriptionStatus = (): SubscriptionStatusResult => {
|
|
|
26
26
|
),
|
|
27
27
|
queryFn: async () => {
|
|
28
28
|
if (!isAuthenticated(userId)) {
|
|
29
|
-
return
|
|
29
|
+
return null;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
try {
|
|
33
33
|
const result = await SubscriptionManager.checkPremiumStatus();
|
|
34
|
-
return result
|
|
34
|
+
return result;
|
|
35
35
|
} catch {
|
|
36
|
-
return
|
|
36
|
+
return null;
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
enabled: queryEnabled,
|
|
@@ -59,8 +59,18 @@ export const useSubscriptionStatus = (): SubscriptionStatusResult => {
|
|
|
59
59
|
const isLoading = status === "pending";
|
|
60
60
|
|
|
61
61
|
return {
|
|
62
|
-
isPremium: data?.isPremium
|
|
63
|
-
expirationDate: data?.expirationDate
|
|
62
|
+
isPremium: data?.isPremium || false,
|
|
63
|
+
expirationDate: data?.expirationDate || null,
|
|
64
|
+
willRenew: data?.willRenew || false,
|
|
65
|
+
productIdentifier: data?.productIdentifier || null,
|
|
66
|
+
originalPurchaseDate: data?.originalPurchaseDate || null,
|
|
67
|
+
latestPurchaseDate: data?.latestPurchaseDate || null,
|
|
68
|
+
billingIssuesDetected: data?.billingIssuesDetected || false,
|
|
69
|
+
isSandbox: data?.isSandbox || false,
|
|
70
|
+
periodType: data?.periodType || null,
|
|
71
|
+
store: data?.store || null,
|
|
72
|
+
gracePeriodExpiresDate: data?.gracePeriodExpiresDate || null,
|
|
73
|
+
unsubscribeDetectedAt: data?.unsubscribeDetectedAt || null,
|
|
64
74
|
isLoading,
|
|
65
75
|
error: error as Error | null,
|
|
66
76
|
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;
|