I have combined the tab demo and iap demo so that my first tab has functionality and the second tab is a store.
The load product call back and transactionCallback remain on the main.lua so that they can be called immediately and are listening for any callbacks.
Everything appears to work correctly. The store loads the items, clicking buy registers the sale and the transactionCallback is called but for some reason when I try to save the data it stops and no error is generated.
Here is some sample code…
–main.lua
local saveloaddata = require(“saveloaddata”)
if event.transaction.state == “purchased” then
print(“Purchased start”)
infoString = “Transaction successful!”
print (infoString)
descriptionArea.text = infoString
saveloaddata.addProduct(event.transaction.productIdentifier)
print(“Purchased end”)
–saveloaddata.lua
function addProduct( id )
print(“Adding Product:” … id)
_G.productsOwned[id] = “1”
saveData(id)
end
In the log I see “Purchased Start” & “Transaction successful!” but then nothing. I never see “Adding Product” or “Purchased end”
It works correctly from the simulator where I call the same “addProduct” function as soon as the button is clicked.
function newBuyButton (index)
– Handler for buy button
local buttonDefault = “buttonBuy.png”
local buttonOver = “buttonBuyDown.png”
local buyThis = function ( product )
print ("Ka-ching! Purchasing " …product)
– Purchase the item
if isSimulator then
saveloaddata.addProduct(product)
else
It doesn’t help that there are no errors or anything in the console giving some hint to what might have gone wrong.
Can anyone suggest anything that might help me fix or work around this problem.
s. [import]uid: 51622 topic_id: 10504 reply_id: 310504[/import]