简体   繁体   中英

Google Play Billing method “queryPurchaseHistoryAsync” not getting all purchases

I have 4 subscription types in the app I'm developing. Two monthly (one with discount) and two yearly (one with discount). I am in the testing step. When I ask the purchases history I am not getting all the lasts subscriptions of each type as the documentation says. And also the purchases I get are not the lasts of each SKU type. Did anyone have this issue?

It's giving me problems with grace period as I don't get the last purchase I did so I don't get the updated expiry time.

I checked Google Play Console order management and I see the purchases, and also in my Google Play app, so I don't know what's the problem?

It's difficult to understand your situation without you providing a code snippet. But here is a general implementation of queryPurchaseHistoryAsync . If you are still having problems, please provide more context such as your actual code snippet and where you are making the call. For the following snippet -- just for testing -- I am making the call right before I call queryPurchases .

private fun queryPurchaseHistoryAsync(){
    playStoreBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.SUBS){
        responseCode, purchasesList ->
        if(purchasesList.isNullOrEmpty()){
            Log.d(LOG_TAG,"history for SUBS is empty")
        }else{
            Log.d(LOG_TAG,"history subs has ${purchasesList.size} items : ${purchasesList.toString()}")
        }
    }
    playStoreBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP){
        responseCode, purchasesList ->
        if(purchasesList.isNullOrEmpty()){
            Log.d(LOG_TAG,"history for INAPP is empty")
        }else{
            Log.d(LOG_TAG,"history INAPP has ${purchasesList.size} items : ${purchasesList.toString()}")
        }
    }
}

Also in my cases, I have no problem getting the purchase histories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM