Reputation: 3667
I am testing in-app-billing on Android. I am able to purchase the managed products and I get the expected response from the server. However when I try to re-buy the managed product from same device , I don't get any response from google play.
When re-buying I do get the popup message titled "Item already purchased", but then there's no response.But the amazing thing is i got response all time earlier.Even if i am trying to re buy same product from same device. Can anyone help me to resolve the issue?
Also is there any way to check if a product is already purchased or not?
Code :
@Override
public void onPurchaseStateChange(PurchaseState purchaseState,
String itemId, int quantity, long purchaseTime,
String developerPayload) {}
onPurchaseStateChange() function was not called when I tried to re-buy.
Only got a RESULT_ERROR response to onRequestPurchaseResponse() from google play.But i am I am able to purchase the product on first time and got PurchaseState.PURCHASED status.In the case of re-buying no state is returned. Is this due to a server error associated with Google Play?
Upvotes: 0
Views: 1373
Reputation: 3654
You're not supposed to re-buy managed items. If you want to sell something more than once use an unmanaged item.
RESULT_ERROR in response to an attempt to re-buy something you already own seems reasonable. You aren't going to request a Purchase State Changed message if no purchase has occurred.
Are you sure you haven't changed the item you're using from unmanaged to managed? Or maybe you were using a test product and now you are using an actual product? (You can buy android.test.purchased over and over)
Your app should be keeping track of the purchases that have been made so that you can mark managed items as purchased to prevent the user trying to repurchase them (and so they know they have already purchased them).
The only time you need to check if a user already owns any of your managed items is if they reinstall your app. In that case you make a Restore Transactions call and update the apps local record of what has been purchased.
Upvotes: 1