@umituz/react-native-subscription 2.15.7 → 2.16.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.
|
|
3
|
+
"version": "2.16.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",
|
|
@@ -1,49 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Expiration Date Calculator
|
|
3
|
-
*
|
|
3
|
+
* Returns RevenueCat expiration date directly
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Best Practice: Trust RevenueCat's expiration date
|
|
6
|
+
* RevenueCat handles all subscription logic server-side
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { RevenueCatEntitlement } from '../../domain/types/RevenueCatTypes';
|
|
10
|
-
import { detectPackageType } from '../../../utils/packageTypeDetector';
|
|
11
|
-
import { addProductionPeriod } from './SandboxDurationConverter';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Check if two dates are on the same day
|
|
15
|
-
*/
|
|
16
|
-
function isSameDay(date1: Date, date2: Date): boolean {
|
|
17
|
-
return (
|
|
18
|
-
date1.getFullYear() === date2.getFullYear() &&
|
|
19
|
-
date1.getMonth() === date2.getMonth() &&
|
|
20
|
-
date1.getDate() === date2.getDate()
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
10
|
|
|
24
11
|
/**
|
|
25
12
|
* Get expiration date from entitlement
|
|
26
|
-
*
|
|
27
|
-
* Handles edge case: If expiration date equals purchase date (same day),
|
|
28
|
-
* calculates correct expiration by adding subscription period.
|
|
13
|
+
* Returns RevenueCat's expiration date directly without modification
|
|
29
14
|
*/
|
|
30
15
|
export function getExpirationDate(
|
|
31
16
|
entitlement: RevenueCatEntitlement | null
|
|
32
17
|
): string | null {
|
|
33
|
-
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const expDate = new Date(entitlement.expirationDate);
|
|
38
|
-
const purchaseDate = entitlement.latestPurchaseDate
|
|
39
|
-
? new Date(entitlement.latestPurchaseDate)
|
|
40
|
-
: null;
|
|
41
|
-
|
|
42
|
-
// Only adjust if expiration equals purchase date (same day bug)
|
|
43
|
-
if (purchaseDate && isSameDay(expDate, purchaseDate)) {
|
|
44
|
-
const packageType = detectPackageType(entitlement.productIdentifier);
|
|
45
|
-
return addProductionPeriod(purchaseDate, packageType).toISOString();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return entitlement.expirationDate;
|
|
18
|
+
return entitlement?.expirationDate ?? null;
|
|
49
19
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscription Duration Configuration
|
|
3
|
-
* Production subscription durations by package type
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { SubscriptionPackageType } from '../../../utils/packageTypeDetector';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Subscription durations in days
|
|
10
|
-
*/
|
|
11
|
-
export const SUBSCRIPTION_DURATIONS: Record<SubscriptionPackageType, number> = {
|
|
12
|
-
weekly: 7,
|
|
13
|
-
monthly: 30,
|
|
14
|
-
yearly: 365,
|
|
15
|
-
unknown: 30,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get subscription duration in days for a package type
|
|
20
|
-
*/
|
|
21
|
-
export function getProductionDurationDays(packageType: SubscriptionPackageType): number {
|
|
22
|
-
return SUBSCRIPTION_DURATIONS[packageType] ?? SUBSCRIPTION_DURATIONS.unknown;
|
|
23
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscription Duration Utilities
|
|
3
|
-
* Calculates subscription period based on package type
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { SubscriptionPackageType } from '../../../utils/packageTypeDetector';
|
|
7
|
-
import { getProductionDurationDays } from '../config/SandboxDurationConfig';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Add subscription period to a date based on package type
|
|
11
|
-
*/
|
|
12
|
-
export function addProductionPeriod(
|
|
13
|
-
date: Date,
|
|
14
|
-
packageType: SubscriptionPackageType
|
|
15
|
-
): Date {
|
|
16
|
-
const newDate = new Date(date);
|
|
17
|
-
const daysToAdd = getProductionDurationDays(packageType);
|
|
18
|
-
newDate.setDate(newDate.getDate() + daysToAdd);
|
|
19
|
-
return newDate;
|
|
20
|
-
}
|