gpt4 book ai didi

flutter :storekit_duplicate_product_object。同一产品标识符有待处理的交易

转载 作者:行者123 更新时间:2023-12-04 12:29:24 25 4
gpt4 key购买 nike

我正在使用应用内购买官方插件。但是当我尝试在 iOS 上购买订阅时,我看到以下错误:

Unhandled Exception: PlatformException(storekit_duplicate_product_object, There is a pending transaction for the same product identifier. Please either wait for it to be finished or finish it manually using `completePurchase` to avoid edge cases., {applicationUsername: null, requestData: null, quantity: 1, productIdentifier: in_app_test, simulatesAskToBuyInSandbox: false}, null)
我正在使用版本 in_app_purchase: ^0.5.2 in_app_purchase 包的
我调用它的代码看起来像这样:
   TextButton(
child: Text(productDetails.price),
style: flatButtonStyle,
onPressed: () async {
PurchaseParam purchaseParam = PurchaseParam(
productDetails: productDetails,
applicationUserName: null,
sandboxTesting: false);
if (productDetails.id == _kConsumableId) {
_connection.buyConsumable(
purchaseParam: purchaseParam,
autoConsume: kAutoConsume || Platform.isIOS);
} else {
_connection.buyNonConsumable(
purchaseParam: purchaseParam);

}},
)

最佳答案

请关注 #60763
您可以使用 SKPaymentQueueWrapper().finishTransaction(skPaymentTransactionWrapper) 完成交易这些交易
为了避免这个错误,把下面的代码放在 buyNonConsumable 之前和工作:

var transactions = await SKPaymentQueueWrapper().transactions();
transactions.forEach((skPaymentTransactionWrapper) {
SKPaymentQueueWrapper().finishTransaction(skPaymentTransactionWrapper);
});
完整示例
TextButton(
child: Text(productDetails.price),
style: flatButtonStyle,
onPressed: () async {
PurchaseParam purchaseParam = PurchaseParam(
productDetails: productDetails,
applicationUserName: null,
sandboxTesting: false);
if (productDetails.id == _kConsumableId) {
_connection.buyConsumable(
purchaseParam: purchaseParam,
autoConsume: kAutoConsume || Platform.isIOS);
} else {
_connection.buyNonConsumable(
purchaseParam: purchaseParam);
var transactions = await SKPaymentQueueWrapper().transactions();
transactions.forEach((skPaymentTransactionWrapper) {
SKPaymentQueueWrapper().finishTransaction(skPaymentTransactionWrapper);
});
}
},
)
答案来源 siloebb's answer

关于 flutter :storekit_duplicate_product_object。同一产品标识符有待处理的交易,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67367861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com