Skip to content
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

Not receiving products on iOS #32

Closed
gildaswise opened this issue Sep 10, 2018 · 12 comments
Closed

Not receiving products on iOS #32

gildaswise opened this issue Sep 10, 2018 · 12 comments
Labels
help wanted Extra attention is needed ios ios related issue

Comments

@gildaswise
Copy link

gildaswise commented Sep 10, 2018

Version of flutter_inapp_purchase

0.6.5

Platforms you faced the error (iOS or Android or both?)

iOS

Expected behavior

Receiving product as an IAPItem

Actual behavior

Not receiving anything

Tested environment (Emulator? Real Device?)

Both emulator and real device

Steps to reproduce the behavior

Call getProducts with the desired product IDs

Other info

I'm using TestFlight with this app and already registered an IAP there, its status is Waiting for Review and I've already checked with @lukepighetti that his IAP worked even with this status.

Also, neither catchError or try/catch block are working on this code I'm using:

 Future<List<IAPItem>> refreshProducts({bool includeTests = false}) async {
    final items = _skus.values.toList();
    if (includeTests && _platformVersion.contains("Android"))
      items.addAll(_tests);
    Logger.log(TAG,
        message: "Requesting ${items.length} SKUs: ${items.toString()}");
    List<IAPItem> products = [];
    try {
      await FlutterInappPurchase.getProducts(items)
          .catchError((exception, stacktrace) {
        Logger.log(TAG,
            message:
                "Couldn't refresh products, error: $exception, $stacktrace");
      }).then(products.addAll);
    } catch (error) {
      Logger.log(TAG, message: "Couldn't refresh products: $error");
    }
    Logger.log(TAG, message: "Got: ${products?.length} products");
    if (products != null && products.isNotEmpty) {
      _availableProducts.clear();
      _availableProducts.addAll(products);
    }
    return _availableProducts;
  }
@hyochan hyochan added help wanted Extra attention is needed ios ios related issue labels Sep 11, 2018
@hyochan
Copy link
Member

hyochan commented Sep 11, 2018

@gildaswise You should use the whole name for productId.
I hope you take a look at the product detail on App Store connect (iTunes connect).
Check the contract info and fill the right info.
Please refer to the example project, also.

@RobertBrunhage
Copy link

Can confirm that this is happening to me as well. Using the full example from GitHub, but receive no products nor error. Have also added a product with 'Waiting for Review' status.

@lukepighetti
Copy link
Contributor

lukepighetti commented Sep 11, 2018

Here is all of my code for IAP for subscriptions. Maybe it's helpful. It works on iOS and Android. I am package locked into 24f85b79b1d8c023f2f1e28069315bd5149b4cfc

class Store {
  static Store _instance = new Store();
  static Store get instance => _instance;
  static String sku = 'when_coin_premium';

  static setup() async {
    await FlutterInappPurchase.prepare;
    final bool isSubscribed = await checkSubscribed();
    _saveToFirebase(isSubscribed);
    FlutterInappPurchase.endConnection;
  }

  static Future<bool> subscribe() async {
    try {
      await FlutterInappPurchase.prepare;
      await FlutterInappPurchase.getSubscriptions([sku]);
      await FlutterInappPurchase.buySubscription(sku);
      FlutterInappPurchase.endConnection;
      await _saveToFirebase(true);
      return true;
    } catch (e) {
      return false;
    }
  }

  static Future<bool> checkSubscribed() async {
    bool isSubscribed = await FlutterInappPurchase.checkSubscribed(
      sku: sku,
      duration: Duration(minutes: 5),
      grace: Duration(minutes: 1),
    );

    await _saveToFirebase(isSubscribed);
    return isSubscribed;
  }

  static Future<void> _saveToFirebase(bool isSubscribed) =>
      User.instance.ref.child('subscribed').set(isSubscribed ?? false);
}

@RobertBrunhage
Copy link

My code is working on Android so would be weird that it wouldn't be working on IOS.

@gildaswise
Copy link
Author

I tried calling buyProduct without calling getProducts before and finally got an error:

[PURCHASE_MANAGER] Couldn't buy product, error: PlatformException(E_DEVELOPER_ERROR, Invalid product ID., null)

But I called buyProduct with the exact productId that is on App Store Connect's In-App Purchases section, it doesn't make sense.

@hyochan
Copy link
Member

hyochan commented Sep 11, 2018

@gildaswise Could you check issue and issue here? Also did you complete the Agreements, Tax and Banking in itunesconnect? I feel this is problem with your appstore environment and not with the plugin.

@gildaswise
Copy link
Author

gildaswise commented Sep 11, 2018

Finished Agreements, Tax and Banking and getProducts is finally working, but now I'm receiving this error on buyProduct:

[PURCHASE_MANAGER] Couldn't buy product, error: PlatformException(E_UNKNOWN, An unknown or unexpected error has occured. Please try again later., null), stacktrace: 
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
<asynchronous suspension>
#2      FlutterInappPurchase.buyProduct (package:flutter_inapp_purchase/flutter_inapp_purchase.dart:212:12)

@RobertBrunhage
Copy link

@gildaswise Did you have to wait for the Agreements, Tax and Banking status to be done or can you fetch products when it is pending?

@gildaswise
Copy link
Author

gildaswise commented Sep 11, 2018

@RobertBrunhage I had to click Request on the Paid Applications contract and then fill all forms (except for the AUS' tax info one). A few minutes later, when it moved to Contracts In Effect, I could get getProducts working, but I still can't finish the IAP with buyProduct.

@gildaswise
Copy link
Author

Update: it worked now (maybe it had a delay?) on a physical device (iPhone 7+), but nothing on the Simulator yet.

@hyochan
Copy link
Member

hyochan commented Sep 12, 2018

@gildaswise Actual payment test should be working only on real device with sandbox account. You can only testing fetching in simulator. Will close this since it seems np.

@hyochan hyochan closed this as completed Sep 12, 2018
@lukepighetti
Copy link
Contributor

Payment test and notifications are physical device only on iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed ios ios related issue
Projects
None yet
Development

No branches or pull requests

4 participants