How to test validate InAppPurchase in iOS with flutter

1,933

If the products aren't being fetched by your app it's most likely a configuration issue in App Store Connect. If you're products are in the 'Ready to Submit' stage then it sounds like you've set up everything that's needed for the product.

The only other thing it could be is missing the 'Paid Applications Agreement' in App Store Connect. If that isn't signed, your product fetch request will silently fail even in sandbox.

See the Configuring In-app Products is Hard post for other common reasons products fail to fetch.

Share:
1,933
Aruk
Author by

Aruk

Updated on December 15, 2022

Comments

  • Aruk
    Aruk over 1 year

    I've been searching far and wide for a solution for my problem but, although I've seen many similar questions, none of them really had the answer.

    I'm developing an app using flutter and the in_app_purchase (https://pub.dev/packages/in_app_purchase) plugin. I've followed step by step the plugin and the iOS docs, but I still am not able to test the purchase.

    The product is created in the app store connect features panel (let's say it's ID is app_subscription). Since I created and submitted the product, it's "pending for revision" (or something similar, I use the panel in Spanish). I've created a sandbox account to do the tests on the product. Finally, I've implemented the code needed to make the purchase from the app, but when I try to test the purchase from a physical device, I fail, since the queryProductDetails function doesn't finde an product with the app_subscription ID.

    Simply put, the code that retrieves the product is like this, as the plugin doc says:

    import 'package:in_app_purchase/in_app_purchase.dart';
    ...
    InAppPurchaseConnection _iap = InAppPurchaseConnection.instance;
    ...
    Set<String> ids = Set.from(['app_subscription']);
    ProductDetailsResponse response = await _iap.queryProductDetails(ids);
    print(response.productDetails); // prints: []
    

    I started to think that the reason I can't get the product is because it hasn't been validated by the reviewers, but it has been one week and the status hasn't changed. I've filled in all the required metadata, including the screenshot.

    Please tell me if you need any more info.

    Thanks in advance

    EDIT (2019/12/02): App Store has finally accepted my build and published my app, but they put my product in a "needs developer action" status, allegedly because they made a purchase but that was returned... The thing is, I still can't test my own purchase because the code isn't recognized yet. What should I do? I've tried editting my product description and testing the purchase again but it doesn't work...

    • Chance
      Chance over 4 years
      Yes you are right, you must submit a new version of your app including the products available. It's a bit of a nonsense, since you need the products available for you to perform the purchase tests, but doing what apple is mind-boggling.
    • Aruk
      Aruk over 4 years
      Thanks for your help! They've published my app but the payment doesn't work yet... I've editted the original post with this info.
  • Aruk
    Aruk over 4 years
    I really thought that the Paid Applications Agreement was completely filled in, but it turned out it didn't (the customer was supposed to do this part but it got mistaken, thinking I was talking about the info you have to provide to create the Developer account). Thanks a lot!