Iap.restore() issue on Android (DEF-3636) (SOLVED)


seems like a new strange behaviour here. Recently I’ve got reports from players: they can’t restore his purchases. Hmm, before this month I haven’t reports about this issue. I was absolutely sure that all ok with this part of code and tested it before (in 2017).

Today I’ve a new test with debug build and what I saw in console:

  1. in init()
    after that listener immediately catch 3 callbacks with state 1 iap.TRANS_STATE_PURCHASED (there are 3 in apps in my game and all was made on the testing device)

  2. pushed “restore button” in my game and call iap.restore() function
    iap.restore() returns true
    but nothing happened in listener. No callback, no errors, nothing.

  3. pushed iap button in menu and immediately have all 3 callbacks with state 1 iap.TRANS_STATE_PURCHASED without any purchasing dialog on device

and IAP error 7 in console:

Used 1.2.127 for this test and release builds in store.
The same code on iOS test build works ok.

I double checked all restoring code. It calls iap.restore

  elseif message_id == game.IAPRESTORE then
        print("iap restore request from:", self.senderIapUrl)
        local res=iap.restore()
        print("iap.restore result:",res)

|DEBUG:SCRIPT: iap restore request from:|url: [settings:/gui#settings]
|DEBUG:SCRIPT: iap.restore result:|true|

As I remember there was similar theme Restore purchase (DEF-2738) SOLVED an year ago.

Well. Any ideas?

1 Like


updated engine to 1.2.129, issue still.

Also when call iap.restore() the app lost focus for a few milliseconds
just saw in console

DEBUG:SCRIPT: focus lost
DEBUG:SCRIPT: focus gained

p.s. all in-apps ingame are non-consumable purchases



Can you isolate this into a minimal app that I can set up and test against some products of my own?

1 Like


Hi there,

This issue still seems to appear on Android devices as of version 1.2.134. Like stated above, iap.restore() causes the app to lose and regain focus, and there does not seem to be any callbacks sent to the listener. I am also using non-consumable purchases.



First of all, the Google Play Store doesn’t have non-consumable products when setting up products in the console. There’s only consumable products and subscriptions. If you want to have a consumable product act as a buy-once and never again non-consumable product (ie like a pay to unlock ads product) you need to make sure that you’re not consuming the product after you buy it.

I need to get some more information about this before opening a ticket:

  • What is the state of the Auto Finish Transactions checkbox in game.project under IAP section? It needs to be unchecked, otherwise Defold will automatically consume/finish every purchase you make.
  • If Auto Finish Transactions is unchecked please also make sure to not call iap.finish() on any product that should be non-consumable on Android. Can you verify that you’re not calling iap.finish() on the product(s) in question?


in my project:


in iap_listener

elseif transaction.state == iap.TRANS_STATE_PURCHASED then
    if game.platform==game.iOS then

this parts of code hasn’t changed for the long time. I can confirm that “restore purchase” worked corrected on Android on the Winter 2017-2018 and Spring 2018, but something changing now.

For the now in game I use “auto restore” trick :



Thanks for responding. Like @Dragosha, I can confirm that Auto Finish Transactions is unchecked, and I am not calling iap.finish(transaction) for the Android version. In the meantime, I will try that workaround trick.

1 Like


Looks like it’s still an issue, and restore (on android) works only when app loads and doesn’t work when we call iap.restore()

1 Like


Created ticket: DEF-3636



Solved in 1.2.145



Bundled for Android with v1.2.174, iap.TRANS_STATE_RESTORED is not returned when triggering iap.restore(). Instead this is the flow:

  1. iap.restore()
  2. listener returning transaction.state = 1 (TRANS_STATE_PURCHASED) for each purchase.


You will only get the TRANS_STATE_RESTORED state on stores which support restoring purchases (Apple). On Android you get a list of previous purchases I think.

1 Like


Oh! Yes, that’s exactly what I get. I didn’t realise Google Play didn’t support restore.

Update: On a different note, when testing the same thing on iOS Testflight I see this behaviour (IAP extension v2.0.1):

  1. iap.restore() doesn’t return anything, even though the user has previously purchased an item.
  2. When attempting to purchase the item again, a successful purchase immediately fires.

Has someone here used iap.restore() recently and seen it work on iOS?

Update 2: I figured it out. On iOS all transactions have to use iap.finish(), even if it’s a non-consumable. I was only triggering it for consumables. If iap.finish() is not triggered on a non-consumable, the above behaviour is seen.

Leaving this here for next time this confuses me. :stuck_out_tongue_closed_eyes: