I'm working on a Flutter application & using the latest version of in_app_purchase to manage In-App Purchase Subscriptions.
I can make a successful subscription purchase & I can get the data needed to store a server-side receipt.
A scenario I am testing is if I were to make a successful purchase but if my server-side data was somehow set to null.
I am checking if my server-side receipt exists first to set the user's app status & if that does not exist I check if there is anything returned on the device level. If so, reset the server data.
This works perfectly on iOS.
On Android, nothing is returned. But I do get the popup that I have an active subscription. So I can't restore or attempt to make another purchase & no purchase detail data is available.
What should I be using to check for known Android subscription purchase data?
Update:
I have recently found this logic, but it is returning empty everytime. Even when I make a subscription, then set myself up to where I need to restore. It tells me there is nothing to restore, but if I try to purchase it tells me I already have a subscription.
_checkAndroidPastPurchases() async {
final InAppPurchaseAndroidPlatformAddition androidAddition = _inAppPurchase
.getPlatformAddition<InAppPurchaseAndroidPlatformAddition>();
final QueryPurchaseDetailsResponse oldpurchases =
await androidAddition.queryPastPurchases();
for (final oldP in oldpurchases.pastPurchases) {
// pastPurchases is empty
}
}
Update on 8/27/22:
I am getting stuck on this line:
Unhandled Exception: type 'PurchaseDetails' is not a subtype of type 'GooglePlayPurchaseDetails' in type cast
Seems I need to get my purchase details as GooglePlayPurchaseDetails but I have no idea how to accomplish this. Any advice is appreciated.