In App Billing Library doesn't provide the Updated PurchaseList after Consuming the Purchase Item?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



In App Billing Library doesn't provide the Updated PurchaseList after Consuming the Purchase Item?



I am currently Implementing in App Purchase using In App Billing Library,



After Consuming the Purchased Item using method :


mBillingClient.consumeAsync(purchaseToken, new ConsumeResponseListener()
@Override
public void onConsumeResponse(int responseCode, String purchaseToken)
if (responseCode == BillingClient.BillingResponse.OK)
Toast.makeText(getApplicationContext(), "Item Consumed Successfully..." + purchaseToken, Toast.LENGTH_LONG).show();


);
break;



when I open the app again and want to Retrieve the list of the Purchases List using the Method:


mBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener()
@Override
public void onPurchaseHistoryResponse(int responseCode, List<Purchase> purchasesList)
if (responseCode == BillingClient.BillingResponse.OK)
purchases = purchasesList;
retrieveItemList();


);



It also provides me the Item which I have consumed in the list. So, help me to find what i'm doing wrong to get the updated purchase List.
Thanks.




1 Answer
1



You just have to use queryPurchase method instead of queryPurchaseHistoryAsync as below:


queryPurchase


queryPurchaseHistoryAsync


mBillingClient.queryPurchase(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener()
@Override
public void onPurchaseHistoryResponse(int responseCode, List<Purchase> purchasesList)
if (responseCode == BillingClient.BillingResponse.OK)
purchases = purchasesList;
retrieveItemList();


);



Difference between both the method is that queryPurchaseHistoryAync will provide you the list of all the items you have purchased in your lifetime, even after the purchased item is used; while queryPurchase will provide you the list of currently purchased items.


queryPurchaseHistoryAync


queryPurchase






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard