IAP Badger

A simple, unified, IAP library for Corona SDK


Type function
Library iap_badger.*
Return value Table
Keywords inventory, save, serialize
See also iap_badger.loadInventory()


Saves the inventory to the file specified in iap_badger.init(). Whenever a file is saved, random variables will be randomised, and item refactoring occurs automatically.

If true is passed to saveInventory(), the inventory file will not be saved to the user's device. Instead, the function will return a hashed, JSON string representing the user's current inventory (as it would have been saved on the user's device). This data can then be stored elsewhere (for instance, on the cloud). This string can be passed to iap_badger.loadInventory() to recover the inventory at a later date.


asString (optional)

Table. Set to true to return a string containing the inventory file contents instead of saving them on the user's device.


Add a product to the inventory and save it to the file inventory.txt

--Include the plugin
local iap = require 'plugin.iap_badger'

--Create the product catalogue
local catalogue = {

    --Information about the product on the app stores
    products = {    

    --Information about how to handle the inventory item
    inventoryItems = {
        hat = { productType="consumable" },

--This table contains all of the options we need to specify in this example program.
local iapOptions = {
    --The catalogue generated above
    --The filename in which to save the inventory

--Initialise IAP badger

--Add an item to the inventory

--Save the inventory file - this will now contain a hat.

This website uses cookies. Click here to see our privacy policy. Created using the Responsive Grid System.