2

I am trying to verify whether product is purchased or not from store.

For that I have used the below code :

mHelper.queryInventoryAsync(mGotInventoryListener);

And call back is as mentioned below :

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
        Log.d(TAG, "Query inventory finished.");

        // Have we been disposed of in the meantime? If so, quit.
        if (mHelper == null) return;

        // Is it a failure?
        **if (result.isFailure()) { // This fails in our case**
            complain("Failed to query inventory: " + result);
            return;
        }

    }
};

But every time I am getting same error as shown in below attached screen.

enter image description here

I have tried with below mentioned steps but failed to get success.

  • "base64EncodedPublicKey" verified from our google play account where app is launched in alpha testing mode
  • Application is signed with release keystore
  • "base64EncodedPublicKey" - copied to notepad first and then copy to java file (read somewhere in blogs for this solution) , but that has not work for me.

Can anybody suggest for the same. Please let me know if I need to add something in order to solve this issue?

Nirav Shah
  • 2,064
  • 5
  • 24
  • 34

2 Answers2

1

Are you trying to purchase android.test.purchased or another item? If you are using android.test.purchased, check this answer, it should answer your question: Android in app purchase: Signature verification failed

Community
  • 1
  • 1
user3673952
  • 698
  • 10
  • 30
1

Found the solution :)

There was an issue with registering a broadcast receiver.

Plese find below code of startSetup method which is registering broadcast receiver that was missing from the following snippet.

mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {   public void onIabSetupFinished(IabResult result) {
  if (!result.isSuccess()) {
     // Oh noes, there was a problem.
     Log.d(TAG, "Problem setting up In-app Billing: " + result);
  }  mBroadcastReceiver = new IabBroadcastReceiver(MainActivity.this);
            IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
            registerReceiver(mBroadcastReceiver, broadcastFilter);
     // Hooray, IAB is fully set up!   }});
Nirav Shah
  • 2,064
  • 5
  • 24
  • 34