5

I have a problem with the google play billing. I have an android app consist of in-app purchase there. I maintain the SharedPreference to purchase an app status. If google gave purchase status as success then I maintain boolean value as app purchased.
Problem Scenario: I am a new user for XYZ app, I have paid for premium version. After a successful payment, the app will switch to the premium version. At the same time I go to the google play account and cancel the order. The developer gets 0 price for refunding the price, and as a new user I get a premium version without paying.

Q. How to deal with the purchase status of SKU for google play billing?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Rabindra Acharya
  • 1,868
  • 2
  • 18
  • 32
  • Why this question get downvote? – Rabindra Acharya Apr 22 '19 at 07:53
  • I think this is a great question and I have the same problem. Did you find any answers pls? How to find out whether the user has the item or not? – Namikaze Minato Jun 23 '20 at 00:45
  • I haven't found any solution to that. But I made a simple logic to return the user to the free application if the order is cancelled or refunded. This is manual work. I made a api for refund status. I kept the google order id / refund token for product canceled on my server database. When the user opens the app, first I go to get the list of all refunds, if the user's id matches the order id or google token, then I consume that product for that specific user and make false the status of the purchase. This allows the user to become a free user again and can order it again if interested. – Rabindra Acharya Jun 23 '20 at 01:51
  • I used firebase remote config for keeping the refund order id/token. – Rabindra Acharya Jun 23 '20 at 01:52

2 Answers2

1

You should always do queryPurchases (with Billing Library) or getPurchases (with AIDL) to find the outstanding purchases. Only unlock the premium contents if you found that user has that purchase.

DrPower
  • 445
  • 3
  • 6
  • 1
    queryPurchases Purchase object doesn't gives any information about purchase state, such as declined or pending. . . I am in same problem. – Stav Bodik Oct 15 '19 at 06:20
  • Why not? Say I have the SKU "unlock_premium". Once user refund that SKU, queryPurchases won't return this any more (there might be a delay but eventually it won't be there). – DrPower Nov 07 '19 at 06:48
  • apologize I was using old version of the API, you are correct. – Stav Bodik Nov 10 '19 at 11:27
  • `queryPurchases` doesn't always get the latest purchase updates. – Mohamed Salah May 21 '21 at 19:50
0

Late answer, but I think the strategy is to re-check the purchase status after a grace period. For example, you can save the current time when the switch to premium version happens. After 7 days have passed (or whatever refund window you want to have), check the purchase status again and remove premium features if the result comes negative.

Edit: here is another detailed and relevant answer https://stackoverflow.com/a/34005001/4613031

JGS
  • 51
  • 6
  • 1
    This "relevant" answer is from 2015 and there probably is no way to do this with the `BillingClient` alone. – Martin Zeitler Aug 02 '21 at 22:03
  • You can easily re-check the purchase status using BillingClient alone. It is prone to caching and fraud/abuse though, and using backend validation is the recommended approach by Google https://developer.android.com/google/play/billing/integrate#life – JGS Aug 02 '21 at 23:05
  • It's rather alike this: https://developer.android.com/google/play/billing/rtdn-reference ...meanwhile, in 2021. – Martin Zeitler Aug 03 '21 at 04:02