@umituz/react-native-subscription 2.14.99 โ 2.14.101
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 +3 -3
- 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/entities/SubscriptionStatus.ts +1 -1
- 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/components/TransactionItem.tsx +1 -1
- 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/ActivationHandler.ts +1 -1
- package/src/infrastructure/services/README.md +95 -370
- package/src/infrastructure/services/SubscriptionService.ts +1 -1
- 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/useDeductCredit.ts +1 -1
- 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/presentation/utils/subscriptionDateUtils.ts +1 -1
- 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
|
@@ -2,421 +2,90 @@
|
|
|
2
2
|
|
|
3
3
|
**Development-only** hook for testing subscription renewal and credit operations.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Location
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import { useDevTestCallbacks } from '@umituz/react-native-subscription';
|
|
9
|
-
```
|
|
7
|
+
**Import Path**: `@umituz/react-native-subscription`
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
**File**: `src/presentation/hooks/useDevTestCallbacks.ts`
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
function useDevTestCallbacks(): {
|
|
15
|
-
onTestRenewal: () => void;
|
|
16
|
-
onCheckCredits: () => void;
|
|
17
|
-
onTestDuplicate: () => void;
|
|
18
|
-
} | undefined
|
|
19
|
-
```
|
|
11
|
+
**Type**: Hook
|
|
20
12
|
|
|
21
|
-
##
|
|
13
|
+
## Strategy
|
|
22
14
|
|
|
23
|
-
|
|
15
|
+
### Development Testing Utilities
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
1. **Renewal Simulation**: Simulate subscription renewal with credit allocation
|
|
18
|
+
2. **Credits Inspection**: Display current credit balance and purchase date
|
|
19
|
+
3. **Duplicate Protection Testing**: Test that duplicate renewals are prevented
|
|
20
|
+
4. **Development Mode Guard**: Only available in `__DEV__` mode
|
|
21
|
+
5. **Production Safety**: Returns `undefined` in production builds
|
|
22
|
+
6. **Alert-Based Feedback**: Show test results in alert dialogs
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
### Integration Points
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
26
|
+
- **useInitializeCredits**: For credit initialization testing
|
|
27
|
+
- **Credits Repository**: `src/domains/wallet/infrastructure/repositories/CreditsRepository.ts`
|
|
28
|
+
- **Development Tools**: For testing and debugging
|
|
29
|
+
- **Alert API**: For displaying test results
|
|
37
30
|
|
|
38
|
-
##
|
|
31
|
+
## Restrictions
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
function DevTestSection() {
|
|
42
|
-
const devCallbacks = useDevTestCallbacks();
|
|
33
|
+
### REQUIRED
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
- **Development Only**: MUST only use in `__DEV__` mode
|
|
36
|
+
- **Guard Checks**: MUST check if hook returns undefined
|
|
37
|
+
- **Visual Distinction**: SHOULD make dev tools visually distinct
|
|
38
|
+
- **Documentation**: MUST document behavior for other developers
|
|
46
39
|
|
|
47
|
-
|
|
40
|
+
### PROHIBITED
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
- **NEVER** use in production code paths
|
|
43
|
+
- **NEVER** ship dev UI to production
|
|
44
|
+
- **DO NOT** rely on dev tools for production features
|
|
45
|
+
- **DO NOT** expose dev functionality to end users
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
<Button onPress={onCheckCredits} title="Check Credits" />
|
|
55
|
-
<Button onPress={onTestDuplicate} title="Test Duplicate Protection" />
|
|
56
|
-
</View>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
```
|
|
47
|
+
### CRITICAL SAFETY
|
|
60
48
|
|
|
61
|
-
|
|
49
|
+
- **ALWAYS** guard with `__DEV__` checks
|
|
50
|
+
- **NEVER** call hook functions in production
|
|
51
|
+
- **MUST** remove or disable before release
|
|
52
|
+
- **ALWAYS** test that dev tools don't affect production
|
|
62
53
|
|
|
63
|
-
|
|
54
|
+
## AI Agent Guidelines
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
function DevTestPanel() {
|
|
67
|
-
const devCallbacks = useDevTestCallbacks();
|
|
56
|
+
### When Implementing Development Testing
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
1. **Always** guard with `__DEV__` checks
|
|
59
|
+
2. **Always** check if hook returns undefined
|
|
60
|
+
3. **Always** make dev tools visually distinct
|
|
61
|
+
4. **Never** expose dev tools to production users
|
|
62
|
+
5. **Always** document development-only behavior
|
|
70
63
|
|
|
71
|
-
|
|
64
|
+
### Integration Checklist
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
- [ ] Import from correct path: `@umituz/react-native-subscription`
|
|
67
|
+
- [ ] Guard with `__DEV__` check
|
|
68
|
+
- [ ] Check if hook returns undefined
|
|
69
|
+
- [ ] Make dev UI visually distinct
|
|
70
|
+
- [ ] Test renewal simulation
|
|
71
|
+
- [ ] Test credits inspection
|
|
72
|
+
- [ ] Test duplicate protection
|
|
73
|
+
- [ ] Verify undefined returned in production
|
|
74
|
+
- [ ] Remove or disable before release
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
<Text style={styles.sectionTitle}>Renewal Testing</Text>
|
|
76
|
+
### Common Patterns
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
</TouchableOpacity>
|
|
78
|
+
1. **Dev Test Panel**: Dedicated screen for testing
|
|
79
|
+
2. **Settings Integration**: Add dev tools to settings screen
|
|
80
|
+
3. **Debug Menu**: Hidden menu for testing
|
|
81
|
+
4. **Flow Testing**: Test complete renewal flows
|
|
82
|
+
5. **Edge Case Testing**: Test duplicate handling and errors
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
Simulates a subscription renewal and adds credits using ACCUMULATE mode
|
|
89
|
-
</Text>
|
|
90
|
-
</View>
|
|
84
|
+
## Related Documentation
|
|
91
85
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
>
|
|
99
|
-
<Text>Check Current Credits</Text>
|
|
100
|
-
</TouchableOpacity>
|
|
101
|
-
|
|
102
|
-
<Text style={styles.help}>
|
|
103
|
-
Display current credit balance and purchase date
|
|
104
|
-
</Text>
|
|
105
|
-
</View>
|
|
106
|
-
|
|
107
|
-
<View style={styles.section}>
|
|
108
|
-
<Text style={styles.sectionTitle}>Duplicate Protection</Text>
|
|
109
|
-
|
|
110
|
-
<TouchableOpacity
|
|
111
|
-
style={styles.button}
|
|
112
|
-
onPress={onTestDuplicate}
|
|
113
|
-
>
|
|
114
|
-
<Text>Test Duplicate Protection</Text>
|
|
115
|
-
</TouchableOpacity>
|
|
116
|
-
|
|
117
|
-
<Text style={styles.help}>
|
|
118
|
-
Tests that duplicate renewals with the same ID are prevented
|
|
119
|
-
</Text>
|
|
120
|
-
</View>
|
|
121
|
-
</ScrollView>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### With Settings Screen Integration
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
function SettingsScreen() {
|
|
130
|
-
const devCallbacks = useDevTestCallbacks();
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<ScrollView>
|
|
134
|
-
<Section title="Account">
|
|
135
|
-
<SettingsItem label="Email" value={user?.email} />
|
|
136
|
-
<SettingsItem label="Subscription" value={isPremium ? 'Premium' : 'Free'} />
|
|
137
|
-
</Section>
|
|
138
|
-
|
|
139
|
-
{/* Only show in development */}
|
|
140
|
-
{__DEV__ && devCallbacks && (
|
|
141
|
-
<Section title="Developer Tools">
|
|
142
|
-
<SettingsItem
|
|
143
|
-
label="Test Renewal"
|
|
144
|
-
onPress={devCallbacks.onTestRenewal}
|
|
145
|
-
/>
|
|
146
|
-
<SettingsItem
|
|
147
|
-
label="Check Credits"
|
|
148
|
-
onPress={devCallbacks.onCheckCredits}
|
|
149
|
-
/>
|
|
150
|
-
<SettingsItem
|
|
151
|
-
label="Test Duplicate Protection"
|
|
152
|
-
onPress={devCallbacks.onTestDuplicate}
|
|
153
|
-
/>
|
|
154
|
-
</Section>
|
|
155
|
-
)}
|
|
156
|
-
</ScrollView>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### With Debug Menu
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
function DebugMenu() {
|
|
165
|
-
const devCallbacks = useDevTestCallbacks();
|
|
166
|
-
|
|
167
|
-
if (!__DEV__) return null;
|
|
168
|
-
|
|
169
|
-
return (
|
|
170
|
-
<Menu>
|
|
171
|
-
{devCallbacks && (
|
|
172
|
-
<>
|
|
173
|
-
<MenuItem onPress={devCallbacks.onTestRenewal}>
|
|
174
|
-
Test Renewal
|
|
175
|
-
</MenuItem>
|
|
176
|
-
<MenuItem onPress={devCallbacks.onCheckCredits}>
|
|
177
|
-
Check Credits
|
|
178
|
-
</MenuItem>
|
|
179
|
-
<MenuItem onPress={devCallbacks.onTestDuplicate}>
|
|
180
|
-
Test Duplicate Protection
|
|
181
|
-
</MenuItem>
|
|
182
|
-
</>
|
|
183
|
-
)}
|
|
184
|
-
</Menu>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
## Test Functions
|
|
190
|
-
|
|
191
|
-
### onTestRenewal
|
|
192
|
-
|
|
193
|
-
Simulates a subscription renewal event:
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
const onTestRenewal = () => {
|
|
197
|
-
// Simulates renewal with:
|
|
198
|
-
// - renewalId: `dev_renewal_${Date.now()}`
|
|
199
|
-
// - productId: 'test_yearly_subscription'
|
|
200
|
-
// - Mode: ACCUMULATE (adds to existing credits)
|
|
201
|
-
|
|
202
|
-
// Shows alert with:
|
|
203
|
-
// - New credit balance
|
|
204
|
-
// - Confirmation of ACCUMULATE mode
|
|
205
|
-
};
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**Example output:**
|
|
209
|
-
```
|
|
210
|
-
โ
Test Renewal Success
|
|
211
|
-
Credits Updated!
|
|
212
|
-
|
|
213
|
-
New Balance: 1200
|
|
214
|
-
|
|
215
|
-
(ACCUMULATE mode - credits added to existing)
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### onCheckCredits
|
|
219
|
-
|
|
220
|
-
Displays current credit information:
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
const onCheckCredits = () => {
|
|
224
|
-
// Shows alert with:
|
|
225
|
-
// - Current credit balance
|
|
226
|
-
// - Purchase date (or "N/A")
|
|
227
|
-
};
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
**Example output:**
|
|
231
|
-
```
|
|
232
|
-
๐ Current Credits
|
|
233
|
-
Credits: 100
|
|
234
|
-
|
|
235
|
-
Purchased: January 15, 2024
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### onTestDuplicate
|
|
239
|
-
|
|
240
|
-
Tests duplicate renewal protection:
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
const onTestDuplicate = () => {
|
|
244
|
-
// Performs two initialization calls with same renewalId:
|
|
245
|
-
// - First call: Adds credits
|
|
246
|
-
// - Second call: Should be skipped
|
|
247
|
-
|
|
248
|
-
// Shows alert with:
|
|
249
|
-
// - First call result
|
|
250
|
-
// - Second call result (should indicate protection worked)
|
|
251
|
-
};
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
**Example output:**
|
|
255
|
-
```
|
|
256
|
-
Duplicate Test
|
|
257
|
-
First call: โ
Added credits
|
|
258
|
-
|
|
259
|
-
Second call: โ
Skipped (protection works!)
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
## Development Logging
|
|
263
|
-
|
|
264
|
-
The hook logs detailed information in development:
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
// Test renewal
|
|
268
|
-
๐งช [Dev Test] Simulating auto-renewal...
|
|
269
|
-
{
|
|
270
|
-
userId: 'user-123',
|
|
271
|
-
renewalId: 'dev_renewal_1705311234567'
|
|
272
|
-
}
|
|
273
|
-
โ
[Dev Test] Renewal completed:
|
|
274
|
-
{
|
|
275
|
-
success: true,
|
|
276
|
-
credits: 1100
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Check credits
|
|
280
|
-
๐ Current Credits
|
|
281
|
-
Credits: 100
|
|
282
|
-
Purchased: January 15, 2024
|
|
283
|
-
|
|
284
|
-
// Test duplicate
|
|
285
|
-
๐งช [Dev Test] Testing duplicate protection...
|
|
286
|
-
First call: { credits: 100, ... }
|
|
287
|
-
Second call: { credits: 100, ... }
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
## Examples
|
|
291
|
-
|
|
292
|
-
### Comprehensive Dev Dashboard
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
function DevDashboard() {
|
|
296
|
-
const devCallbacks = useDevTestCallbacks();
|
|
297
|
-
|
|
298
|
-
if (!__DEV__ || !devCallbacks) return null;
|
|
299
|
-
|
|
300
|
-
const { user } = useAuth();
|
|
301
|
-
const { credits } = useCredits();
|
|
302
|
-
|
|
303
|
-
return (
|
|
304
|
-
<View style={styles.dashboard}>
|
|
305
|
-
<View style={styles.header}>
|
|
306
|
-
<Text style={styles.title}>Development Dashboard</Text>
|
|
307
|
-
<Text style={styles.subtitle}>
|
|
308
|
-
User: {user?.uid || 'Not logged in'}
|
|
309
|
-
</Text>
|
|
310
|
-
<Text style={styles.subtitle}>
|
|
311
|
-
Credits: {credits?.credits || 0}
|
|
312
|
-
</Text>
|
|
313
|
-
</View>
|
|
314
|
-
|
|
315
|
-
<View style={styles.actions}>
|
|
316
|
-
<TouchableOpacity
|
|
317
|
-
style={styles.actionButton}
|
|
318
|
-
onPress={devCallbacks.onTestRenewal}
|
|
319
|
-
>
|
|
320
|
-
<Icon name="refresh" size={20} />
|
|
321
|
-
<Text>Simulate Renewal</Text>
|
|
322
|
-
</TouchableOpacity>
|
|
323
|
-
|
|
324
|
-
<TouchableOpacity
|
|
325
|
-
style={styles.actionButton}
|
|
326
|
-
onPress={devCallbacks.onCheckCredits}
|
|
327
|
-
>
|
|
328
|
-
<Icon name="search" size={20} />
|
|
329
|
-
<Text>Inspect Credits</Text>
|
|
330
|
-
</TouchableOpacity>
|
|
331
|
-
|
|
332
|
-
<TouchableOpacity
|
|
333
|
-
style={styles.actionButton}
|
|
334
|
-
onPress={devCallbacks.onTestDuplicate}
|
|
335
|
-
>
|
|
336
|
-
<Icon name="shield" size={20} />
|
|
337
|
-
<Text>Test Duplicate Protection</Text>
|
|
338
|
-
</TouchableOpacity>
|
|
339
|
-
</View>
|
|
340
|
-
|
|
341
|
-
<View style={styles.info}>
|
|
342
|
-
<Text style={styles.infoTitle}>Test Mode Active</Text>
|
|
343
|
-
<Text style={styles.infoText}>
|
|
344
|
-
All operations use test data and won't affect production
|
|
345
|
-
</Text>
|
|
346
|
-
</View>
|
|
347
|
-
</View>
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### With Flow Testing
|
|
353
|
-
|
|
354
|
-
```typescript
|
|
355
|
-
function RenewalFlowTest() {
|
|
356
|
-
const devCallbacks = useDevTestCallbacks();
|
|
357
|
-
|
|
358
|
-
if (!__DEV__ || !devCallbacks) return null;
|
|
359
|
-
|
|
360
|
-
const testRenewalFlow = async () => {
|
|
361
|
-
// 1. Check initial credits
|
|
362
|
-
devCallbacks.onCheckCredits();
|
|
363
|
-
|
|
364
|
-
// 2. Simulate renewal
|
|
365
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
366
|
-
devCallbacks.onTestRenewal();
|
|
367
|
-
|
|
368
|
-
// 3. Verify credits increased
|
|
369
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
370
|
-
devCallbacks.onCheckCredits();
|
|
371
|
-
|
|
372
|
-
// 4. Test duplicate protection
|
|
373
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
374
|
-
devCallbacks.onTestDuplicate();
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
return (
|
|
378
|
-
<Button
|
|
379
|
-
onPress={testRenewalFlow}
|
|
380
|
-
title="Run Complete Renewal Flow Test"
|
|
381
|
-
/>
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
## Best Practices
|
|
387
|
-
|
|
388
|
-
1. **Development only** - Never use in production code
|
|
389
|
-
2. **Guard with `__DEV__`** - Always check if in development mode
|
|
390
|
-
3. **Clear UI** - Make dev tools visually distinct
|
|
391
|
-
4. **Test thoroughly** - Use for testing renewal flows
|
|
392
|
-
5. **Document behavior** - Leave clear comments for other developers
|
|
393
|
-
6. **Remove before release** - Ensure dev UI doesn't ship
|
|
394
|
-
7. **Test edge cases** - Duplicate handling, error cases
|
|
395
|
-
|
|
396
|
-
## Production Safety
|
|
397
|
-
|
|
398
|
-
The hook is production-safe:
|
|
399
|
-
|
|
400
|
-
```typescript
|
|
401
|
-
export const useDevTestCallbacks = (): DevTestActions | undefined => {
|
|
402
|
-
// ... implementation
|
|
403
|
-
|
|
404
|
-
if (!__DEV__) {
|
|
405
|
-
return undefined; // โ
Returns undefined in production
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return { onTestRenewal, onCheckCredits, onTestDuplicate };
|
|
409
|
-
};
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
## Related Hooks
|
|
413
|
-
|
|
414
|
-
- **useCredits** - For accessing credits balance
|
|
415
|
-
- **useInitializeCredits** - For credit initialization
|
|
416
|
-
- **usePremiumWithCredits** - For premium + credits integration
|
|
417
|
-
|
|
418
|
-
## See Also
|
|
419
|
-
|
|
420
|
-
- [Credits README](../../../domains/wallet/README.md)
|
|
421
|
-
- [Renewal Testing Guide](../../../docs/RENEWAL_TESTING.md)
|
|
422
|
-
- [Development Tools](../../../docs/DEV_TOOLS.md)
|
|
86
|
+
- **useCredits**: For accessing credits balance
|
|
87
|
+
- **useInitializeCredits**: For credit initialization
|
|
88
|
+
- **usePremiumWithCredits**: For premium + credits integration
|
|
89
|
+
- **Credits README**: `src/domains/wallet/README.md`
|
|
90
|
+
- **Renewal Testing Guide**: `src/docs/RENEWAL_TESTING.md`
|
|
91
|
+
- **Development Tools**: `src/docs/DEV_TOOLS.md`
|