Conversation
A 7-day subscription period is exactly one week, but the day↔week conversions used an approximate 52/365 weeks-per-day factor (52 weeks is only 364 days). For a product the SDK sees as `.day` × 7, this made `weeklyPrice` divide by 7 × 52/365 ≈ 0.9973 instead of 1, inflating the result — e.g. a £6.99/7-day product reported a `weeklyPrice` of £7.00 while StoreKit's own purchase sheet (correctly) showed £6.99. Replace the day↔week factor with the exact ratio (7 days = 1 week) in all four computed-price paths — the `SubscriptionPeriod` helper (SK1) and the inline switches in `SK2StoreProduct`, `APIStoreProduct`, and `StripeProductType`. Month↔year was already exact (12); week/month and week/year conversions remain conventional approximations since those relationships genuinely aren't whole-number. Adds a regression test: a 7-day period at 6.99 yields a `weeklyPrice` of 6.99 (pre-fix it produced 7.00), plus a consistency check that 7-day and 1-week periods yield the same weekly price. Bumps version to 4.15.3. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-conversion # Conflicts: # CHANGELOG.md
SK2StoreProduct's dailyPrice/weeklyPrice/monthlyPrice/yearlyPrice switched directly on the raw StoreKit `Product.SubscriptionPeriod`, bypassing `SubscriptionPeriod.normalized()`. StoreKit can report a weekly subscription as `.day × 7` rather than `.week × 1`, so those getters hit the day↔week conversion branch and a £6.99 weekly product reported a `weeklyPrice` of £7.00 — even though `SK2StoreProduct` already had a `subscriptionPeriod` property that builds the normalized SDK type. Replace the four inline switches with calls through that normalized `subscriptionPeriod` and its `pricePerDay/Week/Month/Year` helpers. A StoreKit `.day × 7` now collapses to `.week × 1` before the price math, so a weekly product's weekly price equals its price. Also removes the per-getter duplicated conversion logic. Make `SubscriptionPeriod.normalized()` internal and add tests: 7-day → 1 week, 14-day → 2 weeks, 3-day stays in days, and the full chain (7-day normalized → weeklyPrice equals the price). Adds the missing pricePerDay coverage for the day↔week fix as well. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fix day↔week price conversion (6.99 weekly shows as 7.00)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release 4.15.3
Merges
developintomasterfor the 4.15.3 release.Fixes
weeklyPrice,dailyPrice) being off by a small amount for products whose subscription period is expressed in days.Checklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.swiftlintin the main directory and fixed any issues.🤖 Generated with Claude Code
Greptile Summary
This release (4.15.3) fixes computed subscription period prices (
weeklyPrice,dailyPrice) that were off by a small amount for products expressed in days, by replacing the approximate 365/52 day↔week conversion with the exact factor of 7.SubscriptionPeriod.pricePerDay(.weekcase) andpricePerWeek(.daycase) now use 7 as the exact conversion factor instead of 365/52 ≈ 7.019, which caused a 7-day subscription'sweeklyPriceto read e.g. £7.00 instead of £6.99. The same fix is applied inline toAPIStoreProductandStripeProductType.SK2StoreProduct's four computed-price properties are collapsed into a singleformattedComputedPricehelper that delegates to the now-centralizedSubscriptionPeriodmethods, with normalization (collapsing.day × 7→.week × 1) applied at theSubscriptionPeriod.from(...)layer.normalized()is widened fromprivatetointernalso new unit tests can exercise the normalization path directly.Confidence Score: 5/5
Safe to merge — the arithmetic fix is narrow, well-reasoned, and backed by new regression tests covering the exact failure cases.
The change replaces an approximate week↔day factor (365/52) with the exact value (7) uniformly across SubscriptionPeriod, APIStoreProduct, and StripeProductType. SK2StoreProduct is also cleaned up by centralising the four price computations into one helper that routes through the normalised SubscriptionPeriod. The new tests pin the before/after values and verify that a 7-day period and a 1-week period produce identical prices. No untested edge cases were identified that weren't already exercised by the existing or new test suite.
No files require special attention.
Important Files Changed
Reviews (1): Last reviewed commit: "Merge pull request #473 from superwall/f..." | Re-trigger Greptile