Hi Rob. So I’ve just gone through testing the refunds and am having no luck. I bought a IAP on my app, and then went into the merchant account and refunded it. Then I waited 18 hours to give Google a chance to send the refunded message to my app.
On my menu.lua I have it set to check if the google store is available, then if it is, call store.restore(). In the transactionCallback() I have the “restored” and “refunded” setup just like your tutorial. The “restored” part works perfectly (Reinstalling the app loads the purchased items), however the “refunded” does nothing.
I even tested the store.purchase() to see if the “refunded” would be called there, also no luck.
Another odd thing is if I uninstall the app and reinstall it (After the IAP is still been refunded) the refunded IAP is being “restored” as if it’s still “purchased”.
As far as I can tell the “refunded” state never gets called.
*Edit*
I just did some more testing with the debugging terminal open. It’s showing that the IAP that should be refunded is still coming in as “purchased”
debug stuff:
D/Finsky ( 6408): [5168] InAppBillingUtils.getPreferredAccount: com.cncconsulting.speedsandfeeds: Account from first account - [ySa0LHYkMhwIEOdQ_F_LQ6x3giQ]
D/Finsky ( 6408): [5168] InAppBillingUtils.getPreferredAccount: com.cncconsulting.speedsandfeeds: Account from first account - [ySa0LHYkMhwIEOdQ_F_LQ6x3giQ]
I/qtaguid ( 6408): Failed write_ctrl(u 39) res=-1 errno=22
I/qtaguid ( 6408): Untagging socket 39 failed errno=-22
W/NetworkManagementSocketTagger( 6408): untagSocket(39) failed with errno -22
D/Finsky ( 6408): [1] MarketBillingService.sendResponseCode: Sending response RESULT_OK for request 8211714729784685140 to com.cncconsulting.speedsandfeeds.
I/Corona (11277): In transactionCallback purchased
I/Corona (11277): Transaction restored (from previous session)
I/Corona (11277): done with store business for now
I/Corona (11277): In transactionCallback purchased
I/Corona (11277): Transaction restored (from previous session)
I/Corona (11277): done with store business for now
I/Corona (11277): In transactionCallback purchased
I/Corona (11277): Transaction restored (from previous session)
I/Corona (11277): done with store business for now
menu.lua code:
local function transactionCallback( event ) print("In transactionCallback", event.transaction.state) local transaction = event.transaction local tstate = event.transaction.state local product = event.transaction.productIdentifier if tstate == "purchased" then tstate = "restored" end if tstate == "restored" then buyCount = buyCount + 1 print("Transaction restored (from previous session)") if "com.speedfeed.iap.sine" == product then storeSettings.sinePaid = true elseif "com.speedfeed.iap.trig" == product then storeSettings.trigPaid = true elseif "com.speedfeed.iap.bolt" == product then storeSettings.boltPaid = true -- elseif "com.speedfeed.iap.speed" == product then -- storeSettings.speedPaid = true end loadsave.saveTable(storeSettings, "store.json") if buyCount == 1 then timer.performWithDelay(1500, function() composer.gotoScene( "restorePage", { effect="fade", time=100} ); end) end store.finishTransaction( transaction ) elseif tstate == "refunded" then print("User requested a refund -- locking app back") if "com.speedfeed.iap.sine" == product then storeSettings.sinePaid = false elseif "com.speedfeed.iap.trig" == product then storeSettings.trigPaid = false elseif "com.speedfeed.iap.bolt" == product then storeSettings.boltPaid = false -- elseif "com.speedfeed.iap.speed" == product then -- storeSettings.speedPaid = false end loadsave.saveTable(storeSettings, "store.json") myData.refund = true store.finishTransaction( transaction ) elseif tstate == "cancelled" then print("User cancelled transaction") store.finishTransaction( transaction ) elseif tstate == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) native.showAlert("Failed", transaction.errorType.." - "..transaction.errorString, {"Okay"}) store.finishTransaction( transaction ) else print("unknown event") store.finishTransaction( transaction ) end print("done with store business for now") end appleRestore = function(event) if event.phase == "ended" then store.init( "apple", transactionCallback) timer.performWithDelay(500, store.restore) end end googleRefund = function() if myData.refund then composer.gotoScene( "restorePage", { effect="fade", time=100} ) end end --------------------------------------------------------------------------------- -- "scene:create()" function scene:create( event ) local sceneGroup = self.view myData.inch = false myData.refund = false buyCount = 0 timesOpen2 = loadsave.loadTable("timesOpen2.json") if timesOpen2.opened == 5 then native.showAlert ( "Find this App useful?", "Leave a review and help others find it!", { "Never", "Later", "OK" }, alertListener ) end print("Times Opened "..timesOpen2.opened) storeSettings = loadsave.loadTable("store.json") if (loadsave.loadTable("store.json") == nil) then storeSettings = {} storeSettings.trigPaid = false storeSettings.sinePaid = false storeSettings.boltPaid = false loadsave.saveTable(storeSettings, "store.json") end -- storeSettings.sinePaid = true -- storeSettings.trigPaid = true -- storeSettings.boltPaid = true going = {} goingTo = {} going.num = 1 bought = 4 back = display.newRect( sceneGroup, display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight ) backEdgeX = back.contentBounds.xMin backEdgeY = back.contentBounds.yMin Runtime:addEventListener( "key", onKeyEvent ) logo = display.newImageRect(sceneGroup, "Images/title.png", 175, 100) logo.x = backEdgeX + 10 logo.anchorX = 0 logo.anchorY = 0.5 logo.y = logo.contentHeight / 2 + 40 topBar = display.newRect( sceneGroup, 0, 0, display.contentWidth, 30 ) topBar:setFillColor(0.15, 0.4, 0.729, 0.75) topBar.anchorX = 0 topBar.anchorY = 0 facebookButt = display.newImageRect(sceneGroup, "Images/facebook.png", 42, 42) facebookButt.anchorX = 0 facebookButt.anchorY = 0.5 facebookButt.x = logo.x facebookButt.y = logo.y \* 2 facebookButt:addEventListener ( "touch", goingFacebook ) if device.isApple then restoreBut = display.newImageRect(sceneGroup, "Images/restoreBut.png", 42, 42) restoreBut.anchorX = 0 restoreBut.anchorY = 0.5 restoreBut.x = logo.x + facebookButt.contentWidth + 15 restoreBut.y = logo.y \* 2 restoreBut.alpha = 0.6 restoreBut:addEventListener("touch", appleRestore) local restoreLabel = display.newText( { parent = sceneGroup, text = "Restore Purchases", 0, 0, font = "BerlinSansFB-Reg", fontSize = 14, width = 85, align = "center"}) restoreLabel.x = restoreBut.x + 21 restoreLabel.y = restoreBut.y + 40 restoreLabel:setFillColor(0.608, 0, 0, 0.6) else if store.availableStores.google then store.init( "google", transactionCallback ) timer.performWithDelay( 300, store.restore) timer.performWithDelay( 1500, googleRefund) end end ...