android-inapp-billing-v3
android-inapp-billing-v3 copied to clipboard
isPurchased returns false on every screen even after product purchased successfully
I am using this library to purchase products on different fragments. I have a baseFragment that calls the billing processor from the HomeActivity in every fragment I need the billingProcessor. I am facing an issue where even if after successful purchase of products I am still getting the boolean value from billingProcessor.isPurchased as false. I have tested with both, the static responses provided by Google and test purchases, but I am getting isPurchased as false in every condition.
I had similar issues with isSubscribed() but it would always return TRUE after a subscription was purchased.. even well after the subscription was cancel or expired.
I am having this issue with one time purchases. It is returning false every time even if purchased by "android.test.purchased". For subscription, it takes up to 24 hours to reflect.
This is because isPurchased() and isSubscribed() uses the values in the Shared Preferences file.. they DO NOT check the current status with Google.
I now use the following code to get the CURRENT status from Google.
boolean purchaseResult = bp.loadOwnedPurchasesFromGoogle();
if(purchaseResult){
TransactionDetails subscriptionTransactionDetails = bp.getSubscriptionTransactionDetails("widget_subscription");
if(subscriptionTransactionDetails!=null) {
//User is still subscribed
Log.d("BILLING ", "Subscription is valid");
} else {
//Not subscribed
Log.d("BILLING ", "Subscription is NOT valid");
}
You should be checking autoRenewing flag:
https://github.com/anjlab/android-inapp-billing-v3#handle-canceled-subscriptions