Android InApp Billing v3 - multi-device testing

I ran into one problem on Android InApp billing v3. I created the inapp managed product in the playstore and I need to buy it several times from multiple devices. To do this, I am testing the application on two different devices. I do not store purchase data on the local server. Therefore, whenever I need to buy this item again, I will ask for the item to get the purchase status, and based on this, if I buy the purchased product, I will call the purchase function again. I describe my error scenario in detail below

  • On the first devices , I did with payment, and I got the result of success.
  • On the same device, if I ask for the purchase details, it will give accurate information.
  • At the same time, if I request on the second device . it gives inventory.hasPurchase(sku) as false and inventory.getPurchase(sku) as null .

While googling, I found that it was related to the Google cache file and all. After clearing the cache manually, I get the result as expected. Can anyone advise me on the above issue.

 IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { invokePurchaseError(ResponseCode.FAILED_TO_QUERY_INVENTORY, result.toString()); } else{ if(mActionCode == RC_REQUEST_FOR_QUERYING){ boolean mIsPurchased = false; Log.e("hasPurchase", inventory.hasPurchase(mSku)+""); Log.e("getPurchase", inventory.getPurchase(mSku)+""); if( inventory.hasPurchase(mSku)){ mPurchaseStatus = inventory.getPurchase(mSku); mIsPurchased = (mPurchaseStatus != null && verifyDeveloperPayload(mPurchaseStatus)); if(mPurchaseStatus!=null){ mPurchaseStatus.getOriginalJson()); } else{ //Not purchased } } } } }; 
+5
source share
1 answer

I had the same problem: I bought a managed item on the first device, but the second and third could not "know" about it. The solution was simple for me, though: As a first step, I cleared the PlayStore caches on all the devices involved (not sure if it was necessary, though ..) Secondly, I bought the item again on the first device, but again the others, it seems have not received the information. I gave the whole β€œsystem” for a while (about 10-15 minutes) and ran a second check on device 2 and 3. And - lo and behold! - they finally got the correct information hasPurchase = true .

0
source

Source: https://habr.com/ru/post/1206543/


All Articles