In the past, my IAP was working quite well with the “IAP Badger” plugin (well, the spinner kept spinning after the successful payment, so there never was a positive reply to the customer, but that was at least somewhat okay).
Now I am trying to build a new IAP function for all of my apps and cannot get it to work properly.
The IAP product is quite simple: the user can buy the full version of an app which just sets and saves a couple of variables.
I got this version to work with Android, it was possible to make purchases, the customer gets a positive response (thankyou.lua)… BUT for some reason the code in the function “freischalten” didn’t get called properly. OK, I can fix that probably.
On iOS on the other hand, I don’t get a connection to the app store.
It all seems so easy, but there still must be some faults in my code…?
Can maybe someone post his own IAP code that works?
local function freischalten() -- set variables here to unlock full version !! end local function StoreListener(event) local function afterDelay() -- it seems to be needed to include a delay here! local transaction = event.transaction if transaction == "purchased" then if isGoogleRestore then -- Restore purchase code goes here freischalten() -- add some text message to the user that restore was successful else -- successful purchase. Give user what they paid for freischalten() composer.gotoScene("thankyou") end elseif transaction == "restored" then -- Apple or Amazon restore code goes here freischalten() -- add some text message to the user that restore was successful elseif transaction == "cancelled" then -- User decided to cancel purchase elseif transaction == "failed" then -- Something went wrong. User could not purchase item. -- add some alert message end store.finishTransaction(transaction) end -- End function afterDelay timer.performWithDelay(500, afterDelay) end local function kaufVorgang() -- make a purchase btn.alpha = 0 -- hide button if platform == "amazon" then store.init(StoreListener) else store.init(platform, StoreListener) end if platform == "apple" then if store.canMakePurchases then store.purchase({"Apple product name"}) else -- add some text message: no product available end else store.purchase("Google product name") end end -- /////// BUY-Button /////// ------------------------------------------------------------------ btn = widget.newButton ( { defaultFile = "buy1.png", overFile = "buy2.png", left = 20, top = 370, onEvent = kaufVorgang } ) sceneGroup:insert(btn)