store.init()

Type Function
Return value none
Revision Release 2024.3703
Keywords Amazon, IAP, in-app purchases, init
See also store.isActive
store.*

Overview

This call is required and must be executed before making other Amazon IAP calls. This prepares the Amazon IAP library and, upon successful initialization, sets store.isActive to true.

This also initiates the process to retrieve any pending/future purchases, dispatching a storeTransaction event to the listener defined as listener.

Syntax

store.init( listener )
listener (required)

Listener. The listener that will handle storeTransaction events.

Example

local store = require( "plugin.amazon.iap.v3" )
local json = require( "json" )

-- Transaction listener function
local function transactionListener( event )

    if not ( event.isError ) then  -- Successful transaction
        print( json.prettify( event ) )     
        print( "event.transaction: " .. json.prettify( event.transaction ) )

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

    -- Notify Amazon about the transaction being processed
    store.finishTransaction( event.transaction )
end

-- Initialize Amazon IAP
store.init( transactionListener )