2

i am developing a app in android using in app subscription. i am trying to query my purchase items using IabHelper.QueryInventoryFinishedListener. but it always coming as a failure results. IabResult returns failure. i added in app products in developer console. can any one help me on this?

here is some of my code,

bindService(new  Intent("com.android.vending.billing.InAppBillingService.BIND"),
                        mServiceConn, Context.BIND_AUTO_CREATE);

String base64EncodedPublicKey = "my key";                                        

mHelper = new IabHelper(this, base64EncodedPublicKey);
        mHelper.enableDebugLogging(true);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
               public void onIabSetupFinished(IabResult result) {
                  if (!result.isSuccess()) {
                      System.out.println("Not Success");                      
                     Log.d("In APP Billing", "Problem setting up In-app Billing: " + result);
                     return;
                  } else {
                      System.out.println("Success");
                      Log.d(" In APP Billing", "Setting up In-app Billing Success: " + result);
                  }

                  List<String> additionalSkuList = new ArrayList<String>();
                  additionalSkuList.add(SKU_ID);                  

                  mHelper.queryInventoryAsync(true, additionalSkuList,
                           mQueryFinishedListener);

               }


});     

    IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {

        @Override
        public void onQueryInventoryFinished(IabResult result, Inventory inv) {
            // TODO Auto-generated method stub

            if (result.isFailure()) {
                 // handle error
                System.out.println("mQueryFinishedListener is Failure"); // i am always getting this
                 return;
            }
            System.out.println("mQueryFinishedListener is Success");


            Boolean hasPur = inv.hasPurchase(SKU_ID);

            if (hasPur) {
                System.out.println("Query - - subscribed ");
                isSubscribed = true;
            } else {
                System.out.println("Query - not subscribed ");
                isSubscribed = false;
            }

            System.out.println("Purchase panic:"+inv.getPurchase(SKU_ID));

        }
};

any idea why its not working? thanks in advance.

Amarnath
  • 1,091
  • 3
  • 19
  • 32
  • Sorry, I validated my answer and figured it was wrong. What device are you testing your code on? Are you sure the Google Play on the device supports IAB V3 (introduced half a year ago or so)? – class stacker Apr 10 '13 at 06:48
  • i am using galaxy y. it worked 2 days before. i changed some coding now. but im not sure about this. due to some reasons its not working. – Amarnath Apr 10 '13 at 06:58
  • Which call is exactly failing? And which status code do you get? – class stacker Apr 10 '13 at 06:59
  • IabHelper.QueryInventoryFinishedListener has a method onQueryInventoryFinished. i am getting result.isFailure() in this method – Amarnath Apr 10 '13 at 07:13
  • `result.isFailure()` is not a status code, it's a method that is applied to the status and yields a `boolean`. So what is the status code? – class stacker Apr 10 '13 at 07:49
  • could you please, tell me how can i get the result code? – Amarnath Apr 10 '13 at 08:54
  • Hi, error code:-1003 message:Error refreshing inventory (querying owned subscriptions). (response: -1003:Purchase signature verification failed) – Amarnath Apr 10 '13 at 09:07
  • 1
    See http://stackoverflow.com/a/9193392 – class stacker Apr 10 '13 at 09:12
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/27942/discussion-between-amarnath-and-class-stacker) – Amarnath Apr 10 '13 at 12:32

1 Answers1

2

To work with in app subscription i think you will gave to call "launchSubscriptionPurchaseFlow()" method on IabHelper instance you create.

    mHelper.launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode,
        OnIabPurchaseFinishedListener listener, String extraData);

OR

mHelper.launchPurchaseFlow(Activity act, String sku, String itemType, int requestCode,
                OnIabPurchaseFinishedListener listener, String extraData);

Where itemType = IabHelper.ITEM_TYPE_SUBS

Vikas Rathod
  • 374
  • 2
  • 14