Is this this how to correctly integrate google iap v3 ?

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 ?

There are a few things that you might want to think about. But before we get there, are there any messages in the device’s console.log?  You need to run “adb logcat” from the command line when your test device is tethered to the USB port and you’re trying to run the app. Do not add on any extras to the command line that filters only Corona messages. We need messages from other activities.

If you need help with this debugging step please read: http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Hi, Rob. I can’t do as you told me cause I’m not using a real device. I’m using BlueStacks android simulator. but I already tested the app on my friend’s phone. 

Is there any template or tutorial to follow ?

We don’t officially support BlueStacks. However they should have a way to view the simulated device’s console log. And also add in some print statements to make sure you’re getting to the purchase code.

Rob

You can use adb tools to logcat bluestacks the same as a device. There are several guides around for setting up and using adb/logcat.

There are a few things that you might want to think about. But before we get there, are there any messages in the device’s console.log?  You need to run “adb logcat” from the command line when your test device is tethered to the USB port and you’re trying to run the app. Do not add on any extras to the command line that filters only Corona messages. We need messages from other activities.

If you need help with this debugging step please read: http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Hi, Rob. I can’t do as you told me cause I’m not using a real device. I’m using BlueStacks android simulator. but I already tested the app on my friend’s phone. 

Is there any template or tutorial to follow ?

We don’t officially support BlueStacks. However they should have a way to view the simulated device’s console log. And also add in some print statements to make sure you’re getting to the purchase code.

Rob

You can use adb tools to logcat bluestacks the same as a device. There are several guides around for setting up and using adb/logcat.