0

I have following method for fetching product info:

public void getProductInfo(final ProductListener listener, final String sku) {
    IabHelper.QueryInventoryFinishedListener
            mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory)
        {
            if (result.isFailure()) {
                listener.onProductInfo(false,null,null,result.getMessage());
                return;
            }
            //consumeProduct(inventory);
            Purchase purchase=inventory.getPurchase(sku);
            if (purchase!=null) {
                listener.onProductInfo(true,purchase,inventory.getSkuDetails(sku).getPrice(),"ok");
            } else {
                listener.onProductInfo(true,null,null,"no_product");
            }
        }
    };
    ArrayList<String> skuList = new ArrayList();
    skuList.add(sku);
    //make a request
    try {
        mHelper.queryInventoryAsync(true, skuList,null,mQueryFinishedListener);
    } catch (IabHelper.IabAsyncInProgressException e) {
        listener.onProductInfo(false,null,null,context.getResources().getString(R.string.product_error)+e.getLocalizedMessage());
        e.printStackTrace();
    }
}

However for subscription this metod returns 0-sized inventory list.Subscription itself works as expected and after I subscribe this method returns valid sku details.But I'd like user to see product price/details in the app's ui before he starts purchase flow.
I tried to update util package according to this with no luck

Community
  • 1
  • 1
undefined
  • 623
  • 7
  • 27

1 Answers1

0

Just realized its incorrect to search product details in purchase since subscription is not purchased yet.Instead one can get all info with this call:

SkuDetails details=inventory.getSkuDetails(sku);

undefined
  • 623
  • 7
  • 27