Type Function
Return value none
Revision Current Public Release (2018.3326)
Keywords Google, IAP, in-app purchases, init
See also store.isActive


This call is required and must be made before making other Google IAP calls. This prepares the Google IAP library and allows you to detect storeTransaction events to the listener defined as listener.


This method also dispatches an init event to the specified listener (the same listenter used for storeTransaction events). At this point, store.isActive will be true unless an error occurred.

To reiterate, you must wait until the init event is dispatched before attempting to load products, restore previously-purchased items, consume an item, etc.

Note that initialization is done ansynchronously because it may require network calls which take a variable amount of time depending on server load and network latencies.


store.init( listener )
listener (required)

Listener. The listener that will handle storeTransaction events. Note that this listener will also handle the init event as outlined above.


local store = require( "" )
local json = require( "json" )

local function transactionListener( event )

    -- Google IAP initialization event
    if ( == "init" ) then

        if not ( event.transaction.isError ) then
            -- Perform steps to enable IAP, load products, etc.

        else  -- Unsuccessful initialization; output error details
            print( event.transaction.errorType )
            print( event.transaction.errorString )

    -- Store transaction event
    elseif ( == "storeTransaction" ) then

        if not ( event.transaction.state == "failed" ) then  -- Successful transaction
            print( json.prettify( event ) )
            print( "event.transaction: " .. json.prettify( event.transaction ) )

        else  -- Unsuccessful transaction; output error details
            print( event.transaction.errorType )
            print( event.transaction.errorString )

-- Initialize Google IAP
store.init( transactionListener )