@umituz/react-native-subscription 2.27.108 → 2.27.110
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.
|
|
3
|
+
"version": "2.27.110",
|
|
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",
|
|
@@ -42,6 +42,20 @@ export async function initializeCreditsTransaction(
|
|
|
42
42
|
purchaseHistory: [],
|
|
43
43
|
platform: Platform.OS as any,
|
|
44
44
|
lastUpdatedAt: now,
|
|
45
|
+
purchasedAt: now,
|
|
46
|
+
expirationDate: null,
|
|
47
|
+
lastPurchaseAt: null,
|
|
48
|
+
willRenew: false,
|
|
49
|
+
productId: null,
|
|
50
|
+
packageType: null,
|
|
51
|
+
originalTransactionId: null,
|
|
52
|
+
appVersion: null,
|
|
53
|
+
periodType: null,
|
|
54
|
+
isTrialing: false,
|
|
55
|
+
trialStartDate: null,
|
|
56
|
+
trialEndDate: null,
|
|
57
|
+
trialCredits: 0,
|
|
58
|
+
convertedFromTrial: false,
|
|
45
59
|
} as any;
|
|
46
60
|
|
|
47
61
|
if (existingData.processedPurchases.includes(purchaseId)) {
|
|
@@ -6,7 +6,14 @@ import type { UserCreditsDocumentRead } from "./UserCreditsDocument";
|
|
|
6
6
|
/** Maps Firestore document to domain entity with expiration validation */
|
|
7
7
|
export class CreditsMapper {
|
|
8
8
|
static toEntity(doc: UserCreditsDocumentRead): UserCredits {
|
|
9
|
-
const
|
|
9
|
+
const safeDate = (ts: any): Date | null => {
|
|
10
|
+
if (!ts) return null;
|
|
11
|
+
if (typeof ts.toDate === "function") return ts.toDate();
|
|
12
|
+
if (ts instanceof Date) return ts;
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const expirationDate = safeDate(doc.expirationDate);
|
|
10
17
|
const periodType = doc.periodType;
|
|
11
18
|
|
|
12
19
|
// Validate isPremium against expirationDate (real-time check)
|
|
@@ -18,10 +25,10 @@ export class CreditsMapper {
|
|
|
18
25
|
status,
|
|
19
26
|
|
|
20
27
|
// Dates
|
|
21
|
-
purchasedAt: doc.purchasedAt
|
|
28
|
+
purchasedAt: safeDate(doc.purchasedAt) ?? new Date(),
|
|
22
29
|
expirationDate,
|
|
23
|
-
lastUpdatedAt: doc.lastUpdatedAt
|
|
24
|
-
lastPurchaseAt: doc.lastPurchaseAt
|
|
30
|
+
lastUpdatedAt: safeDate(doc.lastUpdatedAt) ?? new Date(),
|
|
31
|
+
lastPurchaseAt: safeDate(doc.lastPurchaseAt),
|
|
25
32
|
|
|
26
33
|
// RevenueCat details
|
|
27
34
|
willRenew: doc.willRenew,
|
|
@@ -32,8 +39,8 @@ export class CreditsMapper {
|
|
|
32
39
|
// Trial fields
|
|
33
40
|
periodType,
|
|
34
41
|
isTrialing: doc.isTrialing,
|
|
35
|
-
trialStartDate: doc.trialStartDate
|
|
36
|
-
trialEndDate: doc.trialEndDate
|
|
42
|
+
trialStartDate: safeDate(doc.trialStartDate),
|
|
43
|
+
trialEndDate: safeDate(doc.trialEndDate),
|
|
37
44
|
trialCredits: doc.trialCredits,
|
|
38
45
|
convertedFromTrial: doc.convertedFromTrial,
|
|
39
46
|
|
|
@@ -54,7 +54,7 @@ export function detectPackageType(productIdentifier: string): SubscriptionPackag
|
|
|
54
54
|
return PACKAGE_TYPE.LIFETIME;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (__DEV__) {
|
|
57
|
+
if (__DEV__ && productIdentifier !== 'unknown_product') {
|
|
58
58
|
console.warn("[PackageTypeDetector] Unknown package type for:", productIdentifier);
|
|
59
59
|
}
|
|
60
60
|
|