In the terminal, I am getting this error:
Lua Runtime Error: lua_pcall failed with status: 2, error message is: ?:0: attempt to index field ‘transcation’ (a nil value)
Why am i getting this error?
here is my in app purchase code:
store = require("store") local listOfProducts = { "com.boltvisual.buy.all" } ---------------------------------- -- In-App area ---------------------------------- local validProducts, invalidProducts = {}, {} local function light() localGroup.alpha = 1 end local function dark() localGroup.alpha = .2 end 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) pop.alpha = 0 rest.alpha = 0 open1 = true saveFile("open11.txt", open1) end function transactionCallback( event ) if event.transaction.state == "purchased" then light() print("ITS A GO") savePurchase(listOfProducts[1]) --you should enter here the product being purchased elseif event.transcation.state == "restored" then light() print("RESTORED") savePurchase(listOfProducts[1]) --you should enter here the product being purchased elseif event.transaction.state == "cancelled" then light() print("CANCEL") elseif event.transaction.state == "failed" then light() print("failed") infoString = "Transaction failed, type: ", event.transaction.errorType, event.transaction.errorString local alert = native.showAlert("Failed ", infoString,{ "OK" }) else light() infoString = "Unknown event" local alert = native.showAlert("Unknown ", infoString,{ "OK" }) end store.finishTransaction( event.transaction ) end function setupMyStore (event) store.loadProducts( listOfProducts, loadProductsCallback ) end local onbuyButTouch = function(event) if store.canMakePurchases then dark() print("yay") local buyThis = function ( product ) if store.canMakePurchases then print("woo") store.purchase( {validProducts[1]} ) else native.showAlert("Store purchases are not available, please try again later", { "OK" } ) print("okay") end end -- Enter your product id here print("1") buyThis("com.boltvisual.buy.all") print("2") end end timer.performWithDelay (100, setupMyStore, 10) store.init(transactionCallback)