@umituz/react-native-subscription 2.14.99 → 2.14.100
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/README.md +211 -394
- package/package.json +1 -1
- package/src/application/README.md +46 -225
- package/src/application/ports/README.md +42 -97
- package/src/domain/README.md +36 -384
- package/src/domain/constants/README.md +0 -56
- package/src/domain/entities/README.md +43 -169
- package/src/domain/errors/README.md +33 -287
- package/src/domain/value-objects/README.md +43 -179
- package/src/domains/README.md +50 -238
- package/src/domains/README.md.bak +274 -0
- package/src/domains/config/README.md +93 -383
- package/src/domains/config/domain/README.md +23 -376
- package/src/domains/config/domain/entities/README.md +34 -343
- package/src/domains/paywall/README.md +99 -369
- package/src/domains/paywall/components/README.md +34 -178
- package/src/domains/paywall/entities/README.md +34 -193
- package/src/domains/paywall/hooks/README.md +34 -122
- package/src/domains/wallet/README.md +34 -275
- package/src/domains/wallet/README.md.bak +209 -0
- package/src/domains/wallet/domain/README.md +34 -101
- package/src/domains/wallet/domain/entities/README.md +34 -115
- package/src/domains/wallet/domain/errors/README.md +34 -151
- package/src/domains/wallet/infrastructure/README.md +34 -89
- package/src/domains/wallet/presentation/components/README.md +34 -224
- package/src/domains/wallet/presentation/hooks/README.md +34 -248
- package/src/infrastructure/README.md +37 -496
- package/src/infrastructure/mappers/README.md +0 -13
- package/src/infrastructure/repositories/README.md +74 -360
- package/src/infrastructure/services/README.md +95 -370
- package/src/presentation/README.md +123 -408
- package/src/presentation/README.md.bak +172 -0
- package/src/presentation/components/README.md +151 -179
- package/src/presentation/components/README.md.bak +217 -0
- package/src/presentation/components/details/CreditRow.md +65 -310
- package/src/presentation/components/details/DetailRow.md +63 -255
- package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
- package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
- package/src/presentation/components/details/README.md +97 -447
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
- package/src/presentation/components/feedback/README.md +97 -445
- package/src/presentation/components/paywall/PaywallModal.md +66 -416
- package/src/presentation/components/paywall/README.md +50 -186
- package/src/presentation/components/sections/README.md +97 -466
- package/src/presentation/components/sections/SubscriptionSection.md +92 -244
- package/src/presentation/hooks/README.md +154 -741
- package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
- package/src/presentation/hooks/useAuthGate.md +61 -375
- package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
- package/src/presentation/hooks/useCreditChecker.md +73 -378
- package/src/presentation/hooks/useCredits.md +74 -313
- package/src/presentation/hooks/useCredits.md.bak +231 -0
- package/src/presentation/hooks/useCreditsGate.md +66 -318
- package/src/presentation/hooks/useDeductCredit.md +0 -76
- package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
- package/src/presentation/hooks/useFeatureGate.md +105 -150
- package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
- package/src/presentation/hooks/useInitializeCredits.md +64 -430
- package/src/presentation/hooks/usePaywall.md +61 -306
- package/src/presentation/hooks/usePaywallOperations.md +64 -458
- package/src/presentation/hooks/usePaywallVisibility.md +67 -316
- package/src/presentation/hooks/usePremium.md +84 -226
- package/src/presentation/hooks/usePremiumGate.md +60 -395
- package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
- package/src/presentation/hooks/useSubscription.md +66 -422
- package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
- package/src/presentation/hooks/useSubscriptionGate.md +80 -164
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
- package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
- package/src/presentation/hooks/useUserTier.md +63 -328
- package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
- package/src/presentation/screens/README.md +48 -190
- package/src/presentation/types/README.md +0 -16
- package/src/presentation/utils/README.md +0 -21
- package/src/revenuecat/README.md +99 -518
- package/src/revenuecat/application/README.md +35 -150
- package/src/revenuecat/application/ports/README.md +34 -162
- package/src/revenuecat/domain/README.md +42 -141
- package/src/revenuecat/domain/constants/README.md +34 -176
- package/src/revenuecat/domain/entities/README.md +34 -374
- package/src/revenuecat/domain/errors/README.md +47 -191
- package/src/revenuecat/domain/types/README.md +34 -366
- package/src/revenuecat/domain/value-objects/README.md +34 -434
- package/src/revenuecat/infrastructure/README.md +34 -43
- package/src/revenuecat/infrastructure/config/README.md +32 -23
- package/src/revenuecat/infrastructure/handlers/README.md +34 -211
- package/src/revenuecat/infrastructure/managers/README.md +34 -42
- package/src/revenuecat/infrastructure/services/README.md +35 -318
- package/src/revenuecat/infrastructure/utils/README.md +34 -375
- package/src/revenuecat/presentation/README.md +34 -176
- package/src/revenuecat/presentation/hooks/README.md +29 -35
- package/src/utils/README.md +38 -525
|
@@ -1,183 +1,41 @@
|
|
|
1
1
|
# RevenueCat Domain Constants
|
|
2
2
|
|
|
3
|
+
## Location
|
|
3
4
|
Constants used throughout the RevenueCat integration.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export const PACKAGE_PERIODS = {
|
|
39
|
-
MONTHLY: 'monthly',
|
|
40
|
-
ANNUAL: 'annual',
|
|
41
|
-
LIFETIME: 'lifetime',
|
|
42
|
-
WEEKLY: 'weekly',
|
|
43
|
-
} as const;
|
|
44
|
-
|
|
45
|
-
export type PackagePeriod = typeof PACKAGE_PERIODS[keyof typeof PACKAGE_PERIODS];
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Product Categories
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
export const PRODUCT_CATEGORIES = {
|
|
52
|
-
SUBSCRIPTION: 'subscription',
|
|
53
|
-
ONE_TIME_PURCHASE: 'non_subscription',
|
|
54
|
-
CONSUMABLE: 'consumable',
|
|
55
|
-
} as const;
|
|
56
|
-
|
|
57
|
-
export type ProductCategory = typeof PRODUCT_CATEGORIES[keyof typeof PRODUCT_CATEGORIES];
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Error Codes
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
export const ERROR_CODES = {
|
|
64
|
-
// Configuration Errors
|
|
65
|
-
CONFIGURATION_ERROR: 'CONFIGURATION_ERROR',
|
|
66
|
-
API_KEY_NOT_SET: 'API_KEY_NOT_SET',
|
|
67
|
-
INVALID_API_KEY: 'INVALID_API_KEY',
|
|
68
|
-
|
|
69
|
-
// Purchase Errors
|
|
70
|
-
PURCHASE_ERROR: 'PURCHASE_ERROR',
|
|
71
|
-
PURCHASE_CANCELLED: 'PURCHASE_CANCELLED',
|
|
72
|
-
PURCHASE_INVALID: 'PURCHASE_INVALID',
|
|
73
|
-
PRODUCT_NOT_AVAILABLE: 'PRODUCT_NOT_AVAILABLE',
|
|
74
|
-
|
|
75
|
-
// Network Errors
|
|
76
|
-
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
77
|
-
CONNECTION_TIMEOUT: 'CONNECTION_TIMEOUT',
|
|
78
|
-
SERVER_ERROR: 'SERVER_ERROR',
|
|
79
|
-
|
|
80
|
-
// Customer Info Errors
|
|
81
|
-
CUSTOMER_INFO_ERROR: 'CUSTOMER_INFO_ERROR',
|
|
82
|
-
ENTITLEMENT_NOT_FOUND: 'ENTITLEMENT_NOT_FOUND',
|
|
83
|
-
OFFERING_NOT_FOUND: 'OFFERING_NOT_FOUND',
|
|
84
|
-
|
|
85
|
-
// Receipt Errors
|
|
86
|
-
RECEIPT_ERROR: 'RECEIPT_ERROR',
|
|
87
|
-
RECEIPT_INVALID: 'RECEIPT_INVALID',
|
|
88
|
-
RECEIPT_ALREADY_USED: 'RECEIPT_ALREADY_USES',
|
|
89
|
-
|
|
90
|
-
// User Errors
|
|
91
|
-
USER_NOT_AUTHENTICATED: 'USER_NOT_AUTHENTICATED',
|
|
92
|
-
USER_ID_NOT_SET: 'USER_ID_NOT_SET',
|
|
93
|
-
} as const;
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Configuration Defaults
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
export const CONFIG_DEFAULTS = {
|
|
100
|
-
// Timeout Settings
|
|
101
|
-
NETWORK_TIMEOUT_MS: 10000,
|
|
102
|
-
PURCHASE_TIMEOUT_MS: 30000,
|
|
103
|
-
|
|
104
|
-
// Retry Settings
|
|
105
|
-
MAX_RETRIES: 3,
|
|
106
|
-
RETRY_DELAY_MS: 1000,
|
|
107
|
-
|
|
108
|
-
// Cache Settings
|
|
109
|
-
CUSTOMER_INFO_CACHE_TTL_MS: 60000, // 1 minute
|
|
110
|
-
OFFERINGS_CACHE_TTL_MS: 300000, // 5 minutes
|
|
111
|
-
|
|
112
|
-
// Debug Settings
|
|
113
|
-
ENABLE_DEBUG_LOGS: __DEV__,
|
|
114
|
-
LOG_LEVEL: 'info' as const,
|
|
115
|
-
} as const;
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Entitlement Verification
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
export const ENTITLEMENT_VERIFICATION = {
|
|
122
|
-
// Verification Modes
|
|
123
|
-
MODE_STRICT: 'strict',
|
|
124
|
-
MODE_LOOSE: 'loose',
|
|
125
|
-
|
|
126
|
-
// Grace Periods (milliseconds)
|
|
127
|
-
GRACE_PERIOD_MS: 3 * 24 * 60 * 60 * 1000, // 3 days
|
|
128
|
-
REFUND_GRACE_PERIOD_MS: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
129
|
-
} as const;
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Usage Examples
|
|
133
|
-
|
|
134
|
-
### Checking Entitlements
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
import { ENTITLEMENT_IDS } from './constants';
|
|
138
|
-
|
|
139
|
-
const hasPremium = await checkEntitlement(ENTITLEMENT_IDS.PREMIUM);
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Filtering Offerings
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { OFFERING_IDS } from './constants';
|
|
146
|
-
|
|
147
|
-
const defaultOffering = offerings[OFFERING_IDS.DEFAULT];
|
|
148
|
-
const annualOffering = offerings[OFFERING_IDS.ANNUAL_OFFER];
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Handling Errors
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
import { ERROR_CODES } from './constants';
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
await purchasePackage(pkg);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
if (error.code === ERROR_CODES.PURCHASE_CANCELLED) {
|
|
160
|
-
// Handle cancellation
|
|
161
|
-
} else if (error.code === ERROR_CODES.NETWORK_ERROR) {
|
|
162
|
-
// Handle network error
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Configuration
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
import { CONFIG_DEFAULTS } from './constants';
|
|
171
|
-
|
|
172
|
-
const config = {
|
|
173
|
-
apiKey: 'your_api_key',
|
|
174
|
-
timeout: CONFIG_DEFAULTS.NETWORK_TIMEOUT_MS,
|
|
175
|
-
enableDebugLogs: CONFIG_DEFAULTS.ENABLE_DEBUG_LOGS,
|
|
176
|
-
};
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Related
|
|
180
|
-
|
|
6
|
+
## Strategy
|
|
7
|
+
This directory contains constant definitions for RevenueCat-specific values including entitlement IDs, error codes, and configuration defaults for maintainability and consistency.
|
|
8
|
+
|
|
9
|
+
## Restrictions
|
|
10
|
+
|
|
11
|
+
### REQUIRED
|
|
12
|
+
- Must use constants for all RevenueCat-specific values
|
|
13
|
+
- Must provide clear constant names
|
|
14
|
+
- Must maintain consistency across codebase
|
|
15
|
+
- Must document constant purposes
|
|
16
|
+
|
|
17
|
+
### PROHIBITED
|
|
18
|
+
- DO NOT use magic strings or numbers
|
|
19
|
+
- DO NOT duplicate constant definitions
|
|
20
|
+
- DO NOT use hardcoded values
|
|
21
|
+
- DO NOT create ambiguous constants
|
|
22
|
+
|
|
23
|
+
### CRITICAL SAFETY
|
|
24
|
+
- All RevenueCat-specific values MUST use constants
|
|
25
|
+
- Constants MUST be clearly named and documented
|
|
26
|
+
- Constant values MUST be consistent
|
|
27
|
+
- Entitlement IDs MUST match RevenueCat dashboard
|
|
28
|
+
|
|
29
|
+
## AI Agent Guidelines
|
|
30
|
+
1. Use constants for all RevenueCat-specific values
|
|
31
|
+
2. Provide clear, descriptive constant names
|
|
32
|
+
3. Maintain consistency across the codebase
|
|
33
|
+
4. Document the purpose of each constant
|
|
34
|
+
5. Organize constants by category (entitlements, offerings, errors)
|
|
35
|
+
6. Validate constants match RevenueCat dashboard configuration
|
|
36
|
+
7. Avoid magic strings and numbers throughout code
|
|
37
|
+
|
|
38
|
+
## Related Documentation
|
|
181
39
|
- [RevenueCat Domain](../README.md)
|
|
182
40
|
- [RevenueCat Errors](../errors/README.md)
|
|
183
41
|
- [RevenueCat Entities](../entities/README.md)
|
|
@@ -1,381 +1,41 @@
|
|
|
1
1
|
# RevenueCat Domain Entities
|
|
2
2
|
|
|
3
|
+
## Location
|
|
3
4
|
Core domain entities for RevenueCat integration.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### EntitlementInfos
|
|
42
|
-
|
|
43
|
-
Collection of entitlement information.
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
interface EntitlementInfos {
|
|
47
|
-
[key: string]: EntitlementInfo;
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### EntitlementInfo
|
|
52
|
-
|
|
53
|
-
Information about a specific entitlement.
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
interface EntitlementInfo {
|
|
57
|
-
// Identifier
|
|
58
|
-
identifier: string;
|
|
59
|
-
|
|
60
|
-
// Active Status
|
|
61
|
-
isActive: boolean;
|
|
62
|
-
willRenew: boolean;
|
|
63
|
-
|
|
64
|
-
// Period Type
|
|
65
|
-
periodType: 'normal' | 'trial' | 'intro';
|
|
66
|
-
|
|
67
|
-
// Product Information
|
|
68
|
-
productId: string;
|
|
69
|
-
productIdentifier: string;
|
|
70
|
-
|
|
71
|
-
// Dates
|
|
72
|
-
latestPurchaseDate: Date;
|
|
73
|
-
originalPurchaseDate: Date;
|
|
74
|
-
expirationDate: Date | null;
|
|
75
|
-
|
|
76
|
-
// Renewal Information
|
|
77
|
-
renewAt: Date | null;
|
|
78
|
-
isSandbox: boolean;
|
|
79
|
-
|
|
80
|
-
// Billing
|
|
81
|
-
billingIssueDetectedAt: Date | null;
|
|
82
|
-
|
|
83
|
-
// Cancellation
|
|
84
|
-
unsubscribeDetectedAt: Date | null;
|
|
85
|
-
|
|
86
|
-
// Store
|
|
87
|
-
store: 'app_store' | 'play_store' | 'stripe' | 'mac_app_store' | 'play_store_amazon' | 'promotional';
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Offerings
|
|
92
|
-
|
|
93
|
-
Collection of available offerings.
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
interface Offerings {
|
|
97
|
-
// All Offerings
|
|
98
|
-
all: Record<string, Offering>;
|
|
99
|
-
|
|
100
|
-
// Current Offering
|
|
101
|
-
current: Offering | null;
|
|
102
|
-
|
|
103
|
-
// Specific Offerings
|
|
104
|
-
[key: string]: Offering | null;
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Offering
|
|
109
|
-
|
|
110
|
-
A collection of packages available for purchase.
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
interface Offering {
|
|
114
|
-
// Identifier
|
|
115
|
-
identifier: string;
|
|
116
|
-
|
|
117
|
-
// Server Description
|
|
118
|
-
serverDescription: string;
|
|
119
|
-
|
|
120
|
-
// Available Packages
|
|
121
|
-
availablePackages: Package[];
|
|
122
|
-
|
|
123
|
-
// Lifetime Packages
|
|
124
|
-
lifetime: Package | null;
|
|
125
|
-
|
|
126
|
-
// Annual Packages
|
|
127
|
-
annual: Package | null;
|
|
128
|
-
|
|
129
|
-
// Monthly Packages
|
|
130
|
-
monthly: Package | null;
|
|
131
|
-
|
|
132
|
-
// Weekly Packages
|
|
133
|
-
weekly: Package | null;
|
|
134
|
-
|
|
135
|
-
// Single Purchase
|
|
136
|
-
singlePurchase: Package | null;
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Package
|
|
141
|
-
|
|
142
|
-
A purchasable product within an offering.
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
interface Package {
|
|
146
|
-
// Identifier
|
|
147
|
-
identifier: string;
|
|
148
|
-
|
|
149
|
-
// Package Type
|
|
150
|
-
packageType: PackageType;
|
|
151
|
-
|
|
152
|
-
// Product Information
|
|
153
|
-
product: Product;
|
|
154
|
-
|
|
155
|
-
// Offering
|
|
156
|
-
offeringIdentifier: string;
|
|
157
|
-
|
|
158
|
-
// Pricing
|
|
159
|
-
price: Price;
|
|
160
|
-
localizedPriceString: string;
|
|
161
|
-
|
|
162
|
-
// Metadata
|
|
163
|
-
metadata: PackageMetadata;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
type PackageType =
|
|
167
|
-
| 'monthly'
|
|
168
|
-
| 'annual'
|
|
169
|
-
| 'lifetime'
|
|
170
|
-
| 'weekly'
|
|
171
|
-
| 'single_purchase';
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Product
|
|
175
|
-
|
|
176
|
-
Details about a purchasable product.
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
interface Product {
|
|
180
|
-
// Identifier
|
|
181
|
-
identifier: string;
|
|
182
|
-
|
|
183
|
-
// Description
|
|
184
|
-
description: string;
|
|
185
|
-
|
|
186
|
-
// Title
|
|
187
|
-
title: string;
|
|
188
|
-
|
|
189
|
-
// Price
|
|
190
|
-
price: Price;
|
|
191
|
-
|
|
192
|
-
// Subscription Period
|
|
193
|
-
subscriptionPeriod: SubscriptionPeriod | null;
|
|
194
|
-
|
|
195
|
-
// Introductory Offer
|
|
196
|
-
introductoryPrice: IntroductoryOffer | null;
|
|
197
|
-
|
|
198
|
-
// Product Type
|
|
199
|
-
type: ProductType;
|
|
200
|
-
|
|
201
|
-
// Store
|
|
202
|
-
defaultOption: ProductOption;
|
|
203
|
-
|
|
204
|
-
// Options (for iOS)
|
|
205
|
-
options: ProductOption[];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
type ProductType = 'subscription' | 'non_subscription' | 'consumable';
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Price
|
|
212
|
-
|
|
213
|
-
Price information.
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
interface Price {
|
|
217
|
-
amount: number;
|
|
218
|
-
currencyCode: string;
|
|
219
|
-
formattedPrice: string;
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
### SubscriptionPeriod
|
|
224
|
-
|
|
225
|
-
Duration of a subscription period.
|
|
226
|
-
|
|
227
|
-
```typescript
|
|
228
|
-
interface SubscriptionPeriod {
|
|
229
|
-
value: number;
|
|
230
|
-
unit: 'day' | 'week' | 'month' | 'year';
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### IntroductoryOffer
|
|
235
|
-
|
|
236
|
-
Special pricing for new subscribers.
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
interface IntroductoryOffer {
|
|
240
|
-
price: Price;
|
|
241
|
-
period: SubscriptionPeriod;
|
|
242
|
-
periodNumberOfUnits: number;
|
|
243
|
-
cycles: number;
|
|
244
|
-
}
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### PurchaseResult
|
|
248
|
-
|
|
249
|
-
Result of a purchase operation.
|
|
250
|
-
|
|
251
|
-
```typescript
|
|
252
|
-
interface PurchaseResult {
|
|
253
|
-
// Customer Information
|
|
254
|
-
customerInfo: CustomerInfo;
|
|
255
|
-
|
|
256
|
-
// Transaction
|
|
257
|
-
transaction: Transaction | null;
|
|
258
|
-
|
|
259
|
-
// Error (if failed)
|
|
260
|
-
error?: PurchasesError;
|
|
261
|
-
|
|
262
|
-
// Whether it was a renewal
|
|
263
|
-
isRenewal: boolean;
|
|
264
|
-
}
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### RestoreResult
|
|
268
|
-
|
|
269
|
-
Result of a restore purchases operation.
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
interface RestoreResult {
|
|
273
|
-
// Customer Information
|
|
274
|
-
customerInfo: CustomerInfo;
|
|
275
|
-
|
|
276
|
-
// Error (if failed)
|
|
277
|
-
error?: PurchasesError;
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Transaction
|
|
282
|
-
|
|
283
|
-
Information about a purchase transaction.
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
interface Transaction {
|
|
287
|
-
transactionIdentifier: string;
|
|
288
|
-
productIdentifier: string;
|
|
289
|
-
purchaseDate: Date;
|
|
290
|
-
transactionDate: Date;
|
|
291
|
-
revenueCatId: string;
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
## Usage Examples
|
|
296
|
-
|
|
297
|
-
### Accessing Customer Info
|
|
298
|
-
|
|
299
|
-
```typescript
|
|
300
|
-
const customerInfo: CustomerInfo = await getCustomerInfo();
|
|
301
|
-
|
|
302
|
-
// Check if user has premium
|
|
303
|
-
const premiumEntitlement = customerInfo.entitlements.premium;
|
|
304
|
-
if (premiumEntitlement?.isActive) {
|
|
305
|
-
console.log('User has premium');
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Get expiration date
|
|
309
|
-
const expirationDate = premiumEntitlement?.expirationDate;
|
|
310
|
-
console.log('Expires on:', expirationDate);
|
|
311
|
-
|
|
312
|
-
// Check active subscriptions
|
|
313
|
-
console.log('Active subscriptions:', customerInfo.activeSubscriptions);
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
### Working with Offerings
|
|
317
|
-
|
|
318
|
-
```typescript
|
|
319
|
-
const offerings: Offerings = await getOfferings();
|
|
320
|
-
|
|
321
|
-
// Get current offering
|
|
322
|
-
const current = offerings.current;
|
|
323
|
-
if (current) {
|
|
324
|
-
// Get monthly package
|
|
325
|
-
const monthly = current.monthly;
|
|
326
|
-
console.log('Monthly price:', monthly?.localizedPriceString);
|
|
327
|
-
|
|
328
|
-
// Get all packages
|
|
329
|
-
current.availablePackages.forEach(pkg => {
|
|
330
|
-
console.log(pkg.identifier, pkg.localizedPriceString);
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Handling Purchase Results
|
|
336
|
-
|
|
337
|
-
```typescript
|
|
338
|
-
const result: PurchaseResult = await purchasePackage(selectedPackage);
|
|
339
|
-
|
|
340
|
-
if (result.error) {
|
|
341
|
-
console.error('Purchase failed:', result.error.message);
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
console.log('Purchase successful!');
|
|
346
|
-
console.log('Transaction ID:', result.transaction?.transactionIdentifier);
|
|
347
|
-
|
|
348
|
-
// Check entitlement
|
|
349
|
-
if (result.customerInfo.entitlements.premium?.isActive) {
|
|
350
|
-
console.log('Premium is now active');
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### Checking Entitlement Details
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
const entitlement: EntitlementInfo = customerInfo.entitlements.premium;
|
|
358
|
-
|
|
359
|
-
if (entitlement) {
|
|
360
|
-
console.log('Active:', entitlement.isActive);
|
|
361
|
-
console.log('Will Renew:', entitlement.willRenew);
|
|
362
|
-
console.log('Period Type:', entitlement.periodType);
|
|
363
|
-
console.log('Expiration:', entitlement.expirationDate);
|
|
364
|
-
console.log('Store:', entitlement.store);
|
|
365
|
-
console.log('Is Sandbox:', entitlement.isSandbox);
|
|
366
|
-
|
|
367
|
-
if (entitlement.billingIssueDetectedAt) {
|
|
368
|
-
console.warn('Billing issue detected');
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (entitlement.unsubscribeDetectedAt) {
|
|
372
|
-
console.warn('User cancelled subscription');
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
## Related
|
|
378
|
-
|
|
6
|
+
## Strategy
|
|
7
|
+
This directory contains TypeScript type definitions and entities representing RevenueCat concepts like customer info, entitlements, offerings, and packages with proper type safety.
|
|
8
|
+
|
|
9
|
+
## Restrictions
|
|
10
|
+
|
|
11
|
+
### REQUIRED
|
|
12
|
+
- Must use TypeScript types for all entities
|
|
13
|
+
- Must maintain type safety
|
|
14
|
+
- Must validate entity data
|
|
15
|
+
- Must provide clear type definitions
|
|
16
|
+
|
|
17
|
+
### PROHIBITED
|
|
18
|
+
- DO NOT use `any` type for entities
|
|
19
|
+
- DO NOT bypass type checking
|
|
20
|
+
- DO NOT create invalid entity states
|
|
21
|
+
- DO NOT use loose type definitions
|
|
22
|
+
|
|
23
|
+
### CRITICAL SAFETY
|
|
24
|
+
- All entities MUST be type-safe
|
|
25
|
+
- Entity data MUST be validated
|
|
26
|
+
- Type definitions MUST be clear and specific
|
|
27
|
+
- Entity states MUST be valid
|
|
28
|
+
|
|
29
|
+
## AI Agent Guidelines
|
|
30
|
+
1. Define clear TypeScript types for all RevenueCat concepts
|
|
31
|
+
2. Maintain strict type safety for all entities
|
|
32
|
+
3. Validate entity data before use
|
|
33
|
+
4. Provide comprehensive type definitions
|
|
34
|
+
5. Document entity properties and relationships
|
|
35
|
+
6. Use type guards for runtime validation
|
|
36
|
+
7. Test entity creation and validation thoroughly
|
|
37
|
+
|
|
38
|
+
## Related Documentation
|
|
379
39
|
- [RevenueCat Domain](../README.md)
|
|
380
40
|
- [RevenueCat Value Objects](../value-objects/README.md)
|
|
381
41
|
- [RevenueCat Errors](../errors/README.md)
|