I'm using the Flutter in_app_purchase plugin, v0.3.3+1
.
While testing on iOS, I began a purchase but cancelled mid-way through. After that, whenever I try the purchase again, I get an exception with this message:
There is a pending transaction for the same product identifier
I have a listener setup on the purchase stream (code below) to complete the purchases. But the stream is not emitting any events.
_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;
});
}
});
});