I'm using purchase state to valid if a user still purchased the product or refund it using:
TransactionDetails.purchaseInfo.purchaseData.purchaseState
But it Always returns PurchasedSuccessfully even after I refund it and after a week
Is there any way I could effectively valid product purchases
under onBillingInit....
try..
bp.loadOwnedPurchasesFromGoogle())
bp.listOwnedPurchases())
its probably caching for you like all the others.
Unfortunately, I tried everything from bp.loadOwnedPurchasesFromGoogle()to bp.listOwnedPurchases() and remove app cache and data from storage.
Nothing worked.
I tried to verify the purchase from the backend using google client API for Android admin and it returns the status as canceled but from the library, it returns purchased.
This library states that in order to check if a product was purchased you should use bp.isPurchased("yourSKU") (please see the following issues #215), the problem with that is, once a products was purchased the SKU will remain valid for that user, no matter what.
I spoke with Google support and they said the only way to check whether a product was cancelled or refunded is to use the Voided Purchase API. So using Oauth2 you will be able to use the products token and Voided Purchase API to check if the product is valid or not.
But this library only uses the SKU, that will always return true when calling bp.isPurchased("yourSKU" after a purchase has been made.
Also, people saying that you should use
@Override
public void onBillingInitialized() {
bp.loadOwnedPurchasesFromGoogle();
bp.listOwnedProducts();
StringBuilder builder = new StringBuilder();
for (String i : bp.listOwnedProducts()) {
builder.append("" + i + " ");
}
Toast.makeText(MainActivity.this, builder, Toast.LENGTH_LONG).show();
}
bp.loadOwnedPurchasesFromGoogle(); will return a boolean, just true or false, thats it. bp.listOwnedProducts(); will return a string array of all the products (SKU's) that you have purchased.
So, tell me, does what you are saying make any sense if Google told me the following:

It is ok to use bp.isPurchased("yourSKU") to check if your product was purchased successfully.
The only feasible way (in my opinion, and Google's opinion) to check the status of you SKU/Token is to make use of the Voided Purchase API.
Can we get a clarification on this? What @HBiSoft wrote makes me very concerned, because user can simply purchase and then make a refund and enjoy the IAP for free basically.
@c0dehunter If you wish not to implement the Voided Purchase API, you are protected (Somewhat). After a purchase was made the buyer has 48hours to request a refund:

Luckily Google keeps track of how many refunds a user has requested and a account can be suspended if the user ask for refunds regularly.
After the 48hours the user can contact the developer, not to be refunded, but to resolve a issue that they have.
Also Google states Google does not give refunds for most Google Play purchases. However there are exceptions. If someone takes the time to request a refund they are likely to uninstall your application and newer install it again.
If you don't like the idea that a very small amount of people might get your application for free, I would suggest you use the Voided Purchases API.
Hopefully this will change in the future, but I doubt it.
Good luck.
Alright, for my use this is fine. Thanks
I found a way to solve this problem
clear all cache before you initialize billingProcess
val sharedPreferences=PreferenceManager.getDefaultSharedPreferences(this)
sharedPreferences.all.entries.filter {
it.key.contains("_preferences.subscriptions")
|| it.key.contains("_preferences.products")
}.forEach { sharedPreferences.edit { remove(it.key) } }
You can figure out how cache work on BillingCache class
@Suki-VT
App info-Storage-CLEAR DATA = free application
Uninstall - Re-install = free application
There is work-arounds yes, but ultimately, the best way is to use Voided Purchase API, especially if your application has a lot of downloads. I have reversed engineered a lot of applications released by big companies and all of them uses the Voided Purchase API.
Applications should never rely on SharedPreferences and Cache alone to handle billing related info.
Most helpful comment
@c0dehunter If you wish not to implement the Voided Purchase API, you are protected (Somewhat). After a purchase was made the buyer has 48hours to request a refund:
Luckily Google keeps track of how many refunds a user has requested and a account can be suspended if the user ask for refunds regularly.
After the 48hours the user can contact the developer, not to be refunded, but to resolve a issue that they have.
Also Google states
Google does not give refunds for most Google Play purchases. However there are exceptions. If someone takes the time to request a refund they are likely to uninstall your application and newer install it again.If you don't like the idea that a very small amount of people might get your application for free, I would suggest you use the Voided Purchases API.
Hopefully this will change in the future, but I doubt it.
Good luck.