Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 完成采购时,i';m收到开发者错误,如响应(应用内购买)_Flutter_Dart_In App Purchase - Fatal编程技术网

Flutter 完成采购时,i';m收到开发者错误,如响应(应用内购买)

Flutter 完成采购时,i';m收到开发者错误,如响应(应用内购买),flutter,dart,in-app-purchase,Flutter,Dart,In App Purchase,BillingResponse.developerRor I/颤振(5091):购买处于无效状态 有时我会遇到这个错误,但我有一些情况下账单响应是正常的(BillingResponse.ok)。有什么问题吗?我的代码遵循的是flatter.dev的官方示例 在这段代码之前,一切都很好 var completePurchase = await InAppPurchaseConnection.instance .completePurchase(purchaseDetai

BillingResponse.developerRor I/颤振(5091):购买处于无效状态

有时我会遇到这个错误,但我有一些情况下账单响应是正常的(BillingResponse.ok)。有什么问题吗?我的代码遵循的是flatter.dev的官方示例 在这段代码之前,一切都很好

var completePurchase = await InAppPurchaseConnection.instance
              .completePurchase(purchaseDetails);
它返回BillingResponse.developerRor,有时也返回BillingResponse.ok

在widget中,我只称之为buynconsummable

  instance.buyNonConsumable(prod);
有没有可能是因为它不在生产中,或者是因为应用程序正在进行内部测试而与内部测试相关的其他东西? 总之,代码如下所示

     _subscription = getPurchaseStream.listen(
        (purchaseDetailsList) {
          _listenToPurchaseUpdated(purchaseDetailsList);
        }, onDone: () {
      _subscription.cancel();
      }, onError: (error) {
        // handle error here.
        print('Subscription error: $error');
      });

    _isAvailable = await _connection.isAvailable();
    if(!_isAvailable) {
      print('The store is not available, try again later..');
      return;
    }
    _myProductsIds = await _categoryRepository.getCategoriesGoogleProductsIds(); 
    await _getProducts();
    await _getPastPurchases();
    for (PurchaseDetails purchase in _purchases) {
      verifyPurchase(purchase.productID);
      if (_isPurchased) {  //Check if product is purchased
        await deliverProduct(); // Give the products on the user
      } else {
         _handleInvalidPurchase(purchase);
      }
    }

我不知道为什么在官方的例子中有ConsumerPurchase,如果平台是android,但是由于这段代码,我的应用程序崩溃了,在重要的行中返回了一个错误“Developer.error”,它们是

var completePurchase = await InAppPurchaseConnection.instance
              .completePurchase(purchaseDetails);
我阅读了completePurchase方法的文档,看到了重要的评论,内容如下:

  /// The [consumePurchase] acts as an implicit [completePurchase] on Android.
  Future<BillingResultWrapper> completePurchase(PurchaseDetails purchase);
//[consumePurchase]在Android上充当隐式的[completePurchase]。
未来完成采购(采购详情采购);
可能应用内购买的版本有更新,在此之后,某些示例没有更新

示例链接:

  /// The [consumePurchase] acts as an implicit [completePurchase] on Android.
  Future<BillingResultWrapper> completePurchase(PurchaseDetails purchase);