[code]
– In-App area
local validProducts, invalidProducts = {}, {}
function unpackValidProducts()
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
invalidProducts = event.invalidProducts
unpackValidProducts ()
end
function savePurchase(product)
local files = product…".txt"
local path = system.pathForFile( files, system.DocumentsDirectory )
local file = io.open( path, “r” )
if file then
io.close( file )
else
local path = system.pathForFile( files, system.DocumentsDirectory )
local file = io.open( path, “w+b” )
file:write( “1” )
io.close( file )
end
end
function transactionCallback( event )
if event.transaction.state == “purchased” then
if event.transaction.productIdentifier == “com.gpanimations.digitalnurseryrhymes” then
savePurchase(“digitalnurseryrhymes”)
end
elseif event.transaction.state == “restored” then
if event.transaction.productIdentifier == “com.gpanimations.digitalnurseryrhymes” then
savePurchase(“digitalnurseryrhymes”)
end
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
–ENDS IN-APP PURCHASE AREA
[/code] [import]uid: 98804 topic_id: 18285 reply_id: 70083[/import]