Closed wilfredbtan closed 1 month ago
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
Right, sounds like you've stumbled across a bit of a wonky glitch in the Purchases SDK, mate. Inconsistent formatting and rounding errors? That's a proper nuisance when you're trying to give your users a clear picture of your pricing.
It's smart that you're looking into the pricePerYear calculation in the SDK's code. That rounding down behaviour could definitely be the culprit behind those pesky cent discrepancies.
You're spot on about not being able to rely solely on localizedPriceString for everything. Showing the localizedPricePerMonth for annual subscriptions is a crucial bit of transparency for users.
The Singapore locale issue is interesting, but don't assume it's isolated. Definitely test other locales and see if the problem crops up elsewhere.
As for that workaround... yeah, sometimes those quick fixes don't quite hit the mark. It's good you tried, though.
Here's the deal: you've done your due diligence, mate. You've updated the SDK, checked the docs, scoured the community, and even poked around in the code. This bug deserves some attention from the RevenueCat crew.
Hit up their support team or submit a detailed bug report on GitHub. Include all the info you've got here: environment details, steps to reproduce, expected vs. actual behaviour, and those insightful code snippets. The more info you provide, the quicker they can get to the bottom of it and roll out a fix.
In the meantime, you might have to get a bit creative with your UI or consider temporarily tweaking your pricing display to avoid confusion for your users.
Keep your chin up, bruv. You'll get this sorted.
Hi @wilfredbtan, many thanks for reporting this!
We've worked on a fix in #4275, which should have been released in 5.3.4? Please let us know if that works!
Thanks for fixing this. It works perfectly now :D
Nice! Thanks for letting us know! Will close this issue but feel free to reopen if needed
Describe the bug There seems to be a rounding issue for prices such as $19.99 and $1.99. Furthermore, there is inconsistent formatting between localizedPriceString and the localizedPricePerYear variants.
usesStoreKit2IfAvailable(true)
)Purchases.logLevel = .verbose
will help us debug this issue.I have an annual subscription priced at $19.99/year, when using
localizedPriceString
(e.g.yearlyPackage.storeProduct.localizedPriceString
), it is displayed as "S $19.99" (with the S infront). However, when I uselocalizedPricePerYear
, the displayed string is "$19.98" (without the S and a rounding error in the last cent).The same issue occurs for my monthly subscription priced at $2.99. That is, using localizedPricePerYear on my monthly package is displayed as "$2.98" (with the last cent rounded wrongly)
I can't simply use localizedPriceString for all my products because I intend to show the localizedPricePerMonth for my annual subscription to aid the user in comparing my annual and monthly prices.
Thus it's a bit inconvenient if both are formatted differently.
I suspect this may be due to the way that pricePerYear is calculated, particularly the rounding down behaviour here: https://github.com/RevenueCat/purchases-ios/blob/0d112d084e13faea89160577dfa086124a7504aa/Sources/Purchasing/StoreKitAbstractions/SubscriptionPeriod.swift#L154
I also tried this workaround but it doesn't work as well: