@umituz/react-native-subscription 2.14.98 → 2.14.99
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 +0 -1
- package/package.json +1 -1
- package/src/domains/README.md +240 -0
- package/src/domains/config/domain/README.md +390 -0
- package/src/domains/config/domain/entities/README.md +350 -0
- package/src/presentation/hooks/useDeductCredit.md +146 -130
- package/src/revenuecat/application/README.md +158 -0
- package/src/revenuecat/application/ports/README.md +169 -0
- package/src/revenuecat/domain/constants/README.md +183 -0
- package/src/revenuecat/domain/entities/README.md +382 -0
- package/src/revenuecat/domain/types/README.md +373 -0
- package/src/revenuecat/domain/value-objects/README.md +441 -0
- package/src/revenuecat/infrastructure/README.md +50 -0
- package/src/revenuecat/infrastructure/handlers/README.md +218 -0
- package/src/revenuecat/infrastructure/services/README.md +325 -0
- package/src/revenuecat/infrastructure/utils/README.md +382 -0
- package/src/revenuecat/presentation/README.md +184 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# RevenueCat Domain Entities
|
|
2
|
+
|
|
3
|
+
Core domain entities for RevenueCat integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This directory contains TypeScript type definitions and entities representing RevenueCat concepts like customer info, entitlements, offerings, and packages.
|
|
8
|
+
|
|
9
|
+
## Entities
|
|
10
|
+
|
|
11
|
+
### CustomerInfo
|
|
12
|
+
|
|
13
|
+
Represents the subscriber's current information and entitlements.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
interface CustomerInfo {
|
|
17
|
+
// Subscriber Information
|
|
18
|
+
originalAppUserId: string;
|
|
19
|
+
originalApplicationVersion: string | null;
|
|
20
|
+
requestDate: Date;
|
|
21
|
+
allExpirationDates: Record<string, Date | null>;
|
|
22
|
+
allPurchaseDates: Record<string, Date | null>;
|
|
23
|
+
originalPurchaseDates: Record<string, Date | null>;
|
|
24
|
+
|
|
25
|
+
// Entitlements
|
|
26
|
+
entitlements: EntitlementInfos;
|
|
27
|
+
|
|
28
|
+
// Active Subscriptions
|
|
29
|
+
activeSubscriptions: string[];
|
|
30
|
+
|
|
31
|
+
// All Purchases
|
|
32
|
+
allPurchasedProductIds: string[];
|
|
33
|
+
|
|
34
|
+
// Latest Purchase
|
|
35
|
+
latestExpirationDate: Date | null;
|
|
36
|
+
firstSeen: Date;
|
|
37
|
+
managementURL: string | null;
|
|
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
|
+
|
|
379
|
+
- [RevenueCat Domain](../README.md)
|
|
380
|
+
- [RevenueCat Value Objects](../value-objects/README.md)
|
|
381
|
+
- [RevenueCat Errors](../errors/README.md)
|
|
382
|
+
- [RevenueCat Types](../types/README.md)
|