@umituz/react-native-subscription 2.35.8 → 2.35.10

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.35.8",
3
+ "version": "2.35.10",
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",
@@ -1,6 +1,9 @@
1
1
  import type { CustomerInfo } from "react-native-purchases";
2
2
  import { getPremiumEntitlement } from "../../../revenuecat/core/types";
3
3
  import { toDate } from "../../../../shared/utils/dateConverter";
4
+ import { detectPackageType } from "../../../../utils/packageTypeDetector";
5
+
6
+ declare const __DEV__: boolean;
4
7
 
5
8
  export interface PremiumStatus {
6
9
  isPremium: boolean;
@@ -23,17 +26,25 @@ export class PurchaseStatusResolver {
23
26
  const entitlement = getPremiumEntitlement(customerInfo, entitlementId);
24
27
 
25
28
  if (entitlement) {
29
+ const productIdentifier = entitlement.productIdentifier ?? null;
30
+ const detectedPackageType = productIdentifier ? detectPackageType(productIdentifier) : null;
31
+
32
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
33
+ console.log("[PurchaseStatusResolver] productIdentifier:", productIdentifier);
34
+ console.log("[PurchaseStatusResolver] detectedPackageType:", detectedPackageType);
35
+ }
36
+
26
37
  return {
27
38
  isPremium: true,
28
39
  expirationDate: toDate(entitlement.expirationDate),
29
40
  willRenew: entitlement.willRenew ?? false,
30
- productIdentifier: entitlement.productIdentifier ?? null,
41
+ productIdentifier,
31
42
  originalPurchaseDate: toDate(entitlement.originalPurchaseDate) ?? null,
32
43
  latestPurchaseDate: toDate(entitlement.latestPurchaseDate) ?? null,
33
44
  billingIssuesDetected: entitlement.billingIssueDetectedAt !== null && entitlement.billingIssueDetectedAt !== undefined,
34
45
  isSandbox: entitlement.isSandbox ?? false,
35
46
  periodType: entitlement.periodType ?? null,
36
- packageType: null,
47
+ packageType: detectedPackageType,
37
48
  store: null,
38
49
  gracePeriodExpiresDate: null,
39
50
  unsubscribeDetectedAt: toDate(entitlement.unsubscribeDetectedAt) ?? null,
@@ -40,8 +40,14 @@ export const SubscriptionHeaderContent: React.FC<SubscriptionHeaderContentProps>
40
40
  latestPurchaseDate,
41
41
  billingIssuesDetected,
42
42
  isSandbox,
43
- }) => (
44
- <View style={styles.details}>
43
+ }) => {
44
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
45
+ console.log('[SubscriptionHeaderContent] packageType:', packageType);
46
+ console.log('[SubscriptionHeaderContent] periodType:', periodType);
47
+ }
48
+
49
+ return (
50
+ <View style={styles.details}>
45
51
  {isLifetime ? (
46
52
  <DetailRow
47
53
  label={translations.statusLabel}
@@ -139,4 +145,5 @@ export const SubscriptionHeaderContent: React.FC<SubscriptionHeaderContentProps>
139
145
  </>
140
146
  )}
141
147
  </View>
142
- );
148
+ );
149
+ };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Package Type Detector Tests
3
+ * Test various product ID patterns
4
+ */
5
+
6
+ import { detectPackageType } from "./packageTypeDetector";
7
+ import { PACKAGE_TYPE } from "../domains/subscription/core/SubscriptionConstants";
8
+
9
+ // Test common product ID patterns
10
+ const testCases = [
11
+ // Standard patterns
12
+ { id: "com.umituz.aibabyfacepredictor.weekly", expected: PACKAGE_TYPE.WEEKLY },
13
+ { id: "com.umituz.aibabyfacepredictor.monthly", expected: PACKAGE_TYPE.MONTHLY },
14
+ { id: "com.umituz.aibabyfacepredictor.yearly", expected: PACKAGE_TYPE.YEARLY },
15
+
16
+ // Test store patterns
17
+ { id: "com.umituz.aibabyfacepredictor.test.weekly", expected: PACKAGE_TYPE.WEEKLY },
18
+ { id: "com.umituz.aibabyfacepredictor.test.monthly", expected: PACKAGE_TYPE.MONTHLY },
19
+ { id: "com.umituz.aibabyfacepredictor.test.yearly", expected: PACKAGE_TYPE.YEARLY },
20
+
21
+ // Alternative naming
22
+ { id: "weekly_subscription", expected: PACKAGE_TYPE.WEEKLY },
23
+ { id: "monthly_subscription", expected: PACKAGE_TYPE.MONTHLY },
24
+ { id: "annual_subscription", expected: PACKAGE_TYPE.YEARLY },
25
+
26
+ // Edge cases
27
+ { id: "week_pass", expected: PACKAGE_TYPE.WEEKLY },
28
+ { id: "month_pass", expected: PACKAGE_TYPE.MONTHLY },
29
+ { id: "year_pass", expected: PACKAGE_TYPE.YEARLY },
30
+
31
+ // Should NOT match
32
+ { id: "credit_package", expected: PACKAGE_TYPE.UNKNOWN },
33
+ { id: "random_product", expected: PACKAGE_TYPE.UNKNOWN },
34
+ ];
35
+
36
+ console.log("=== Package Type Detector Tests ===\n");
37
+
38
+ let passed = 0;
39
+ let failed = 0;
40
+
41
+ testCases.forEach(({ id, expected }) => {
42
+ const result = detectPackageType(id);
43
+ const isPass = result === expected;
44
+
45
+ if (isPass) {
46
+ passed++;
47
+ console.log(`✅ PASS: "${id}" → ${result}`);
48
+ } else {
49
+ failed++;
50
+ console.log(`❌ FAIL: "${id}" → ${result} (expected: ${expected})`);
51
+ }
52
+ });
53
+
54
+ console.log(`\n=== Results: ${passed} passed, ${failed} failed ===`);
55
+
56
+ // Test actual RevenueCat product IDs (if available)
57
+ console.log("\n=== Test Your Actual Product IDs ===");
58
+ console.log("Add your actual product IDs below to test:\n");
59
+
60
+ const yourProductIds = [
61
+ // Add your actual product IDs here
62
+ // "com.yourapp.yourproduct.weekly",
63
+ ];
64
+
65
+ if (yourProductIds.length > 0) {
66
+ yourProductIds.forEach(id => {
67
+ const result = detectPackageType(id);
68
+ console.log(`Product: "${id}" → Detected as: ${result}`);
69
+ });
70
+ }