Missing currencyCode in StoreKit2

Anyone knows if there is a good reason why StoreKit2 In App Purchase Product and Transaction objects do not contain a complete price with a priceLocale or a currencyCode?

I understand that we are supposed to use the preformatted displayPrice for user-facing labels. However for the app that we are working on we really need to know the currencyCode or priceLocale for accounting purposes otherwise there is really no way to know how much the user actually paid for the purchase.

Note: I know that App Store Connect API provides detailed financial reports, but our use case requires this information on the app-side.

Answered by RobertDresler in 750799022

Update: For the moment we are able to solve this issue by using a SKProductRequest.. SKProduct includes the priceLocale which is what we need. I hope StoreKit 2 can include this information as well in the future.

Hey you can you displayPrice will give you the price with local currency symbol. use product.displayPrice And you want to know user's App Store Account currencyCode you can find that from

        if let storeFront = SKPaymentQueue.default().storefront {             print(storeFront.countryCode) }

Thanks but these do not really answer the problem.

First, displayPrice is a String. We can not realistically parse that string and get back a numeric price value, even if we know the currency code.

Second, storeFront.countryCode gives a country code. Country code and currency code are two entirely different things.

You can also get currency code but with one trick for now: let price = product.price.formatted() // give you price in string let displayPrice = product.displayPrice let currencySymbol = displayPrice.replacingOccurrences(of: price, with: "")

We are using this quick fix for now. Until apple provide any proper solution. Hope will love your problem.

Update: It was announced in WWDC 2022 that the priceLocale would be reintroduced in Product. However the latest version of the beta SDK (Xcode 14.0 beta 2) does not contain it. A reference to a currency formatter style is introduced instead, with var priceFormatStyle: Decimal.FormatStyle.Currency which should allow formatting calculated user-facing strings.

Accepted Answer
Missing currencyCode in StoreKit2
 
 
Q