-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SK2 RenewalInfo to get renewal prices & currency #4608
Conversation
if let renewalPrice { | ||
self.price = renewalPrice | ||
} else { | ||
self.price = entitlement.priceBestEffort(product: subscribedProduct) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fall back to our old calculation method if the RenewalInfo method failed for some reason
// to make sure that this is being built with an Xcode version >=15.0. | ||
#if compiler(>=6.0) | ||
guard let currency = renewalInfo.currency else { return nil } | ||
if currency.isISOCurrency { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, what's the other option if it's not ISO? just curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm honestly not sure, but NumberFormatter.currencyCode
depends on the currency code being a ISO 4217 currency code, so I figured it was worth a check here
transaction: Transaction, | ||
customerCenterStoreKitUtilities: CustomerCenterStoreKitUtilitiesType | ||
) async -> PurchaseInformation { | ||
let renewalPriceDetails = await Self.extractPriceDetailsFromRenwalInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to extract the date from the RenewalInfo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have to since we're already calculating it accurately from the transaction today, so I think we can keep doing that to keep the size of the change down. Even in the scenario where you switch product durations (say you switch from a monthly product to a yearly), the new product won't be active until the the renewal at the end of the current subscription period.
Do you know of any edge cases where the current renewal date calculation is inaccurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right I was thinking of cases where the product change would happen before the end of the period, but in that case, it would be immediate and it would be showing the new product. So I think this makes sense!
Co-authored-by: Cesar de la Vega <[email protected]>
Co-authored-by: Cesar de la Vega <[email protected]>
@RCGitBot please test |
Motivation
We were previously showing all renewal prices as the product's price in the Customer Center. This is usually accurate, but doesn't cover several edge cases, including product changes, price increase/decreases, and various offers.
This PR addresses this by getting the renewal price directly from StoreKit 2.
Description
currentPrice
default string value from "Current price" to "Price"Manual Testing
I tested the following flows manually on a physical device in sandbox: