@umituz/react-native-subscription 2.27.27 → 2.27.28

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.27.27",
3
+ "version": "2.27.28",
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",
@@ -109,18 +109,31 @@ export async function initializeCreditsTransaction(
109
109
 
110
110
  const status = resolveSubscriptionStatus({ isPremium, willRenew, isExpired: !isPremium, periodType });
111
111
 
112
+ // Determine if this is a status sync (not a new purchase or renewal)
113
+ // Status sync should preserve existing credits, only update metadata
114
+ const isStatusSync = purchaseId?.startsWith("status_sync_") ?? false;
115
+ const isNewPurchaseOrRenewal = purchaseId?.startsWith("purchase_") || purchaseId?.startsWith("renewal_");
116
+
112
117
  let newCredits = creditLimit;
113
- if (status === SUBSCRIPTION_STATUS.TRIAL) newCredits = TRIAL_CONFIG.CREDITS;
114
- else if (status === SUBSCRIPTION_STATUS.TRIAL_CANCELED) newCredits = 0;
118
+ if (status === SUBSCRIPTION_STATUS.TRIAL) {
119
+ newCredits = TRIAL_CONFIG.CREDITS;
120
+ } else if (status === SUBSCRIPTION_STATUS.TRIAL_CANCELED) {
121
+ newCredits = 0;
122
+ } else if (isStatusSync && existingData?.credits !== undefined && existingData.isPremium) {
123
+ // Status sync for existing premium user: preserve current credits
124
+ newCredits = existingData.credits;
125
+ }
115
126
 
116
127
  const creditsData: Record<string, unknown> = {
117
128
  isPremium,
118
129
  status,
119
130
  credits: newCredits,
120
131
  creditLimit,
132
+ // Clear free credits flag when user becomes premium
133
+ isFreeCredits: false,
121
134
  purchasedAt,
122
135
  lastUpdatedAt: now,
123
- lastPurchaseAt: now,
136
+ lastPurchaseAt: isNewPurchaseOrRenewal ? now : (existingData?.lastPurchaseAt ?? now),
124
137
  processedPurchases,
125
138
  };
126
139
 
package/src/init/index.ts CHANGED
@@ -6,5 +6,7 @@
6
6
  export {
7
7
  createSubscriptionInitModule,
8
8
  type SubscriptionInitModuleConfig,
9
- type InitModule,
10
9
  } from './createSubscriptionInitModule';
10
+
11
+ // Re-export InitModule from design-system for convenience
12
+ export type { InitModule } from '@umituz/react-native-design-system';