flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[in_app_purchase] Status change from pending to error missing

Open bworwa opened this issue 5 years ago • 4 comments

Steps to Reproduce

Having the following:

final InAppPurchaseConnection _connection = InAppPurchaseConnection.instance;
StreamSubscription<List<PurchaseDetails>> _subscription;

_subscription = _connection.purchaseUpdatedStream.listen((purchaseDetailsList) async {
  if (purchaseDetails.status == PurchaseStatus.pending) {
    print('pending');
  } else {
    if (purchaseDetails.status == PurchaseStatus.purchased) {
      print('purchased');
    } else {
      print(purchaseDetails.status);
    }
  }
}, onDone: () {
  _subscription.cancel();
}, onError: (error) {
  // TODO: handle error here.
});

await _connection.isAvailable();

final Future<ProductDetailsResponse> _products = _connection.queryProductDetails({==my ids==});
  1. Let's assume products' ids are ok.
  2. Let's assume we trigger the buy by:
_connection.buyConsumable(
 purchaseParam: PurchaseParam(productDetails: product),
 autoConsume: true,
);
  1. If we select "test card, always declines" as payment method (PM) we get PurchaseStatus.error as expected.
  2. If we select "test card, always approves" as PM, we get purchased as expected.
  3. If we select "slow test card, approves after a few minutes" as PM, we get pending and after a couple of minutes we get purchased, as expected.
  4. If we select "slow test card, declines after a few minutes" as PM:

Expected results: as far as I know, we should get pending and after a couple of minutes PurchaseStatus.error.

Actual results: pending, no other event is fired, no matter how long we wait.

Logs
Analyzing...
No issues found! (ran in 19.9s)
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
    • Flutter version 1.20.4 at C:\Flutter\src\flutter
    • Framework revision fba99f6cf9 (12 days ago), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2


[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\user\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

bworwa avatar Sep 26 '20 17:09 bworwa

@bworwa can confirm on flutter 2.0.6. and in_app_purchase 1.0.0

quambene avatar May 29 '21 12:05 quambene

@bworwa can confirm on flutter 2.2.3 and in_app_purchase 1.0.6

deengel avatar Jul 29 '21 00:07 deengel

Hi, any update on this? Have been facing the same issue. Without the status it is difficult to handle the error & loading state for it.

vineesh-tartlabs avatar Jul 02 '24 07:07 vineesh-tartlabs

While not exactly the same problem if the user cancels the dialog box on Android I get PurchaseStatus.cancel but on iOS I get PurchaseStatus.pending which runs my pending code by mistake.

The same reproducible code above should demonstrate the issue. I am looking into a work around but the only choice I seem to have at the moment is to remove the pending logic when in iOS.

penhorwood avatar Nov 23 '24 03:11 penhorwood

any updates on this.

ZoftPranav avatar Dec 03 '24 12:12 ZoftPranav