Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

in app purchase - Android - queryPurchase() returns an empty list but I purchased an in app product

I have implemented in app products in my app. I can make successful purchase and everything works fine. But in one device, purchase doesn't work although when I try to make a purchase again, I get the response "Product already owned" which shows that the purchase is fine. But queryPurchase() returns an empty purchase list. I've only one email on that device.

public void queryPurchase() {
    Runnable queryPurchaseRequest = getQueryPurchaseRequest();
    executeRequest(queryPurchaseRequest);
}

    private Runnable getQueryPurchaseRequest() {
        return new Runnable() {
            @Override
            public void run() {
                Purchase.PurchasesResult purchasesResult = mBillingClient.queryPurchases(BillingClient.SkuType.INAPP);
                if(purchasesResult.getResponseCode() == BillingResponseCode.OK) {
                    ArrayList<Purchase> purchaseList = new ArrayList<>();
                    purchaseList.addAll(purchasesResult.getPurchasesList());
    
                    if(isSubscriptionSupported()) {
                        Purchase.PurchasesResult subscriptionResult
                                = mBillingClient.queryPurchases(BillingClient.SkuType.SUBS);
    
                        if (subscriptionResult.getResponseCode() == BillingResponseCode.OK) {
                            purchaseList.addAll(subscriptionResult.getPurchasesList());
                        } else {
                            Log.e(TAG, "Got an error response trying to query subscription purchases");
                        }
                    }
                    onQueryPurchasesFinished(purchaseList);
                } else {
                    Utilities.setPurchaseLog("onBilling manager on query purchase request: result unknown
");
    
                }
            }
        };
    }

Note: Billing result, subscription response code everything seems successful. And everything is working perfectly on other devices.

Have anyone any solution? Thanks for your help!

question from:https://stackoverflow.com/questions/65848755/android-querypurchase-returns-an-empty-list-but-i-purchased-an-in-app-produc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...