Skip to content

[in_app_purchase_storekit] Product display price with wrong precision using StoreKit 2 #159080

Closed
flutter/packages
#8127

Description

@remi-denele

What package does this bug report belong to?

in_app_purchase

What target platforms are you seeing this bug on?

iOS

Have you already upgraded your packages?

Yes

Dependency versions

pubspec.yaml
in_app_purchase: 3.2.0
in_app_purchase_android: 0.3.6+12
in_app_purchase_platform_interface: 1.4.0
in_app_purchase_storekit: 0.3.20

Steps to reproduce

  1. Pre-requisites: have your products defined in App Store Connect or a local StoreKit config with your products
  2. Enable StoreKit 2
  3. Query your products details

Expected results

@LouiseHsu Based on comment #116383 (comment) (and because we have an issue with StoreKit 1 where failed transactions can never be completed when testing as per #98484), we wanted to try StoreKit 2.

We expected the formatted localized string of a product price to be displayable as this to the user, like it was with StoreKit 1.
If the defined price is 24.99 in US Dollar, ProductDetails.price should contains "$24.99" for US locale.

Actual results

We currently have 6 prices defined in App Store Connect and only 2 are displayed as expected with StoreKit 2:

✅ 0.99 -> "$0.99"
❌ 2.99 -> "$2.9899999999999998"
❌ 3.99 -> "$3.9899999999999998"
✅ 8.99 ->"$8.99"
❌ 17.99 -> "$17.990000000000002"
❌ 24.99 -> "$24.990000000000002"

This is the value returned by ProductDetails.price.
The value from (productDetails as AppStoreProduct2Details).sk2Product.displayPrice seems correct.

We found a similar issue discussed in RevenueCat: RevenueCat/purchases-ios#2207

Code sample

Code sample
InAppPurchaseStoreKitPlatform.registerPlatform();
final iapStoreKitPlatform = InAppPurchasePlatform.instance as InAppPurchaseStoreKitPlatform;
iapStoreKitPlatform.enableStoreKit2();

final storeResponse = await InAppPurchase.instance.queryProductDetails({'your_product_id'});

Screenshots or Videos

Screenshots / Video demonstration

Simulator Screenshot - iPhone 16 Pro - 2024-11-18 at 16 02 11
Capture d’écran 2024-11-18 à 15 53 07

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on macOS 14.6.1 23G93 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Activity

  1. LouiseHsu commented on Nov 18, 2024

    @LouiseHsu
    Contributor

    Ah, thanks for filing this!! I'll take a look.

  2. added
    P2Important issues not at the top of the work list
    team-iosOwned by iOS platform team
    triaged-iosTriaged by iOS platform team
    on Nov 18, 2024
  3. github-actions commented on Dec 5, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: in_app_purchasePlugin for in-app purchaseteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions