@umituz/react-native-subscription 2.11.4 → 2.11.5

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.11.4",
3
+ "version": "2.11.5",
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",
@@ -88,11 +88,40 @@ export const SubscriptionPackageList: React.FC<SubscriptionPackageListProps> = R
88
88
  isBestValue = isYearlyPackage(pkg);
89
89
  }
90
90
 
91
- // Get credit amount for this package if provided
92
- // check both product identifier (e.g., com.app.weekly) and package identifier (e.g., $rc_weekly)
93
- const creditAmount =
94
- creditAmounts?.[pkg.product.identifier] ??
95
- creditAmounts?.[pkg.identifier];
91
+ // Smart matching for credit amounts
92
+ const findCreditAmount = () => {
93
+ if (!creditAmounts) return undefined;
94
+
95
+ const productId = pkg.product.identifier;
96
+ const packageId = pkg.identifier;
97
+
98
+ // 1. Exact match (case sensitive)
99
+ if (creditAmounts[productId] !== undefined) return creditAmounts[productId];
100
+ if (creditAmounts[packageId] !== undefined) return creditAmounts[packageId];
101
+
102
+ // 2. Case-insensitive match
103
+ const lowerProductId = productId.toLowerCase();
104
+ const lowerPackageId = packageId.toLowerCase();
105
+
106
+ for (const [key, value] of Object.entries(creditAmounts)) {
107
+ const lowerKey = key.toLowerCase();
108
+ if (lowerProductId === lowerKey || lowerPackageId === lowerKey) {
109
+ return value;
110
+ }
111
+ }
112
+
113
+ // 3. Partial match (if key is contained in identifier)
114
+ for (const [key, value] of Object.entries(creditAmounts)) {
115
+ const lowerKey = key.toLowerCase();
116
+ if (lowerKey.length > 3 && (lowerProductId.includes(lowerKey) || lowerPackageId.includes(lowerKey))) {
117
+ return value;
118
+ }
119
+ }
120
+
121
+ return undefined;
122
+ };
123
+
124
+ const creditAmount = findCreditAmount();
96
125
 
97
126
  return (
98
127
  <SubscriptionPlanCard