Search code examples
androidin-app-purchasein-app-billingnokianokiax

Nokia X IAP getProductDetails() and getPurchases() error for published product


I'm trying to add Nokia IAP in my app and following the exact code as stated in Nokia In-App Payment Guide.

I've tested with test IDs, I can get product details and also I can purchase the item. But with an actual product, with a Published (revision 7) publication status, although I can purchase it using the getBuyIntent() method, I cannot get product details. I'm using the method getProductDetails() inside an AsyncTask doInBackground() method. And I'm getting the response from the returned bundle via:

ArrayList<String> responseList = result.getStringArrayList("DETAILS_LIST");

The responseList size is 1, and it contains the 7-digit product ID looks like:

{"isvalid":false,"productId":"*******"}

But it should contain the product details with price, right?

Also when I try to restore using getPurchases() method, it's returning with an error code 6. And if I try:

ArrayList<String> items = mBundle.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

The items object is always null.

Can anyone please help what's wrong and how to fix these? I'm using the Nokia X emulator and my product id is the numeric one. Thanks!


Solution

  • For getProductDetails() method:

    • Based on Dr. Jukka's answer, if an alias is created for a product, that must be used inside the code instead of the default numeric one.

    For getPurchases() method:

    • All the codes for getting purchases should be inside an AsyncTask. The Nokia In-App Payment Guide only refers that the getProductDetails() method should not be executed in the main thread and nothing is specified for getPurchases() method. I wasn't using the AsyncTask while restoring which always returned error code 6. Now it works using the AsyncTask.

    N.B. The getBuyIntent() method however doesn't need an AsyncTask, it works fine without it.