I'm testing my Android app and facing with the "Unable to buy item (response: 7:Item Already Owned)". The item is a "Managed In-app Product" type. I did some research and found this (http://developer.android.com/google/play/billing/api.html#managed):
Managed in-app products are items that have their ownership information tracked and managed
by Google Play. When a user purchases a managed in-app item, Google Play stores the
purchase information for each item on a per-user basis. This enables you to later query
Google Play at any time to restore the state of the items a specific user has purchased.
This information is persistent on the Google Play servers even if the user uninstalls the
application or if they change devices.
If you are using the Version 3 API, you can also consume managed items within your
application. You would typically implement consumption for items that can be purchased
multiple times (such as in-game currency, fuel, or magic spells). Once purchased, a managed
item cannot be purchased again until you consume the item, by sending a consumption request
to Google Play. To learn more about in-app product consumption, see Consuming Items.
...
You can use the consumption mechanism to track the user's ownership of in-app products.
In Version 3, all in-app products are managed. This means that the user's ownership of all
in-app item purchases is maintained by Google Play, and your application can query the
user's purchase information when needed. When the user successfully purchases an in-app
product, that purchase is recorded in Google Play. Once an in-app product is purchased, it
is considered to be "owned". In-app products in the "owned" state cannot be purchased from
Google Play. You must send a consumption request for the "owned" in-app product before
Google Play makes it available for purchase again. Consuming the in-app product reverts it
to the "unowned" state, and discards the previous purchase data.
How can I "send a consumption request" in Codename One?
Assuming that you are using
IabHelper.java
provided by google in its androidSDK
. Following is the path:Below is code for initializing in-app billing, querying google play for user's purchase and consuming the purchase.
Initializing In-app billing.
Query user's purchases
Purchase consumed listener