Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using the following BillingClient.

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

Although I have issued refund as bellow

enter image description here

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.

like image 280
Cheok Yan Cheng Avatar asked Jun 14 '19 08:06

Cheok Yan Cheng


1 Answers

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.

like image 167
Cheok Yan Cheng Avatar answered Sep 21 '22 19:09

Cheok Yan Cheng