android-inapp-billing-v3 icon indicating copy to clipboard operation
android-inapp-billing-v3 copied to clipboard

isPurchased returns false on every screen even after product purchased successfully

Open kartikj07 opened this issue 5 years ago • 4 comments

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.

kartikj07 avatar May 30 '19 10:05 kartikj07

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.

wishie avatar May 30 '19 12:05 wishie

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.

kartikj07 avatar May 30 '19 13:05 kartikj07

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");
    }

wishie avatar May 31 '19 00:05 wishie

You should be checking autoRenewing flag:

https://github.com/anjlab/android-inapp-billing-v3#handle-canceled-subscriptions

c0dehunter avatar Sep 13 '19 12:09 c0dehunter