17

I was wondering how to detect a refund, or any type of cancelation of an in-app purchase(not a subscription and not a consumable).

I'm currently making my test and when I refund a test in google like that :

enter image description here

The purchase is still present in billingClient.queryPurchaseHistoryAsync() (even in queryPurchase()).

How can I detect such changes and how can I disable my app for refunded users?

Thanks in advance.

Eric
  • 16,397
  • 8
  • 68
  • 76
Ananta
  • 660
  • 1
  • 7
  • 19
  • I'm also getting already refunded purchases through `queryPurchaseHistoryAsync()`. Have you found any info yet? – Jenix Nov 26 '20 at 14:13
  • 1
    I have not solved this problem. But during my research I found that there is a Google API to check that. You have to send a request to check the purchase state. I have not tested it. Maybe this link will help you : https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products – Ananta Nov 27 '20 at 18:48
  • 1
    Thanks for your reply. I'm aware that we could solve this with backend servers and Google API service as you said. But it seems there's no solution without them. Thank you for your confirmation :) – Jenix Nov 27 '20 at 20:39

2 Answers2

0

I do understand your concern regarding refunded items.

If you offer in-app products, you can use the Voided Purchases API to request a list of voided purchases for your in-app products. When a user requests a refund for in-app purchases, you can see what was purchased and take back the refunded digital goods from that user.

To protect you app from refund abuse please use the Protect your apps from refund abuse help guide, for the best practises in protecting your app’s in-app products.

Duna
  • 1,564
  • 1
  • 16
  • 36
  • It returns results of the last 30 days only, so it's not really a 100% solution. – Minas Mina Jan 08 '20 at 20:11
  • 1
    You will not found a solution until Google will implement it. Did you post a bug/feature to google? It would be nice to post a link here. – Duna Jan 21 '20 at 10:47
  • 1
    So, essentially Google forces you to have a backend for your app if you want this functionality, but you have to infer this from reading several obscure sections of their Byzantine documentation. – blimpse Apr 25 '23 at 20:29
-2

Have to tried this function

PurchasesUpdatedListener

Listener interface for purchase updates which happen when, for example, the user buys something within the app or by initiating a purchase from Google Play Store.

void onPurchasesUpdated (int responseCode, 
                List<Purchase> purchases)

Implement this method to get notifications for purchases updates. Both purchases initiated by your app and the ones initiated by Play Store will be reported here.

OnPurchasesUpdated on developer.android

Haseeb Mirza
  • 432
  • 2
  • 7
  • 2
    Yes I have tested this, but if the refund occurs when the app is closed it is never called. – Ananta Oct 02 '18 at 07:21
  • 2
    that listener is for handling the results from launching the purchase flow, and consuming in-app products... the possible response codes for that method are here: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse it doesn't work for detecting refunds afaik.... – Eric Feb 11 '19 at 19:13
  • @Eric Have you found any solution to this? This library is really bad... – Jenix Nov 26 '20 at 14:18
  • @Jenix no, haven't found any solution unfortunately, but it has been a while since then. – Eric Nov 26 '20 at 18:32
  • @Eric I see... That's sad. Thanks anyway! – Jenix Nov 26 '20 at 19:24