Simulator
Simulator & Device Build
Run with Simulator
- After copy_pages script is used, the image folders of the episodes are removed from build4/assets/images.
- loading main.lua with Corona Simulator, clicking purchase text will show up the IAP dialog
- Files > Show Project Sandbox, you find downloaded zip and bg.png.
- If you want to refresh the state beginning, delete the files from the Sandbox folders. TemporaryFiles must be cleared because the files from Internet are cached there.
Build for device
After everything all right with simulator, turn off debug mode IAP.lua and set the valid product IDs of apple, google or amazon.
Project Properties > Advanced

- IAP Debug mode should be unchecked for device testing
Please make sure the following lua files of BookShelfTOC project. You may edit the files in App/TOC.
- App/TOC/components/store/model.lua
- App/TOC/components/store/IAP.lua
In components/store/model.lua, please change debug to false
local M = {}
--
local IAP = require("components.store.IAP")
--
M.bookShelfType = 0 --{none = -1, pages = 0, embedded = 1, tmplt=2}
--
M.debug = false
In components/store/IAP.lua, please change the text in salt field.
function M:init(catalogue, restoreAlert, purchaseAlert)
...
local iapOptions = {
catalogue = catalogue,
filename = "episodes_inventory.txt",
--Salt for the hashing algorithm
salt = "something tr1cky to gue55!",
failedListener = failedListener,
cancelledListener = failedListener,
--Once the product has been purchased, it will remain in the inventory. Uncomment the following line
--to test the purchase functions again in future. It's also useful for testing restore purchases.
--doNotLoadInventory=true,
debugMode = debug,
}
- iapOptions.salt change it as your own text
components/store/model.lua
M.catalogue = {
products = {
Episode02 = {
productNames = { apple="Episode02_apple", google="Episode02_googgle", amazon="Episode02_amazon"},
productType = "non-consumable",
onPurchase = function() IAP.setInventoryValue("unlock_Episode02") end,
onRefund = function() IAP.removeFromInventory("unlock_Episode02") end,
},
Episode03 = {
productNames = { apple="Episode03_apple", google="Episode03_googgle", amazon="Episode03_amazon"},
productType = "non-consumable",
onPurchase = function() IAP.setInventoryValue("unlock_Episode03") end,
onRefund = function() IAP.removeFromInventory("unlock_Episode03") end,
},
},
inventoryItems = {
unlock_Episode02 = { productType="non-consumable" },
unlock_Episode03 = { productType="non-consumable" },
}
}
- productNames.apple, productNames.google, productNames.amazon to be set for device build. If not used, make it empty string as ""