Type Function Return value none Revision 2017.3060 Keywords Google, IAP, in-app purchases, init See also store.isActive store.*
This call is required and must be executed before making other Google IAP calls. This prepares the Google IAP library and, upon successful initialization, sets store.isActive to true.
This also allows you to detect storeTransaction events to the listener defined as listener.
store.init( listener )
Listener. The listener that will handle storeTransaction events.
local store = require( "plugin.google.iap.v3" )
local json = require( "json" )
-- Transaction listener function
local function transactionListener( event )
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 )
end
end
-- Initialize Google IAP
store.init( transactionListener )