If you look in the catalogue table, this contains callbacks (onPurchase, onRefund) that you can use to update your preference file and save the data, so basically the business end of things. Add this to your main.lua so its always running. Here is the code from their site:
--Create the catalogue local catalogue = { --Information about the product on the app stores products = { --removeAds is the product identifier. --Always use this identifier to talk to IAP Badger about the purchase. removeAds = { --A list of product names or identifiers specific to apple's App Store or Google Play. productNames = { apple="remove\_ads", google="REMOVE\_BANNER", amazon="Banner\_Remove"}, --The product type productType = "non-consumable", --This function is called when a purchase is complete. onPurchase=function() iap.setInventoryValue("unlock", true) end, --The function is called when a refund is made onRefund=function() iap.removeFromInventory("unlock", true) end, } }, --Information about how to handle the inventory item inventoryItems = { unlock = { productType="non-consumable" } } }
Then in your scenes you can pass a listener to the purchase function, again taken from their site:
--Called when the relevant app store has completed the purchase local function purchaseListener(product) --Save the inventory change iap.saveInventory() --Give the user a message saying the purchase was successful native.showAlert("Info", "Your purchase was successful", {"Okay"}) end --Tell IAP to initiate a purchase iap.purchase("removeAds", purchaseListener)
So in this example you can use the purchase listener to update the UI in your scene(s) to reflect the purchase.
You can also use iap.getInventoryValue() to verify if an item was purchased.
Hopefully that makes some sense?!