Skip to content

Release 4.15.3#474

Merged
yusuftor merged 7 commits into
masterfrom
develop
May 18, 2026
Merged

Release 4.15.3#474
yusuftor merged 7 commits into
masterfrom
develop

Conversation

@yusuftor
Copy link
Copy Markdown
Collaborator

@yusuftor yusuftor commented May 18, 2026

Release 4.15.3

Merges develop into master for the 4.15.3 release.

Fixes

  • Fixes computed period prices (weeklyPrice, dailyPrice) being off by a small amount for products whose subscription period is expressed in days.

Checklist

  • All unit tests pass.
  • All UI tests pass.
  • Demo project builds and runs on iOS.
  • Demo project builds and runs on Mac Catalyst.
  • Demo project builds and runs on visionOS.
  • I added/updated tests or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run swiftlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

🤖 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.

  • Price calculation fix: SubscriptionPeriod.pricePerDay (.week case) and pricePerWeek (.day case) now use 7 as the exact conversion factor instead of 365/52 ≈ 7.019, which caused a 7-day subscription's weeklyPrice to read e.g. £7.00 instead of £6.99. The same fix is applied inline to APIStoreProduct and StripeProductType.
  • SK2 refactor: SK2StoreProduct's four computed-price properties are collapsed into a single formattedComputedPrice helper that delegates to the now-centralized SubscriptionPeriod methods, with normalization (collapsing .day × 7.week × 1) applied at the SubscriptionPeriod.from(...) layer.
  • Testability: normalized() is widened from private to internal so 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

Filename Overview
Sources/SuperwallKit/StoreKit/Products/StoreProduct/SubscriptionPeriod.swift Core fix: replaces the approximate 365/52 week↔day factor with the exact value 7 in pricePerDay and pricePerWeek; normalized() is widened to internal for testability. Logic is correct and consistent.
Sources/SuperwallKit/StoreKit/Products/StoreProduct/SK2StoreProduct.swift Refactors four duplicated price-computation blocks into a single formattedComputedPrice helper that routes through the normalized SubscriptionPeriod; eliminates ~72 lines of inline logic.
Sources/SuperwallKit/StoreKit/Products/StoreProduct/APIStoreProduct.swift Applies the same day↔week conversion fix inline (not refactored to use SubscriptionPeriod helpers); numerically correct and consistent with the SubscriptionPeriod changes.
Sources/SuperwallKit/StoreKit/Products/StoreProduct/StripeProductType.swift Applies the same day↔week conversion fix inline for dailyPrice (.week case) and weeklyPrice (.day case); comments explain the rationale.
Tests/SuperwallKitTests/StoreKit/Products/StoreProduct/SubscriptionPeriodPriceTests.swift Adds targeted regression tests for the day↔week fix, normalization, and consistency between 7-day and 1-week periods. Good coverage of the changed logic.

Reviews (1): Last reviewed commit: "Merge pull request #473 from superwall/f..." | Re-trigger Greptile

yusuftor and others added 7 commits May 14, 2026 18:04
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>
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)
@yusuftor yusuftor merged commit f738aeb into master May 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant