store.canLoadProducts

Type Boolean
Revision Release 2024.3703
Keywords Samsung, IAP, in-app purchases, canLoadProducts
See also store.loadProducts()
[store.*][plugin.samsung-iap-v3]

Overview

This property will be true if the store supports the loading of products. Following confirmation, the store.loadProducts() function can be used to retrieve information about items available for sale.

Syntax

store.canLoadProducts

Example

local store = require( "plugin.samsung.iap" )

-- Transaction listener function
local function transactionListener( event )
    local transaction = event.transaction
end

-- Product listener function
local function productListener( event )
    print( "Valid products:", #event.products )
    print( "Invalid products:", #event.invalidProducts )
end

-- Initialize Samsung IAP
store.init( transactionListener )

-- Sometime later, load products
if ( store.canLoadProducts ) then

    local productIdentifiers = {
        "com.coronalabs.ExampleInAppPurchase.Consumable",
        "com.coronalabs.ExampleInAppPurchase.NonConsumable"
    }
    store.loadProducts( productIdentifiers, productListener )
end