get product price from App store

Hi All,

I am trying to get product price from App store and display it in the app as text. This is how I am doing

local function loadedCallback(e)

for i=1, #e.products do
table.insert(localizedPrices, i, tostring(e.products[i].price));
end

end
store.loadProducts(productID, loadedCallback);

This code is in a separate file names iap.lua. while localizedPrices is an array. Now I try to get price from another lua file like this. iap.localizedPrices[item No.]. When tested in sandbox environment it gives error and treats localizedPrices as nil. So app crashes. Please help me about this and guide me where I am wrong ?
I will be thankful.

Mueed [import]uid: 126619 topic_id: 37606 reply_id: 67606[/import]

Hi there,

I notice that you are passing a variable called productID to the loadProducts function. If productID is a string with the product name, then it won’t work, since loadProducts is supposed to get a table with the strings of the products. If you have just one product, you could try store.loadProducts( {productID}, loadedCallback) instead.

  • Andrew [import]uid: 109711 topic_id: 37606 reply_id: 145829[/import]

Hi Andrew,

 

Thanks for reply. Well this is what my productID is like

 

 

local productID = 

{

    com.mycompay.AppName.item1
    com.mycompay.AppName.item2

    com.mycompay.AppName.item3

    com.mycompay.AppName.item4

    com.mycompay.AppName.item5

    

}

 

Please tell me if you can find something or guide me where I am going wrong. I am trying again and again but no success.

 

Thanks

 

-Mueed

Hi there,

I notice that you are passing a variable called productID to the loadProducts function. If productID is a string with the product name, then it won’t work, since loadProducts is supposed to get a table with the strings of the products. If you have just one product, you could try store.loadProducts( {productID}, loadedCallback) instead.

  • Andrew [import]uid: 109711 topic_id: 37606 reply_id: 145829[/import]

Hi Andrew,

 

Thanks for reply. Well this is what my productID is like

 

 

local productID = 

{

    com.mycompay.AppName.item1
    com.mycompay.AppName.item2

    com.mycompay.AppName.item3

    com.mycompay.AppName.item4

    com.mycompay.AppName.item5

    

}

 

Please tell me if you can find something or guide me where I am going wrong. I am trying again and again but no success.

 

Thanks

 

-Mueed

Did you ever get to the bottom of this? I am dealing with this exact same issue now.

@bearchell can you describe your problem better?  I know that store.loadProducts() is working as expected.

Rob

Erg, thanks for getting back to me, Rob. I had actually posted my own topic on the issue I was having before the above question in this thread, and then it turned out I made a horrifically embarrassing mistake in my own code… so I quickly deleted it  :rolleyes:

In any case, everything is working as expected for me now.

Thanks again!

Gary

Did you ever get to the bottom of this? I am dealing with this exact same issue now.

@bearchell can you describe your problem better?  I know that store.loadProducts() is working as expected.

Rob

Erg, thanks for getting back to me, Rob. I had actually posted my own topic on the issue I was having before the above question in this thread, and then it turned out I made a horrifically embarrassing mistake in my own code… so I quickly deleted it  :rolleyes:

In any case, everything is working as expected for me now.

Thanks again!

Gary