IAP Badger

A simple, unified, IAP library for Corona SDK


Type function
Library iap_badger.*
Return value Table
Keywords currency, price, title, description, app, store, products, catalogue
See also iap_badger.getLoadProductsCatalogue(), iap_badger.printLoadProductsCatalogue(), iap_badger.getLoadProductsFinished()


Contacts the relevant app store for the current device, and downloads product information about your products including their title, description and price (as defined in your user's local currency). Please refer to each individual device vendor (Apple, Google, Amazon) for information about how to enter product information into their web consoles.

When working on the simulator, or in debug mode, the function will return the information hard-coded into the products table (see example below).

This function is asynchronous - it will return immediately, even though the product catalogue download is not yet complete. This means there will be a short delay between calling iap_badger.loadProducts() and the product catalogue becoming available on a real device. When working on the simulator, or in debug mode, IAP Badger will fake a delay of a couple of seconds to ensure your code handles the wait correctly.

If a callback listener is specified, the user defined listener function will be called with the original Corona raw event data and a copy of the completed product table. On the simulator, or in debug mode, an empty table {} will be returned for the raw data.

Your app can manually check whether the product catalogue download is complete by calling the function iap_badger.getLoadProductsFinished().




Load and print the loadProducts catalogue.

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

--Create the product catalogue
local catalogue = {

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

        --buy50coins is the product identifier.
        --Always use this identifier to talk to IAP Badger about the purchase.
        buy50coins = {
                --A list of product names or identifiers specific to apple's App Store or Google Play.
                productNames = { apple="buy50coins", google="50_coins", amazon="COINSx50"},
                --The product type
                productType = "consumable",
                --This function is called when a purchase is complete.
                onPurchase=function() iap.addToInventory("coins", 50) end,
                --The function is called when a refund is made
                onRefund=function() iap.removeFromInventory("coins", 50) end,

                --Simulator / debug information about app store pricing etc.
                simulatorPrice = "£0.79",
                simulatorDescription = "A packy of 50 shiny coins.  Spend them wisely.",
                simulatorTitle = "50 coins",



    --Information about how to handle the inventory item
    inventoryItems = {
        coins = { 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

local function loadProductsListener()

    --Grab the product information catalogue
    local products=iap.getLoadProductsCatalogue()

    --Example of how to ask the user if they would like to purchase a product at a given price.
    print ("Would you like to buy a " .. products.buy50coins.title .. " for " .. products.buy50coins.localizedPrice .. "?")

    --Print out catalogue


--Initialise IAP badger

--Load the product catalogue from the relevant app store - when this is complete, print out a sample message

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