Question: Everything is working on Android with the new implementation of `in_app_purchase` (<https://pub.dev/packages/in_app_purchase>) but on iOS I don't get past purchases. Following the documentation I don't see anything special.

My code is:

```
final Stream<List<PurchaseDetails>> purchaseUpdated =
          inAppPurchase.purchaseStream;

      _subscription = purchaseUpdated.listen((purchaseDetailsList) {
        if (purchaseDetailsList.isEmpty) {
          Provider.of<AdState>(context, listen: false).toggleAds(context, true);
        } else {
          Provider.of<AdState>(context, listen: false)
              .toggleAds(context, false);
          this.purchases.addAll(purchaseDetailsList);
          listenToPurchaseUpdated(purchaseDetailsList);
        }
      }, onDone: () {
        _subscription.cancel();
      }, onError: (error) {
        // handle error here.
      });

      inAppPurchase.restorePurchases();

```

It just doesn't go in and if I try to buy same product I get this error:

> 
> 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
> 
> 
>

Answer: 
You need to call `_inAppPurchase.completePurchase(purchase);` to complete it. [Code here:](https://github.com/flutter/plugins/blob/d5b65742487f64166a73f116b925ce800c45dcd7/packages/in_app_purchase/in_app_purchase/example/lib/main.dart#L245-L247)

```dart
if (purchase.pendingCompletePurchase) {
  _inAppPurchase.completePurchase(purchase);
}

```

You also need to call it every time your app is opened to ensure that all payments have been completed, **it's very important**, remember to check `purchase.pendingCompletePurchase` before calling it.

Btw, I prefer `flutter_inapp_purchase` over `in_app_purchase` because I also had some unexpected issues with it in iOS.
I opened a ticket on the repo and it was fixed on version 1.0.9:
<https://github.com/flutter/flutter/issues/89950>