Refund customer in-app purchase but BillingClient still indicate user has purchased?

…衆ロ難τιáo~ 提交于 2019-12-23 12:37:29

问题


I'm using the following BillingClient.

implementation 'com.android.billingclient:billing:1.2.2'

Although I have issued refund as bellow

But I'm still getting the following respond from BillingClient.queryPurchases

{
  "orderId": "GPA.3352-2555-5719-25534",
  "packageName": "com.yocto.wenote",
  "productId": "note_list_promo",
  "purchaseTime": 1560501011137,
  "purchaseState": 0,
  "purchaseToken": "djjneabakdaenkjafajbbclo.AO-J1OzbDNn5WkobYbSqLNzoBokm1F552-CqzfLQuNXK69bhxC-TnOTqdPV1RCl9T2okpSWfRD9RrE0eFhSN8glUbsOM5XUBDRnm_yK2Ohq_uyNuU17i1dc3CBhdeEn9uZCIfD3zY4tF"
}

According to documentation of BillingClient.queryPurchases

Get purchases details for all the items bought within your app. This method uses a cache of Google Play Store app without initiating a network request.

This might be the reason. I try with another function - queryPurchaseHistoryAsync wouldn't help either. According to documentation

Returns the most recent purchase made by the user for each SKU, even if that purchase is expired, canceled, or consumed.

For queryPurchaseHistoryAsync, there are no purchaseState to indicate the following purchase is cancelled!

{
  "productId": "note_list_promo",
  "purchaseToken": "djjneabakdaenkjafajbbclo.AO-J1OzbDNn5WkobYbSqLNzoBokm1F552-CqzfLQuNXK69bhxC-TnOTqdPV1RCl9T2okpSWfRD9RrE0eFhSN8glUbsOM5XUBDRnm_yK2Ohq_uyNuU17i1dc3CBhdeEn9uZCIfD3zY4tF",
  "purchaseTime": 1560501011137,
  "developerPayload": null
}

Google should really provide a non-cached version of queryPurchases.

Any idea what I have done wrong? I don't wish users can continue using paid features, after I have issued the refund.


回答1:


We clear the cache in the following way

private static void clearGooglePlayStoreBillingCacheIfPossible(BillingClient billingClient) {
    billingClient.queryPurchaseHistoryAsync(SkuType.INAPP, (responseCode, purchasesList) -> {
    });

    billingClient.queryPurchaseHistoryAsync(SkuType.SUBS, (responseCode, purchasesList) -> {
    });
}

After that, we will call BillingClient.queryPurchases as usual.

Take note, such cache clearing doesn't happen immediately. It may take as long as 24 hours, for the cache to be cleared. Strangely, this important requirement isn't documented any way.



来源:https://stackoverflow.com/questions/56594713/refund-customer-in-app-purchase-but-billingclient-still-indicate-user-has-purcha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!