Conversation
Previously the SDK used simple divisors for cross-period price conversions (e.g. month→week divided by 4), which produced different results than the paywall editor which annualizes first then divides. For example, $29.99/month weekly price: - Before: $29.99 ÷ 4 = $7.49 - After: $29.99 × 12 ÷ 52 = $6.92 (matches editor) Updated conversion factors across SK1, SK2, Stripe, and Test product types, plus trial period discount calculations. Added consistent rounding behavior using NSDecimalNumberHandler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…all/Superwall-iOS into fix_editor_pricing_parity # Conflicts: # Sources/SuperwallKit/StoreKit/Products/StoreProduct/Discount/StoreProductDiscount.swift # Sources/SuperwallKit/StoreKit/Products/StoreProduct/SubscriptionPeriod.swift # Sources/SuperwallKit/StoreKit/Products/StoreProduct/TestStoreProduct.swift # Tests/SuperwallKitTests/StoreKit/Products/StoreProduct/SubscriptionPeriodPriceTests.swift
Additional Comments (3)
Prompt To Fix With AIThis is a comment left during a code review.
Path: Sources/SuperwallKit/StoreKit/Products/StoreProduct/SK2StoreProduct.swift
Line: 236-240
Comment:
`periodDays` still uses the old 7 days/week and 30 days/month approximations while the pricing calculations below (lines 272-274) use the new annualized approach (365/52, 365/12). This inconsistency could cause confusion if `periodDays` is used elsewhere in the codebase.
How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix With AIThis is a comment left during a code review.
Path: Sources/SuperwallKit/StoreKit/Products/StoreProduct/StripeProductType.swift
Line: 258-263
Comment:
`periodDays` still uses the old 7 days/week and 30 days/month approximations while the pricing calculations below (lines 303, 307) use the new annualized approach (365/52, 365/12). This inconsistency could cause confusion if `periodDays` is used elsewhere in the codebase.
How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix With AIThis is a comment left during a code review.
Path: Sources/SuperwallKit/StoreKit/Products/StoreProduct/TestStoreProduct.swift
Line: 159-160
Comment:
`periodDays` still uses the old 7 days/week and 30 days/month approximations while the pricing calculations below (lines 189, 193) use the new annualized approach (365/52, 365/12). This inconsistency could cause confusion if `periodDays` is used elsewhere in the codebase.
How can I resolve this? If you propose a fix, please make it concise. |
Summary
Greptile Summary
Aligned iOS pricing calculations with editor behavior by implementing annualized conversion formulas and consistent 2-decimal round-down rounding across all StoreKit product types (SK1, SK2, Stripe, TestStore).
Key Changes:
roundedPrice()helper method to SK2, Stripe, and TestStore products that applies 2-decimal round-down behavior usingSubscriptionPeriod.roundingBehaviorStoreProductDiscount.periodsPerUnit()to use the same annualized conversion ratiosConfidence Score: 5/5
Important Files Changed
roundedPrice()helper and updated price conversion calculations to match editor's annualized approach with 2-decimal round-down behaviorroundedPrice()helper and updated pricing formulas across all period conversions for Stripe products to align with annualized calculationsroundedPrice()helper and updated all subscription price calculations to use annualized formulas consistent with other product typesperiodsPerUnit()to use annualized conversion ratios (365/52, 365/12, etc.) matching the changes in other pricing filesLast reviewed commit: 4d61ad8