Fix price-per-period rounding to floor instead of round-half-up#807
Merged
Conversation
Per-period prices (pricePerWeek, pricePerMonth, pricePerYear) were rounding up via Math.round / Intl.NumberFormat halfExpand, causing prices like $83.99/yr to show $7.00/mo instead of $6.99/mo. This aligns with the iOS SDK fix (purchases-ios#5821) to always round down, ensuring per-period prices never exceed what the customer actually pays. Changes: - Add shared floorMicrosToCurrencyUnit helper in price-labels.ts with cached Intl.NumberFormat lookup and IEEE 754 epsilon correction - Fix offerings.ts toPricingPhase to floor per-period micros to the currency's display precision - Fix paywall-price-helpers.ts to floor divided micros before formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RosieWatson
approved these changes
Mar 19, 2026
tonidero
pushed a commit
that referenced
this pull request
Mar 24, 2026
**This is an automatic release.** ## RevenueCat SDK ### ✨ New Features * Refactor wallet button renderer (#810) via Marek Dabek (@marek-dabek) ### 🐞 Bugfixes * Add font-family to simulated store modal (#809) via Perttu (@plahteenlahti) * Fix price-per-period rounding to floor instead of round-half-up (#807) via Dan Pannasch (@dpannasch) ### 🔄 Other Changes * Require PR approval before release tagging (#811) via Antonio Pallares (@ajpallares) * PW-1121 | Add paywall events (impression, close, cancel) (#806) via Drago Crnjac (@popcorn)
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.
Summary
pricePerWeek,pricePerMonth,pricePerYear) were usingMath.round/Intl.NumberFormathalfExpand rounding, causing prices like $83.99/yr to display as $7.00/mo instead of $6.99/mofloorMicrosToCurrencyUnithelper with cachedIntl.NumberFormatlookup and IEEE 754 epsilon correctionofferings.ts(toPricingPhaseentity builder) andpaywall-price-helpers.ts(paywall variable formatting)Test plan
floorMicrosToCurrencyUnitcovering USD, EUR, JPY, zero values, and FP epsilon🤖 Generated with Claude Code