Just wanted to share some IAP confusion I’m seeing on Android; when I use iap.buy() on Android and cancel it, a previous non-consumable purchase is returned. Is this expected behaviour?
I went to the docs to get clarity, and then I noticed that iap.buy() “Sets the listener function for In-app purchase events.” rather than “requests a purchase” or something along those lines.
Until you call iap.finish() on a transaction it will keep being returned to you when you set the listener (and maybe also after each call to iap.buy()).
On Android it is returned, but not on iOS. These are the differences in behaviour that I’ve spotted so far:
Android returns TRANS_STATE_PURCHASED automatically after init for purchases that have not been consumed. iOS doesn’t.
iap.buy() also returns TRANS_STATE_PURCHASED for items that have previously been purchased, on top of the item requested. iOS returns only the requested item.
iOS returns TRANS_STATE_RESTORED after calling iap.restore(). Android returns TRANS_STATE_PURCHASED.
The consumable difference is fine and can be taken care of easily enough. The things that are confusing to me, and probably anyone who’s working with IAPs on Defold, are the undocumented (as far as I know) differences in behaviour I mentioned above.