title: android: Inapp billing: Error response: 7:Item Already Owned
body: <p>I am learning to implement an in-app billing for my app such that people can for example, donate $ when press the donate button. </p>
  
  <p>The user is allowed to donate more than one time, i.e. the purchase is consumable.</p>
  
  <p>The codes below are sourced from the TrivalDrive sample and some tutorials from the web:</p>
  
  <h2>Code:</h2>
  
  <pre><code>IabHelper mHelper;
  static final String ITEM_SKU = "android.test.purchased"; 
  
  @Override
  protected void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_in_app_billing);
  
      buy10Button = (Button) findViewById(R.id.buy10Button); 
      buy15Button = (Button) findViewById(R.id.buy15Button); 
      buy20Button = (Button) findViewById(R.id.buy20Button);      
  
      String base64EncodedPublicKey = "keykeykey";
  
      mHelper = new IabHelper(this, base64EncodedPublicKey);
  
  
      mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() 
      {
            public void onIabSetupFinished(IabResult result) 
            {
              if (!result.isSuccess()) 
              {
                 Log.d(TAG, "In-app Billing setup failed: " + result);
                 return;
              } 
              if (mHelper == null) 
              {
                  return;
              }          
              Log.d(TAG, "In-app Billing is set up OK");
            }
      });     
  }
  
  public void buy10Click(View view) 
  {
      mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001,  mPurchaseFinishedListener, "");
  }
  
  public void buy15Click(View view) 
  {
  
  }
  
  public void buy20Click(View view) 
  {
  
  }   
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) 
  {
      if (mHelper == null) return;  
      if (!mHelper.handleActivityResult(requestCode, resultCode, data)) 
      {     
          super.onActivityResult(requestCode, resultCode, data);
      }
  }
  
  IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() 
  {
      public void onIabPurchaseFinished(IabResult result, Purchase purchase) 
      {
          if (mHelper == null) return;
          if (result.isFailure()) 
          {
             // Handle error
                 return;
          }      
          else if ((purchase.getSku().equals(ITEM_SKU)))   
          {
             consumeItem();
          }              
      }
  };
  
  public void consumeItem() 
  {
      mHelper.queryInventoryAsync(mReceivedInventoryListener);
  }
  
  IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener = new IabHelper.QueryInventoryFinishedListener() 
  {
      public void onQueryInventoryFinished(IabResult result, Inventory inventory) 
      {
          if (mHelper == null) return;
          if (result.isFailure()) 
          {
              // Handle failure
          } 
          else 
          {
              mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU), mConsumeFinishedListener);
          }
      }
  };
  
  IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() 
  {
      public void onConsumeFinished(Purchase purchase, IabResult result) 
      {
          if (mHelper == null) return;
          if (result.isSuccess()) 
          {
              Toast.makeText(InAppBillingActivity.this, "Thank you for your donation!!", Toast.LENGTH_LONG).show();   
          } 
          else 
          {
              // handle error
          }
      }
  };
  </code></pre>
  
  <h2>Question:</h2>
  
  <p>Yet I keep on receiving <code>E/IabHelper(13392): In-app billing error: Unable to buy item, Error response: 7:Item Already Owned</code> error and that the payment dialog of the Google Play just does not popup. </p>
  
  <p>I have researched and found out many similar situations, some suggested to wait for a few minute and then the purchase will be reset by itself, but I have waited for almost an hour but it still sucks. </p>
  
  <p>I have also found that someone suggest to change the IabResult     <code>public boolean isSuccess() { return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK; }</code> to return also the <code>BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED</code> as isSuccess =  true, yet i dont know how to amend such...</p>
  
  <p>How could the problem be fixed? Thanks!!</p>