Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check purchase history after delete and reinstall application

I am developing an application which will allow user to purchase using In App Purchase and I want to remove ads after purchase. I can purchase succesfully with code below

BillingFlowParams flowParams = BillingFlowParams.newBuilder()
                        .setSku("android.test.purchased")
                        .setType(BillingClient.SkuType.INAPP)
                        .build();
mBillingClient.launchBillingFlow(getActivity(), flowParams);

But I cannot see the result from queryPurchaseHistoryAsync when I open app again and call this method below.

mBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener() {
            @Override
            public void onPurchaseHistoryResponse(int responseCode, List<Purchase> purchasesList) {

                purchasesList.size();
            }
        });

purchasesList.size() == 0

Is "queryPurchaseHistoryAsync" method cannot show test purchase or Am I doing something wrong?

Edit: Is queryPurchaseHistoryAsync method check purchase after delete and install app again.

like image 713
6155031 Avatar asked Nov 07 '22 20:11

6155031


1 Answers

Yes queryPurchaseHistoryAsync method check purchase after deleting and installing the app again against particular user

mBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener() {
        @Override
        public void onPurchaseHistoryResponse(@NonNull BillingResult billingResult, @Nullable List<PurchaseHistoryRecord> list) {
            
        }
    });
like image 143
Muhammad Bilal Avatar answered Nov 14 '22 22:11

Muhammad Bilal