Android – In-App Billing test: android.test.purchased already owned

androidin-app-billing

I am currently testing In-App Billing for a future app, and after I successfully "bought" the test item "android.test.purchased" the first time, I now receive the response code 7 every time I try to buy it again, which means that I already own this item.

12-15 23:02:14.149: E/IabHelper(19829): In-app billing error: Unable
to buy item, Error response: 7:Item Already Owned

From what I understand, this purchase is supposed to always be possible, right? So that the developer can test his/her app?

If not, how can I "reset" its state to not owned? I am using the util package from the Google In-App Billing Sample.

Best Answer

Add this code to a thread to initiate consume request.

int response = mService.consumePurchase(3, getPackageName(), purchaseToken);

Here for the purchase test, purchaseToken is

purchaseToken = "inapp:" + getPackageName() + ":android.test.purchased";

And

if (response == 0)

then the consumption is successful.

also don't forget to make mService public in

IabHelper.Java

then it would be possible to access like this:

int response = mHelper.mService.consumePurchase(3, getPackageName(), purchaseToken);
Related Topic