@umituz/react-native-subscription 2.27.20 → 2.27.23

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.20",
3
+ "version": "2.27.23",
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",
@@ -13,7 +13,7 @@ import { View, TouchableOpacity, StyleSheet } from "react-native";
13
13
  import { AtomicText, AtomicIcon, AtomicBadge, useAppDesignTokens } from "@umituz/react-native-design-system";
14
14
  import type { PurchasesPackage } from "react-native-purchases";
15
15
 
16
- import { formatPrice } from '../../../utils/priceUtils';
16
+ import { formatPriceWithPeriod } from '../../../utils/priceUtils';
17
17
 
18
18
  interface PlanCardProps {
19
19
  pkg: PurchasesPackage;
@@ -33,7 +33,7 @@ export const PlanCard: React.FC<PlanCardProps> = React.memo(
33
33
  ({ pkg, isSelected, onSelect, badge, creditAmount, creditsLabel, hasFreeTrial, trialSubtitleText }) => {
34
34
  const tokens = useAppDesignTokens();
35
35
  const title = pkg.product.title;
36
- const price = formatPrice(pkg.product.price, pkg.product.currencyCode);
36
+ const price = formatPriceWithPeriod(pkg.product.price, pkg.product.currencyCode, pkg.identifier);
37
37
 
38
38
  return (
39
39
  <TouchableOpacity onPress={onSelect} activeOpacity={0.7} style={styles.touchable}>
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Price Formatting Utilities
3
+ * Apple App Store Guideline 3.1.2 Compliance
3
4
  */
4
5
 
5
6
  /**
@@ -18,3 +19,55 @@ export function formatPrice(price: number, currencyCode: string): string {
18
19
  return `${currencyCode} ${price.toFixed(2)}`;
19
20
  }
20
21
  }
22
+
23
+ /**
24
+ * Extract billing period suffix from package identifier
25
+ * Apple App Store Guideline 3.1.2 Compliance:
26
+ * - Displays billing frequency clearly and conspicuously
27
+ * - Format: /week, /month, /year
28
+ *
29
+ * @param identifier - RevenueCat package identifier (e.g., "$rc_weekly", "$rc_monthly", "$rc_annual")
30
+ * @returns Billing period suffix (e.g., "/week", "/month", "/year") or empty string
31
+ */
32
+ export function getBillingPeriodSuffix(identifier: string): string {
33
+ const lowerIdentifier = identifier.toLowerCase();
34
+
35
+ if (lowerIdentifier.includes('weekly') || lowerIdentifier.includes('week')) {
36
+ return '/week';
37
+ }
38
+
39
+ if (lowerIdentifier.includes('monthly') || lowerIdentifier.includes('month')) {
40
+ return '/month';
41
+ }
42
+
43
+ if (lowerIdentifier.includes('annual') || lowerIdentifier.includes('year') || lowerIdentifier.includes('yearly')) {
44
+ return '/year';
45
+ }
46
+
47
+ return '';
48
+ }
49
+
50
+ /**
51
+ * Format price with billing period
52
+ * Apple App Store Guideline 3.1.2 Compliance:
53
+ * - Combines price with billing frequency for clear display
54
+ * - Format: $2.99/week, $14.99/month, $39.99/year
55
+ *
56
+ * RevenueCat Best Practice:
57
+ * - Follows recommended price_per_period format
58
+ * - Clear and conspicuous billing frequency display
59
+ *
60
+ * @param price - Price value
61
+ * @param currencyCode - Currency code (e.g., 'USD', 'EUR')
62
+ * @param identifier - RevenueCat package identifier
63
+ * @returns Formatted price with billing period (e.g., "$2.99/week")
64
+ */
65
+ export function formatPriceWithPeriod(
66
+ price: number,
67
+ currencyCode: string,
68
+ identifier: string
69
+ ): string {
70
+ const formattedPrice = formatPrice(price, currencyCode);
71
+ const periodSuffix = getBillingPeriodSuffix(identifier);
72
+ return `${formattedPrice}${periodSuffix}`;
73
+ }