• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps In App billing issue

WillNy3

Lurker
I have been trying to implement in app purchases and have followed the tutorials to the best of my ability. However, I am getting some odd bugs. The purchase shows as being successful but doesn't seem to be consuming the item. Also, after the purchase succeeds the first time the OnIabPurchaseFinishedListener is failing but from what I've read that could be related to the item not being properly consumed. I am getting error code 7: unable to purchase since item is already owned Here is what I've got:

Java:
        public void consumeItem(String chipType) {
            if (chipType.equals(itemOne)) {
                Log.v("oneChip", "Attempting to query inventory");
              ChipUpdate.updateChipCount(2500);
                mHelper.queryInventoryAsync(mReceivedInventoryListenerOne);
                Log.v("oneChip", "Inventory Queried");
            }
        }
  
        IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
            public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
                if (result.isFailure()) {
                    Log.v("Chip", "Listener Failed");
                    consumeItem("oneChip");
                        return;
                }
            }
        };
  
        IabHelper.OnConsumeFinishedListener mConsumeFinishedListenerOne =
                 new IabHelper.OnConsumeFinishedListener() {
                  public void onConsumeFinished(Purchase purchase,
                        IabResult result) {
                if (result.isSuccess()) {          
                        Log.v("oneChip", "Update passed");                
                } else {
                    Log.v("oneChip", "Update failed");
                    }
             }
            };
            IabHelper.QueryInventoryFinishedListener mReceivendInventoryListenerOne = new IabHelper.QueryInventoryFinishedListener() {
                public void onQueryInventoryFinished(IabResult result,
                        Inventory inventory) {
                    if (result.isFailure()) {
                        Log.v("oneChip", "Query failed");
                        // Handle failure
                    } else {
                        Log.v("oneChip", "Query passed");          
                      ChipUpdate.updateChipCount(2500);
                        mHelper.consumeAsync(inventory.getPurchase(itemOne),
                                mConsumeFinishedListenerOne);
                    }
                }
            };
        public void oneChip(String noVal){
            Log.v("oneChip", "Calling launch purchase flow");
            mHelper.launchPurchaseFlow(this, itemOne, 10001,
                  mPurchaseFinishedListener, "mypurchasetoken");
            Log.v("oneChip", "made it through launch purchase flow");
      }
Any help would be awesome, thanks! Also, sorry for the formatting not sure how it works on here, I tried ctrl + k but no luck (sorry I'm a bambi on here)
 
Last edited by a moderator:
Hi @WillNy3 and welcome to Android Forums :)

I'm afraid I'm not a developer so I can't help with your question, but I can help by wrapping your code excerpt in [code=java]...[/code] tags to make it a bit easier to read. :thumbsupdroid:

Good luck!
 
Back
Top Bottom