Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android In-App-Billing refund/cancel takes long

)

I'm trying to implement in-app-billing within my app. In the Google Play Developer Console I declared a managed item. Buying this item works really fine. But now, when I refund or cancel the purchase in the google wallet merchant center, my app takes very long (more days) to recognize that the item is not longer owned.

I've already read lots of other articles about this problem and think one logical explanation is that the purchase is saved in the cache of the Google Play Store. Although I know that this question has asked often before, I ask here again:

Is it possible to clear the cache or does anyone know how to tell my app, when the purchase is not longer owned?

I'm thankful for any hint, that helps me to solve this problem :D

In addition, my code where I ask, if the item is purchased. I'm using in-app-billing v3.

public boolean hasUserBoughtItem() {

    try {
        Bundle ownedItems = mService.getPurchases(mUsedAPI, mContext.getPackageName(),
                mPurchaseType, null);

        int response = ownedItems.getInt("RESPONSE_CODE");
        if(response == 0) {
            ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

            if(!ownedSkus.isEmpty()) {
                for(String sku : ownedSkus) {

                    if(sku.equals(Constants.ITEM_ID_ALL_RECIPES)) {
                        return true;
                    }
                }
            } 

            return false;
        }
    } catch(Exception e) {
        e.printStackTrace();
    }

    return false;
}
like image 379
jennymo Avatar asked Oct 07 '13 14:10

jennymo


1 Answers

The IAP purchase inventory isn't cached by the Play Store at all and should be queried regularly in your activities. It should only take approximately 15-30mins for order cancellations to propagate.

Are you using the IABHelper as per the sample app to connect to Google Play?

 IabHelper.QueryInventoryFinishedListener mGotInventoryListener 
   = new IabHelper.QueryInventoryFinishedListener() {
   public void onQueryInventoryFinished(IabResult result,
      Inventory inventory) {

      if (result.isFailure()) {
        // handle error here
      }
      else {
        // does the user have the premium upgrade?
        mIsPremium = inventory.hasPurchase(SKU_PREMIUM);        
        // update UI accordingly
      }
   }
};
like image 145
lovince Avatar answered Oct 04 '22 04:10

lovince