@umituz/react-native-subscription 2.14.98 → 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.
Files changed (92) hide show
  1. package/README.md +211 -395
  2. package/package.json +1 -1
  3. package/src/application/README.md +46 -225
  4. package/src/application/ports/README.md +42 -97
  5. package/src/domain/README.md +36 -384
  6. package/src/domain/constants/README.md +0 -56
  7. package/src/domain/entities/README.md +43 -169
  8. package/src/domain/errors/README.md +33 -287
  9. package/src/domain/value-objects/README.md +43 -179
  10. package/src/domains/README.md +52 -0
  11. package/src/domains/README.md.bak +274 -0
  12. package/src/domains/config/README.md +93 -383
  13. package/src/domains/config/domain/README.md +37 -0
  14. package/src/domains/config/domain/entities/README.md +41 -0
  15. package/src/domains/paywall/README.md +99 -369
  16. package/src/domains/paywall/components/README.md +34 -178
  17. package/src/domains/paywall/entities/README.md +34 -193
  18. package/src/domains/paywall/hooks/README.md +34 -122
  19. package/src/domains/wallet/README.md +34 -275
  20. package/src/domains/wallet/README.md.bak +209 -0
  21. package/src/domains/wallet/domain/README.md +34 -101
  22. package/src/domains/wallet/domain/entities/README.md +34 -115
  23. package/src/domains/wallet/domain/errors/README.md +34 -151
  24. package/src/domains/wallet/infrastructure/README.md +34 -89
  25. package/src/domains/wallet/presentation/components/README.md +34 -224
  26. package/src/domains/wallet/presentation/hooks/README.md +34 -248
  27. package/src/infrastructure/README.md +37 -496
  28. package/src/infrastructure/mappers/README.md +0 -13
  29. package/src/infrastructure/repositories/README.md +74 -360
  30. package/src/infrastructure/services/README.md +95 -370
  31. package/src/presentation/README.md +123 -408
  32. package/src/presentation/README.md.bak +172 -0
  33. package/src/presentation/components/README.md +151 -179
  34. package/src/presentation/components/README.md.bak +217 -0
  35. package/src/presentation/components/details/CreditRow.md +65 -310
  36. package/src/presentation/components/details/DetailRow.md +63 -255
  37. package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
  38. package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
  39. package/src/presentation/components/details/README.md +97 -447
  40. package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
  41. package/src/presentation/components/feedback/README.md +97 -445
  42. package/src/presentation/components/paywall/PaywallModal.md +66 -416
  43. package/src/presentation/components/paywall/README.md +50 -186
  44. package/src/presentation/components/sections/README.md +97 -466
  45. package/src/presentation/components/sections/SubscriptionSection.md +92 -244
  46. package/src/presentation/hooks/README.md +154 -741
  47. package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
  48. package/src/presentation/hooks/useAuthGate.md +61 -375
  49. package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
  50. package/src/presentation/hooks/useCreditChecker.md +73 -378
  51. package/src/presentation/hooks/useCredits.md +74 -313
  52. package/src/presentation/hooks/useCredits.md.bak +231 -0
  53. package/src/presentation/hooks/useCreditsGate.md +66 -318
  54. package/src/presentation/hooks/useDeductCredit.md +96 -156
  55. package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
  56. package/src/presentation/hooks/useFeatureGate.md +105 -150
  57. package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
  58. package/src/presentation/hooks/useInitializeCredits.md +64 -430
  59. package/src/presentation/hooks/usePaywall.md +61 -306
  60. package/src/presentation/hooks/usePaywallOperations.md +64 -458
  61. package/src/presentation/hooks/usePaywallVisibility.md +67 -316
  62. package/src/presentation/hooks/usePremium.md +84 -226
  63. package/src/presentation/hooks/usePremiumGate.md +60 -395
  64. package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
  65. package/src/presentation/hooks/useSubscription.md +66 -422
  66. package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
  67. package/src/presentation/hooks/useSubscriptionGate.md +80 -164
  68. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
  69. package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
  70. package/src/presentation/hooks/useUserTier.md +63 -328
  71. package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
  72. package/src/presentation/screens/README.md +48 -190
  73. package/src/presentation/types/README.md +0 -16
  74. package/src/presentation/utils/README.md +0 -21
  75. package/src/revenuecat/README.md +99 -518
  76. package/src/revenuecat/application/README.md +43 -0
  77. package/src/revenuecat/application/ports/README.md +41 -0
  78. package/src/revenuecat/domain/README.md +42 -141
  79. package/src/revenuecat/domain/constants/README.md +41 -0
  80. package/src/revenuecat/domain/entities/README.md +42 -0
  81. package/src/revenuecat/domain/errors/README.md +47 -191
  82. package/src/revenuecat/domain/types/README.md +41 -0
  83. package/src/revenuecat/domain/value-objects/README.md +41 -0
  84. package/src/revenuecat/infrastructure/README.md +41 -0
  85. package/src/revenuecat/infrastructure/config/README.md +32 -23
  86. package/src/revenuecat/infrastructure/handlers/README.md +41 -0
  87. package/src/revenuecat/infrastructure/managers/README.md +34 -42
  88. package/src/revenuecat/infrastructure/services/README.md +42 -0
  89. package/src/revenuecat/infrastructure/utils/README.md +41 -0
  90. package/src/revenuecat/presentation/README.md +42 -0
  91. package/src/revenuecat/presentation/hooks/README.md +29 -35
  92. package/src/utils/README.md +38 -525
package/README.md CHANGED
@@ -2,461 +2,277 @@
2
2
 
3
3
  Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps.
4
4
 
5
- ## Features
6
-
7
- - 🚀 **RevenueCat Integration** - Full RevenueCat SDK integration with auto-initialization
8
- - 💳 **Subscription Management** - Handle monthly, annual, and lifetime subscriptions
9
- - 💰 **Credits System** - Built-in credits system with transaction tracking
10
- - 🎨 **Paywall Components** - Beautiful, customizable paywall UI components
11
- - 🔐 **Gate System** - Premium, auth, and credit gates for feature access control
12
- - 🌍 **Multi-language Support** - Built-in i18n support
13
- - 📊 **Analytics Ready** - Track subscription events and user behavior
14
- - 🏗️ **DDD Architecture** - Domain-driven design with clean architecture
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install @umituz/react-native-subscription
20
- # or
21
- yarn add @umituz/react-native-subscription
22
- ```
5
+ ## Package Overview
23
6
 
24
- ## Peer Dependencies
25
-
26
- ```json
27
- {
28
- "@tanstack/react-query": ">=5.0.0",
29
- "expo-constants": ">=16.0.0",
30
- "expo-image": ">=2.0.0",
31
- "expo-linear-gradient": ">=14.0.0",
32
- "firebase": ">=10.0.0",
33
- "react": ">=18.2.0",
34
- "react-native": ">=0.74.0",
35
- "react-native-purchases": ">=7.0.0",
36
- "react-native-safe-area-context": ">=5.0.0"
37
- }
38
- ```
7
+ **Import Path**: `@umituz/react-native-subscription`
39
8
 
40
- ## Quick Start
9
+ **Version**: Latest
41
10
 
42
- ### 1. Initialize Subscription
11
+ **Type**: React Native Package
43
12
 
44
- ```typescript
45
- import { initializeSubscription, SubscriptionProvider } from '@umituz/react-native-subscription';
46
-
47
- // Wrap your app with provider
48
- function App() {
49
- return (
50
- <SubscriptionProvider
51
- config={{
52
- revenueCatApiKey: 'your_api_key',
53
- revenueCatEntitlementId: 'premium',
54
- }}
55
- >
56
- <YourApp />
57
- </SubscriptionProvider>
58
- );
59
- }
13
+ This package provides comprehensive subscription and credit management with:
14
+ - RevenueCat integration for subscriptions
15
+ - Credits system with transaction tracking
16
+ - Paywall UI components
17
+ - Feature gating (premium, auth, credits)
18
+ - DDD architecture with clean layers
60
19
 
61
- // Or initialize manually
62
- await initializeSubscription({
63
- revenueCatApiKey: process.env.REVENUECAT_API_KEY,
64
- revenueCatEntitlementId: 'premium',
65
- });
66
- ```
20
+ ## Strategy
67
21
 
68
- ### 2. Check Subscription Status
22
+ ### Architecture Principles
69
23
 
70
- ```typescript
71
- import { usePremium } from '@umituz/react-native-subscription';
24
+ 1. **Domain-Driven Design (DDD)**
25
+ - Separate domains: Wallet, Paywall, Config
26
+ - Each domain has its own entities, rules, and boundaries
27
+ - Business logic stays in domain layer
72
28
 
73
- function PremiumFeature() {
74
- const { isPremium, isLoading } = usePremium();
29
+ 2. **Clean Architecture**
30
+ - Presentation: React hooks and components
31
+ - Application: Use cases and orchestration
32
+ - Domain: Entities and business rules
33
+ - Infrastructure: External integrations
75
34
 
76
- if (isLoading) return <ActivityIndicator />;
35
+ 3. **Separation of Concerns**
36
+ - UI components are pure and reusable
37
+ - Business logic is in hooks and services
38
+ - Data persistence is abstracted behind repositories
77
39
 
78
- if (!isPremium) {
79
- return <UpgradePrompt />;
80
- }
40
+ ### Integration Flow
81
41
 
82
- return <PremiumContent />;
83
- }
84
- ```
42
+ 1. **Initialization**
43
+ - Configure RevenueCat with API key
44
+ - Set up Firebase for credits storage
45
+ - Initialize providers at app root
85
46
 
86
- ### 3. Show Paywall
47
+ 2. **Subscription Management**
48
+ - Check user tier and subscription status
49
+ - Gate premium features
50
+ - Handle purchase flows
87
51
 
88
- ```typescript
89
- import { PaywallModal } from '@umituz/react-native-subscription';
90
-
91
- function MyComponent() {
92
- const [isVisible, setIsVisible] = useState(false);
93
-
94
- return (
95
- <>
96
- <Button onPress={() => setIsVisible(true)} title="Upgrade" />
97
-
98
- <PaywallModal
99
- isVisible={isVisible}
100
- onClose={() => setIsVisible(false)}
101
- config={{
102
- title: 'Unlock Premium',
103
- description: 'Get unlimited access',
104
- features: [
105
- { icon: 'star', text: 'Unlimited credits' },
106
- { icon: 'zap', text: 'AI-powered tools' },
107
- ],
108
- }}
109
- />
110
- </>
111
- );
112
- }
113
- ```
52
+ 3. **Credits System**
53
+ - Initialize credits on purchase
54
+ - Deduct credits for feature usage
55
+ - Track all transactions
56
+ - Handle credit exhaustion
114
57
 
115
- ### 4. Use Credits
58
+ 4. **Paywall Display**
59
+ - Show paywall on feature gates
60
+ - Handle purchase operations
61
+ - Manage paywall visibility state
116
62
 
117
- ```typescript
118
- import { useCreditsGate } from '@umituz/react-native-subscription';
119
-
120
- function FeatureWithCredits() {
121
- const { hasCredits, consumeCredit } = useCreditsGate({
122
- creditCost: 5,
123
- featureId: 'ai_generation',
124
- });
125
-
126
- const handleAction = async () => {
127
- if (!hasCredits) {
128
- showPaywall();
129
- return;
130
- }
131
-
132
- const result = await consumeCredit();
133
- if (result.success) {
134
- await performAction();
135
- }
136
- };
137
-
138
- return <Button onPress={handleAction} title="Use Feature (5 credits)" />;
139
- }
140
- ```
63
+ ### Key Dependencies
141
64
 
142
- ## Documentation
65
+ - **RevenueCat**: `react-native-purchases` >= 7.0.0
66
+ - **Firebase**: `firebase` >= 10.0.0
67
+ - **State Management**: `@tanstack/react-query` >= 5.0.0
68
+ - **React Native**: `react-native` >= 0.74.0
143
69
 
144
- ### Domain Architecture
70
+ ## Restrictions
145
71
 
146
- The package follows Domain-Driven Design (DDD) principles:
72
+ ### REQUIRED
147
73
 
148
- - **[Wallet Domain](./src/domains/wallet/README.md)** - Credits, transactions, and wallet management
149
- - **[Paywall Domain](./src/domains/paywall/README.md)** - Paywall components and flows
150
- - **[Config Domain](./src/domains/config/README.md)** - Plan configuration and metadata
74
+ - **RevenueCat Configuration**: MUST provide valid API key and entitlement ID
75
+ - **Firebase Setup**: MUST initialize Firebase for credits system
76
+ - **Provider Setup**: MUST wrap app with `SubscriptionProvider`
77
+ - **Authentication**: MUST have authenticated user for credits operations
78
+ - **Error Handling**: MUST handle all error states appropriately
151
79
 
152
- ### Layer Architecture
80
+ ### PROHIBITED
153
81
 
154
- - **[Application Layer](./src/application/README.md)** - Service contracts and ports
155
- - **[Domain Layer](./src/domain/README.md)** - Entities, value objects, and domain logic
156
- - **[Infrastructure Layer](./src/infrastructure/README.md)** - Repository implementations
157
- - **[Presentation Layer](./src/presentation/README.md)** - React hooks and UI components
82
+ - **NEVER** use subscription hooks outside provider
83
+ - **NEVER** deduce credits without checking balance first
84
+ - **NEVER** gate features without proper user feedback
85
+ - **DO NOT** bypass gate hooks for premium features
86
+ - **DO NOT** initialize RevenueCat multiple times
158
87
 
159
- ### Key Features
88
+ ### CRITICAL SAFETY
160
89
 
161
- - **[RevenueCat Integration](./src/revenuecat/README.md)** - RevenueCat SDK wrapper
162
- - **[Subscription Hooks](./src/presentation/hooks/README.md)** - React hooks for subscription management
163
- - **[Premium Components](./src/presentation/components/details/README.md)** - Premium UI components
164
- - **[Utils](./src/utils/README.md)** - Helper functions for subscriptions and credits
90
+ - **ALWAYS** check loading states before rendering
91
+ - **ALWAYS** handle edge cases (no subscription, expired, etc)
92
+ - **ALWAYS** validate return values from credit operations
93
+ - **NEVER** assume user has premium or credits
94
+ - **MUST** implement proper error boundaries
165
95
 
166
- ## API Reference
96
+ ## Rules
167
97
 
168
- ### Hooks
98
+ ### Provider Setup
169
99
 
170
100
  ```typescript
171
- // Subscription
172
- import {
173
- useSubscription,
174
- useSubscriptionStatus,
175
- usePremium,
176
- usePremiumGate,
177
- } from '@umituz/react-native-subscription';
178
-
179
- // Credits
180
- import {
181
- useCredits,
182
- useCreditsGate,
183
- useDeductCredit,
184
- } from '@umituz/react-native-subscription';
185
-
186
- // Paywall
187
- import {
188
- usePaywall,
189
- usePaywallActions,
190
- usePaywallVisibility,
191
- } from '@umituz/react-native-subscription';
192
-
193
- // User Tier
194
- import {
195
- useUserTier,
196
- useAuthGate,
197
- useFeatureGate,
198
- } from '@umituz/react-native-subscription';
101
+ // CORRECT - Wrap app with provider
102
+ <SubscriptionProvider config={{ revenueCatApiKey: 'xxx' }}>
103
+ <App />
104
+ </SubscriptionProvider>
105
+
106
+ // INCORRECT - No provider
107
+ <App /> // Hooks will fail
108
+
109
+ // INCORRECT - Multiple providers
110
+ <SubscriptionProvider>
111
+ <SubscriptionProvider> // Duplicate
112
+ <App />
113
+ </SubscriptionProvider>
114
+ </SubscriptionProvider>
199
115
  ```
200
116
 
201
- ### Components
117
+ ### Feature Gating
202
118
 
203
119
  ```typescript
204
- import {
205
- // Premium components
206
- PremiumDetailsCard,
207
- PremiumStatusBadge,
208
- DetailRow,
209
- CreditRow,
210
-
211
- // Paywall components
212
- PaywallModal,
213
- PaywallScreen,
214
- SubscriptionSection,
215
-
216
- // Feedback
217
- PaywallFeedbackModal,
218
- } from '@umituz/react-native-subscription';
219
- ```
220
-
221
- ### Services
120
+ // CORRECT - Use gate hooks
121
+ const { canAccess, showPaywall } = usePremiumGate();
122
+ if (!canAccess) {
123
+ showPaywall();
124
+ return;
125
+ }
222
126
 
223
- ```typescript
224
- import {
225
- // Initialization
226
- initializeSubscription,
227
- SubscriptionService,
228
-
229
- // Credits
230
- configureCreditsRepository,
231
- getCreditsRepository,
232
-
233
- // RevenueCat
234
- useRevenueCat,
235
- useCustomerInfo,
236
- useRestorePurchase,
237
- } from '@umituz/react-native-subscription';
127
+ // INCORRECT - Manual check
128
+ if (!user.isPremium) { // No feedback, no paywall
129
+ return;
130
+ }
238
131
  ```
239
132
 
240
- ## Examples
241
-
242
- ### Complete Premium Feature Example
133
+ ### Credit Operations
243
134
 
244
135
  ```typescript
245
- import React from 'react';
246
- import { View, Text, Button, ActivityIndicator } from 'react-native';
247
- import {
248
- usePremiumGate,
249
- useCreditsGate,
250
- useUserTier,
251
- PaywallModal,
252
- } from '@umituz/react-native-subscription';
253
-
254
- function PremiumFeature() {
255
- const { tier, isPremium } = useUserTier();
256
- const { canAccess, showPaywall } = usePremiumGate({
257
- featureId: 'ai_tools',
258
- });
259
-
260
- const { hasCredits, credits, consumeCredit } = useCreditsGate({
261
- creditCost: 5,
262
- featureId: 'ai_generation',
263
- });
264
-
265
- const handleGenerate = async () => {
266
- if (!canAccess) {
267
- showPaywall();
268
- return;
269
- }
270
-
271
- if (isPremium) {
272
- // Premium: unlimited access
273
- await generateContent();
274
- } else if (hasCredits) {
275
- // Free: use credits
276
- const result = await consumeCredit();
277
- if (result.success) {
278
- await generateContent();
279
- }
280
- } else {
281
- // No access: show upgrade
282
- showPaywall();
283
- }
284
- };
285
-
286
- return (
287
- <View>
288
- <Text>Tier: {tier}</Text>
289
- {!isPremium && <Text>Credits: {credits}</Text>}
290
-
291
- <Button
292
- onPress={handleGenerate}
293
- title={
294
- isPremium
295
- ? 'Generate (Unlimited)'
296
- : 'Generate (5 credits)'
297
- }
298
- />
299
- </View>
300
- );
136
+ // CORRECT - Check return value
137
+ const success = await deductCredit(5);
138
+ if (success) {
139
+ executeFeature();
301
140
  }
141
+
142
+ // INCORRECT - Assume success
143
+ await deductCredit(5);
144
+ executeFeature(); // May execute if deduction failed
302
145
  ```
303
146
 
304
- ### Complete Settings Screen Example
147
+ ### Loading States
305
148
 
306
149
  ```typescript
307
- import React from 'react';
308
- import { ScrollView, RefreshControl } from 'react-native';
309
- import {
310
- PremiumDetailsCard,
311
- SubscriptionSection,
312
- useSubscription,
313
- } from '@umituz/react-native-subscription';
314
-
315
- function SettingsScreen() {
316
- const { subscription, isLoading, refetch } = useSubscription();
317
- const [refreshing, setRefreshing] = React.useState(false);
318
-
319
- const handleRefresh = async () => {
320
- setRefreshing(true);
321
- await refetch();
322
- setRefreshing(false);
323
- };
324
-
325
- return (
326
- <ScrollView
327
- refreshControl={
328
- <RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
329
- }
330
- >
331
- <SubscriptionSection
332
- subscription={subscription}
333
- onPress={() => navigation.navigate('SubscriptionDetail')}
334
- />
335
-
336
- {subscription?.isPremium && (
337
- <PremiumDetailsCard
338
- status={subscription}
339
- onManagePress={handleManageSubscription}
340
- />
341
- )}
342
- </ScrollView>
343
- );
344
- }
150
+ // CORRECT - Respect loading
151
+ if (isLoading) return <Spinner />;
152
+ if (!isPremium) return <UpgradePrompt />;
153
+ return <Content />;
154
+
155
+ // INCORRECT - Ignore loading
156
+ {!isPremium && <UpgradePrompt />} // Flickers during load
345
157
  ```
346
158
 
347
- ## Configuration
159
+ ## AI Agent Guidelines
348
160
 
349
- ### Subscription Config
161
+ ### When Implementing Features
350
162
 
351
- ```typescript
352
- import type { SubscriptionConfig } from '@umituz/react-native-subscription';
353
-
354
- const config: SubscriptionConfig = {
355
- revenueCatApiKey: 'your_api_key',
356
- revenueCatEntitlementId: 'premium',
357
-
358
- plans: {
359
- monthly: monthlyPlan,
360
- annual: annualPlan,
361
- lifetime: lifetimePlan,
362
- },
363
-
364
- defaultPlan: 'monthly',
365
-
366
- features: {
367
- requireAuth: true,
368
- allowRestore: true,
369
- syncWithFirebase: true,
370
- },
371
-
372
- ui: {
373
- showAnnualDiscount: true,
374
- highlightPopularPlan: true,
375
- showPerks: true,
376
- },
377
- };
378
- ```
163
+ 1. **Always** use appropriate gate hooks for feature access
164
+ 2. **Always** handle loading, error, and empty states
165
+ 3. **Always** provide user feedback for blocked features
166
+ 4. **Always** check return values from operations
167
+ 5. **Never** bypass gate system or checks
168
+ 6. **Must** test with different user tiers
169
+ 7. **Must** handle network errors gracefully
379
170
 
380
- ### Credits Config
171
+ ### Implementation Checklist
381
172
 
382
- ```typescript
383
- import type { CreditsConfig } from '@umituz/react-native-subscription';
384
-
385
- const creditsConfig: CreditsConfig = {
386
- initialCredits: 100,
387
-
388
- creditPackages: [
389
- {
390
- id: 'credits_small',
391
- productId: 'com.app.credits.small',
392
- amount: 100,
393
- price: 0.99,
394
- currency: 'USD',
395
- },
396
- {
397
- id: 'credits_medium',
398
- productId: 'com.app.credits.medium',
399
- amount: 500,
400
- price: 3.99,
401
- currency: 'USD',
402
- },
403
- ],
404
-
405
- creditCosts: {
406
- ai_generation: 1,
407
- ai_analysis: 2,
408
- premium_feature: 5,
409
- },
410
- };
411
- ```
173
+ - [ ] Import from correct path
174
+ - [ ] Wrap with necessary providers
175
+ - [ ] Use gate hooks for features
176
+ - [ ] Handle loading states
177
+ - [ ] Handle error states
178
+ - [ ] Provide user feedback
179
+ - [ ] Test with guest user
180
+ - [ ] Test with free user
181
+ - [ ] Test with premium user
182
+ - [ ] Test with no credits
183
+ - [ ] Test with insufficient credits
412
184
 
413
- ## Architecture
185
+ ### Common Patterns
414
186
 
415
- The package follows Clean Architecture and Domain-Driven Design principles:
187
+ 1. **Premium Feature**: Use `usePremiumGate`
188
+ 2. **Credit Feature**: Use `useCreditsGate` or `useDeductCredit`
189
+ 3. **Auth Feature**: Use `useAuthGate`
190
+ 4. **Combined Gates**: Use `useFeatureGate` for complex scenarios
191
+ 5. **Paywall Trigger**: Use `usePaywallVisibility` for global state
416
192
 
417
- ```
418
- ┌─────────────────────────────────────────┐
419
- │ Presentation Layer │
420
- │ (React Hooks & Components) │
421
- ├─────────────────────────────────────────┤
422
- │ Application Layer │
423
- │ (Use Cases & Service Contracts) │
424
- ├─────────────────────────────────────────┤
425
- │ Domain Layer │
426
- │ (Entities & Business Logic) │
427
- ├─────────────────────────────────────────┤
428
- │ Infrastructure Layer │
429
- │ (External Services & Repositories) │
430
- └─────────────────────────────────────────┘
431
- ```
193
+ ### Error Scenarios to Handle
432
194
 
433
- ## Best Practices
195
+ - **No Subscription**: Show upgrade prompt
196
+ - **Expired Subscription**: Show renewal prompt
197
+ - **No Credits**: Show credit purchase prompt
198
+ - **Insufficient Credits**: Show credit cost and purchase option
199
+ - **Network Error**: Show retry option
200
+ - **Purchase Failed**: Show error message and retry
434
201
 
435
- 1. **Always check loading states** before rendering subscription-dependent UI
436
- 2. **Use gate hooks** (`usePremiumGate`, `useCreditsGate`) for feature access control
437
- 3. **Handle errors gracefully** and show user-friendly messages
438
- 4. **Provide restore purchase** option for iOS and Android
439
- 5. **Track subscription events** with analytics
440
- 6. **Use translations** for multi-language support
441
- 7. **Test different subscription states** (guest, free, premium, expired)
202
+ ## Documentation Structure
442
203
 
443
- ## Contributing
204
+ ### Domain Documentation
444
205
 
445
- Contributions are welcome! Please feel free to submit a Pull Request.
206
+ - **[Wallet Domain](./src/domains/wallet/README.md)**: Credits and transactions
207
+ - **[Paywall Domain](./src/domains/paywall/README.md)**: Paywall components
208
+ - **[Config Domain](./src/domains/config/README.md)**: Configuration management
446
209
 
447
- ## License
210
+ ### Layer Documentation
448
211
 
449
- MIT License - see LICENSE file for details
212
+ - **[Presentation Layer](./src/presentation/README.md)**: Hooks and components
213
+ - **[Application Layer](./src/application/README.md)**: Use cases and ports
214
+ - **[Domain Layer](./src/domain/README.md)**: Entities and logic
215
+ - **[Infrastructure Layer](./src/infrastructure/README.md)**: Repositories and services
216
+
217
+ ### Feature Documentation
218
+
219
+ - **[RevenueCat Integration](./src/revenuecat/README.md)**: RevenueCat setup
220
+ - **[Subscription Hooks](./src/presentation/hooks/README.md)**: Available hooks
221
+ - **[Premium Components](./src/presentation/components/README.md)**: UI components
222
+
223
+ ### Quick Reference
224
+
225
+ #### Subscription Hooks
226
+
227
+ Location: `src/presentation/hooks/`
228
+
229
+ - `useSubscription` - Core subscription management
230
+ - `usePremium` - Check premium status
231
+ - `usePremiumGate` - Gate premium features
232
+ - `useUserTier` - Get user tier (guest/free/premium)
450
233
 
451
- ## Author
234
+ #### Credit Hooks
452
235
 
453
- Ümit UZ <umit@umituz.com>
236
+ Location: `src/presentation/hooks/`
454
237
 
455
- ## Links
238
+ - `useCredits` - Access credit balance
239
+ - `useDeductCredit` - Deduct credits with optimistic updates
240
+ - `useCreditChecker` - Check credit availability
241
+ - `useCreditsGate` - Gate features by credits
456
242
 
457
- - [GitHub](https://github.com/umituz/react-native-subscription)
458
- - [NPM](https://www.npmjs.com/package/@umituz/react-native-subscription)
243
+ #### Paywall Hooks
244
+
245
+ Location: `src/presentation/hooks/`
246
+
247
+ - `usePaywallVisibility` - Manage paywall state
248
+ - `usePaywallOperations` - Handle purchase operations
249
+
250
+ #### Components
251
+
252
+ Location: `src/presentation/components/`
253
+
254
+ - `PremiumDetailsCard` - Display subscription details
255
+ - `PremiumStatusBadge` - Show subscription badge
256
+ - `PaywallModal` - Full paywall modal
257
+ - `CreditRow` - Display credit balance with progress
258
+
259
+ ## Contributing
260
+
261
+ When contributing to this package:
262
+
263
+ 1. **Follow Documentation Template**: Use `README_TEMPLATE.md`
264
+ 2. **Update Strategy Section**: Document architectural decisions
265
+ 3. **List Restrictions**: Clearly state what's required/prohibited
266
+ 4. **Provide Rules**: Show correct/incorrect usage
267
+ 5. **AI Guidelines**: Include agent instructions
268
+ 6. **No Code Examples**: Keep documentation code-agnostic
269
+ 7. **English Only**: All documentation in English
459
270
 
460
271
  ## Support
461
272
 
462
- For issues and questions, please use the [GitHub Issues](https://github.com/umituz/react-native-subscription/issues).
273
+ - **Issues**: [GitHub Issues](https://github.com/umituz/react-native-subscription/issues)
274
+ - **Author**: Ümit UZ <umit@umituz.com>
275
+
276
+ ## License
277
+
278
+ MIT License - see LICENSE file for details
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.14.98",
3
+ "version": "2.14.100",
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",