Flutter:购买流为空,并且尝试购买会引发“同一商品标识符的待处理交易”

问题描述 投票:0回答:1

我正在使用Flutter in_app_purchase插件,v0.3.3 + 1。

[在iOS上进行测试时,我开始进行购买,但在中途取消。之后,每当我再次尝试购买时,都会出现此消息异常:

There is a pending transaction for the same product identifier

我在购买信息流(下面的代码)上设置了一个监听器,以完成购买。但是流没有发出任何事件。

_purchaseListener = InAppPurchaseConnection.instance.purchaseUpdatedStream.listen((purchases) {
  purchases.forEach((purchase) async {
    if (purchase.status == PurchaseStatus.purchased) //...
    if (purchase.pendingCompletePurchase) {
      //Complete purchase (retrying as Google Play refunds after 3 days if this does not succeed)
      retry<BillingResultWrapper>(() async {
        final completion = await InAppPurchaseConnection.instance.completePurchase(purchase);
        const errors = {BillingResponse.error, BillingResponse.serviceUnavailable};
        if (errors.contains(completion.responseCode)) throw Exception();
        return completion;
      });
    }
  });
});
flutter in-app-purchase in-app-billing
1个回答
0
投票

debug模式下,流没有发出任何事件,因此购买从未完成并完成。

release模式下测试,效果很好。

© www.soinside.com 2019 - 2024. All rights reserved.