Google In-App Purchases Not Working

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

You should try IAP Badger, which streamlines IAP and makes it easier to work with in Corona apps:

https://forums.coronalabs.com/topic/59137-iap-badger-a-unified-approach-to-in-app-purchases

According to Google:

BILLING_RESPONSE_RESULT_DEVELOPER_ERROR 5 Invalid arguments provided to the API. This error can also indicate that the application was not correctly signed or properly set up for In-app Billing in Google Play, or does not have the necessary permissions in its manifest

http://developer.android.com/google/play/billing/billing_reference.html

There are three things this identifies:

  1. It’s not signed correctly.

  2. Something isn’t setup correctly in Google Play

  3. You’re missing permissions.

Your permissions look right. I doubt you could upload the app if it wasn’t signed correctly. BTW: you can upload it as Alpha or Beta status and be able to test it. You don’t have to make it live.

This leaves #2 as the most likely issue.

Rob

Thanks for the feedback Alex & Rob.

Rob,

I have confirmed that my product ID’s in Google play match what is in the code.  What else might be set up wrong in Google Play? 

Thanks!

One gotcha with building an app through Corona SDK while using the Google IAP v3 plugin is that you need to ensure these options in the android build dialog match the APK you’ve uploaded to Google Play Dev Console. Otherwise, your purchases won’t work:

Application Name

Version Code

Version Name

Package

Furthermore, make sure you sign with the same keystore as the app you uploaded to Google Play Dev Console.

When I’ve had this error in the past, I’m sure it was because I was testing an app that had a version code that was later/larger than the last version I’d uploaded to Google Play console.

I’m having similar problems with Google IAP, was there a conclusion/fix?

Hello!

I have app A published on store A (mine). It works fine. I can buy IAP products as tester with my C account.

But I have an other app B, published on store B (that of my client, where I have permissions). On that one, I’m having the error: “Unable to buy item(response:5: Developer Error)” when trying to buy items as alpha tester. I even tried with product “android.test.purchased”, or with an invented product id, but I got the same result.

Both apps are done with Corona. In both aps iap is managed the same way. And both are signed with the same certificate.

For B app, on build.settings I have:

android ={ usesPermissions = {             "android.permission.INTERNET",             "com.android.vending.BILLING", }, }, plugins =     {     -- ADS         ["plugin.google.play.services"] =         {             publisherId = "com.coronalabs"         },                  -- IAP         ["plugin.google.iap.v3"] =         {             publisherId = "com.coronalabs",             supportedPlatforms = { android=true }         },     }, 

On config.lua:

   license =     {         google =         {         -- key taken from Services and APIs section of B app             key = "MIIBIjANB...wIDAQAB"         },     }, 

I’ve checked too what Ajay says… App Name and Package Name are the same on Corona Simulator and on Play Store, and the version number on Play Store is set automatically from apk, so it’s the same too.

Thank you for you time

Hi mariona dsr,

Just to clarify, app B is published on Google Play Dev Console with the same keystore as app A?

If that’s the case, you’ll probably need to use a separate keystore for app B than app A.

Hello!

Yes, I use the same certificate, from the same keystore, to sign both apps.

I’ll try with different keys and I let you know. Thank you!

:o

I’m really ashamed to confess than the true problem was not the certificate, nor the package name, nor nothing so difficult.

I was just that the parameter that I passed to store.purchase doesn’t exist.

So, if someone never have this problem, “Unable to buy item(response:5: Developer Error)”, verify at least three time that you are passing something as product identifier  ;) 

Thank you Ajay for your attention.

You should try IAP Badger, which streamlines IAP and makes it easier to work with in Corona apps:

https://forums.coronalabs.com/topic/59137-iap-badger-a-unified-approach-to-in-app-purchases

According to Google:

BILLING_RESPONSE_RESULT_DEVELOPER_ERROR 5 Invalid arguments provided to the API. This error can also indicate that the application was not correctly signed or properly set up for In-app Billing in Google Play, or does not have the necessary permissions in its manifest

http://developer.android.com/google/play/billing/billing_reference.html

There are three things this identifies:

  1. It’s not signed correctly.

  2. Something isn’t setup correctly in Google Play

  3. You’re missing permissions.

Your permissions look right. I doubt you could upload the app if it wasn’t signed correctly. BTW: you can upload it as Alpha or Beta status and be able to test it. You don’t have to make it live.

This leaves #2 as the most likely issue.

Rob

Thanks for the feedback Alex & Rob.

Rob,

I have confirmed that my product ID’s in Google play match what is in the code.  What else might be set up wrong in Google Play? 

Thanks!

One gotcha with building an app through Corona SDK while using the Google IAP v3 plugin is that you need to ensure these options in the android build dialog match the APK you’ve uploaded to Google Play Dev Console. Otherwise, your purchases won’t work:

Application Name

Version Code

Version Name

Package

Furthermore, make sure you sign with the same keystore as the app you uploaded to Google Play Dev Console.

When I’ve had this error in the past, I’m sure it was because I was testing an app that had a version code that was later/larger than the last version I’d uploaded to Google Play console.

I’m having similar problems with Google IAP, was there a conclusion/fix?

Hello!

I have app A published on store A (mine). It works fine. I can buy IAP products as tester with my C account.

But I have an other app B, published on store B (that of my client, where I have permissions). On that one, I’m having the error: “Unable to buy item(response:5: Developer Error)” when trying to buy items as alpha tester. I even tried with product “android.test.purchased”, or with an invented product id, but I got the same result.

Both apps are done with Corona. In both aps iap is managed the same way. And both are signed with the same certificate.

For B app, on build.settings I have:

android ={ usesPermissions = {             "android.permission.INTERNET",             "com.android.vending.BILLING", }, }, plugins =     {     -- ADS         ["plugin.google.play.services"] =         {             publisherId = "com.coronalabs"         },                  -- IAP         ["plugin.google.iap.v3"] =         {             publisherId = "com.coronalabs",             supportedPlatforms = { android=true }         },     }, 

On config.lua:

   license =     {         google =         {         -- key taken from Services and APIs section of B app             key = "MIIBIjANB...wIDAQAB"         },     }, 

I’ve checked too what Ajay says… App Name and Package Name are the same on Corona Simulator and on Play Store, and the version number on Play Store is set automatically from apk, so it’s the same too.

Thank you for you time

Hi mariona dsr,

Just to clarify, app B is published on Google Play Dev Console with the same keystore as app A?

If that’s the case, you’ll probably need to use a separate keystore for app B than app A.

Hello!

Yes, I use the same certificate, from the same keystore, to sign both apps.

I’ll try with different keys and I let you know. Thank you!