Sure, more code below.
As mentioned, the purchase seems to work. It actually auths my real credit card (hope that’s normal for testing) and the storeTransaction handler is called properly. It’s only for restore that the handler is never reached and I always get a “target server failed to respond” in the log.
initing the store:
function initStore() if (not gDebug) then if ( store.availableStores.apple ) then currentProductList = appleProductList store.init( "apple", storeTransaction ) elseif ( store.availableStores.google ) then currentProductList = googleProductList store.init( "google", storeTransaction ) else print( "In-app purchases are not supported on this system/device." ) end end end
When the restore button is touched onscreen, this gets called. It always prints “trying to restore” so it’s getting to the right place:
function restoreOKClicked(event) if (event.action=="clicked") then if (event.index== 2) then -- for now just check if full game present if (gGameOptions.freeVersion == false) then showAlert(lstrings.store.congrats,lstrings.store.purchased) -- already full game, no need to restore else gWaitingGroup=showBrowser(gRWaitIcon,true) showActivityInd() -- now attempt restore print ("\>\>\>\> trying restore") store.restore() end end end end
and then the storeTransaction function, which it’s not even getting to for restore, but getting to for purchases.
function storeTransaction(event) local transaction=event.transaction print ("\>\>\>\> transaction state: " .. transaction.state) if (transaction.state=="purchased" or transaction.state=="restored") then local pid=transaction.productIdentifier print ("transation " .. transaction.state .. " pid: " .. pid) -- eventually go through products and see which item purchased/restored, for now assume full game -- turn game into FULL version. gGameOptions.freeVersion=false saveGameOptions() gActiveDemoNum=gDemoNums.full productDescriptions[fullPDIndex].status="purchased" -- show that full item already purchased showFooter(docdata:getGameTitle()) hideActivityInd() showAlert(lstrings.store.congrats,lstrings.store.purchased) elseif (transaction.state== "refunded") then -- turn game back into FREE version. gGameOptions.freeVersion=true saveGameOptions() gActiveDemoNum=gDemoNums.free productDescriptions[fullPDIndex].status="available" showFooter(docdata:getGameTitle()) hideActivityInd() showAlert(lstrings.store.congrats,lstrings.store.refunded) elseif (transaction.state=="cancelled") then hideActivityInd() elseif (transaction.state=="failed") then local message=lstrings.store.failed.pre .. transaction.errorType .. lstrings.store.failed.post .. transaction.errorString hideActivityInd() showAlert(lstrings.alert.alert,message) end store.finishTransaction( event.transaction ) end
If no one else is having this issue (though I’ve seen similar forum topics on the restore call on Android), then it must be something on my end. I’m using the last release build of Corona 1137.