Corona Simulator

Corona Simulator & Device Build

Run with Corona Simulator

Build for device

After everything all right with corona simulator, turn off debug mode IAP.lua and set the valid product IDs of apple, google or amazon.

Project Properties > Advanced

Please make sure the following lua files of BookShelfTOC project. You may edit the files in App/TOC.


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,
    }

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" },
    }
}