Flutter's in_app_purchase
plugin has been updated to version 0.3.0
, migrating the Google Play Library to 2.0.3
.
According to the Google Play Library v2, all purchases have to be acknowledged within 3 days (or 5 minutes in the case of test orders) or they will be canceled automatically.
In the latest commit of in_app_purchase
, a method called acknowledgePurchase
is added to the BillingClient
class.
However, the current documented way of making an in-app purchase is via InAppPurchaseConnection.instance
which does not provide any method to acknowledge a purchase.
A generic implementation of in_app_purchase
looks like this:
// Listening for new purchases
final Stream purchaseUpdates = InAppPurchaseConnection.instance.purchaseUpdatedStream;
StreamSubscription<List<PurchaseDetails>> _subscription = purchaseUpdates.listen((purchases) {
_handlePurchaseUpdates(purchases);
});
// Product Details
ProductDetailsResponse _productDetailsResponse = await InAppPurchaseConnection.instance.queryProductDetails(this.productIDs.toSet());
// Past Purchases
QueryPurchaseDetailsResponse _purchaseDetailsResponse = await InAppPurchaseConnection.instance.queryPastPurchases();
// Making an nonConsumable purchase
PurchaseParam param = PurchaseParam(
productDetails: productDetails,
applicationUserName: null,
sandboxTesting: sandboxTesting
);
InAppPurchaseConnection.instance.buyNonConsumable(purchaseParam: param);
Once the purchase is made and verified, the product is delivered. But how can we acknowledge the new purchases while listening for new purchases and acknowledge the old ones (if they are not acknowledged) while getting the list of past purchases?