How to detect refund with google billingclient library
Asked Answered
P

3

18

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.

Pontifical answered 24/9, 2018 at 17:36 Comment(3)
I'm also getting already refunded purchases through queryPurchaseHistoryAsync(). Have you found any info yet?Briscoe
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 : developers.google.com/android-publisher/api-ref/rest/v3/…Pontifical
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 :)Briscoe
I
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.

Intergrade answered 6/1, 2020 at 8:19 Comment(3)
It returns results of the last 30 days only, so it's not really a 100% solution.Kaylee
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.Intergrade
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.Ind
D
0

Use Voided Purchases API

This API applies to one-time in-app orders and App Subscriptions.

A purchase can be voided in the following ways:

  • The user requests a refund for their order.
  • The user cancels their order.
  • An order is charged back.
  • Developer cancels or refunds order.

This is not very convenient but it is the only way to ensure fair treatment of all users. Also it will give you the reason of refund, which maybe a very valuable info:

0. Other 
1. Remorse 
2. Not_received 
3. Defective 
4. Accidental_purchase 
5. Fraud 
6. Friendly_fraud 
7. Chargeback
Danikadanila answered 14/11, 2023 at 21:42 Comment(0)
H
-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

Hyperpyrexia answered 2/10, 2018 at 3:12 Comment(5)
Yes I have tested this, but if the refund occurs when the app is closed it is never called.Pontifical
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: developer.android.com/reference/com/android/billingclient/api/… it doesn't work for detecting refunds afaik....Orgulous
@Orgulous Have you found any solution to this? This library is really bad...Briscoe
@Briscoe no, haven't found any solution unfortunately, but it has been a while since then.Orgulous
@Orgulous I see... That's sad. Thanks anyway!Briscoe

© 2022 - 2024 — McMap. All rights reserved.