Why doesn’t this code for an in-app-purchase work? Also, the store.loadProducts isn’t required right?
[lua]store = require(“store”)
local arrayOfProducts =
{
“com.boltvisual.songs”
}
local listOfProducts =
{
“com.boltvisual.songs”
}
local function onButtonEvent()
if store.canMakePurchases then
store.purchasestore.purchase( {“com.boltvisual.songs”} )
else
native.showAlert(“Arts for Education”, “Sorry, You cannot purchase this product.”, {“OK”})
end
end
local all = widget.newButton{
id = “btn001”,
left = 80,
top = 40,
label = “Unlock All! $4.99”,
width = 320, height = 60,
emboss = true,
onEvent = onButtonEvent
}
function storeTransaction( event )
local transaction = event.transaction
if transaction.state == “purchased” then
local alert = native.showAlert( “Sightread for Education”, “Transaction Successful!”, { “OK”})
doSomething()
elseif transaction.state == “restored” then
local alert = native.showAlert( “Sightread for Education”, “Transaction restored (from previous session)”, { “OK”})
elseif transaction.state == “cancelled” then
local alert = native.showAlert( “Sightread for Education”, “User cancelled transaction”, { “OK”})
elseif transaction.state == “failed” then
local alert = native.showAlert( “Sightread for Education”, “Transaction failed!”…transaction.errorString, { “OK”})
else
end
store.finishTransaction( transaction )
end
end
store.init( storeTransaction )[/lua]
Thank you! Why won’t this work? [import]uid: 59735 topic_id: 21502 reply_id: 321502[/import]