[in_app_purchase] Status change from pending to error missing
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==});
- Let's assume products' ids are ok.
- Let's assume we trigger the buy by:
_connection.buyConsumable(
purchaseParam: PurchaseParam(productDetails: product),
autoConsume: true,
);
- If we select "test card, always declines" as payment method (PM) we get
PurchaseStatus.erroras expected. - If we select "test card, always approves" as PM, we get
purchasedas expected. - If we select "slow test card, approves after a few minutes" as PM, we get
pendingand after a couple of minutes we getpurchased, as expected. - 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 can confirm on flutter 2.0.6. and in_app_purchase 1.0.0
@bworwa can confirm on flutter 2.2.3 and in_app_purchase 1.0.6
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.
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.
any updates on this.