[Resolved] iOS IAP broken? store.canMakePurchases & store.purchase throw out runtime error

Hi Naomi,

Your issue sounds similar to something I experienced using the Amazon IAP plugin.  It tuned out that the way I was originally requiring store in my main, while the same as the sample code provided with the plugin, didn’t work correctly for me.  It was perhaps related to the fact that I init the store later in another module rather than in main, which it looks like is what you are doing, too.  Anyway, to fix it, I use this if statement in main to init store so this might help you:

[lua]

if system.getInfo(“targetAppStore”) == “amazon” then

    store = require “plugin.amazon.iap” --covers Android for Amazon store

    print(“using amazon iap plugin”)

else

    store = require(“store”) --covers Apple and Google Play stores

    print(“using regular corona iap”)

end

[/lua]

here’s the original forum thread

http://forums.coronalabs.com/topic/37747-amazon-store-plugin-seems-to-be-loading-but-storecanloadproducts-returns-false-what-am-i-doing-wrong/

Andrew @aukStudios, I agree.  It makes no sense to me either, and yeah, I should figure this out down the road.

@HardBoiledIndustries, I actually do require store and call store.init in main.lua.  My products are all listed in main.lua too.  I only use my shop.lua module for all purchases and store front related functions.  

And in fact, I use exactly the same if-statement in main.lua to require store as the one I used in shop.lua (which I posted above) – except that, for whatever reason, the if-statement in shop.lua wouldn’t execute while it does in main.lua – very strange.  I really don’t get this.

Hopefully, somehow down the road, I’ll figure out why.  But for now, I’ll just manually switch how I require store in shop.lua – rather awkward and inefficient, but at least it works.

Naomi

I love our community.  Gang, thanks for helping solve this.  We don’t say it enough, but your contributions to this forum make it as amazing as it is.

Thank you!