29

I have defined some in app products in my app. I've uploaded the apk to the Google Play and added the inapp purchase products on the Google play.

I've got my ServiceConnection defined as followed:

ServiceConnection mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            mService = IInAppBillingService.Stub.asInterface(service);
            connect();
        }
    };

The onServiceConnected function is called, the bindService returns true.

Next is the connect function.

public void connect() {
        new Thread(new Runnable() {
            public void run() {
                try {

                    // Purchase type is "inapp", as required by  API v3
                    Bundle skuDetails = mService.getSkuDetails(3, PACKET, "inapp", querySkus);

                    }

                    int response = skuDetails.getInt("RESPONSE_CODE");

                    Log.e("IAP connect", response + "");


                    if (response == 0) {
                        ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
                        Log.e("size list", responseList.size()+"");
                        ...
                      }
                    }
            } catch (RemoteException e) {
                e.printStackTrace();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }).start();
}

PACKET here is set to the getPackageName(). The response code is 0 but the Log prints that the size of the list is 0. I have no idea why the list is empty, as I have entered 5 items in total to the Google Play and each of them are active. I have waited 2 days now and tested with three devices, but still no items get through.

I pretty much tried everything I can think of so any suggestions are welcome.

Gooey
  • 4,740
  • 10
  • 42
  • 76

4 Answers4

51

You need to publish your application to Beta/Alpha to access inapp billing functionality. It has recenty changed, but they did not announce it:)

http://developer.android.com/google/play/billing/billing_testing.html#draft_apps

It is worth to mention that you don't have to upload every new build to be able to test it. Just use the same versionCode and versionName, and it will work if the app is published.

kupsef
  • 3,357
  • 1
  • 21
  • 31
  • That's odd. In another project which runs almost the exact same code, most notably also running Version 3, it uses unmanaged products fine. – Gooey Jul 21 '14 at 11:04
  • It reads indeed "Unmanaged products behave differently if you are using in-app billing v3 rather than in-app billing v2. If you are using in-app billing v3, Unmanaged products are treated as Managed products and will need to be explicitly consumed. Learn more" However, I have not purchased anything yet, and I do run a (redundant) loop that consumes the purchases. – Gooey Jul 21 '14 at 11:07
  • Well, maybe you are right. Then my only idea is that your application is not published. Have you published it to (Beta/Alpha) or is it in Draft? – kupsef Jul 21 '14 at 11:14
  • I am going to delete all my inapp purchases and select the managed product type. I hope it works. My app is currently in draft – Gooey Jul 21 '14 at 11:17
  • Do not delete them. The problem is that your app is in Draft. It has recently changed, you need to publish it to access billing info. – kupsef Jul 21 '14 at 11:19
  • 1
    Shit I just read it now... after I deleted my products. Well this was a hard lesson for me. Thanks for your help! I can give the bounty in 22 hours, so you'll have to wait for it :) – Gooey Jul 21 '14 at 11:31
  • Be aware of the export/import functionality. You could export them, manually edit the type with a text editor, and reimport them. However I'm not sure whether it works for unmanaged items also. – kupsef Jul 21 '14 at 11:32
  • The list is empty, so I can no longer export them. Do you know a way to 'undelete' the product ids? I cannot add them -> "This Product ID has already been used and deleted. It cannot be reused." – Gooey Jul 21 '14 at 11:34
  • I guess you are out of luck. You have to create a new app to use those skus again. Once you publish it, it will stay there. – kupsef Jul 21 '14 at 11:36
  • I see, I guess i'll use new product IDs then :( Thanks! – Gooey Jul 21 '14 at 11:37
  • Gooey, I have same problem. the status of application is Draft but i have uploaded apk in alpha testing section. this is what in google documentation. how did you manage to solve the problem ? plz help – Mohsin Aug 20 '15 at 05:42
  • For those whose app is already published, you still have to upload another release (in beta or alpha or internal tester) for subscriptions to work. – Bugs Happen Mar 17 '20 at 12:03
  • 1
    https://developer.android.com/google/play/billing/test says "License testers can bypass this check, meaning you can sideload apps for testing, even for apps using debug builds with debug signatures without the need to upload to the new version of your app." Some say you do not need to publish the app to test in app purchase. What's the point of getting Google to review your unfinished app just to test in app purchase? – coolcool1994 Aug 16 '20 at 05:33
  • 4
    you do have to publish your app - as my published app started to return the skydetailslist. It's a real beauty. You need to complete in App Store information in GooglePLay and pass Google's review just to test out in-app purchases, which in my opinion is a terrible design as of Sep 9th 2020, but it is how it is. – coolcool1994 Sep 09 '20 at 23:58
  • @coolcool1994 How to know if the app has passed the review process in the new developers console? Is there a label somewhere? I get always an empty list response when querying the products. My testers can download already the app from beta and alpha. – API_1024 Oct 29 '20 at 10:43
27

Your Code looks ok.

Make sure you query the right SKUs. The single items in querySkus must match exactly the id of the in app product.

Second make sure to query the correct type if items. If you configured "in app products" as a car to buy in the developer console, use "inapp" as you did. If you have subscriptions, use "subs" as type of your query against Google Play.

Hope this helps.

2

I had the problem on an old device. Deleting Play Services app data fixed the problem.

So we simply need to get ready for the bad reviews...

Tim Autin
  • 6,043
  • 5
  • 46
  • 76
0

I had the same problem, the fix was setting my subscription status to "active". After a few minutes it finally worked.

Christian C
  • 369
  • 3
  • 10