I am having trouble getting Google IAP to work. This is my first time working with IAP. I was able to successfully test and submit the IAP on Apple but I am not able to make it work on Google for some reason.
Has anyone done this successfully who can assist?
I have given up on trying to test IAP on Google. I am using a gmail not associated with my developer account and I can test the rest of the app but I have to officially publish live to the store to test the IAP. That’s another issue but for now I would like to just focus on getting the IAP to work.
I have a deck of 10 cards that are free then I have two in app purchases. One for 100 cards and/or a second option for 300 cards.
The last error I received when testing the live app was: “Transaction Failed” "Unable to buy item(response:5: Developer Error)
I have done the following:
In build.settings I added:
android = { usesPermissions = { "android.permission.RECORD\_AUDIO", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.CHECK\_LICENSE", "com.android.vending.BILLING", }, },
and also:
plugins = { ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, },
In config.lua I added the google Key in two places. I am not sure if I placed these correctly.
elseif ( display.pixelHeight \> 1024 ) then -- iPhone 5 (and all other high-res devices) checking - uses the iPad Air Retina image application = { content = { width = 1536, height = 2048, fps = 60, scale = kScale, }, license = { google = { key = "MY RIDICULOUSLY LONG KEY", }, }, } else -- all other devices application = { content = { width = 1536, height = 2048, fps = 60, scale = kScale, imageSuffix = { ["@2"] = .4, } }, license = { google = { key = "MY RIDICULOUSLY LONG KEY", }, }, }
In Main.lua I added:
local store local googleIAP = false if ( system.getInfo( "platformName" ) == "Android" ) then store = require( "plugin.google.iap.v3" ) googleIAP = true elseif ( system.getInfo( "platformName" ) == "iPhone OS" ) then store = require( "store" ) else native.showAlert( "Notice", "In-app purchases are not supported in the Corona Simulator.", { "OK" } ) end local function transactionCallback(event) local transaction = event.transaction if transaction.state == 'purchased' or transaction.state == 'restored' then local id = transaction.productIdentifier id = id:lower() if id == 'com.icebreakerentertainment.naughty\_charades.100cards' then composer.inApps['100cards'] = true elseif id == 'com.icebreakerentertainment.naughty\_charades.300cards' then composer.inApps['300cards'] = true end loadsave.saveTable(composer.inApps, 'inapps.json') if transaction.state == 'purchased' then if composer.transactionCallback then local callback = composer.transactionCallback() composer.transactionCallback = nil callback() end end elseif transaction.state == 'failed' then native.showAlert('Transaction failed', transaction.errorString, {'OK'}) end store.finishTransaction(transaction) end store.init(transactionCallback)
And lastly in the scene where the upgrade occurs:
function but\_iap100(self) audio.setVolume(10, {channel=2} ) plopx9 = audio.play( composer.plop, {loops = 0 } ) composer.transactionCallback = function() self:updateUpgradeButtons() end store.purchase({'com.icebreakerentertainment.naughty\_charades.100cards'}) end function but\_iap300(self) audio.setVolume(10, {channel=2} ) plopx9 = audio.play( composer.plop, {loops = 0 } ) composer.transactionCallback = function() self:updateUpgradeButtons() end store.purchase({'com.icebreakerentertainment.naughty\_charades.300cards'}) end function but\_restore(self) audio.setVolume(10, {channel=2} ) plopx9 = audio.play( composer.plop, {loops = 0 } ) store.restore()
Any help would be greatly appreciated!!
Thanks!!
Christi