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 manuelly usingcompletePurchase to avoid edge cases., {applicationUsername: null, requestData: null, quantity: 1, productIdentifier: premium, simulatesAskToBuyInSandbox: null})
in_app_purchase can not open purchase dialog
If you are using the in_app_purchase plugin then before starting a new purchase cycle you need to mark all the previous purchase cycles as complete.
you can use a simple for loop to find all the purchase details and mark them as complete.
for (var _purchaseDetails in purchaseList) {
if (_purchaseDetails.pendingCompletePurchase) {
await _inAppPurchase.completePurchase(_purchaseDetails);
}
}
Remember to use this code before starting the purchase so that no pending purchases are there.
we do same as you say but still getting error. –
Disposed
Try printing the list of purchaseDetails.pendingCompletePurchase –
Bowden
I am also trying this but getting the error occasionally –
Fanchan
How are you getting the
purchaseList
. I am unable to find it. –
Longwinded final purchaseUpdatedStream = _inAppPurchase.purchaseStream; purchaseUpdatedStream.listen((purchaseDetailsList) { completePurchases(purchaseDetailsList); // here is purchaseDetailsList })
–
Palate Before trying to trigger the purchase window, you can call finish transaction on open transactions, and it should help.
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
final transactions = await SKPaymentQueueWrapper().transactions();
for (var transaction in transactions) {
await SKPaymentQueueWrapper().finishTransaction(transaction);
}
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
final transactions = await SKPaymentQueueWrapper().transactions();
for (var transaction in transactions) {
await SKPaymentQueueWrapper().finishTransaction(transaction);
}
i added this but my app crashed and i tried to finish the pending transation it also crashed my app why
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. –
Mitra
You can also clear the old transaction, here’s an example in Flutter using the package in_app_purchase_storekit
Future<void> _clearPendingPurchases() async {
if (isIOS || isMacOs) {
try {
final transactions = await SKPaymentQueueWrapper().transactions();
for (final transaction in transactions) {
try {
await SKPaymentQueueWrapper().finishTransaction(transaction);
} catch (e) {
debugPrint("Error clearing pending purchases::in::loop");
debugPrint(e.toString());
rethrow;
}
}
} catch (e) {
debugPrint("Error clearing pending purchases");
debugPrint(e.toString());
rethrow;
}
}
}
© 2022 - 2024 — McMap. All rights reserved.