Ok - I have read almost every topic, tutorial and documentation I can find and I can’t see what I’m doing wrong :-/
I have:
- Set up my app on ITC, submitted a binary and rejected it.
- Set up my IAP on ITC, currently at ‘waiting for screenshot’ status
- Built and installed to device using an adhoc provisioning profile
Here is my code. The loadProducts function doesn’t seem to be firing at all - I have debug text fields that aren’t getting up updated. How do I know if store.init() is being called or not?
I’m aware the IAP can take a while to filter through the system, but surely I should be getting some dialog boxes telling me I have invalid products?
[lua]store = require(“store”)
local listOfProducts = {
“KP0001”,
}
local price = {“£0.69”}
local desc = {“Test Description”}
local validProducts, invalidProducts = {}, {}
function unpackValidProducts()
myText[9].text = “Unpack fired”
print (“Loading product list”)
if not validProducts then
native.showAlert( “In-App features not available”, “initStore() failed”, { “OK” } )
else
for i=1, #invalidProducts do
native.showAlert( “Item " … invalidProducts[i] … " is invalid.”,{ “OK” } )
end
end
end
function loadProductsCallback( event )
validProducts = event.products
price[1] = validProducts[1].price
desc[1] = validProducts[1].description
myText[5].text = price[1]
myText[6].text = desc[1]
myText[7].text = “Load products fired”
invalidProducts = event.invalidProducts
unpackValidProducts ()
end
function savePurchase(product)
–function on what should be save when user buy a product
end
function transactionCallback( event )
if event.transaction.state == “purchased” then
savePurchase(“product”) --you should enter here the product being purchased
elseif event.transcation.state == “restored” then
savePurchase(“product”) --you should enter here the product being purchased
elseif event.transaction.state == “cancelled” then
elseif event.transaction.state == “failed” then
infoString = "Transaction failed, type: ", event.transaction.errorType, event.transaction.errorString
local alert = native.showAlert("Failed ", infoString,{ “OK” })
else
infoString = “Unknown event”
local alert = native.showAlert("Unknown ", infoString,{ “OK” })
end
store.finishTransaction( event.transaction )
end
function setupMyStore (event)
store.loadProducts( listOfProducts, loadProductsCallback )
end
store.init(transactionCallback)
timer.performWithDelay (1000, setupMyStore)[/lua]
[import]uid: 93133 topic_id: 21375 reply_id: 321375[/import]