我正在使用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;
});
}
});
});
在debug
模式下,流没有发出任何事件,因此购买从未完成并完成。
在release
模式下测试,效果很好。