Hello, community.
I added the ability to purchase in-app products in my app’s main screen as following.
local store = require( "plugin.google.iap.v3" ) local json = require( "json" ) function scene:createScene( event ) local function transactionListener( event ) if not ( event.transaction.state == "failed" ) then -- Successful transaction \_G.ta.noAds = true loadsave.saveTable(ta, "myTable.json", system.DocumentsDirectory) 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 ) local adsbtn = display.newImageRect( group, "ads.png", 50, 50 ) adsbtn.x = centerX-90; adsbtn.y = centerY+180; function adsbtn:touch(e) if e.phase == "began" then transition.to( adsbtn, { time = 100, xScale = 1.2, yScale = 1.2} ) elseif e.phase == "moved" then transition.to( adsbtn, { time = 100, xScale = 1, yScale = 1} ) elseif e.phase == "ended" then if ( system.getInfo("platformName") == "Android" ) then store.purchase( { "cc1212noAds." } ) -- product id. elseif ( system.getInfo( "platformName" ) == "iPhone OS" ) then --store.purchase( { "com.domain.app.iap\_id" } ) end transition.to( adsbtn, { time = 100, xScale = 1, yScale = 1} ) end end adsbtn:addEventListener( "touch", adsbtn ) end
Now after building this to a device. Nothing happens when I click the button that should allow me to purchase.
Any thoughts ?